home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / MSGED.H < prev    next >
Text File  |  1991-01-23  |  18KB  |  441 lines

  1. /*
  2.  
  3. main header for msged, most globals, lots of prototypes..
  4.  
  5. PUBLIC DOMAIN
  6.  
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <io.h>
  14.  
  15. #ifdef __OS2__
  16. #include "os2supp.h"
  17. #else
  18. #include <dos.h>
  19. #endif
  20.  
  21. #include <time.h>
  22.  
  23. #ifdef __MSC__
  24. #include <malloc.h>
  25. #endif
  26.  
  27. #define NOSPELL
  28.  
  29. #if defined(__ZTC__)
  30. #define NO_HANDLE 1
  31. #include <handle.h>
  32. #else
  33. #include "nohandl.h"
  34. #endif
  35.  
  36. #include "pascal.h" /* hides the oldstyle far/near/pascal */
  37.  
  38. #ifndef max
  39. #define max(a,b) (((a) > (b)) ? (a) : (b))
  40. #endif
  41.  
  42. #ifndef min
  43. #define min(a,b) (((a) < (b)) ? (a) : (b))
  44. #endif
  45.  
  46. #ifndef NDEBUG
  47. #define check(p) printf("%s (%d): %s = %p = %s\n",__FILE__,__LINE__,#p,p,p)
  48. #define checkp(p) printf("%s (%d): %s = %p\n",__FILE__,__LINE__,#p,p)
  49. #else
  50. #define check(p)
  51. #define checkp(p)
  52. #endif
  53.  
  54. #include "nedit.h"
  55. #include "screen.h"
  56.  
  57. #ifndef __OS2__
  58. #define VERSION "2.06c"
  59. #else
  60. #define VERSION "2.06c OS/2"
  61. #endif
  62.  
  63. #define FALSE           0
  64. #define TRUE       !FALSE
  65.  
  66. #define NO              0
  67. #define YES             1
  68. #define HIDE            2
  69.  
  70. #define GDOMAINS        1
  71. #define GZONES          2
  72. #define BOTH            GDOMAINS | GZONES
  73.  
  74. #define FIDO            0
  75. #define QUICK           1
  76.  
  77. #define USENET          1
  78. #define FIDONET         2
  79.  
  80. #define PATHLEN        64
  81. #define BLOCKLEN      255
  82.  
  83. #define thisnode        alias[0]
  84.  
  85. #ifdef __MSC__
  86. #define strcmpl stricmp
  87. #define strncmpi strnicmp
  88. #endif
  89.  
  90. #if defined(__TURBOC__) || defined(__TSC__)
  91. #define strcmpl strcmpi
  92. #endif
  93.  
  94. #define checkmem(x)     { if ((x) == NULL) outamemory(); }
  95.  
  96. /* structures and typedefs */
  97.  
  98. struct _attributes {
  99.     unsigned int private:1;    /* private message flag     */
  100.     unsigned int crash:1;      /* crash mail               */
  101.     unsigned int recvd:1;      /* received by addressee    */
  102.     unsigned int sent:1;       /* message sent             */
  103.     unsigned int attached:1;   /* file attached            */
  104.     unsigned int forward:1;    /* message in transit       */
  105.     unsigned int orphan:1;     /* unknown destination      */
  106.     unsigned int killsent:1;   /* kill after sending       */
  107.     unsigned int local:1;      /* local message            */
  108.     unsigned int hold:1;       /* hold for pickup          */
  109.     unsigned int direct:1;     /* do no gating on this msg */
  110.     unsigned int freq:1;       /* file request             */
  111.     unsigned int rreq:1;       /* return receipt requested */
  112.     unsigned int rcpt:1;       /* return receipt           */
  113.     unsigned int areq:1;       /* audit trail request      */
  114.     unsigned int ureq:1;       /* update file request      */
  115. };
  116.  
  117. typedef struct _address {
  118.     int     zone;
  119.     int     net;
  120.     int     node;
  121.     int     point;
  122.     char   *domain;
  123.     unsigned int notfound:1;
  124.     unsigned int fidonet:1;
  125.     unsigned int internet:1;
  126.     unsigned int bangpath:1;
  127. } ADDRESS;
  128.  
  129. typedef struct _area {
  130.     char *description;      /* what the user calls the area */
  131.     char *tag;              /* what confmail calls it! */
  132.     char *path;             /* where the area is on disk */
  133.     unsigned int local:1;   /* local message area */
  134.     unsigned int netmail:1; /* netmail message area */
  135.     unsigned int echomail:1;/* echomail area */
  136.     unsigned int news:1;    /* usenet news area */
  137.     unsigned int uucp:1;    /* usenet mail area */
  138.     unsigned int new:1;     /* a message has been entered */
  139.     unsigned int priv:1;    /* default privileged */
  140.     unsigned int hold:1;    /* default hold */
  141.     unsigned int direct:1;  /* default direct */
  142.     unsigned int crash:1;   /* default crash */
  143.     unsigned int killsent:1;/* default crash */
  144.     int msgtype;            /* the message type */
  145.     int board;              /* if a quickbbs area, which board number */
  146.     int first;              /* first message in the area */
  147.     int last;               /* last message in the area */
  148.     int current;            /* current message in the area */
  149.     int messages;           /* how many messages in the area */
  150.     int lastread;           /* the highest message read */
  151. } AREA;
  152.  
  153. typedef struct _msg {
  154.     int msgnum;                     /* local message number         */
  155.     char *reply;                    /* id of message this is a reply to */
  156.     char *msgid;                    /* this messages msgid */
  157.     char *isfrom;                   /* who from,                    */
  158.     char *isto;                     /* who to,                      */
  159.     char *subj;                     /* message subject,             */
  160.     unsigned int new:1;             /* new message                  */
  161.     unsigned int change:1;
  162.     time_t timestamp;               /* creation date,               */
  163.     unsigned int replyto;           /* thread to previous msg       */
  164.     unsigned int replyfrom;         /* thread to next msg           */
  165.     struct _attributes attrib;      /* message attribute*/
  166.     int times_read;
  167.     int cost;
  168.     ADDRESS to;                     /* destination address of message  */
  169.     ADDRESS from;                   /* origin address of message    */
  170.     LINE * text;                    /* the message buffer           */
  171. } MSG;
  172.  
  173. struct _command {
  174.     char *label;
  175.     void (_near _pascal *action)();
  176. };
  177.  
  178. typedef struct _msghandle {
  179.     MSG  *(_pascal *msg_readheader)(int n);                       /* read the header */
  180.     char *(_pascal *msg_readtext)(int n);                             /* read one line */
  181.     int   (_pascal *msg_writeheader)(MSG *m);                         /* write the header */
  182.     int   (_pascal *msg_writetext)(char *text, int n);    /* write a line */
  183.     int   (_pascal *msg_delete)(int n);
  184.     int   (_pascal *msg_last)(AREA a);
  185.     int   (_pascal *msg_scan)(AREA *a);
  186. } MSGHANDLE;
  187.  
  188. struct _dta   {
  189.     char            reserved[21];
  190.     char            attribute;
  191.     unsigned        time;
  192.     unsigned        date;
  193.     long            size;
  194.     char            name[13];
  195. };
  196.  
  197. /* imports from screen */
  198.  
  199. extern unsigned int far *macros[41];    /*      one for each of the various
  200.     function keys */
  201.  
  202.  
  203. extern int      maxy,                                   /* how many screen lines? */
  204.             maxx,                                   /* how many screen columns? */
  205.             videomethod;                    /* DIRECT, BIOS or FOSSIL */
  206.  
  207. extern unsigned int vbase;          /* the video segment */
  208.  
  209. /* some more includes (dependent on above) */
  210.  
  211. #include "fido.h"
  212. #include "quick.h"
  213.  
  214. /* global variables */
  215.  
  216. #ifdef MAIN
  217. /* the following table defines which functions are used for what msgtype */
  218.  
  219. MSGHANDLE msgdo[2] = { /* indexed by msgtype in AREA structure */
  220.     {fido_readheader, fido_readtext,
  221.      fido_writeheader, fido_writetext,
  222.      fido_delete, fido_setlast, fido_scan},
  223.  
  224.     {quick_readheader, quick_readtext,
  225.      quick_writeheader, quick_writetext,
  226.      quick_delete, quick_setlast, quick_scan}
  227. };
  228.  
  229. AREA    __handle *arealist = NULL;
  230.  
  231. char    *nitwit   = NULL;
  232.  
  233. char    *username = NULL,              /* who is you */
  234.     *quotestr = NULL,              /* how to prefix a quote */
  235.     *fidolist = NULL,              /* nodelist user list */
  236.     *userlist = NULL,              /* personal user list */
  237.     *origin   = NULL,              /* origin line */
  238.     *outfile  = NULL,              /* default export filename */
  239.     *home     = NULL,              /* home directory */
  240.     *attribline = NULL,            /* attribution string */
  241.     *lastread = NULL,              /* name of the lastread file */
  242.     *cfgfile = NULL,               /* name of the config file */
  243.     *quickbbs = NULL,              /* where a quickbbs message base is */
  244. #ifndef NOSPELL
  245.     *speller  = NULL,       /* name of spelling checker file */
  246. #endif
  247.     *confmail = NULL;              /* confmail log file name */
  248.  
  249. char    *comspec  = NULL;              /* file spec of command processor */
  250.  
  251. int     area = 0,                  /* current area number */
  252. #ifndef NOSPELL
  253.     spell = 0,                 /* use spell checker? */
  254. #endif
  255.     helpctxt = 0,                  /* current help context */
  256.     aliascount = 0,             /* how many aliases do you have? */
  257.     lastline = 0,               /* last line in message */
  258.     rm = 300, qm = 300,         /* the right and quote margins */
  259.     msgids = YES,               /* add msgid lines */
  260.     eids = YES,                 /* add eid lines */
  261.     opusdate = YES,             /* put in the opus time stamp */
  262.     fidozone = NO,              /* put in fido 12 addressing */
  263.     stripnotes = YES,            /* strip hidden lines */
  264.     shownotes = YES,             /* show hidden lines */
  265.     seenbys = YES,               /* show seenby lines */
  266.     pointnet = 0,               /* private net number of point */
  267.     tabsize = 8,                /* how many spaces for a tab */
  268.     tearline = YES,             /* show a tearline? */
  269.     domains = 0,                /* how many domains listed */
  270.     confirmations = YES,        /* confirm deletes, aborts? */
  271.     softcr = YES,                /* put in soft carriage returns? */
  272.     override = 0,               /* override the area origin line */
  273.     gate = BOTH,                /* zone/domain gate messages? */
  274.     rot13 = NO,                 /* rot13 this message? */
  275.     areas = 0,                                      /* how many message areas */
  276.     swapping = YES,
  277.     scanned = 0;                /* areas have been scanned */
  278.  
  279. int   *messages = NULL;            /* what messages exist in this area */
  280.  
  281. unsigned char   co_normal = 0x07,   /* the normal text color */
  282.         co_quote = 0x0,     /* quoted text color */
  283.         co_warn = 0x8f,     /* warning and error message color */
  284.         co_block = 0x0f,    /* block color */
  285.         co_info = 0x07,     /* informational messages */
  286.         co_hilite = 0x70;   /* general highlighting */
  287.  
  288. ADDRESS  *alias = NULL;
  289.  
  290. MSG      *message = NULL;
  291.  
  292. ADDRESS *domain_list = NULL;
  293.  
  294. ADDRESS uucp_gate;
  295.  
  296. #else  /* don't use initializers on extern definitions */
  297.  
  298. extern MSGHANDLE msgdo[];             /* indexed by msgtype in AREA structure */
  299.  
  300. extern AREA  __handle *arealist;
  301.  
  302. extern  char    *username,       /* who is you */
  303.                 *quotestr,                              /* how to prefix a quote */
  304.         *fidolist,              /* nodelist user list */
  305.         *userlist,              /* personal user list */
  306.         *origin,                /* origin line */
  307.         *outfile,               /* default export filename */
  308.         *attribline,            /* attribution string */
  309.         *home,                  /* home directory */
  310.         *lastread,              /* name of the lastread file */
  311.         *cfgfile,               /* name of the config file */
  312.         *quickbbs,                              /* where a quickbbs message base is */
  313. #ifndef NOSPELL
  314.         *speller,               /* name of spelling checker file */
  315. #endif
  316.         *confmail;              /* confmail log file name */
  317.  
  318. extern char *comspec;               /* file spec of command processor */
  319.  
  320. extern  int area,                  /* current area number */
  321. #ifndef NOSPELL
  322.         spell,                     /* use spell checker? */
  323. #endif
  324.         aliascount,             /* how many aliases do you have? */
  325.         helpctxt,               /* current help context */
  326.         lastline,               /* last line in message */
  327.         rm,qm,                  /* the right and quote margins */
  328.         msgids,eids,            /* add *ID lines */
  329.         fidozone,
  330.         opusdate,
  331.         stripnotes,             /* strip hidden lines */
  332.         shownotes,              /* show hidden lines */
  333.         seenbys,                /* show seenby lines */
  334.         pointnet,               /* private net number of point */
  335.         tabsize,                /* how many spaces for a tab */
  336.         tearline,               /* show a tearline? */
  337.         domains,                /* how many domains listed */
  338.         confirmations,          /* confirm deletes, aborts? */
  339.         softcr,                 /* put in soft carriage returns? */
  340.         override,               /* override the area origin line */
  341.         gate,                   /* zone/domain gate messages? */
  342.         rot13,                  /* rot13 this message? */
  343.         areas,                                  /* how many message areas */
  344.         swapping,
  345.         scanned;                /* areas have been scanned */
  346.  
  347. extern int  *messages;             /* what messages exist in this area */
  348.  
  349. extern  unsigned char co_normal,             /* the normal text color */
  350.         co_quote,               /* quoted text color */
  351.         co_warn,                /* warning and error message color */
  352.         co_block,               /* block color */
  353.         co_info,                /* informational messages */
  354.         co_hilite;              /* general highlighting */
  355.  
  356. extern ADDRESS *alias;
  357.  
  358. extern MSG     *message;
  359.  
  360. extern ADDRESS uucp_gate;
  361.  
  362. extern ADDRESS *domain_list;
  363.  
  364. #endif
  365.  
  366. /* prototypes */
  367.  
  368. void    _cdecl  main(int argc, char *argv[]);            /* msged.c      */
  369. void    _pascal cleanup(void);
  370. void    _pascal outamemory(void);                        /* msged.c      */
  371. MSG    *_pascal readmsg(int n);                      /* readmail.c   */
  372. int     _pascal writemsg(MSG *m);                        /* readmail.c   */
  373. void    _pascal deletemsg(void);                         /* maintmsg.c   */
  374. int     _pascal showmsg(MSG *m);                         /* showmail.c   */
  375. void    _pascal opening(char *,char *);              /* config.c     */
  376. void    _pascal parseareas(char *);                  /* areas.c      */
  377. int     _pascal nextmsg(int);                            /* msged.c      */
  378. int     _pascal selectarea(void);                        /* areas.c      */
  379. void    _pascal showheader(MSG *m);                  /* showmail.c   */
  380. ADDRESS _pascal parsenode(char *s);                  /* msged.c      */
  381. LINE *  _pascal clearbuffer(LINE *buffer);           /* readmail.c   */
  382. void    _pascal import(LINE *l);                         /* textfile.c   */
  383. void    _pascal export(LINE *f);                         /* textfile.c   */
  384. int     _pascal confirm(void);                       /* msged.c      */
  385. int     _pascal editheader(void);                        /* makemsg.c    */
  386. void    _pascal save(MSG *message);                  /* makemsg.c    */
  387. ADDRESS _pascal lookup(char *name, char *fn);            /* userlist.c   */
  388. void    _pascal newmsg(void);                            /* makemsg.c    */
  389. void    _pascal reply(void);                             /* makemsg.c    */
  390. void    _pascal quote(void);                             /* makemsg.c    */
  391. void    _pascal movemsg(void);                       /* maintmsg.c   */
  392. void    _pascal writetxt(void);                      /* textfile.c   */
  393. void    _pascal settings(void);                      /* settings.c   */
  394. void    _pascal change(void);                            /* makemsg.c    */
  395. char   *_pascal show_address(ADDRESS a);                 /* showmail.c   */
  396. char   *_pascal striplwhite(char *s);                    /* config.c     */
  397. void    _pascal clearmsg(MSG *m);                                                /* readmail.c   */
  398. int     _pascal setcwd(char *path);                  /* readmail.c   */
  399. void    _pascal dispose(MSG *message);               /* msged.c      */
  400. void    _pascal strins(char *l, char c, int x);      /* string.c     */
  401. void    _pascal strdel(char *l, int x);              /* string.c     */
  402. LINE   *_pascal insline(LINE *nl);                   /* editmail.c   */
  403. int     _pascal dir_findnext(struct _dta * dta);         /* dir.c        */
  404. int     _pascal dir_findfirst(char * filename,
  405.                int attribute, struct _dta * dta);      /* dir.c                */
  406. #ifdef __OS2__
  407. int     _pascal dir_findnext1(struct _dta * dta);         /* dir.c        */
  408. int     _pascal dir_findfirst1(char * filename,
  409.                int attribute, struct _dta * dta);      /* dir.c                */
  410. #endif
  411. #if defined(__ZTC__)
  412. int     _pascal strncmpi(char *si, char *so, int l);
  413. #endif
  414.  
  415. /* command key scancode table */
  416.  
  417. #define DONE    0x001b          /* <ESC> done   */
  418. #define RUBOUT  0x007f          /* DEL          */
  419. #define SPACE   0x0020          /* space bar    */
  420. #define ENTER   0x000d          /* <enter>      */
  421. #define ROOT    0x4700          /* <Home>       */
  422. #define LAST    0x4f00          /* <End>        */
  423. #define SCAN    0x1f00          /* <ALT><S>     */
  424.  
  425. /* various and sundry macros */
  426.  
  427. #define msg_readtext(n) (msgdo[arealist[area].msgtype].msg_readtext(n))
  428. #define msg_readheader(n) (msgdo[arealist[area].msgtype].msg_readheader(n))
  429. #define msg_writetext(t,n) (msgdo[arealist[area].msgtype].msg_writetext(t,n))
  430. #define msg_writeheader(m) (msgdo[arealist[area].msgtype].msg_writeheader(m))
  431. #define msg_last(a) (msgdo[a.msgtype].msg_last(a))
  432. #define msg_delete(n) (msgdo[arealist[area].msgtype].msg_delete(n))
  433. #define msg_scan(a) (msgdo[(a)->msgtype].msg_scan((a)))
  434. #define msgnum(x) ((arealist[area].msgtype == 0)?messages[x]:(x))
  435. #define release(s) {if (s != NULL) free(s); s = NULL;}
  436. #define DOROT13(c) ((rot13==0)?(c):(rot13==1)?(!isalpha((c)))?(c):((((c) >= (char) 'A') && \
  437.                    ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
  438.                    :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
  439.                    ((c) - (char) 0xd):(c):((c) >= (char) '!') ? ((((c) + (char) 47) > (char) '~') ? ((c) - (char) 47) :\
  440.                    ((c) + (char) 47)) : (c))
  441.