/****************************************************************************/
/*                                                                          */
/*    Maxmail.h   : Main include file                                       */
/*                   MaxMail, a message utility for Maximus CBBCS           */
/*                   ARCHIVE current new messages for users download        */
/*                                                                          */
/****************************************************************************/

#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <dos.h>
#include <fcntl.h>
#include <errno.h>
#include <malloc.h>
#include <memory.h>
#include <direct.h>
#include <process.h>
#include <io.h>
#include <time.h>
#include <share.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <sys\locking.h>


#include "compiler.h"
#include "prog.h"
#include "max.h"
#include "swap.h"

/* Packer information linked list structure */

struct packer_st {
   char   *packname;		/* Sysop defined description string for packer */
   char   *packexe;		/* Actual 12 character filename for packer */
   char   *packstring;	/* Command line for executing packer */
   char   *packpname;	/* 12 char filename for packed file */
   char   *viewstring;	/* COmmand line for viewing packed file */
   struct packer_st *next;
};

struct proto_st {
   char   *protoname;	/* Sysop defined description string for protocol */
   char   *protoexe;		/* Actual 12 character filename for portocol */
   char   *protostring;	/* Command line for executing protocol */
   struct proto_st *next;
};

struct repupl_st {
   char   *protoname;	/* Sysop defined description string for protocol */
   char   *protoexe;		/* Actual 12 character filename for protocol */
   char   *protostring;	/* Command line for executing protocol */
   struct repupl_st *next;
};

struct reparc_st {
   char   *packexe;		/* Actual 12 character filename for protocol */
   char   *packstring;	/* Command line for executing protocol */
};

/* Message update linked list structure */
struct msgupd_st {		/* MaxMail uses this to update lastuser file */
   word             areano;
   word             attribute;
   byte             msgpath[80];
   word             msgcount;
   word             startmsg;
   word             himsg;
   word             flags;
   int              update;
   word             readmsgs;
   long             areaindex;
   struct msgupd_st *next;
};

/* Special msgupd flags */
#define  AREA_FORCED 0x0001

/* Message header structure */
struct msghead {
   byte        from[36];
   byte        ourname[36];
   byte        subject[72];
   word        ourmail;
   int         *answers;
};

/* User configuration structure */


struct user_cfg {
   byte  name[36];	  /* Same as in User file */
   byte  rsvd1;   	  /* 1 if used, 0 if not */
   word  msgarea[64];  /* Bitmap for active user areas, allows for 1000 areas! */
                    	  /* If bit is set, area should be scanned,
                          1st bit = 1st area, etc */
  time_t lasttime;	  /* Unix compat time of last logon */
   word  packcount;    /* How many times we have used this */
   byte  protocol;	  /* Default protocol type, if 0 always ask */
                       /* This is 1 based index into proto types in config file */
   byte  packer;		  /* Packer type: If 0, no packing */
                       /* This is 1 based index into packer types in config file */
   word  flags;        /* Various user flags */
   word  calls;        /* # of times we have called */
   word  msgfrmt;      /* Message format, 0: Text, 1: QWK */
   word  totareas;	  /* Total possible areas */
   word  totprotos;	  /* Total possible protocols */
   word  totpackers;	  /* Total possible packers */
   byte  dailycount;		/* Times called today */
   word  maxareamsgs;	/* Max # of messages per area to pack */
   word  totselareas;		/* Total # of selected message areas */
   byte  rsvd[27];
};


/* Global definitions */

#define Version 1.61

#define HEAP_SIZE 0x2000

#define  TEST  1  		/* Disconnect some things for test mode */

#define  IDLETIME 3		/* # of minutes to allow for idle input */


/* Log Modes */

#define  TERSE       1
#define  VERBOSE     2

/* Error codes */
#define  BADALLOC    1
#define  BADEXEC     2
#define  FILEOPEN    3
#define  FILECREATE  4
#define  FILEWRITE   5
#define  DROPCARRIER 6
#define  USERIDLE    7
#define  DEADMODEM   8

/* Some default MESSAGE definitions */

#define MAXFMSGS  9999		/* Maximum # of Fido messages to scan for */
#define MAXFMSGSIZ  1024 * 20 /* Maximum message size, 20K */
#define SOFT  '\215'
#define SEEN "SEEN-BY:"
#define ESC '\033'

/* Message flags */
#define     PRIVATE     0x0002
#define     SCREEN      0x0004
#define     KILL        0x0008
#define     KLUDGE      0x0010
#define     JUNK        0x0020
#define     RANGING     0x1000
#define     HIGH        0x2000
#define     LASTREAD    0x4000

/* MaxMail user flags */

#define     LASTREAD_UPD   0x0001
#define     USRCFG_UPD     0x0002
#define     USRCFG_FUPD    0x0004
#define     NEWFILES_INC   0x0008
#define     DLHANGUP       0x0010
#define     USRCFG_MSGUPD  0x0012

/* Error definitions */
#define NOT_INITIALIZED  -1
#define MEMORY_ALLOC_ERR -2
#define FILE_READ_ERR    -3
#define FILE_SRCH_ERR    -4
#define FILE_OPEN_ERR    -5
#define FILE_WRITE_ERR   -6
#define PVTMSG_ERR       -7
#define FILE_SIZE_ERR    -8

/* Text style attribute defines */

#define STD_TEXT        0
#define HILITE_TEXT     1
#define MENU_KEY        2
#define TIME_LEFT       3
#define PROMPT_TEXT     4
#define ATTN_TEXT       5
#define VIEW_TEXT       6

#define TOTALCOLORS     7
          
#include "globals.h"
#include "protos.h"

