home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol150 / 211ctdl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1984-04-29  |  16.8 KB  |  476 lines

  1. /************************************************************************/
  2. /*                Ctdl210.h                */
  3. /*                                    */
  4. /*    #include file for all Citadel C files.                */
  5. /************************************************************************/
  6.  
  7. /************************************************************************/
  8. /*                History                 */
  9. /*                                    */
  10. /* 83Mar03 CrT    Changed from 2 to 3 sectors / log-record (more mail)    */
  11. /* 83Feb23    termTab, TABMASK                    */
  12. /* 82Dec16 dvm    Place for #defines added                */
  13. /* 82Dec06 CrT    2.00 release.                        */
  14. /* 82Nov02 CrT    General cleanup begun, preparatory to V1.2 mods.    */
  15. /* 82Nov01 CrT    Proofread for distribution version.            */
  16. /* 82Oct05 dvm    distribution version mods begun             */
  17. /* 82Jun03 dvm    MAXROOMS reduced to 64                    */
  18. /* 82Apr22 dvm    mods for HiTech/NMI version completed            */
  19. /* 81Dec19 CrT    Rooms seem to be working...                */
  20. /* 81Dec12 CrT    Started.                        */
  21. /************************************************************************/
  22.  
  23. /************************************************************************/
  24. /*                #defines        82Dec10 dvm    */
  25. /*                                    */
  26. /* #defs supported in current system:                    */
  27. /*                                    */
  28. /* #def FDC-1 for the TeleTek (dvm code)                */
  29. /* #def VFC-2 for the Big Board (dvm code)                */
  30. /*                                    */
  31. /* #def TEST for special small-scale test version            */
  32. /************************************************************************/
  33.  
  34.  
  35. char firstExtern;    /* this should ALWAYS be the first declaration    */
  36.  
  37. char mData;            /* Modem data port            */
  38.  
  39. char megaHz;            /* Z80 clock rate (for wait loops)    */
  40.  
  41. char *nodeName;
  42. char *nodeTitle;
  43. char *nodeId;
  44.  
  45. int  cryptSeed;
  46. char rcpm;            /* TRUE to run in RCP/M mode        */
  47. char clock;            /* TRUE  if we have a hardware clock    */
  48.  
  49. char homeDisk, homeUser, msgDisk;    /* where we keep our data files */
  50. char ourDisk, ourUser;            /* where we are just now    */
  51.  
  52. char unlogEnterOk;        /* TRUE if OK to enter messages anon    */
  53. char unlogReadOk;        /* TRUE if unlogged folks can read mess */
  54. char unlogLoginOk;        /* TRUE if spontan. new accounts ok.    */
  55. char nonAideRoomOk;        /* TRUE general folks can make rooms    */
  56.  
  57. /************************************************************************/
  58. /*                                    */
  59. /*        !   !  !!!   !!!!!  !!!!!   !!                */
  60. /*        !!  ! !   !    !    !        !!                */
  61. /*        ! ! ! !   !    !    !!!     !!                */
  62. /*        !  !! !   !    !    !                    */
  63. /*        !   !  !!!     !    !!!!!   !!                */
  64. /*                                    */
  65. /* Citadel programs use readSysTab() and writeSysTab() to write an    */
  66. /* image of the external variables in RAM to disk, and later restore    */
  67. /* it.    The image is stored in ctdlTabl.sys .  If ctdlTabl.sys is lost, */
  68. /* sysop.com will automatically reconstruct the hard way when invoked,    */
  69. /* and write a new ctdlTabl.sys out when finished.  CtdlTabl.sys is    */
  70. /* always destroyed after reading, to minimize the possibility of    */
  71. /* reading an out-of-date version.  In general, the technique works    */
  72. /* well and saves time and head-banging on bootup.  You should,     */
  73. /* however, note carefully the following cautions:            */
  74. /*  o  "char firstExtern;" should >always< be the first         */
  75. /*     declaration in citadel.h                     */
  76. /*  o  "char lastExtern;"  shoule >always< be the last            */
  77. /*     declaration in citadel.h                     */
  78. /*  o  Whenever you change the declarations in 210Ctdl.h you should:    */
  79. /*   -->  destroy the current ctdlTabl.sys file             */
  80. /*   -->  recompile and reload all citadel programs which access    */
  81. /*      ctdlTabl.sys -- currently citadel.com & consifurg.com     */
  82. /*   -->  use configur.com to build a new ctdlTabl.sys file        */
  83. /*                                    */
  84. /* If you ignore these warnings, little pixies will prick you in your    */
  85. /* sleep for the rest of your life.                    */
  86. /************************************************************************/
  87.  
  88. /************************************************************************/
  89. /*    stuff to distinguish the various Citadel programs        */
  90. /************************************************************************/
  91. #define CITADEL     0    /* prinipal program            */
  92. #define xxxxx        1    /* unused                */
  93. #define NET        2    /* network downloader    (future)    */
  94. #define ARCHIVE     3    /* backup program    (future)    */
  95. char    weAre;            /* set first thing by main()        */
  96.  
  97. /************************************************************************/
  98. /*            Stuff to size system with:            */
  99. /************************************************************************/
  100.  
  101. /* WARNING!!! if you expand MAXROOMS beyond 128, horrible, horrible    */
  102. /* things will happen to the userlog entries, which will no longer    */
  103. /* fit in the assigned 256-byte records and will overwrite things    */
  104. /* with normally undesirable results. 82Nov10CrT            */
  105. #ifdef TEST
  106. #define MAXROOMS    6
  107. #define MAXLOGTAB    4
  108. #else
  109.  
  110. #define MAXROOMS       64    /* number of rooms allowed in system    */
  111.  
  112. #define MAXLOGTAB     180    /* number of log entries supported    */
  113.  
  114. #endif
  115.  
  116. #define SECSPERROOM    2    /* sectors/room             */
  117. #define ROOMSECTORS   (MAXROOMS*SECSPERROOM)
  118. #define SECSPERLOG    3    /* three sectors per log record     */
  119. #define LOGSECTORS    (MAXLOGTAB*SECSPERLOG)
  120.  
  121. /************************************************************************/
  122. /*        Stuff nowadays usually in bdscio.h:            */
  123. /************************************************************************/
  124.  
  125. /* values for functions to return: */
  126. #define TRUE        1
  127. #define FALSE        0
  128. #define ERROR           -1
  129.  
  130. #define SAMESTRING    0    /* value for strcmp() & friend        */
  131.  
  132. /* ASCII characters: */
  133. #define NULL        0
  134. #define SOH        1
  135. #define CNTRLC        3
  136. #define EOT        4
  137. #define ACK        6
  138. #define BELL        7
  139. #define BACKSPACE    8
  140. #define CNTRLI        9    /* aka tab                */
  141. #define TAB        9    /* aka ^I                */
  142. #define NEWLINE        10    /* "linefeed" to philistines.        */
  143. #define CNTRLO           15
  144. #define CNTRLp           16
  145. #define XOFF           19    /* control-s                */
  146. #define NAK           21
  147. #define CNTRLZ           26
  148. #define CPMEOF       CNTRLZ
  149. #define ESC           27    /* altmode                */
  150. #define DEL         0x7F    /* delete char                */
  151.  
  152. /* for packing & unpacking ints: */
  153. #define BYTE          256
  154.  
  155. /************************************************************************/
  156. /*            Stuff for rooms:                */
  157. /************************************************************************/
  158.  
  159. #define LOBBY        0    /* Lobby> is >always< room 0.        */
  160. #define MAILROOM    1    /* Mail>  is >always< room 1.        */
  161. #define AIDEROOM    2    /* Aide> is >always< room 2.        */
  162.  
  163. #define NAMESIZE       20    /* length of room names         */
  164.  
  165. #ifdef TEST
  166. #define MSGSPERRM      58    /* should be >= MAILSLOTS        */
  167. #else
  168. #define MSGSPERRM      58    /* roombuf must be 256 bytes or less.    */
  169. #endif
  170.  
  171. #define FILSPERRM      10    /* roombuf must be 256 bytes or less.    */
  172. #define SECTSIZE      128
  173. char debug;            /* turns debug printout on and off    */
  174. int  roomfl;            /* file descriptor for ctdlRoom.sys    */
  175.  
  176. #define INUSE        1    /* flags mask                */
  177. #define PUBLIC        2    /* flags mask                */
  178. #define CPMDIR        4    /* flags mask                */
  179. #define PERMROOM    8    /* flags mask                */
  180. struct {
  181.     char     rtgen;        /* generation # of room         */
  182.     char     rtflags;        /* public/private flag etc        */
  183.     char     rtname[NAMESIZE];    /* name of room             */
  184.     unsigned rtlastMessage;    /* # of most recent message in room    */
  185. } roomTab[MAXROOMS];
  186.  
  187. struct {
  188.     char     rbgen;        /* generation # of room         */
  189.     char     rbflags;        /* same bits as flags above        */
  190.     char     rbname[NAMESIZE];    /* name of room             */
  191.     char     rbdisk;        /* disk this rooms files are in 0=>none */
  192.     char     rbuser;        /* user area for this rooms files    */
  193.     union {
  194.     struct {
  195.         unsigned rbmsgNo;    /* every message gets unique#        */
  196.         int      rbmsgLoc;    /* sector message starts in        */
  197.     } msg[MSGSPERRM];
  198.  
  199.     /* old idea, will probably drop: */
  200.     struct {
  201.         unsigned rbfilNo;    /* files also get ID#s            */
  202.         char rbfilNam[NAMESIZE];    /* name of file         */
  203.     } fil[FILSPERRM];
  204.     } vp;            /* variable-part            */
  205. #ifdef TEST
  206.     char rbOverRun[256];
  207. #else
  208.     char rbOverRun[2];        /* actually unneeded just now -- roomBuf*/
  209. #endif
  210.                 /* is exactly 256 at present        */
  211. } roomBuf;            /* buffer current room is held in    */
  212.  
  213. char thisRoom;            /* room currently in roomBuf    */
  214.  
  215. /************************************************************************/
  216. /*                  userlog stuff                */
  217. /************************************************************************/
  218. #define CRYPTADD      117    /*                    */
  219.  
  220. #define UCMASK        1    /* bit uppercase flag is in        */
  221. #define LFMASK        2    /* bitmask for linefeed flag        */
  222. #define EXPERT        4    /* bitmask for expert-user flag     */
  223. #define TABMASK     8    /* bitmask for tab flag         */
  224. #define AIDE           16    /* bitmask for aide flag        */
  225.  
  226. #define MAILSLOTS      58    /* twiddle to fit logBuf in 384 bytes    */
  227.  
  228. #define GENSHIFT    3    /* lbgen >> GENSHIFT gives generation    */
  229. #define CALLMASK    7    /* lbgen &  CALLMASK gives last visit    */
  230. #define MAXVISIT    8    /* #visits we remember old newestLo for */
  231. #define MAXGEN           32    /* six bits of generation => 64 of them */
  232.  
  233. /* logbuf must be 384 bytes or less... including lbOverFlow, 384 or MORE*/
  234. struct logBuffer {
  235.     char      lbnulls;        /* #nulls, lCase, lFeeds        */
  236.     char      lbflags;        /* UCMASK, LFMASK, EXPERT, TABMASK, AIDE*/
  237.     char      lbwidth;        /* terminal width            */
  238.     char      lbname[NAMESIZE]; /* caller's name            */
  239.     char      lbpw[NAMESIZE];    /* caller's password            */
  240.     char      lbgen[MAXROOMS];    /* 6 bits gen, two bits lastvisit    */
  241.     int       lbvisit[MAXVISIT];/* newestLo for this and 3 prev. visits */
  242.     int       lbslot[MAILSLOTS];/* for private mail            */
  243.     unsigned  lbId[MAILSLOTS];    /* for private mail            */
  244. #ifdef TEST
  245.     char      lbOverFlow[256];
  246. #else
  247.     char      lbOverFlow[84];
  248. #endif
  249. } logBuf;
  250.  
  251. int thisLog;            /* entry currently in logBuf        */
  252. int thisSlot;            /* logTab slot logBuf was found via    */
  253.  
  254. int logfl;            /* log file fd                */
  255.  
  256. struct {
  257.     int  ltpwhash;        /* hash of password            */
  258.     int  ltnmhash;        /* hash of name             */
  259.     int  ltlogSlot;        /* location in userlog.buf        */
  260.     int  ltnewest;        /* last message on last call        */
  261. } logTab[MAXLOGTAB];
  262. int sizeLTentry;        /* contains size of a logTab entry    */
  263.  
  264. char loggedIn;             /* global have-caller flag         */
  265.  
  266. /************************************************************************/
  267. /*            terminal stuff                    */
  268. /************************************************************************/
  269. #define SPECIAL        27    /* <ESC>    console escape char    */
  270.  
  271. #define MONTHOFFSET    32    /* for packing month and year in a byte */
  272. char *monthTab[13];        /* month names (we don't use loc 0)    */
  273. char filter[128];        /* input character translation table    */
  274.  
  275. char prevChar;            /* for EOLN/EOParagraph stuff        */
  276. char expert;            /* true to suppress hints & noise    */
  277. char termWidth;         /* width to format output to        */
  278. char termUpper;         /* uppercase-only flag            */
  279. char termLF;            /* LF-after-CR flag            */
  280. char termTab;            /* has-tabs flag            */
  281. char aide;            /* aide-privileges flag         */
  282. char termNulls;         /* #nulls to send at eoln        */
  283. char justLostCarrier;        /* room2.c / rmmodem.c    communication    */
  284. char crtColumn;         /* current position on screen        */
  285.  
  286. char newCarrier;
  287. char onConsole;
  288. #define MAXTEXT      3500    /* maximum chars in edit buffer     */
  289.  
  290. /************************************************************************/
  291. /*            message stuff                    */
  292. /************************************************************************/
  293. struct {
  294.     char mbtext[MAXTEXT]  ;    /* buffer text is edited in        */
  295.  
  296.     int  mbheadChar      ;    /* start of message            */
  297.     int  mbheadSector      ;    /* start of message            */
  298.  
  299.     char mbauth[ NAMESIZE];    /* name of author            */
  300.     char mbdate[ NAMESIZE];    /* creation date            */
  301.     char mbId[     NAMESIZE];    /* local number of message        */
  302.     char mboname[NAMESIZE];    /* short human name for origin system    */
  303.     char mborig[ NAMESIZE];    /* US 206 633 3282 style ID        */
  304.     char mbroom[ NAMESIZE];    /* creation room            */
  305.     char mbsrcId[NAMESIZE];    /* message ID on system of origin    */
  306.     char mbto[     NAMESIZE];    /* private message to            */
  307. } msgBuf;
  308.  
  309. int msgfl;        /* message file fd--packed leaky circular queue */
  310.  
  311. char sectBuf[SECTSIZE];     /* temporary buffer for random access    */
  312.  
  313. char GMCCache;            /* to unGetMsgChar() into        */
  314.  
  315. int oldChar;            /* old value of thisChar        */
  316. int oldSector;            /* old value of thisSector        */
  317.  
  318. int thisChar;            /* next char in sectBuf         */
  319. int thisSector;         /* next sector in msgfl         */
  320.  
  321. int catChar;        /* as in cat-and-mouse queue, or conCATenation. */
  322. int catSector;            /* where to write next message        */
  323.  
  324. unsigned oldestLo, oldestHi;    /* 32-bit ID# of first message in system*/
  325. unsigned newestLo, newestHi;    /* 32-bit ID# of last  message in system*/
  326.  
  327. int maxMSector;         /* # sectors (used) in ctdlmsg.sys    */
  328.  
  329.  
  330. /* values for showMess routine */
  331. #define NEWoNLY     0
  332. #define OLDaNDnEW    1
  333. #define OLDoNLY     2
  334. #define GLOBALnEW    3
  335.  
  336. /************************************************************************/
  337. /*            modem stuff                    */
  338. /************************************************************************/
  339. /* somestuff readfile() and sendfile() like:    */
  340. #define LOOPSPERSEC  5000
  341. #define ERRORMAX       10
  342. #define RETRYMAX       10
  343.  
  344. /* sendFile() globals because BDS C lacks coroutines and statics alike: */
  345. char SFcheckSum, SFeofSeen, SFRunning;
  346. int  SFi, SFthisChar, SFthisSector, SFerrorCount, SFtries;
  347. char SFBuf[SECTSIZE];
  348.  
  349. /* fiddle factor to timeout on no input: */
  350. #define HITIMEOUT    2    /* count seems to be about 30 sec    */
  351.  
  352. #define NEWCARRIER   0x01    /* returned to main prog on login    */
  353.  
  354. #define MODEM        0    /* current user of system is        */
  355. #define CONSOLE     1    /* one of these             */
  356. char modStat;            /* whether modem was on line        */
  357.                 /* LAST time it was checked        */
  358.  
  359. char noChat;            /* TRUE to suppress chat attempts    */
  360. char whichIO;            /* CONSOLE or MODEM            */
  361. char visibleMode;        /* make non-printables visible?     */
  362. char haveCarrier;        /* set if DCD == TRUE            */
  363. char exitToCpm;         /* system is being brought down     */
  364.  
  365. char textDownload;        /* read host files, TRUE => ASCII    */
  366.  
  367. /*  output XON/XOFF etc flag... */
  368. #define OUTOK        0    /* normal output            */
  369. #define OUTPAUSE    1    /* a pause has been requested        */
  370. #define OUTNEXT     2    /* quit this message, get the next    */
  371. #define OUTSKIP     3    /* stop current process         */
  372. #define OUTPARAGRAPH    4    /* skip to next paragraph        */
  373. char outFlag;            /* will be one of the above        */
  374.  
  375. #define NEITHER     0    /* don't echo input            */
  376. #define CALLER        1    /* echo to caller only --passwords etc    */
  377. #define BOTH        2    /* echo to caller and console both    */
  378.  
  379. char echo;            /* will be one of above three        */
  380.  
  381. /* scratch externals for speed-critical code:    */
  382. char *fpc1, *fpc2, *fpc3;
  383. char   fc1,   fc2,   fc3;
  384. int    fi1,   fi2,   fi3;
  385.  
  386. char usingWCprotocol;        /* true during Ward Christensen-    */
  387.                 /* protocol file/message transfers.    */
  388.  
  389. /************************************************************************/
  390. /*    stuff for the mini-INTRPreter that drives the modem:        */
  391. /************************************************************************/
  392. /* opcodes for the interpreter: */
  393. #define ANDI        1
  394. #define INP        2
  395. #define LOAD        3
  396. #define LOADI        4
  397. #define ORI        5
  398. #define OUTP        6
  399. #define OUTSTRING    7
  400. #define PAUSEI        8
  401. #define RET        9
  402. #define STORE           10
  403. #define XORI           11
  404. #define STOREX           12
  405. #define LOADX           13
  406. #define OPRNUMBER      14
  407. #define TOBDC           15
  408. #define TODEC           16
  409.  
  410. #define MAXCODE       512
  411. char codeBuf[MAXCODE];    /* buffer for configuration routines    */
  412. char scratch[40];    /* scratch space for config routines    */
  413. char shave[8];        /* shave-and-a-haircut/2 bits pauses    */
  414.  
  415. /* routine addresses in codeBuf: */
  416. char *pHangUp, *pCarrDetect, *pMIReady, *pMOReady, *pInitPort;
  417. char *pInitDate, *pGetDay, *pGetMonth, *pGetYear;
  418.  
  419. /************************************************************************/
  420. /*        get/put message stuff                    */
  421. /************************************************************************/
  422. char pullMessage;        /* true to pull current message     */
  423. int  pulledMLoc;        /* loc of pulled message        */
  424. int  pulledMId;         /* id number of message to be pulled    */
  425.  
  426.  
  427. /************************************************************************/
  428. /*        buffered file I/O stuff                 */
  429. /************************************************************************/
  430. #define NSECTS        8    /*  8 sectors == 1024 byte buffer    */
  431.  
  432. #define BUFSIZ        (NSECTS * SECTSIZE + 6)
  433.  
  434. struct    _buf {
  435.     int  _fd;
  436.     int  _nleft;
  437.     char *_nextp;
  438.     char _buff[NSECTS * SECTSIZE];
  439. };
  440.  
  441. /* file control block structure, for doing directories: */
  442. struct fcb {
  443.     char    fcbDr;        /* drive number             */
  444.     char    fcbfName[8];    /* file name                */
  445.     char    fcbfExt[3];    /* file extention            */
  446.  
  447.     char    fcbEx;        /* file extent -- usually 0        */
  448.  
  449.     char    fcbS1;        /* mysterious BDOS byte         */
  450.     char    fcbS2;        /* same, zero for open, make, search    */
  451.  
  452.     char    fcbRC;        /* record count in this extent, 0-128    */
  453.  
  454.     char    fcbdMap[16];    /* bitmap?                */
  455.  
  456.     char    fcbCr;        /* current record -- initialize to 0    */
  457.  
  458.     unsigned    fcbRecn;    /* highest record number        */
  459.     char    fcbRecOvfl;    /* overflow of above            */
  460. };
  461.  
  462. /* some more stuff for doing directories: */
  463. #define FINDfIRST      17    /* BDOS call to find first match    */
  464. #define FINDnEXT       18    /* BDOS call for next directory match    */
  465.  
  466. #define SETdMA           26    /* BDOS call                */
  467.  
  468. #define SETdISK        14    /* BDOS call                */
  469. #define SETuSER        32    /* BDOS call                */
  470.  
  471. #define GETfILEsIZE    35    /* BDOS call                */
  472.  
  473. int  FDSectCount;        /* fileDirectory() keeps a count here    */
  474.  
  475. char lastExtern;       /* this should ALWAYS be the last declaration  */
  476.