/*
 *
 * socket.h -- header file for socket.c
 *
 * This code is copyright 1995 by James A. Cherry, jac@doe.carleton.ca.
 * It is not to be redistributed or modified without his permission.
 *
 */

/* Size of input buffer */

#define RBUF_SIZE 2000

char ReadBuf[RBUF_SIZE];   /* input buffer storage */
char *RBIn, *RBLast;       /* pointers to input character and buffer end */

/* Read error types */

#define READ_SYSERR    -1
#define READ_EOF       -2
#define READ_BLOCK     -3
#define READ_NODATA    -4

/* Size of output buffer */

#define WBUF_SIZE 400

char WriteBuf[WBUF_SIZE];  /* output buffer storage */

/* recstr structure is defined in funddefs.h */

recstr *RecHead;           /* pointer to head of received strings */

/* Structure for storing outgoing strings */

typedef struct ws {
    struct ws *next;
    char *string;
    int delay;
} sendstr;

sendstr *SendHead;         /* pointer to head of string to be sent */

/* Tagged message types */

#define TTYPE_LOG2  1
#define TTYPE_LOOK  2
#define TTYPE_LOG   3
#define TTYPE_TRACK 4

/* Structure for storing which `-tagged' commands are expected */

typedef struct te {
    struct te *next;
    recstr *data;          /* pointer to received strings, if needed */
    int ttype;             /* TTYPE_LOG2, etc. */
    char name[20];         /* name of command initiator */
    char board[20];        /* board that command was done on */
    char form;             /* form of command (page or say) */
} tagent;

tagent *TagHead;           /* pointer to head of expected tagged queue */
int InTaggedBlock;         /* 1 when we're inside a [BEGIN]/[END] block */

int HasValidLog2;          /* 1 when an item to be log2'ed has a valid log2 */
int Log2GameInProgress;    /* 1 when a log2 is of a game in progress */
int MeInLog2;              /* 1 if log2 contains ACBot's name */
int TheyInLog2;            /* 1 if log2 contains requester's name */
char *EmailAddr;           /* storage for requester's email address */
int FileCount;             /* number of log2 files we've written so far */

#define RS_SIZE   ( sizeof( recstr ) )
#define WS_SIZE   ( sizeof( sendstr ) )
#define TE_SIZE   ( sizeof( tagent ) )

#define LOG2_DIR  "critdir/"

/* Function prototypes */

extern int errno;
extern char *sys_errlist[];
extern int socket();
extern bcopy();
extern connect();
extern void close(), sleep();
extern void bzero();
extern int select();
extern int read(), write();
extern usleep();

