home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / NETMAIL / MSGD2SRC.ZIP / MSGED.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-07  |  14.3 KB  |  434 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.00"
  59. #else
  60. #define VERSION "2.00 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.     scanned = 0;                /* areas have been scanned */
  277.  
  278. int   *messages = NULL;            /* what messages exist in this area */
  279.  
  280. unsigned char    co_normal = 0x07,    /* the normal text color */
  281.         co_quote = 0x0,     /* quoted text color */
  282.         co_warn = 0x8f,     /* warning and error message color */
  283.         co_block = 0x0f,    /* block color */
  284.         co_info = 0x07,     /* informational messages */
  285.         co_hilite = 0x70;    /* general highlighting */
  286.  
  287. ADDRESS  *alias = NULL;
  288.  
  289. MSG      *message = NULL;
  290.  
  291. ADDRESS *domain_list = NULL;
  292.  
  293. ADDRESS uucp_gate;
  294.  
  295. #else  /* don't use initializers on extern definitions */
  296.  
  297. extern MSGHANDLE msgdo[];              /* indexed by msgtype in AREA structure */
  298.  
  299. extern AREA  __handle *arealist;
  300.  
  301. extern    char    *username,          /* who is you */
  302.                 *quotestr,                              /* how to prefix a quote */
  303.         *fidolist,                /* nodelist user list */
  304.         *userlist,                /* personal user list */
  305.         *origin,                /* origin line */
  306.         *outfile,                /* default export filename */
  307.         *attribline,            /* attribution string */
  308.         *home,                    /* home directory */
  309.         *lastread,                /* name of the lastread file */
  310.         *cfgfile,                /* name of the config file */
  311.          *quickbbs,                              /* where a quickbbs message base is */
  312. #ifndef NOSPELL
  313.         *speller,               /* name of spelling checker file */
  314. #endif
  315.         *confmail;                /* confmail log file name */
  316.  
  317. extern char    *comspec;                /* file spec of command processor */
  318.  
  319. extern    int area,                   /* current area number */
  320. #ifndef NOSPELL
  321.         spell,                       /* use spell checker? */
  322. #endif
  323.         aliascount,             /* how many aliases do you have? */
  324.         helpctxt,                /* current help context */
  325.         lastline,                /* last line in message */
  326.         rm,qm,                    /* the right and quote margins */
  327.         msgids,eids,            /* add *ID lines */
  328.         fidozone,
  329.         opusdate,
  330.         stripnotes,             /* strip hidden lines */
  331.         shownotes,                /* show hidden lines */
  332.         seenbys,                /* show seenby lines */
  333.         pointnet,                /* private net number of point */
  334.         tabsize,                /* how many spaces for a tab */
  335.         tearline,                /* show a tearline? */
  336.         domains,                /* how many domains listed */
  337.         confirmations,            /* confirm deletes, aborts? */
  338.         softcr,                 /* put in soft carriage returns? */
  339.         override,                /* override the area origin line */
  340.         gate,                    /* zone/domain gate messages? */
  341.         rot13,                    /* rot13 this message? */
  342.         areas,                    /* how many message areas */
  343.         scanned;                /* areas have been scanned */
  344.  
  345. extern int     *messages;               /* what messages exist in this area */
  346.  
  347. extern    unsigned char co_normal,             /* the normal text color */
  348.         co_quote,                /* quoted text color */
  349.         co_warn,                /* warning and error message color */
  350.         co_block,                /* block color */
  351.         co_info,                /* informational messages */
  352.         co_hilite;                /* general highlighting */
  353.  
  354. extern ADDRESS *alias;
  355.  
  356. extern MSG       *message;
  357.  
  358. extern ADDRESS uucp_gate;
  359.  
  360. extern ADDRESS *domain_list;
  361.  
  362. #endif
  363.  
  364. /* prototypes */
  365.  
  366. void    _cdecl  main(int argc, char *argv[]);             /* msged.c      */
  367. void    _pascal cleanup(void);
  368. void    _pascal outamemory(void);                         /* msged.c      */
  369. MSG    *_pascal readmsg(int n);                         /* readmail.c     */
  370. int     _pascal writemsg(MSG *m);                         /* readmail.c     */
  371. void    _pascal deletemsg(void);                         /* maintmsg.c     */
  372. int     _pascal showmsg(MSG *m);                         /* showmail.c     */
  373. void    _pascal opening(char *,char *);                 /* config.c     */
  374. void    _pascal parseareas(char *);                     /* areas.c      */
  375. int     _pascal nextmsg(int);                             /* msged.c      */
  376. int     _pascal selectarea(void);                         /* areas.c      */
  377. void    _pascal showheader(MSG *m);                     /* showmail.c     */
  378. ADDRESS _pascal parsenode(char *s);                     /* msged.c      */
  379. LINE *    _pascal clearbuffer(LINE *buffer);              /* readmail.c     */
  380. void    _pascal import(LINE *l);                         /* textfile.c     */
  381. void    _pascal export(LINE *f);                         /* textfile.c     */
  382. int     _pascal confirm(void);                          /* msged.c      */
  383. int     _pascal editheader(void);                         /* makemsg.c     */
  384. void    _pascal save(MSG *message);                     /* makemsg.c     */
  385. ADDRESS _pascal lookup(char *name, char *fn);             /* userlist.c     */
  386. void    _pascal newmsg(void);                             /* makemsg.c     */
  387. void    _pascal reply(void);                             /* makemsg.c     */
  388. void    _pascal quote(void);                             /* makemsg.c     */
  389. void    _pascal movemsg(void);                          /* maintmsg.c     */
  390. void    _pascal writetxt(void);                         /* textfile.c     */
  391. void    _pascal settings(void);                         /* settings.c     */
  392. void    _pascal change(void);                             /* makemsg.c     */
  393. char   *_pascal show_address(ADDRESS a);                 /* showmail.c     */
  394. char   *_pascal striplwhite(char *s);                     /* config.c     */
  395. void    _pascal clearmsg(MSG *m);                                                /* readmail.c   */
  396. int     _pascal setcwd(char *path);                     /* readmail.c     */
  397. void    _pascal dispose(MSG *message);                  /* msged.c      */
  398. void    _pascal strins(char *l, char c, int x);         /* string.c     */
  399. void    _pascal strdel(char *l, int x);                 /* string.c     */
  400. LINE   *_pascal insline(LINE *nl);                      /* editmail.c     */
  401. int     _pascal dir_findnext(struct _dta * dta);         /* dir.c         */
  402. int     _pascal dir_findfirst(char * filename,
  403.                int attribute, struct _dta * dta);       /* dir.c                */
  404. #if defined(__ZTC__)
  405. int     _pascal strncmpi(char *si, char *so, int l);
  406. #endif
  407.  
  408. /* command key scancode table */
  409.  
  410. #define DONE    0x001b            /* <ESC> done    */
  411. #define RUBOUT    0x007f            /* DEL            */
  412. #define SPACE    0x0020            /* space bar    */
  413. #define ENTER    0x000d            /* <enter>        */
  414. #define ROOT    0x4700            /* <Home>        */
  415. #define LAST    0x4f00            /* <End>        */
  416. #define SCAN    0x1f00            /* <ALT><S>     */
  417.  
  418. /* various and sundry macros */
  419.  
  420. #define msg_readtext(n) (msgdo[arealist[area].msgtype].msg_readtext(n))
  421. #define msg_readheader(n) (msgdo[arealist[area].msgtype].msg_readheader(n))
  422. #define msg_writetext(t,n) (msgdo[arealist[area].msgtype].msg_writetext(t,n))
  423. #define msg_writeheader(m) (msgdo[arealist[area].msgtype].msg_writeheader(m))
  424. #define msg_last(a) (msgdo[a.msgtype].msg_last(a))
  425. #define msg_delete(n) (msgdo[arealist[area].msgtype].msg_delete(n))
  426. #define msg_scan(a) (msgdo[(a)->msgtype].msg_scan((a)))
  427. #define msgnum(x) ((arealist[area].msgtype == 0)?messages[x]:(x))
  428. #define release(s) {if (s != NULL) free(s); s = NULL;}
  429. #define DOROT13(c) ((rot13==0)?(c):(rot13==1)?(!isalpha((c)))?(c):((((c) >= (char) 'A') && \
  430.                    ((c) <= (char) 'M')) || (((c) >= (char) 'a') && ((c) <= (char) 'm')))?((c) + (char) 0xd)\
  431.                    :((((c) >= (char) 'N') && ((c) <= (char) 'Z')) || (((c) >= (char) 'n') && ((c) <= (char) 'z')))?\
  432.                    ((c) - (char) 0xd):(c):((c) >= (char) '!') ? ((((c) + (char) 47) > (char) '~') ? ((c) - (char) 47) :\
  433.                    ((c) + (char) 47)) : (c))
  434.