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