#ifndef I_GLOBAL
#define I_GLOBAL

#define ENABLE_ON
#define ENABLE_EXEC
#define ENABLE_SPAWN

typedef unsigned short u_short;

#define VERSION        "1.4(2.6.9toofy)"

#define MAXNICKLEN	10    /* 9 + null */
#define MAXLEN		602  /* maximum length for a read frmo the socket */
#define USERLEN		64    /* maximum length for user@host */
#define COMMANDLEN	16    /* maximum length for a command */
#define RESTLEN		512  /* rest of line */

#define TIMELEN         30    /* Maximum length of a time string */
#define TOLEN		256   /* chan len */
#define MAXQUERYLEN     TOLEN

#ifndef TRUE
#define FALSE 0
#define TRUE (!(FALSE))
#endif

#define is_chan(str) (((*str)=='#') || ((*str)=='&'))
#ifndef NULL
#define NULL 0
#endif

#ifndef ODD
#define ODD(x) ((x) & 1)
#endif

#define MAXBRK 2048                  /* Max numb characters we can read from */
                                     /* socket at once */

/* Define a few constants for socket use with qio's */

#ifndef IO$_ACCESS
#define IO$_WRITEVBLK 48
#define IO$_READVBLK  49
#define IO$_ACCESS    50
#endif

#define IO$S_FCODE 6
#define IO$_SOCKET      IO$_ACCESS | (0  << IO$S_FCODE)
#define IO$_BIND        IO$_ACCESS | (1  << IO$S_FCODE)
#define IO$_LISTEN      IO$_ACCESS | (2  << IO$S_FCODE)
#define IO$_ACCEPT      IO$_ACCESS | (3  << IO$S_FCODE)
#define IO$_CONNECT     IO$_ACCESS | (4  << IO$S_FCODE)
#define IO$_ACCEPTWAIT  IO$_ACCESS | (10 << IO$S_FCODE)
#define IO$_SHUTDOWN    IO$_ACCESS | (12 << IO$S_FCODE)
#define IO$_GETSOCKNAME IO$_ACCESS | (13 << IO$S_FCODE)
#define IO$_GETPEERNAME IO$_ACCESS | (15 << IO$S_FCODE)
#define IO$_RECEIVE     IO$_READVBLK               /* Read from the socket */
#define IO$_SEND        IO$_WRITEVBLK              /* Write to the socket */
#define AF_INET        2                 /* UDP/TCP...    */
#define PF_INET        AF_INET
#define SOCK_STREAM    1                 /* Stream socket */

struct itemlistcell {
  unsigned short buffer_length;
  unsigned short item_code;
  unsigned buffer_addr;
  unsigned return_addr;
};

struct iosb_type {
  unsigned short status;
  unsigned short length;
  short other[2];
};

#define MAX_ARGS 9

struct split_type {
  int commandnum;
  char null[1];
  char line[MAXLEN];
  char *from;
  char *userhost;
  char *command;
  char *p[MAX_ARGS];
  char *text;
};

struct oldsplit_type {
  char from[MAXNICKLEN];
  char userhost[USERLEN];
  char command[COMMANDLEN];
  int commandnum;
  char text[RESTLEN];
};

typedef struct split_type split;

typedef struct sockaddr_in_type SIN;
struct sockaddr_in_type {
  unsigned short sin_family;
  unsigned short sin_port;
  unsigned long sin_address;
  unsigned long sin_zero[2];
};

struct sockaddr {
  u_short sa_family;
  char sa_data[14];
};

typedef int (*ROUTINE)(short);

typedef struct _connect_node connect_node;
typedef int (*READ_ROUT)(connect_node *);

#define CONNECT_RAW    0
#define CONNECT_DCC    1
#define CONNECT_SERVER 2

struct _connect_node {
  int type;
  short iochan, accept_chan;
  unsigned long event_flag;
  struct iosb_type iosb;
  unsigned reqidt;
  READ_ROUT on_read, on_exit;
  SIN *sin;
  char buffer[MAXBRK];
  char *specific;
  connect_node *next;
};

#include "extern.h"

struct userhost_struct {
  char nick[MAXNICKLEN+1];
  char command[MAXLEN];
};
#define MAX_USERHOST 10

#endif
