home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / UUCODE / UUPC / TEST / UPC12ES1.ZIP / LIB / lib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  12.9 KB  |  336 lines

  1. /*--------------------------------------------------------------------*/
  2. /*       l i b . h                                                    */
  3. /*--------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------------------------------------------*/
  6. /*       Changes Copyright (c) 1989-1993 by Kendra Electronic         */
  7. /*       Wonderworks.                                                 */
  8. /*                                                                    */
  9. /*       All rights reserved except those explicitly granted by       */
  10. /*       the UUPC/extended license agreement.                         */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                          RCS Information                           */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*
  18.  *    $Id: lib.h 1.16 1993/11/06 17:57:46 rhg Exp $
  19.  *
  20.  *    Revision history:
  21.  *    $Log: lib.h $
  22.  *     Revision 1.16  1993/11/06  17:57:46  rhg
  23.  *     Drive Drew nuts by submitting cosmetic changes mixed in with bug fixes
  24.  *
  25.  *     Revision 1.15  1993/10/12  01:22:27  ahd
  26.  *     Normalize comments to PL/I style
  27.  *
  28.  *     Revision 1.15  1993/10/12  01:22:27  ahd
  29.  *     Normalize comments to PL/I style
  30.  *
  31.  *     Revision 1.14  1993/10/09  15:48:20  rhg
  32.  *     ANSIfy the source
  33.  *
  34.  *     Revision 1.13  1993/09/29  04:56:11  ahd
  35.  *     Revise B_KEWSHORT to B_SHORT
  36.  *
  37.  *     Revision 1.12  1993/09/20  04:51:31  ahd
  38.  *     1.12OS/2 2.x support
  39.  *
  40.  *     Revision 1.11  1993/08/08  17:39:55  ahd
  41.  *     Define denormalize() macro
  42.  *
  43.  *     Revision 1.10  1993/07/22  23:26:19  ahd
  44.  *     First pass of changes for Robert Denny's Windows 3.1 support
  45.  *
  46.  *     Revision 1.9  1993/07/19  02:53:32  ahd
  47.  *     Update copyright year'
  48.  *
  49.  *     Revision 1.8  1993/06/13  14:12:29  ahd
  50.  *     Changes per Mike McLagan for outbound batched news support
  51.  *
  52.  *     Revision 1.7  1993/05/30  15:27:22  ahd
  53.  *     Drop PASSWD, SYSTEMS definitions
  54.  *
  55.  *     Revision 1.6  1993/05/30  00:11:03  ahd
  56.  *     Drop free() macro
  57.  *     Drop hardcoded PASSWD and SYSTEM file names
  58.  *     Add RCSID macro
  59.  *
  60.  *     Revision 1.5  1993/04/04  21:51:00  ahd
  61.  *     Update copyright
  62.  *
  63.  *     Revision 1.4  1993/03/06  23:09:50  ahd
  64.  *     Break variable names out of master lib.h
  65.  *
  66.  *     Revision 1.3  1992/12/01  04:39:34  ahd
  67.  *     Add SpeedOverMemory
  68.  *
  69.  * Revision 1.2  1992/11/22  21:31:22  ahd
  70.  * Allow strpool() to allocate memory for const strings
  71.  *
  72.  * Revision 1.1  1992/11/16  05:00:26  ahd
  73.  * Initial revision
  74.  *
  75.  */
  76.  
  77. #ifndef __LIB
  78. #define __LIB
  79.  
  80. #if _MSC_VER == 700
  81. #pragma function(strcpy)        /* Get around a MS C7 code-generation bug:
  82.                                    The C 7.00 compiler uses the wrong register
  83.                                    for passing the return value of strcpy to
  84.                                    another function!  The bug appears to be
  85.                                    only in C7; Visual C fixed the problem. */
  86. #endif /* _MSC_VER == 700 */
  87.  
  88. #if defined(WIN32) || defined(__OS2__)
  89. #define BIT32ENV
  90. #endif
  91.  
  92. #include <confvars.h>
  93.  
  94. /*--------------------------------------------------------------------*/
  95. /*     Environment variables set by UUXQT before invoking modules     */
  96. /*--------------------------------------------------------------------*/
  97.  
  98. #define UU_USER "UU_USER"
  99. #define UU_MACHINE "UU_MACHINE"
  100. #define LOGNAME "LOGNAME"
  101. #define RMAIL   "rmail"
  102. #define RNEWS   "rnews"
  103.  
  104. /*--------------------------------------------------------------------*/
  105. /*                   Global configuration variables                   */
  106. /*--------------------------------------------------------------------*/
  107.  
  108. #define SYSRCSYM "UUPCSYSRC"
  109. #define USRRCSYM  "UUPCUSRRC"
  110. #define SYSDEBUG  "UUPCDEBUG"    /* Initialize debug level ahd        */
  111.  
  112. /*--------------------------------------------------------------------*/
  113. /*                 Macro for recording when UUPC dies                 */
  114. /*--------------------------------------------------------------------*/
  115.  
  116. #define panic()  bugout( __LINE__, cfnptr)
  117.  
  118. /*--------------------------------------------------------------------*/
  119. /*                 Macro for generic error messages from DOS          */
  120. /*--------------------------------------------------------------------*/
  121.  
  122. #define printerr( x )  prterror( __LINE__, cfnptr, x)
  123.  
  124. /*--------------------------------------------------------------------*/
  125. /*                  Convert hours/minutes to seconds                  */
  126. /*--------------------------------------------------------------------*/
  127.  
  128. #define hhmm2sec(HHMM)    ((time_t)(((HHMM / 100) * 60L) + \
  129.                            (time_t)(HHMM % 100)) * 60L)
  130.  
  131. #define RCSID static const char UUFAR rcsid[] =
  132.  
  133. /*--------------------------------------------------------------------*/
  134. /*                     Configuration file defines                     */
  135. /*--------------------------------------------------------------------*/
  136.  
  137. #define B_REQUIRED 0x00000001L /* Line must appear in configuration   */
  138. #define B_FOUND    0x00000002L /* We found the token                  */
  139.  
  140. #define B_GLOBAL   0x00000004L /* Must not appear in PERSONAL.RC      */
  141. #define B_LOCAL    0x00000008L /* The opposite of B_GLOBAL, sort of   */
  142.  
  143. #define B_MTA      0x00000010L /* Used by Mail Delivery (RMAIL)       */
  144. #define B_MUA      0x00000020L /* Used by Mail User Agent (MAIL)      */
  145. #define B_MUSH     0x00000040L /* Used by MUSH - Not used by UUPC     */
  146. #define B_NEWS     0x00000080L /* Used by NEWS software               */
  147. #define B_UUCICO   0x00000100L /* Used by transport program UUCICO    */
  148. #define B_UUCP     0x00000200L /* Used by UUCP command                */
  149. #define B_UUPOLL   0x00000400L /* UUPOLL program                      */
  150. #define B_UUSTAT   0x00000800L /* UUSTAT, UUSUB, UUNAME programs      */
  151. #define B_UUXQT    0x00001000L /* Used by queue processor UUXQT       */
  152. #define B_INSTALL  0x00002000L /* Used by install program only        */
  153. #define B_BATCH    0x00004000L /* Used by news batching program - GMM */
  154. #define B_MAIL     (B_MUA | B_MTA | B_MUSH)
  155. #define B_SPOOL    (B_MTA | B_NEWS | B_UUCICO | B_UUXQT | B_UUCP | B_UUSTAT)
  156. #define B_ALL      (B_MAIL|B_SPOOL|B_NEWS|B_UUPOLL|B_UUSTAT|B_BATCH)
  157.  
  158. #define B_SHORT    0x00010000L /* Pointer is to short int, not string */
  159. #define B_TOKEN    0x00020000L /* Pointer is one word, ignore blanks  */
  160. #define B_BOOLEAN  0x00040000L /* Pointer is to boolean keywords      */
  161. #define B_LIST     0x00080000L /* Pointer to array of char pointers   */
  162. #define B_CLIST    0x00100000L /* Pointer to array of char pointers,
  163.                                   input is separated by colons, not
  164.                                   spaces                              */
  165. #define B_STRING   0x00200000L /* String value (same as original UUPC
  166.                                   configuration processor             */
  167. #define B_NORMAL   0x00400000L /* Normalize backslashes to slashes in
  168.                                   in this variable                    */
  169. #define B_OBSOLETE 0x00800000L /* Option is obsolete, should be
  170.                                   deleted                             */
  171. #define B_MALLOC   0x01000000L  /* Use malloc(), not newstr()         */
  172. #define B_LONG     0x02000000L  /* Pointer is to long, not string     */
  173. #define B_PATH     (B_TOKEN | B_NORMAL)
  174.                                /* DOS Path name                       */
  175.  
  176. /*--------------------------------------------------------------------*/
  177. /*                     General defines and macros                     */
  178. /*--------------------------------------------------------------------*/
  179.  
  180. #define  MESSAGESEP "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n"
  181.  
  182. #define DCSTATUS    "hostatus"
  183. #define PATHS       "hostpath"
  184. #define PERMISSIONS "permissn"
  185. #define SYSLOG      "syslog"
  186. #define ACTIVE      "active"
  187.  
  188. #define WHITESPACE " \t\n\r"
  189.  
  190. /*--------------------------------------------------------------------*/
  191. /*    Equality macros                                                 */
  192. /*--------------------------------------------------------------------*/
  193.  
  194. #define equal(a,b)               (!strcmp(a,b))
  195. #define equali(a,b)              (!stricmp(a,b))                     /*ahd */
  196. #define equalni(a,b,n)           (!strnicmp(a,b,n))                  /*ahd */
  197. #define equaln(a,b,n)            (!strncmp(a,b,n))
  198.  
  199. #ifndef __FILE__
  200. #error __FILE__ must be defined!!!
  201. #endif
  202.  
  203. #define currentfile()            static char *cfnptr = __FILE__
  204. #define checkref(a)              (checkptr(a, cfnptr ,__LINE__))     /*ahd */
  205. #define newstr(a)                (strpool(a, cfnptr ,__LINE__))
  206. #ifdef SAFEFREE
  207. #define free(a)                  (safefree(a, cfnptr ,__LINE__))
  208. #endif
  209.  
  210. #define nil(type)               ((type *)NULL)
  211.  
  212. /*--------------------------------------------------------------------*/
  213. /*                     Configuration table layout                     */
  214. /*--------------------------------------------------------------------*/
  215.  
  216. typedef struct ConfigTable {
  217.    char *sym;
  218.    char **loc;
  219.    CONFIGBITS bits;
  220. } CONFIGTABLE;
  221.  
  222. /*--------------------------------------------------------------------*/
  223. /*                    Boolean options table layout                    */
  224. /*--------------------------------------------------------------------*/
  225.  
  226. typedef struct FlagTable {
  227.    char *sym;
  228.    int position;
  229.    CONFIGBITS bits;
  230. } FLAGTABLE;
  231.  
  232. /*--------------------------------------------------------------------*/
  233. /*                            linked list                             */
  234. /*--------------------------------------------------------------------*/
  235.  
  236. struct file_queue {
  237.    char name[FILENAME_MAX];
  238.    struct file_queue *next_link;
  239. } ;
  240.  
  241. /*--------------------------------------------------------------------*/
  242. /*                          Global variables                          */
  243. /*--------------------------------------------------------------------*/
  244.  
  245. extern int debuglevel;
  246. extern FILE *logfile;
  247. extern boolean bflag[F_LAST];
  248.  
  249. extern FLAGTABLE configFlags[];
  250.  
  251. /*--------------------------------------------------------------------*/
  252. /*                        Function prototypes                         */
  253. /*--------------------------------------------------------------------*/
  254.  
  255. void prterror(const size_t lineno, const char *fname, const char *prefix);
  256.  
  257. extern void checkptr(const void *block, const char *file, const int line);
  258.  
  259. extern int MKDIR(const char *path);
  260.                               /* Make a directory              ahd */
  261.  
  262. extern int CHDIR(const char *path);
  263.                               /* Change to a directory          ahd */
  264.  
  265. int RENAME(const char *oldname, const char *newname );
  266.  
  267. extern FILE *FSOPEN(const char *name,
  268.                    const char *mode );
  269.  
  270. #define FOPEN( name, mode, ftype ) FSOPEN( name, mode ftype )
  271.                               /* Since the last two are literals,
  272.                                  we just concat them together for
  273.                                  the call                         */
  274.  
  275. extern void options(char *s,
  276.                     SYSMODE sysmode ,
  277.                     FLAGTABLE *flags,
  278.                     boolean *xflag);
  279.  
  280. int getargs(char *line,
  281.             char **flds);                                   /* ahd */
  282.  
  283. void printmsg(int level, char *fmt, ...);
  284.  
  285. boolean configure( CONFIGBITS program );
  286.  
  287. boolean getconfig(FILE *fp,
  288.                   SYSMODE sysmode,
  289.                   CONFIGBITS program,
  290.                   CONFIGTABLE *table,
  291.                   FLAGTABLE *btable);
  292.  
  293. boolean processconfig(char *buff,
  294.                   SYSMODE sysmode,
  295.                   CONFIGBITS program,
  296.                   CONFIGTABLE *table,
  297.                   FLAGTABLE *btable);
  298.  
  299. void bugout( const size_t lineno, const char *fname);
  300.  
  301. char *strpool( const char *input , const char *file, size_t line);
  302.  
  303. void safefree( void *input , const char *file, size_t line);
  304.  
  305. char *normalize( const char *path );
  306.  
  307. #define denormalize( path ) { char *xxp = path; \
  308.    while ((xxp = strchr(xxp,'/')) != NULL)  \
  309.       *xxp++ = '\\';  }
  310.  
  311. boolean IsDOS( void );
  312.  
  313. #ifdef __GNUC__
  314. char *strlwr( char *s );
  315. #endif
  316.  
  317. /*--------------------------------------------------------------------*/
  318. /*                   Compiler specific information                    */
  319. /*--------------------------------------------------------------------*/
  320.  
  321. #if defined(__CORE__)
  322. extern   char *copyright;
  323. extern   char *copywrong;
  324. extern   long *lowcore;
  325. #endif   /* defined(__CORE__)   */
  326.  
  327. /*--------------------------------------------------------------------*/
  328. /*     This triggers a "nice" break into the debugger under BC++      */
  329. /*--------------------------------------------------------------------*/
  330.  
  331. #ifdef __TURBOC__
  332. #define BREAKPOINT   _asm INT 3
  333. #endif
  334.  
  335. #endif   /* ifndef __LIB */
  336.