/* ///Turbo Board ST Version 2.1.X - Main Structures - By Bill Miller  */

/*    Copyright 1990-1991 by Bitblit Systems  */

/* This information may only be used by people who wish to create an online
   program for Turbo Board Version 2.  It may NOT be used for any other
   purpose, OR by anyone programming a competitive BBS program, without the 
   express written consent of Bitblit Systems.    */

/*  Any inquiries may be sent to:

    Bitblit Systems
    1580 Liveoak Dr
    Mississauga ON
    Canada L5E 2X6
*/

#define MAXPW  2000  /* size of pw file */
#define MAXMESS 500  /* size of message bases */
#define MAXLINES 20  /* max lines in message */
#define MAXSIG 16    /* max SIG's */
#define MAXBASE 16   /* max bases under 1 SIG */


/* MENU.DAT file structure */
typedef struct {
  char ID;        /* menu ID number, 0=main menu */
  char smid;      /* if type # then smid = next sub menu ID 
                  if type % then smid = previous menu ID*/
  int access;     /* access for any entry */
  int attrib;     /* flags: check contime, write user dat files */
  char type;      /* entry type "!@#$%^" or main menu function letter */
  char key;       /* actual ascii code used to execute, case ignored*/
  char pars[41];  /* any parameters used for some types */
} MENTRY;
/* 
valid type's:
  ! = executable
  @ = type text file
  # = sub-menu
  $ = macro  
  % = previous menu
  ^ = main menu

attrib:
  bit0 = write TURBO/FOREM.DAT & DORINFO1.DEF files if executable type (!)
  bit1 = use contime.dat doors access level for any entry (column 3)
*/

/*  CONFIG.DAT system configuration file */
typedef struct {
   long callno;         /* caller number */
   char nbbs;           /* number of message bases */
   long nmess;          /* total messages in system */
   char ndrives;        /* number of drives online */
   char ndirect;        /* number of download directories */
   char subdir [20][9]; /* names of download directories */
   int pwnum;           /* size of password file */
   int mconf[65];       /* current number of messages allowed in each base */
   int cmess[65];       /* next message number  in each base */
   int nconf[65];       /* max number of messages in each base */
   int hmess[65];       /* high message on message base */
   char conf[65][41];   /* names of message bases */
   char textcolor;
   char backcolor;
   char drvlist[9];     /* drive search order (not used, see TURBO.OPT)*/
   char defdir[37];     /* default directory (not used, see TURBO.OPT)*/
   long flags;          /* various system flags (saved command options) */
                        /* Bit:
                                  0 = monthly.bat flag
                                  1 = chat mode on/off
                                  2 = log to disk on/off
                                  3 = guest allowed
                                  4 = accounting on/off
                                  5 = new user account number
                                  6 = Executive V3.0 memory save flag
                                  7 = color monitor
                                  8 = survey at new user logon
                                  9 = email deleted after each user
                                 10 = message to sysop as Email
                                 11 = Uploads to sysop only
                                 12 = Logon bulletins on/off
                                 13 = Credit for upload time
                                 14-31 spare
      */     
 
  int counters[10];     /* various system counters */
                        /*  0 = UL/DL ratio
                            1 = user timeout in 1/60 seconds 
                            2 = Fmail auto delete in days
                            3 = FNET default message base 
                            4 = Safs in from mailer  */
  long fnum;            /* number of next download file */
  char expandc[6];
}CONFIG;


/* SIGS.DAT header structure */
typedef struct{
  int maxsig;                   /* curently 16 SIG's max */
  int maxbase;                  /* curently 16 bases/SIG */
  int signum;                   /* number of SIG's  16 max */
  int siglevel[MAXSIG];         /* SIG access level */
  char Bmap[MAXSIG][MAXBASE];   /* Bmap[SIG][MAXBASE] = Real Base number */
  char bflg[65];                /* Base flags indexed from 1*/
  char order[64];               /* order of bases if NO sigs (signum = 0) */
  char *signame[MAXSIG];        /* Name of SIG */
  char *sigdesc[MAXSIG];        /* Description of SIG */
  char *basedesc[64];           /* Message base description */
}SIGHDR; 

/* bflg:  bit0 = handles only
          bit1 = default to handle, user can toggle with /mf
          bit2 = default to real, user can toggle
          bit3 = don't delete conf mail
          if bit0,1 & 2 are OFF then real name only
*/
   

/* Validation mask  MASK.DAT */
typedef struct {
  int  vaccess;
  long vpriv;
  long vrbase1,vrbase2;
  long vebase1,vebase2;
  long vfunct;
  long vusr;
  int vdtime,vclimit,vdcalls,vtilim,vctlim,vulim,vdlim;
  int vdbulim,vdbdlim,vmailim,vmeslim;
  int vdbaccess;
  long vfbase;
  int varclim;
  int vfnetlim;
  int vfnet_level;
  int vuldl, vkuldl;        /* upload/download ratios */
  long vxpriv;              /* extended privileges */
  long vconful1,vconful2;   /* bit map of allowed confmail uploads */
  long vconfdl1, vconfdl2;  /* bit map of allowed confmail downloads */
  long vsysfnk;             /* bit map of allowed Sysop functions */
  int vfedit;               /* bit map of allowed File edit functions */

/* only thing for 2.1 */  
  int vthreshold;           /* Kbytes user can go over the kuldl ratio*/
  char extend[104];
}VMASK;


/* User password file entry   TPAS.DAT  */
typedef struct {
  int  rec;                 /* record number in pas.dat */
  char id[13];              /* password */
  char name[31];            /* real name */
  char phone[13];           /* phone number */
  int  age;                 /* age, auto updated */
  char lfeed;               /* line feeds on/off */
  int  cls;                 /* computer type */
  int  calls;               /* number of calls */
  char last[3];             /* last call date */
  char first[3];            /* first call date */
  int  dl;                  /* number of downloads */
  int  up;                  /* uploads */
  int  mess;                /* messages sent */
  int  dbase;               /* data base files read */
  int  ubase;               /* data base files uploaded */
  int  mail;                /* Email messages sent */
  int  access;              /* access level for download and doors */
  int  dbaccess;            /* data base access level */
  long priv;                /* privilege bitmap */
  long rbase1,rbase2;       /* read message bases bitmap*/
  long ebase1,ebase2;       /* enter message bases bitmap */
  long funct;               /* commands bitmap */
  long usr;                 /* usr functions bitmap */
  int  dtime;               /* daily time limit */
  int  climit;              /* daily call limit */
  int  dcalls;              /* daily calls remaining */
  int  tilim;               /* daily time limit */
  int  ctlim;               /* call time limit */
  int  ulim;                /* upload limit */
  int  dlim;                /* download limit */
  int  dbulim;              /* database upload limit */
  int  dbdlim;              /* database read limit */
  int  mailim;              /* Email limit */
  int  meslim;              /* enter message limit */
  char accnum[10];          /* account number */
  int  himess[65];          /* high message read counters */
  int  moncon;              /* month connect time */
  int  dai_up;              /* daily counters */
  int  dai_dn;
  int  dai_mes;
  int  dai_mai;
  int  dai_dbu;
  int  dai_dbd;
  int msg_delay;            /* continuous scroll delay time */
  long fbase;               /* bitmap of allowed dl directories */
  long ufbase;              /* user set bitmap of Scan ALL directories */
  long urbase1,urbase2;     /* user set bitmap of READ ALL NEW messages bases */
  unsigned char arclim;     /* arcdl lim */
  char street[41];          /* rest of the address */
  char city[21];
  char state[3];
  char zip[11];
  unsigned char fnetlim;    
  unsigned char dai_fnet;   
  unsigned char fnet_level;
  char last_file[3];
  unsigned char lines;
  unsigned char uldl;

/****** Extended user record (not in version 1.0) ******/
  char alias[31];           /* user alias */
  char birth[3];            /* birth date MDY */
  char kuldl;               /* Kilobyte upload/download ratio */
  char mask;                /* mask number 0 -> 99 (255 = not set)*/
  int batpend;              /* number of pending batch uploaded files */
  unsigned long bytesup;    /* bytes uploaded */
  unsigned long bytesdl;    /* bytes downloaded */
  long xpriv;               /* extended privileges */
  long conful1,conful2;     /* bit map of allowed confmail uploads */
  long confdl1, confdl2;    /* bit map of allowed confmail downloads */
  long sysfnk;              /* bit map of allowed Sysop functions */
  int fedit;                /* bit map of allowed File edit functions */
/* 2.1.x addons */  
  int threshold;          /* Kbytes user can go over the kuldl ratio*/
  char emulation;         /* term emulation (0=VT52, 1=VT100) screen ed*/
  char Qctype;            /* Qmail packet compression type A,L or Z*/
  int  Qnmes;             /* Max Qmail messages/base */
  int  Qtmes;             /* Max messages/Qmail packet */
  int  Qflg;              /* assorted user Qmail flags, bit16 = REP process*/
  char extend[32];
}PWORD;

/*Qflg bits:
   bit 0 = include confmail
   bit 1 = prompt on confmail
   bit 2 = include newest to oldest
   bit 3 = use read all flags
   bit 4 = include new files list
   bit 5 = long files list
   bit 6 = include messages from user
   bit 15= internal REP process flag
*/


/* TPAS.IDX  Structure */
typedef struct {
   int ptail;
   int pentry[MAXPW+1];
}PSTACK;


/* MESAGEnn.IDX Structure */
typedef struct {
   int mtail;
   int mentry[MAXMESS+1];
}MSTACK;


/* MESAGEnn.ISM Structure */
typedef struct {
   int  irec;                 /*record number in data file*/
   int  inum;                 /*message number*/
   int  ilevel;               /*user level if sysusr message*/
   char ifrom[31];            /*from users name*/
   char itcl[31];             /*to users name*/
   char istat;                /*message status*/
   int irepnum;               /*message that this message is a reply to*/
   int inode;                 /* destination node */
   unsigned int ird_cnt;      /*times this message has been read*/
}MINDEX;


/* MESAGEnn.DAT Structure */
typedef struct {
   int num;
   int node;                  /* destination node */
   int level;
   char tcl[31];
   char from[31];
   char date[3];
   char time[10];
   char recv[3];
   char status;
   char subject[81];
   unsigned  char count;
   char lines[MAXLINES] [76];
   int repnum;
   int onode;                 /* originating node */
   char tnode[31];            /* name of originating node */
}MDAT;   

/*message status codes:
   bit 0 = 1-locked 0-unlocked
   bit 1 = 1-from anonymous
   bit 2 = 1-to anonymous
   bit 3 = 1-sysusr message
   bit 4 = 1-system message
   bit 5 = 1-received
   bit 6 = 1-Fmail/Conf Mail
   bit 7 = 1-extended message
*/


/*  *.TDB file structure */
typedef struct{
  char  fname[13];    /* filename */
  char  uploader[31]; /* uploader name */
  char  desc[61];     /* description */
  char  date[3];      /* upload date */
  int access;         /* access level */
  int ID;             /* menu identification number*/
  int attrib;         /* record attribute bits */
  long  length;       /* file length */
}TDB;

/* attrib bits:  
  bit 1 = off-line
  bit 2 = free DL
  bit 3 = deleted
  bit 4 = sub-menu
  bit 5 = (sub-menu) list fname instead of menu
  bit 6 = (sub-menu) show fname before listing menu entries
  bit 7 = (sub-menu) show fname only on entry to sub-menu
*/


/* *.FIL file directory structure */
typedef struct {
  char fname[13];     /* filename */
  char fdate[3];      /* date mm/dd/yy */
  long flength;       /* length */
  char flang[8];      /* whatever... */
  int flags;          /* 16 assorted bit flags:
                          bit 1 = archived (off-line file)
                          bit 2 = free download 
                          bit 3 = deleted flag */
  char  rating;       /* uploader file rating 1 - 100 */
  char fdesc[5][80];  /* description */
  char fapp;          /* application */
  char fascii;        /* ascii/binary flag */
  int  flevel;        /* access lavel */
  long frd_cnt;       /* download count */
  long fnum;          /* file number */
  char fuser[31];     /* uploader */
  char lread[3];      /* last download date*/
}TFILE;


/* HELP.IDX  file structure */
typedef struct {
   char topic[61];
   long loc;
}HIDX;


/* FNETMAIL.DAT file structure */
typedef struct {
  int  base;    /* message base the message is in */
  int  pos;     /* record number in message base */
  int  dest;    /* destination node number */
  int  save;    /* 1 if message is not to be deleted */
}FNETMAIL;


