home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XS.ZIP / LIB / LIB.H < prev    next >
C/C++ Source or Header  |  1992-11-30  |  18KB  |  393 lines

  1. /*--------------------------------------------------------------------*/
  2. /*      l i b . h                                                     */
  3. /*                                                                    */
  4. /*      Update log:                                                   */
  5. /*                                                                    */
  6. /*      13 May 89    Added PCMAILVER                        ahd       */
  7. /*      Summer 89    Added equali, equalni, compiled,                 */
  8. /*                         compilet                         ahd       */
  9. /*      22 Sep 89    Add boolean typedef                    ahd       */
  10. /*      01 Oct 89    Make logecho boolean                   ahd       */
  11. /*      19 Mar 90    Move FOPEN prototype to here           ahd       */
  12. /*      02 May 1990  Allow set of booleans options via options=       */
  13. /*  8 May  90  Add 'pager' option                                     */
  14. /* 10 May  90  Add 'purge' option                                     */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*--------------------------------------------------------------------*/
  18. /*    Changes Copyright (c) 1989 by Andrew H. Derbyshire.             */
  19. /*                                                                    */
  20. /*    Changes Copyright (c) 1990-1992 by Kendra Electronic            */
  21. /*    Wonderworks.                                                    */
  22. /*                                                                    */
  23. /*    All rights reserved except those explicitly granted by the      */
  24. /*    UUPC/extended license agreement.                                */
  25. /*--------------------------------------------------------------------*/
  26.  
  27. /*--------------------------------------------------------------------*/
  28. /*                          RCS Information                           */
  29. /*--------------------------------------------------------------------*/
  30.  
  31. /*
  32.  *    $Id: LIB.H 1.3 1992/12/01 04:39:34 ahd Exp $
  33.  *
  34.  *    Revision history:
  35.  *    $Log: LIB.H $
  36.  * Revision 1.3  1992/12/01  04:39:34  ahd
  37.  * Add SpeedOverMemory
  38.  *
  39.  * Revision 1.2  1992/11/22  21:31:22  ahd
  40.  * Allow strpool() to allocate memory for const strings
  41.  *
  42.  * Revision 1.1  1992/11/16  05:00:26  ahd
  43.  * Initial revision
  44.  *
  45.  */
  46.  
  47. #ifndef __LIB
  48. #define __LIB
  49.  
  50. /*--------------------------------------------------------------------*/
  51. /*     Environment variables set by UUXQT before invoking modules     */
  52. /*--------------------------------------------------------------------*/
  53.  
  54. #define UU_USER "UU_USER"
  55. #define UU_MACHINE "UU_MACHINE"
  56. #define LOGNAME "LOGNAME"
  57. #define RMAIL   "rmail"
  58.  
  59. /*--------------------------------------------------------------------*/
  60. /*                   Global configuration variables                   */
  61. /*--------------------------------------------------------------------*/
  62.  
  63. #define SYSRCSYM "UUPCSYSRC"
  64. #define USRRCSYM  "UUPCUSRRC"
  65. #define SYSDEBUG  "UUPCDEBUG"    /* Initialize debug level ahd       */
  66.  
  67. /*--------------------------------------------------------------------*/
  68. /*                 Macro for recording when UUPC dies                 */
  69. /*--------------------------------------------------------------------*/
  70.  
  71. #define panic()  bugout( __LINE__, cfnptr)
  72.  
  73. /*--------------------------------------------------------------------*/
  74. /*                 Macro for generic error messages from DOS          */
  75. /*--------------------------------------------------------------------*/
  76.  
  77. #define printerr( x )  prterror( __LINE__, cfnptr, x)
  78.  
  79. /*--------------------------------------------------------------------*/
  80. /*                  Convert hours/minutes to seconds                  */
  81. /*--------------------------------------------------------------------*/
  82.  
  83. #define hhmm2sec(HHMM)    ((time_t)(((HHMM / 100) * 60L) + \
  84.                            (time_t)(HHMM % 100)) * 60L)
  85.  
  86. /*--------------------------------------------------------------------*/
  87. /*                     Configuration file defines                     */
  88. /*--------------------------------------------------------------------*/
  89.  
  90. #define B_REQUIRED 0x00000001L /* Line must appear in configuration   */
  91. #define B_FOUND    0x00000002L /* We found the token                  */
  92.  
  93. #define B_GLOBAL   0x00000004L /* Must not appear in PERSONAL.RC      */
  94. #define B_LOCAL    0x00000008L /* The opposite of B_GLOBAL, sort of   */
  95.  
  96. #define B_MTA      0x00000010L /* Used by Mail Delivery (RMAIL)       */
  97. #define B_MUA      0x00000020L /* Used by Mail User Agent (MAIL)      */
  98. #define B_MUSH     0x00000040L /* Used by MUSH - Not used by UUPC     */
  99. #define B_NEWS     0x00000080L /* Used by NEWS software               */
  100. #define B_UUCICO   0x00000100L /* Used by transport program UUCICO    */
  101. #define B_UUCP     0x00000200L /* Used by UUCP command                */
  102. #define B_UUPOLL   0x00000400L /* UUPOLL program                      */
  103. #define B_UUSTAT   0x00000800L /* UUSTAT, UUSUB, UUNAME programs      */
  104. #define B_UUXQT    0x00001000L /* Used by queue processor UUXQT       */
  105. #define B_INSTALL  0x00002000L /* Used by install program only        */
  106. #define B_MAIL     (B_MUA | B_MTA | B_MUSH)
  107. #define B_SPOOL    (B_MTA | B_UUCICO | B_UUXQT | B_UUCP | B_UUSTAT)
  108. #define B_ALL      (B_MAIL|B_SPOOL|B_NEWS|B_UUPOLL|B_UUSTAT)
  109.  
  110. #define B_INTEGER  0x00010000L /* Pointer is to short int, not string */
  111. #define B_TOKEN    0x00020000L /* Pointer is one word, ignore blanks  */
  112. #define B_BOOLEAN  0x00040000L /* Pointer is to boolean keywords      */
  113. #define B_LIST     0x00080000L /* Pointer to array of char pointers   */
  114. #define B_CLIST    0x00100000L /* Pointer to array of char pointers,
  115.                                   input is separated by colons, not
  116.                                   spaces                              */
  117. #define B_STRING   0x00200000L /* String value (same as original UUPC
  118.                                   configuration processor             */
  119. #define B_NORMAL   0x00400000L /* Normalize backslashes to slashes in
  120.                                   in this variable                    */
  121. #define B_OBSOLETE 0x00800000L /* Option is obsolete, should be
  122.                                   deleted                             */
  123. #define B_MALLOC   0x01000000L  /* Use malloc(), not newstr()         */
  124. #define B_PATH     (B_TOKEN | B_NORMAL)
  125.                                /* DOS Path name                       */
  126.  
  127. /*--------------------------------------------------------------------*/
  128. /*                     General defines and macros                     */
  129. /*--------------------------------------------------------------------*/
  130.  
  131. #define  MESSAGESEP "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n"
  132.  
  133. #define DCSTATUS    "hostatus"
  134. #define PASSWD      "passwd"
  135. #define PATHS       "hostpath"
  136. #define PERMISSIONS "permissn"
  137. #define SYSLOG      "syslog"
  138. #define SYSTEMS     "systems"
  139. #define ACTIVE      "active"
  140.  
  141. #define WHITESPACE " \t\n\r"
  142.  
  143. /*--------------------------------------------------------------------*/
  144. /*    Equality macros                                                 */
  145. /*--------------------------------------------------------------------*/
  146.  
  147. #define equal(a,b)               (!strcmp(a,b))
  148. #define equali(a,b)              (!stricmp(a,b))                     /*ahd */
  149. #define equalni(a,b,n)           (!strnicmp(a,b,n))                  /*ahd */
  150. #define equaln(a,b,n)            (!strncmp(a,b,n))
  151.  
  152. #ifndef __FILE__
  153. #error __FILE__ must be defined!!!
  154. #endif
  155.  
  156. #define currentfile()            static char *cfnptr = __FILE__
  157. #define checkref(a)              (checkptr(a, cfnptr ,__LINE__))     /*ahd */
  158. #define newstr(a)                (strpool(a, cfnptr ,__LINE__))
  159. #ifndef NOSAFEFREE
  160. #define free(a)                  (safefree(a, cfnptr ,__LINE__))
  161. #endif
  162.  
  163. #define nil(type)               ((type *)NULL)
  164.  
  165. /*--------------------------------------------------------------------*/
  166. /*    Enumerated list used by the options= configuration line         */
  167. /*--------------------------------------------------------------------*/
  168.  
  169. typedef enum {
  170.  
  171. /*--------------------------------------------------------------------*/
  172. /*                          Per user options                          */
  173. /*--------------------------------------------------------------------*/
  174.  
  175.                F_ASKCC,       /* TRUE = ask for Carbon copies              */
  176.                F_DOSKEY,      /* TRUE = Use DOSKEY under DOS 5 if available*/
  177.                F_BACKUP,      /* TRUE = Backup mailbox before rewriting    */
  178.                F_DOT,         /* TRUE = period ends a message              */
  179.                F_AUTOPRINT,   /* TRUE = print next message automatically   */
  180.                F_AUTOEDIT,    /* TRUE = no line prompt, always edit        */
  181.                F_AUTOINCLUDE, /* TRUE = Perform automatic INCLUDE command  */
  182.                F_AUTOSIGN,    /* TRUE = append the signature file          */
  183.                F_EXPERT,      /* TRUE = Let user shoot self in foot w/o
  184.                                         a message.                         */
  185.                F_FROMSEP,     /* TRUE = Allow From to split messages       */
  186.                F_PAGER,       /* TRUE = Invert meaning of P/p T/t commands */
  187.                F_PURGE,       /* TRUE = Delete mailbox, if empty           */
  188.                F_SAVE,        /* TRUE = Save read messages in =mbox when
  189.                                         reading new mail.                  */
  190.                F_SAVERESENT,  /* TRUE = Save forwarded mail a second time  */
  191.                F_SUPPRESSCOPYRIGHT,
  192.                               /* Skip copyright message                    */
  193.                F_SPEEDOVERMEMORY,
  194.                               /* TRUE = Be lazy in strpool()               */
  195.                F_VERBOSE,     /* TRUE = Verbose RMAIL output               */
  196.  
  197. /*--------------------------------------------------------------------*/
  198. /*                    Per system (GLOBAL) options                     */
  199. /*--------------------------------------------------------------------*/
  200.  
  201.                F_BANG,        /* TRUE = re-write addresses in bang (!) form*/
  202.                F_COLLECTSTATS,/* TRUE = Report additional information in
  203.                                         various logs                       */
  204.                F_DIRECT,      /* TRUE = Deliver to subdirectories, not
  205.                                         files                              */
  206.                F_ESCAPE,      /* TRUE = Allow ESCAPE to act as Ctrl-Break  */
  207.                F_HPFS,        /* TRUE = Exploit HPFS names under OS/2      */
  208.                F_HISTORY,     /* TRUE = Maintain history of of articles
  209.                                         read and posted                    */
  210.                F_KANJI,       /* TRUE = enable Kanji (Japanese) support    */
  211.                F_MULTI,       /* TRUE = Deliver to multiple addresses on
  212.                                         remote host at once                */
  213.                F_MULTITASK,   /* TRUE = System is multitasking, watch
  214.                                         for race conditions                */
  215.                F_ONECASE,     /* TRUE = Remote host is case insensitive    */
  216.                F_SNEWS,       /* TRUE = Use Simple news delivery           */
  217.                F_SYMMETRICGRADES,
  218.                               /* TRUE = Use send grade as receive grade    */
  219.                F_SYSLOG,      /* TRUE = Write syslog with name and time of
  220.                                         each file transferred              */
  221.                F_UNDELETE,    /* TRUE = Do not override OS/2 undelete
  222.                                  support                                   */
  223.                F_LAST }       /* Dummy - Must be last - defines array size */
  224.                B_FLAG;        /* Boolean flag array - ahd                  */
  225.  
  226. /*--------------------------------------------------------------------*/
  227. /*                  Your basic Boolean logic values                   */
  228. /*--------------------------------------------------------------------*/
  229.  
  230. #undef FALSE
  231. #undef TRUE
  232. typedef enum { FALSE = 0, TRUE = 1 } boolean;
  233.  
  234. /*--------------------------------------------------------------------*/
  235. /*                      Configuration mode flags                      */
  236. /*--------------------------------------------------------------------*/
  237.  
  238. typedef enum {
  239.       USER_CONFIG,
  240.       SYSTEM_CONFIG,
  241.       MODEM_CONFIG
  242.       } SYSMODE;
  243.  
  244. /*--------------------------------------------------------------------*/
  245. /*               enumerated type for configuration bits               */
  246. /*--------------------------------------------------------------------*/
  247.  
  248. typedef unsigned long CONFIGBITS;
  249.  
  250. typedef unsigned short INTEGER;  /* Integers in the config file      */
  251.  
  252. typedef unsigned int BPS;
  253.  
  254. /*--------------------------------------------------------------------*/
  255. /*                     Configuration table layout                     */
  256. /*--------------------------------------------------------------------*/
  257.  
  258. typedef struct ConfigTable {
  259.    char *sym;
  260.    char **loc;
  261.    CONFIGBITS bits;
  262. } CONFIGTABLE;
  263.  
  264. /*--------------------------------------------------------------------*/
  265. /*                    Boolean options table layout                    */
  266. /*--------------------------------------------------------------------*/
  267.  
  268. typedef struct FlagTable {
  269.    char *sym;
  270.    int position;
  271.    CONFIGBITS bits;
  272. } FLAGTABLE;
  273.  
  274. /*--------------------------------------------------------------------*/
  275. /*                            linked list                             */
  276. /*--------------------------------------------------------------------*/
  277.  
  278. struct file_queue {
  279.    char name[FILENAME_MAX];
  280.    struct file_queue *next_link;
  281. } ;
  282.  
  283. /*--------------------------------------------------------------------*/
  284. /*                          Global variables                          */
  285. /*--------------------------------------------------------------------*/
  286.  
  287. extern int debuglevel;
  288. extern FILE *logfile;
  289. extern boolean bflag[F_LAST];
  290.  
  291. /*--------------------------------------------------------------------*/
  292. /*      Configuration file strings                                    */
  293. /*--------------------------------------------------------------------*/
  294.  
  295. extern char *E_name, *E_mailbox, *E_homedir;
  296. extern char *E_archivedir, *E_newsserv;                        /* news */
  297. extern char *E_mailbox, *E_homedir;
  298. extern char *E_maildir, *E_newsdir, *E_spooldir, *E_confdir;
  299. extern char *E_pubdir, *E_tempdir;
  300. extern char *E_nodename, *E_domain, *E_mailserv;
  301. extern char *E_fdomain;       /* Domain used in From: lines             */
  302. extern char *E_inmodem;
  303. extern char *E_editor, *E_pager;
  304. extern char *E_mailext, *E_backup;
  305. extern char *E_filesent, *E_signature;
  306. extern char *E_altsignature;                                   /* pdm   */
  307. extern char *E_aliases;                                        /* ahd   */
  308. extern char *E_organization, *E_replyto;                       /* ahd   */
  309. extern char *E_localdomain;                                    /* ahd   */
  310. extern char *E_postmaster;                                     /* ahd   */
  311. extern char *E_uuxqtpath;
  312. extern char **E_internal;
  313. extern char *E_charset;
  314. extern char *E_anonymous;
  315. extern char *E_version;
  316. extern char *E_uncompress;
  317. extern INTEGER E_maxhops;
  318.  
  319. extern FLAGTABLE configFlags[];
  320.  
  321. /*--------------------------------------------------------------------*/
  322. /*                        Function prototypes                         */
  323. /*--------------------------------------------------------------------*/
  324.  
  325. void prterror(const size_t lineno, const char *fname, const char *prefix);
  326.  
  327. extern void checkptr(const void *block, const char *file, const int line);
  328.  
  329. extern int MKDIR(const char *path);
  330.                               /* Make a directory              ahd */
  331.  
  332. extern int CHDIR(const char *path);
  333.                               /* Change to a directory          ahd */
  334.  
  335. int RENAME(const char *oldname, const char *newname );
  336.  
  337. extern FILE *FSOPEN(const char *name,
  338.                    const char *mode );
  339.  
  340. #define FOPEN( name, mode, ftype ) FSOPEN( name, mode ftype )
  341.                               /* Since the last two are literals,
  342.                                  we just concat them together for
  343.                                  the call                         */
  344.  
  345. extern void options(char *s,
  346.                     SYSMODE sysmode ,
  347.                     FLAGTABLE *flags,
  348.                     boolean *xflag);
  349.  
  350. int getargs(char *line,
  351.             char **flds);                                   /* ahd */
  352.  
  353. void printmsg(int level, char *fmt, ...);
  354.  
  355. boolean configure( CONFIGBITS program );
  356.  
  357. boolean getconfig(FILE *fp,
  358.                   SYSMODE sysmode,
  359.                   CONFIGBITS program,
  360.                   CONFIGTABLE *table,
  361.                   FLAGTABLE *btable);
  362.  
  363. boolean processconfig(char *buff,
  364.                   SYSMODE sysmode,
  365.                   CONFIGBITS program,
  366.                   CONFIGTABLE *table,
  367.                   FLAGTABLE *btable);
  368.  
  369. void bugout( const size_t lineno, const char *fname);
  370.  
  371. char *strpool( const char *input , const char *file, size_t line);
  372.  
  373. void safefree( void *input , const char *file, size_t line);
  374.  
  375. char *normalize( const char *path );
  376.  
  377. #ifdef __GNUC__
  378. char *strlwr( char *s );
  379. #endif
  380.  
  381. /*--------------------------------------------------------------------*/
  382. /*                   Compiler specific information                    */
  383. /*--------------------------------------------------------------------*/
  384.  
  385. #if defined(__CORE__)
  386. extern   char *copyright;
  387. extern   char *copywrong;
  388. extern   long *lowcore;
  389. #endif   /* defined(__CORE__)   */
  390. #endif   /* ifndef __LIB */
  391.  
  392. #define msdos                 /* Required by dain bramaged compiler  */
  393.