home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / newsgate / gate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-24  |  7.8 KB  |  258 lines

  1. /*
  2. **  HEADER FILE FOR NEWS/MAIL GATEWAY CODE.
  3. **  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/gate.h,v 1.19 91/07/18 21:14:18 rsalz Exp Locker: rsalz $
  4. */
  5. /* SUPPRESS 460 *//* '/' '*' occurred inside a comment */
  6.  
  7.  
  8. /*
  9. **  START OF CONFIGURATION SECTION
  10. */
  11.  
  12.  
  13. /* Paths to some parts of your netnews installation.  Required. */
  14. #define INEWS        "/usr/lib/news/inews"
  15. #define ACTIVE        "/usr/lib/news/active"
  16. #define NGDELIM        ','
  17.  
  18.  
  19. /* In writing Paths into From addresses, we can look at the output
  20.  * of uuname from the L.sys file.  Define both or neither of the next
  21.  * two.  We can also map some UUCP names to their domain names, if
  22.  * the third line is enabled.  The UUCP_INET should match the value
  23.  * in the Makefile.  This violates the "write once" rule, but it's
  24.  * too much of a pain to fix for this one symbol. */
  25. #define UUNAME        "/usr/lib/news/.admin/uuname.out"
  26. #define L_SYS        "/usr/lib/uucp/L.sys"
  27. #define UUCP_INET    "/usr/lib/news/.admin/uucp-2-inet"
  28.  
  29.  
  30. /* Do you want news2mail to use the Path line in generating the From line?
  31.  */
  32. #define USE_PATH_FOR_FROM
  33.  
  34.  
  35. /* Do you need to handle eight-bit characters in your addresses?  If
  36.  * not (e.g., just USASCII) then #undef the next line.
  37.  */
  38. #define DO_8BIT_CHARS
  39.  
  40.  
  41. /* Where does the control file for talk.foo live?
  42.  *    IN_ONEPLACE:    specified filename
  43.  *    IN_SPOOLDIR:    /usr/spool/news/talk/foo/recnews.cmd
  44.  *    IN_CMDDIR:    /usr/lib/news/.admin/talk.foo
  45.  * One of these is required, but you can set IN_ONEPLACE to /dev/null to
  46.  * disable the newsgroup editing. */
  47. /*efine IN_ONEPLACE    "/dev/null"        /* .. */
  48. /*efine IN_SPOOLDIR    "/usr/spool/news"    /* .. */
  49. #define    IN_CMDDIR    "/usr/lib/news/.admin"    /* .. */
  50.  
  51.  
  52. /* What do you want to do with the Path: line?  Put in a fixed string
  53.  * (such as pointing to a mail reflector saying "Don't trust Path:
  54.  * lines as a way to reply").  Put a fixed "fake host" in the Path:
  55.  * before the user's host and name, or put just the user's host and
  56.  * name there.  Note that the latter two can cause the poster's site
  57.  * to never get the article sent to them.  Anyhow, pick one.  To pick
  58.  * neither #define is to get the third behavior -- the user's host. */
  59. #define FIXED_PATH    "gateway"        /* .. */
  60. /*efine    GATEWAY_NAME    "gateway"        /* .. */
  61.  
  62. /* If the "hostname" you use for news (such as in the pathline) is not
  63.  * the same as `hostname`, then define WHOAMI to be your news name (e.g.,
  64.  * the contents of the C News file /usr/lib/news/whoami). */
  65. /*efine WHOAMI        "bbn"            /* .. */
  66.  
  67.  
  68. /* The code in hdr.c does lots of work to canonicalize addresses.  You
  69.  * might want to disable it if your sendmail.cf (e.g.) is very very good.
  70.  * You might want to disable DO_GETHOSTBYNAME because gethostbyname(3)
  71.  * doesn't handle MX records, and in some setups doesn't return a full
  72.  * domain name. */
  73. #define DO_ADDRESS_CLEANUP            /* .. */
  74. #define DO_GETHOSTBYNAME            /* .. */
  75.  
  76.  
  77. /* Are you running sendmail or MMDF?  Pick one.  If you believe in
  78.  * trusted users (MMDF doesn't?) to lie to your mailer, set the
  79.  * user-ID. */
  80. /*efine SENDMAIL    "/usr/lib/sendmail"    /* .. */
  81. #define    MMDF        "/usr/mmdf/lib/submit"    /* .. */
  82. #undef MMDF_DELIVER_NOW
  83. /*efine TRUSTED        1            /* .. */
  84.  
  85.  
  86. /* Does your Sendmail mailer have the M flag on, requiring a Message-ID?
  87.  * And do you want to require that the first line by a "From " line? */
  88. #if    defined(SENDMAIL)
  89. #define REQUIRE_MESSAGE_ID            /* .. */
  90. #undef REQUIRE_UNIX_FROM
  91. #endif    /* defined(SENDMAIL) */
  92.  
  93.  
  94. /* I love how we all speak the same language. */
  95. /*efine CATCHER        int        /* Type of a signal-catcher    */
  96. #define CATCHER        void        /* .. */
  97. #define IDX        index        /* .. */
  98. #define RDX        rindex        /* .. */
  99. /*efine IDX        strchr        /* .. */
  100. /*efine RDX        strrchr        /* .. */
  101. typedef int        *align_t;    /* Worst-case alignment, for lint */
  102. #define CHARSTAR_SPRINTF        /* Need extern char *sprintf();    */
  103. #define VOID_EXIT            /* Need extern void exit();    */
  104. #define HAVE_SYSEXITS            /* Have <sysexits.h>?        */
  105. #define HAVE_TIMEB            /* Have <sys/timeb.h>?        */
  106. #define HAVE_PUTENV            /* Have putenv(3)        */
  107. /*efine HAVE_STRERROR            /* Have strerror(3)?        */
  108.  
  109. #define SM_SIZE        512        /* A smallish buffer size    */
  110. #define LG_SIZE        1024        /* big buffer size        */
  111.  
  112. /* Error log (stderr) for news2mail. */
  113. #define ERR_LOG        "/usr/lib/news/.admin/news2mail.out"
  114. #define TEMPFILE    "/tmp/gateXXXXXX" /* Temporary file pattern    */
  115.  
  116.  
  117. /* Enable debugging code? */
  118. #define STATIC        static
  119. #if    !defined(lint) && !defined(SABER)
  120. #define RCSID
  121. #endif    /* !defined(lint) && !defined(SABER) */
  122.  
  123. /*
  124. **  END OF CONFIGURATION SECTION.
  125. */
  126.  
  127.  
  128.  
  129. #include <stdio.h>
  130. #include <ctype.h>
  131. #include <sys/types.h>
  132.  
  133. #if    defined(HAVE_SYSEXITS)
  134. #include <sysexits.h>
  135. #else
  136. #include "sysexits.h"
  137. #endif    /* defined(HAVE_SYSEXITS) */
  138.  
  139.  
  140. typedef struct _HBUF {
  141.     char    approved[SM_SIZE];    /* Approved:        */
  142.     char    ctlmsg[LG_SIZE];    /* Control:        */
  143.     char    subdate[SM_SIZE];    /* Date: (submission)    */
  144.     char    distribution[SM_SIZE];    /* Distribution:    */
  145.     char    expdate[SM_SIZE];    /* Expires:        */
  146.     char    followto[SM_SIZE];    /* Followup-to:        */
  147.     char    from[SM_SIZE];        /* From:        */
  148.     char    followid[SM_SIZE];    /* References:        */
  149.     char    keywords[SM_SIZE];    /* Keywords:        */
  150.     char    ident[SM_SIZE];        /* Message-ID:        */
  151.     char    nbuf[LG_SIZE];        /* Newsgroups:        */
  152.     char    organization[SM_SIZE];    /* Organization:    */
  153.     char    title[SM_SIZE];        /* Subject:        */
  154.     char    replyto[SM_SIZE];    /* Reply-To:        */
  155.     char    summary[SM_SIZE];    /* Summary:        */
  156.     char    path[LG_SIZE];        /* Path:        */
  157.     char    sender[SM_SIZE];    /* Sender:        */
  158. } HBUF;
  159.  
  160.  
  161. /* String and memory manipulators. */
  162. #define APPEND(p, t)    strlen(strcpy((p), (t)))
  163. #define NEW(T, c)    (T *)MyAlloc((c) * sizeof (T))
  164. #define COPY(s)        strcpy(NEW(char, strlen((s)) + 1), (s))
  165. #define REALLOC(p, s)    realloc((char *)(p), (unsigned int)(s))
  166.  
  167.  
  168. /* Array sizing. */
  169. #define SIZEOF(x)    (sizeof x / sizeof x[0])
  170. #define ENDOF(x)    (&x[SIZEOF(x)])
  171.  
  172. #if    defined(DO_8BIT_CHARS)
  173. #define ADDRCHAR    char    /* Addresses internal representation    */
  174. #define QUOTE_MASK    0x0080    /* Mask to turn on 8-bit quoting    */
  175. #define UNQUOTE_MASK    0x007F    /* Mask to turn off the 8-bit quote    */
  176. #else
  177. #define ADDRCHAR    short    /* Addresses internal representation    */
  178. #define QUOTE_MASK    0x0100     /* Mask to turn on 9-bit quoting    */
  179. #define UNQUOTE_MASK    0x00FF    /* Mask to turn off the 9-bit quote    */
  180. #endif    /* defined(DO_8BIT_CHARS) */
  181.  
  182. /* String and character operations. */
  183. #define WHITE(c)    ((c) == ' ' || (c) == '\t')
  184. #define EQ(a, b)    ((a)[0] == (b)[0] && strcmp((a), (b)) == 0)
  185. #define EQn(a, b, n)    ((a)[0] == (b)[0] && strncmp((a), (b), (n)) == 0)
  186. #define NETCHR(c)    ((c) == '%' || (c) == '@' || (c) == '!')
  187. #define CHREQ(c, d)    ((d) == (islower((c)) ? toupper((c)) : (c)))
  188.  
  189.  
  190. /* Fundamental constants of the universe. */
  191. #define TRUE        1
  192. #define FALSE        0
  193. #define FAIL        (-1)
  194.  
  195.  
  196. /* SHUT UP! */
  197. #if    defined(lint)
  198. #undef    putc
  199. #undef    putchar
  200. #endif    /* defined(lint) */
  201.  
  202. #define Close        (void)close
  203. #define Fflush        (void)fflush
  204. #define Fprintf        (void)fprintf
  205. #define Fputs        (void)fputs
  206. #define Signal        (void)signal
  207. #define Sprintf        (void)sprintf
  208. #define Strcpy        (void)strcpy
  209. #define Strcat        (void)strcat
  210. #define Strncpy        (void)strncpy
  211.  
  212.  
  213. /*
  214. **  External declarations.
  215. */
  216.  
  217. /* Program name; exists once for each main(). */
  218. extern    char    *Pname;
  219.  
  220. /* Routines we provide. */
  221. extern align_t    MyAlloc();
  222. extern int    Split();
  223. extern int    CrackFrom();
  224. extern void    re_modw();
  225. extern void    SplitFree();
  226. extern void    FreeFile();
  227. extern char    **ReadFile();
  228. extern char    *re_comp();
  229. extern char    *HackHeader();
  230.  
  231. extern char    *strerror();
  232.  
  233. /* Variables and routines that Unix(tm) provides. */
  234. extern int    errno;
  235. extern int    sys_nerr;
  236. extern int    optind;
  237. extern char    *sys_errlist[];
  238. extern char    **environ;
  239. extern char    *optarg;
  240.  
  241. extern FILE    *popen();
  242. extern char    *IDX();
  243. extern char    *RDX();
  244. extern char    *ctime();
  245. extern char    *malloc();
  246. extern char    *mktemp();
  247. extern char    *realloc();
  248. extern char    *strcat();
  249. extern char    *strncat();
  250. extern char    *strcpy();
  251. extern char    *strncpy();
  252. #if    defined(CHARSTAR_SPRINTF)
  253. extern char    *sprintf();
  254. #endif    /* defined(CHARSTAR_SPRINTF) */
  255. #if    defined(VOID_EXIT)
  256. extern void    exit();
  257. #endif    /* defined(VOID_EXIT) */
  258.