#ifndef I_GLOBAL
#define I_GLOBAL

#undef DEBUG_MALLOC

#define ENABLE_ON
#define ENABLE_EXEC
#define ENABLE_SERVER
#define ENABLE_SPAWN

/* -------- Shouldn't need to change anything below this line ---------- */

#define KEYGET_EF 19
#define SERVER_EF 20
#define GLOBAL_EF 21

#ifndef __GNUC__
typedef unsigned short u_short;
#endif

#define VERSION        "1.6.0(3.2.6 haplo)"
#define VERSION_DATE   "9502132000 VMS"

#define MAXLEN		604  /* 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 2024                  /* Max numb characters we can read from */
                                     /* socket at once */
#define MAX_ARGS 9

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

typedef struct split_type split;

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

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

#include "types.h"

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;
};

struct userhost_struct {
  char *nick;
  char command[MAXLEN];
};
#define MAX_USERHOST 10

#define AF_INET        2                 /* UDP/TCP...    */
#define PF_INET        AF_INET
#define SOCK_STREAM    1                 /* Stream socket */

#ifndef IN_WINDOW
extern void win_say(win_ptr win, char *, ...);
extern void say(char *, ...), yell(char *, ...);
#endif
extern int get_logical(char *, char *, int);
extern char *m_strcpy(char *);
extern int strcasecmp(char *, char *), grab_word(char **, char, char *);
extern int strncasecmp(char *, char *, int);
extern char *strip_ends(char *, char, char, char *, int);

#include "debug.h"

#ifdef DEBUG_MALLOC
extern void myfree();
extern char *mymalloc();
#else
#include <stdlib.h>
#define myfree(_xx) free(_xx)
#define mymalloc(_xx) malloc(_xx)
#endif

#ifndef __GNUC__
typedef unsigned char u_char;
#endif

#ifdef DEBUG_PCA
#define log_enter yell("enter line %d at %s", __LINE__, __FILE__);
#define log_exit yell("exit line %d at %s", __LINE__, __FILE__);
#else
#define log_enter ;
#define log_exit ;
#endif

/* This includes the definitions for all of the sys$ routines */
#include <starlet.h>

extern major_mode mode_set;
extern win_mode curr_mode;

#endif
