home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / include / news.h < prev    next >
C/C++ Source or Header  |  1993-12-16  |  5KB  |  140 lines

  1. /*
  2.  * definitions unique to all of C news
  3.  * things marked with qqq are subject to being configured by "build"
  4.  */
  5.  
  6. /*
  7.  * tunable parameters
  8.  * which actually very seldom need to be tuned
  9.  * in particular, don't get alarmed about MAXCOMP, it's not used for
  10.  *  anything where it matters
  11.  */
  12. #define MAXPATH 1024        /* max. length of pwd output */
  13. #define MAXCOMP 14        /* file name component length */
  14. #define MAXHOST 128        /* max. length of this host's name */
  15. #define SPOOLTMP ".tmpXXXXXX"    /* template for NEWSARTS temporary link */
  16.  
  17.  
  18. /* STATIC & FORWARD must agree to avoid redeclarations(!) */
  19. #ifndef STATIC
  20. #define STATIC    static        /* "static" when not debugging|profiling */
  21. #endif
  22.  
  23. /* adapt to compiler limitations */
  24. #ifndef FORWARD
  25. #ifdef pdp11
  26. #define FORWARD            /* "static" except for dmr's 11 compiler */
  27. #else
  28. #define FORWARD static        /* "static" except for dmr's 11 compiler */
  29. #endif
  30. #endif
  31. #ifdef NOVOID
  32. #define void int        /* if your compiler doesn't understand void's */
  33. #endif
  34. #ifdef NOUNSLONG
  35. #define MAXLONG 017777777777L    /* if your compiler lacks "unsigned long" type */
  36. #endif
  37.  
  38.  
  39. /* types */
  40. typedef short statust;
  41. typedef char boolean;
  42. struct newsconf {
  43.     boolean    nc_link;    /* link() works */
  44.     boolean    nc_symlink;    /* symlink() works */
  45. };
  46. extern struct newsconf newsconf;
  47.  
  48. /* status bits */
  49. #define ST_OKAY        0    /* nothing wrong */
  50. #define ST_SHORT    (1<<1)    /* article shorter than byte count; truncated? */
  51. #define ST_ACCESS    (1<<2)    /* no access permission */
  52. #define ST_REFUSED    (1<<3)    /* article was deliberately refused - OK */
  53. #define ST_DROPPED    (1<<4)    /* article was accidentally dropped - serious */
  54. #define ST_DISKFULL    (1<<5)    /* disk full - give up fast */
  55. #define ST_JUNKED    (1<<6)    /* article was accepted, but junked */
  56. #define ST_NEEDATTN    (1<<7)    /* news system needs human attention - give up */
  57.  
  58. /* newsgroup specific definitions */
  59. #define NGSEP ','        /* separates groups */
  60. #define NGNEG '!'        /* preceding a pattern, negates it */
  61. #define NGDELIM '.'        /* within a group */
  62. #define SNGDELIM "."        /* string of NGDELIM */
  63. #define FNDELIM '/'        /* within a group, on disk */
  64. #define SFNDELIM "/"        /* string of FNDELIM */
  65.  
  66. /* macros, replacing functions for speed */
  67. #define max(a,b) ((a) > (b)? (a): (b))
  68. #define min(a,b) ((a) < (b)? (a): (b))
  69. #define iswhite(c) ((c) == ' ' || (c) == '\t')
  70. /* STREQ is an optimised strcmp(a,b)==0 */
  71. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  72. /* STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 */
  73. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, (int)(n)) == 0)
  74. #define STRLEN(s) ((unsigned)sizeof(s) - 1)    /* s must be a char array */
  75. #ifdef FASTSTRCHR
  76. #define STRCHR(src, chr, dest) (dest) = strchr(src, chr)
  77. #else
  78. #define STRCHR(src, chr, dest) \
  79.     for ((dest) = (src); *(dest) != '\0' && *(dest) != (chr); ++(dest)) \
  80.         ; \
  81.     if (*(dest) == '\0') \
  82.         (dest) = NULL        /* N.B.: missing semi-colon */
  83. #endif
  84.  
  85. /* macros, of necessity */
  86. /* nnafree(any **) where "any" is any type; must be a macro */
  87. #define nnafree(mempp) (*(mempp) != 0? (free((char *)*(mempp)), (*(mempp) = 0)): 0)
  88. #ifdef lint
  89. static
  90. nnfree(mempp)        /* If *mempp is non-null, free it and zero it. */
  91. register char **mempp;            /* pointer to malloc'ed ptr. */
  92. {
  93.     if (*mempp != 0) {
  94.         free(*mempp);
  95.         *mempp = 0;
  96.     }
  97. }
  98. #else                    /* lint */
  99. #define nnfree nnafree
  100. #endif                    /* lint */
  101.  
  102. #define YES 1
  103. #define NO 0
  104.  
  105. #define SIZENUL (sizeof(char))        /* size in bytes of an ASCII NUL byte */
  106.  
  107. #define NOTALLHDRS NO            /* hdrdump flags for "all headers seen?" */
  108. #define ALLHDRS YES
  109.  
  110. #define DEFEXP "-"            /* default expiry period */
  111.  
  112. /* imports from news */
  113. extern char *progname;
  114.  
  115. extern FILE *fopenexcl();            /* from ../libos */
  116.  
  117. extern FILE *fopenclex(), *fopenwclex();    /* from ../libcnews/fopenclex.c */
  118. extern char *gethdr();                /* from ../libcnews/gethdr.c */
  119. extern char *hostname();            /* from ../libcnews/hostname.c */
  120. extern void lockdebug(), newslock(), newsunlock();    /* from ../libcnews/lock.c */
  121. extern void errunlock();            /* from ../libcnews/lock.c */
  122. extern void matchdebug();            /* from ../libcnews/ngmatch.c */
  123. extern boolean ngmatch();            /* from ../libcnews/ngmatch.c */
  124. extern void mkfilenm();                /* from ../libcnews/string.c */
  125. extern char *trim();                /* from ../libcnews/string.c */
  126. extern boolean anyhostin(), hostin();        /* from ../libcnews/string.c */
  127. extern char *skipsp(), *first(), *strsvto();    /* from ../libcnews/string.c */
  128. extern char *sendersite(), *nullify();        /* from ../libcnews/string.c */
  129. extern char *canonpath();            /* from ../libcnews/string.c */
  130. extern void timestamp();            /* from ../libcnews/time.c */
  131.  
  132. extern void warning(), error();            /* from ../libc */
  133. extern void closeall();                /* from ../libc */
  134. extern void stdfdopen();            /* from ../libc */
  135.  
  136. #include "alloc.h"                /* ugh */
  137. #define NOART ((struct article *)NULL)
  138.  
  139. extern char *strsave(), *str3save();
  140.