1: /* $Header: common.h,v 4.3.1.4 86/10/31 15:46:09 lwall Exp $
2: *
3: * $Log: common.h,v $
4: * Revision 4.3.1.4 86/10/31 15:46:09 lwall
5: * Expanded maximum number of .newsrc lines for net reorganization.
6: *
7: * Revision 4.3.1.3 85/05/23 17:19:32 lwall
8: * Now allows 'r' and 'f' on null articles.
9: *
10: * Revision 4.3.1.2 85/05/13 09:30:39 lwall
11: * Added CUSTOMLINES option.
12: *
13: * Revision 4.3.1.1 85/05/10 11:32:04 lwall
14: * Branch for patches.
15: *
16: * Revision 4.3 85/05/01 11:37:11 lwall
17: * Baseline for release with 4.3bsd.
18: *
19: */
20:
21: #include "config.h" /* generated by installation script */
22: #ifdef WHOAMI
23: # include <whoami.h>
24: #endif
25:
26: #include <stdio.h>
27: #include <sys/types.h>
28: #include <sys/stat.h>
29: #include <ctype.h>
30:
31: #ifndef isalnum
32: # define isalnum(c) (isalpha(c) || isdigit(c))
33: #endif
34:
35: #include <errno.h>
36: #include <signal.h>
37: #ifdef IOCTL
38: #include <sys/ioctl.h>
39: #endif IOCTL
40:
41: #ifdef FCNTL
42: # include <fcntl.h>
43: #endif
44:
45: #ifdef TERMIO
46: # include <termio.h>
47: #else
48: # include <sgtty.h>
49: #endif
50:
51: #ifdef GETPWENT
52: # include <pwd.h>
53: #endif
54:
55: #define BITSPERBYTE 8
56: #define LBUFLEN 512 /* line buffer length */
57: /* (don't worry, .newsrc lines can exceed this) */
58: #ifdef pdp11
59: # define CBUFLEN 256 /* command buffer length */
60: # define PUSHSIZE 128
61: #else
62: # define CBUFLEN 512 /* command buffer length */
63: # define PUSHSIZE 256
64: #endif
65: #ifdef pdp11
66: # define MAXFILENAME 128
67: #else
68: # define MAXFILENAME 512
69: #endif
70: #define LONGKEY 15 /* longest keyword: currently "posting-version" */
71: #define FINISHCMD 0177
72:
73: /* some handy defs */
74:
75: #define bool char
76: #define TRUE (1)
77: #define FALSE (0)
78: #define Null(t) ((t)0)
79: #define Nullch Null(char *)
80: #define Nullfp Null(FILE *)
81:
82: #define Ctl(ch) (ch & 037)
83:
84: #define strNE(s1,s2) (strcmp(s1,s2))
85: #define strEQ(s1,s2) (!strcmp(s1,s2))
86: #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
87: #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
88:
89: /* Things we can figure out ourselves */
90:
91: #ifdef SIGTSTP
92: # define BERKELEY /* include job control signals? */
93: #endif
94:
95: #ifdef SIGPROF
96: # define BSD42 /* do we have Berkeley 4.2? */
97: #endif
98:
99: #ifdef FIONREAD
100: # define PENDING
101: #else
102: # ifdef O_NDELAY
103: # define PENDING
104: # endif
105: #endif
106:
107: #ifdef EUNICE
108: # define LINKART /* add 1 level of possible indirection */
109: # define UNLINK(victim) while (!unlink(victim))
110: #else
111: # define UNLINK(victim) unlink(victim)
112: #endif
113:
114: /* Valid substitutions for strings marked with % comment are:
115: * %a Current article number
116: * %A Full name of current article (%P/%c/%a)
117: * (if LINKART defined, is the name of the real article)
118: * %b Destination of a save command, a mailbox or command
119: * %B The byte offset to the beginning of the article for saves
120: * with or without the header
121: * %c Current newsgroup, directory form
122: * %C Current newsgroup, dot form
123: * %d %P/%c
124: * %D Old Distribution: line
125: * %f Old From: line or Reply-To: line
126: * %F Newsgroups to followup to from Newsgroups: and Followup-To:
127: * %h Name of header file to pass to mail or news poster
128: * %H Host name (yours)
129: * %i Old Message-I.D.: line, with <>
130: * %I Inclusion indicator
131: * %l News administrator login name
132: * %L Login name (yours)
133: * %M Number of articles markd with M
134: * %n Newsgroups from source article
135: * %N Full name (yours)
136: * %o Organization (yours)
137: * %O Original working directory (where you ran rn from)
138: * %p Your private news directory (-d switch)
139: * %P Public news spool directory (SPOOLDIR)
140: * %r Last reference (parent article id)
141: * %R New references list
142: * %s Subject, with all Re's and (nf)'s stripped off
143: * %S Subject, with one Re stripped off
144: * %t New To: line derived from From: and Reply-To (Internet always)
145: * %T New To: line derived from Path:
146: * %u Number of unread articles
147: * %U Number of unread articles disregarding current article
148: * %x News library directory, usually /usr/lib/news
149: * %X Rn library directory, usually %x/rn
150: * %z Size of current article in bytes.
151: * %~ Home directory
152: * %. Directory containing . files
153: * %$ current process number
154: * %{name} Environment variable "name". %{name-default} form allowed.
155: * %[name] Header line beginning with "Name: ", without "Name: "
156: * %"prompt"
157: * Print prompt and insert what is typed.
158: * %`command`
159: * Insert output of command.
160: * %(test_text=pattern?if_text:else_text)
161: * Substitute if_text if test_text matches pattern, otherwise
162: * substitute else_text. Use != for negated match.
163: * % substitutions are done on test_text, if_text, and else_text.
164: * (Note: %() only works if CONDSUB defined.)
165: * %digit Substitute the text matched by the nth bracket in the last
166: * pattern that had brackets. %0 matches the last bracket
167: * matched, in case you had alternatives.
168: *
169: * Put ^ in the middle to capitalize the first letter: %^C = Net.jokes
170: * Put _ in the middle to capitalize last component: %_c = net/Jokes
171: *
172: * ~ interpretation in filename expansion happens after % expansion, so
173: * you could put ~%{NEWSLOGNAME-news} and it will expand correctly.
174: */
175:
176: /* *** System Dependent Stuff *** */
177:
178: /* NOTE: many of these are defined in the config.h file */
179:
180: /* name of organization */
181: #ifndef ORGNAME
182: # define ORGNAME "ACME Widget Company, Widget Falls, Southern North Dakota"
183: #endif
184:
185: #ifndef MBOXCHAR
186: # define MBOXCHAR 'F' /* how to recognize a mailbox by 1st char */
187: #endif
188:
189: #ifndef ROOTID
190: # define ROOTID 0 /* uid of superuser */
191: #endif
192:
193: #ifdef NORMSIG
194: # define sigset signal
195: # define sigignore(sig) signal(sig,SIG_IGN)
196: #endif
197:
198: #ifndef LOGDIRFIELD
199: # define LOGDIRFIELD 6 /* Which field (origin 1) is the */
200: /* login directory in /etc/passwd? */
201: /* (If it is not kept in passwd, */
202: /* but getpwnam() returns it, */
203: /* define the symbol GETPWENT) */
204: #endif
205: #ifndef GCOSFIELD
206: # define GCOSFIELD 5
207: #endif
208:
209: #ifndef NEGCHAR
210: # define NEGCHAR '!'
211: #endif
212:
213: /* Space conservation section */
214:
215: /* To save D space, cut down size of MAXRCLINE, NGMAX, VARYSIZE. */
216: #define MAXRCLINE 900 /* number of lines allowed in .newsrc */
217: /* several parallel arrays affected. */
218: /* (You can have more lines in the active file, */
219: /* just not in the .newsrc) */
220: #define HASHSIZ 991 /* should be prime, and at least MAXRCLINE + 10% */
221: #define NGMAX 10 /* number of newsgroups allowed on command line -10*/
222: /* undefine ONLY symbol to disable "only" feature */
223: #define VARYSIZE 128 /* this makes a block 1024 bytes long in DECville */
224: /* this makes a block 512 bytes long in DECville */
225: /* (used by virtual array routines) */
226:
227: /* Undefine any of the following features to save both I and D space */
228: /* In general, earlier ones are easier to get along without */
229: /* Pdp11's without split I and D may have to undefine them all */
230: /* #define DEBUGGING /* include debugging code */
231: /* #define CUSTOMLINES /* include code for HIDELINE and PAGESTOP */
232: /* #define PUSHBACK /* macros and keymaps using pushback buffer */
233: /* #define SPEEDOVERMEM /* use more memory to run faster */
234: #define WORDERASE /* enable ^W to erase a word */
235: #define MAILCALL /* check periodically for mail */
236: #define CLEAREOL /* use clear to end-of-line instead of clear screen */
237: #define NOFIREWORKS /* keep whole screen from flashing on certain */
238: /* terminals such as older Televideos */
239: #define VERIFY /* echo the command they just typed */
240: #undef HASHNG /* hash newsgroup lines for fast lookup-- */
241: /* linear search used if not defined */
242: #define CONDSUB /* allow %(cond?text:text) */
243: #define BACKTICK /* allow %`command` */
244: #define PROMPTTTY /* allow %"prompt" */
245: #define ULSMARTS /* catch _^H in text and do underlining */
246: #define TERMMOD /* allow terminal type modifier on switches */
247: /* #define BAUDMOD /* allow baudrate modifier on switches */
248: #define GETLOGIN /* use getlogin() routine as backup to environment */
249: /* variables USER or LOGNAME */
250: #define ORGFILE /* if organization begins with /, look up in file */
251: #define TILDENAME /* allow ~logname expansion */
252: #define SETENV /* allow command line environment variable setting */
253: #define GETWD /* use our getwd() instead of piped in pwd */
254: #ifndef BSD42 /* 4.2 sites should just use groups for this */
255: #define SETUIDGID /* substitute eaccess() for access() so that rn */
256: /* can run setuid or setgid */
257: /* if not setuid or setgid, you don't need it */
258: #endif
259: #define MAKEDIR /* use our makedir() instead of shell script */
260: /* #define MEMHELP /* keep help messages in memory */
261: /* #define VERBOSE /* compile in more informative messages */
262: #define TERSE /* compile in shorter messages */
263: /* (Note: both VERBOSE and TERSE can be defined; -t
264: * sets terse mode. One or the other MUST be defined.
265: */
266: #ifndef pdp11
267: # define CACHESUBJ /* cache subject lines in memory */
268: /* without this ^N still works but runs really slow */
269: /* but you save lots and lots of D space */
270: # define CACHEFIRST /* keep absolute first article numbers in memory */
271: /* cost: about 2k */
272: #endif
273: #define ROTATION /* enable x, X and ^X commands to work */
274: #define DELBOGUS /* ask if bogus newsgroups should be deleted */
275: #define RELOCATE /* allow newsgroup rearranging */
276: #define ESCSUBS /* escape substitutions in multi-character commands */
277: #define DELAYMARK /* allow articles to be temporarily marked as read */
278: /* until exit from current newsgroup or Y command */
279: #define MCHASE /* unmark xrefed articles on m or M */
280: #define /* allow alternate header formatting via */
281: /* environment variable ALTHEADER (not impl) */
282: #define ASYNC_PARSE /* allow parsing headers asyncronously to reading */
283: /* used by MCHASE and MUNGHEADER */
284: #define FINDNEWNG /* check for new newsgroups on startup */
285: #undef FASTNEW /* do optimizations on FINDNEWNG for faster startup */
286: /* (this optimization can make occasional mistakes */
287: /* if a group is removed and another group of the */
288: /* same length is added, and if no softpointers are */
289: /* affected by said change.) */
290: #define INNERSEARCH /* search command 'g' with article */
291: #define CATCHUP /* catchup command at newsgroup level */
292: #define NGSEARCH /* newsgroup pattern matching */
293: #define ONLY /* newsgroup restrictions by pattern */
294: #define KILLFILES /* automatic article killer files */
295: #define ARTSEARCH /* pattern searches among articles */
296: /* /, ?, ^N, ^P, k, K */
297:
298: /* some dependencies among options */
299:
300: #ifndef ARTSEARCH
301: # undef KILLFILES
302: # undef INNERSEARCH
303: # undef CACHESUBJ
304: #endif
305:
306: #ifndef DELAYMARK
307: # ifndef MCHASE
308: # ifndef MUNGHEADER
309: # undef ASYNC_PARSE
310: # endif
311: # endif
312: #endif
313:
314: #ifndef SETUIDGID
315: # define eaccess access
316: #endif
317:
318: #ifdef ONLY /* idiot lint doesn't grok #if */
319: # define NGSORONLY
320: #else
321: # ifdef NGSEARCH
322: # define NGSORONLY
323: # endif
324: #endif
325:
326: #ifdef VERBOSE
327: # ifdef TERSE
328: # define IF(c) if (c)
329: # define ELSE else
330: # else !TERSE
331: # define IF(c)
332: # define ELSE
333: # endif
334: #else !VERBOSE
335: # ifndef TERSE
336: # define TERSE
337: # endif
338: # define IF(c) "IF" outside of VERBOSE???
339: # define ELSE "ELSE" outside of VERBOSE???
340: #endif
341:
342: #ifdef DEBUGGING
343: # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);sig_catcher(0);}}
344: #else
345: # define assert(ex) ;
346: #endif
347:
348: #ifdef SPEEDOVERMEM
349: # define OFFSET(x) (x)
350: #else
351: # define OFFSET(x) ((x)-absfirst)
352: #endif
353:
354: /* If you're strapped for space use the help messages in shell scripts */
355: /* if {NG,ART,PAGER,SUBS}HELP is undefined, help messages are in memory */
356: #ifdef MEMHELP /* undef MEMHELP above to get them all as sh scripts */
357: # undef NGHELP
358: # undef ARTHELP
359: # undef PAGERHELP
360: # undef SUBSHELP
361: #else
362: # ifndef NGHELP /* % and ~ */
363: # define NGHELP "%X/ng.help"
364: # endif
365: # ifndef ARTHELP /* % and ~ */
366: # define ARTHELP "%X/art.help"
367: # endif
368: # ifndef PAGERHELP /* % and ~ */
369: # define "%X/pager.help"
370: # endif
371: # ifndef SUBSHELP /* % and ~ */
372: # define SUBSHELP "%X/subs.help"
373: # endif
374: #endif
375:
376: #ifdef CLEAREOL
377: # define TCSIZE 512 /* capacity for termcap strings */
378: #else
379: # ifdef pdp11
380: # define TCSIZE 256 /* capacity for termcap strings */
381: # else
382: # define TCSIZE 512 /* capacity for termcap srings */
383: # endif
384: #endif
385:
386: /* Additional ideas:
387: * Make the do_newsgroup() routine a separate process.
388: * Keep .newsrc on disk instead of in memory.
389: * Overlays, if you have them.
390: * Get a bigger machine.
391: */
392:
393: /* End of Space Conservation Section */
394:
395: /* More System Dependencies */
396:
397: /* news library */
398: #ifndef LIB /* ~ and %l only ("~%l" is permissable) */
399: # define LIB "/usr/lib/news"
400: #endif
401:
402: /* path to private executables */
403: #ifndef RNLIB /* ~, %x and %l only */
404: # define RNLIB "%x/rn"
405: #endif
406:
407: /* system-wide RNINIT switches */
408: #ifndef GLOBINIT
409: # define GLOBINIT "%X/INIT"
410: #endif
411:
412: /* where to find news files */
413: #ifndef SPOOL /* % and ~ */
414: # define SPOOL "/usr/spool/news"
415: #endif
416:
417: /* file containing list of active newsgroups and max article numbers */
418: #ifndef ACTIVE /* % and ~ */
419: # define ACTIVE "%x/active"
420: #endif
421:
422: /* location of history file */
423: #ifndef ARTFILE /* % and ~ */
424: # define ARTFILE "%x/history"
425: #endif
426:
427: /* command to setup a new .newsrc */
428: #ifndef NEWSETUP /* % and ~ */
429: # define NEWSETUP "newsetup"
430: #endif
431:
432: /* command to display a list of un-subscribed-to newsgroups */
433: #ifndef NEWSGROUPS /* % and ~ */
434: # define NEWSGROUPS "newsgroups"
435: #endif
436:
437: /* preferred shell for use in doshell routine */
438: /* ksh or sh would be okay here */
439: #ifndef PREFSHELL
440: # define PREFSHELL "/bin/csh"
441: #endif
442:
443: /* path to fastest starting shell */
444: #ifndef SH
445: # define SH "/bin/sh"
446: #endif
447:
448: /* path to default editor */
449: #ifndef DEFEDITOR
450: # define DEFEDITOR "/usr/ucb/vi"
451: #endif
452:
453: /* location of macro file */
454: #ifndef RNMACRO
455: # ifdef PUSHBACK
456: # define RNMACRO "%./.rnmac"
457: # endif
458: #endif
459:
460: /* location of full name */
461: #ifndef FULLNAMEFILE
462: # ifndef PASSNAMES
463: # define FULLNAMEFILE "%./.fullname"
464: # endif
465: #endif
466:
467: /* virtual array file name template */
468: #ifndef VARYNAME /* % and ~ */
469: # define VARYNAME "/tmp/rnvary.%$"
470: #endif
471:
472: /* file to pass header to followup article poster */
473: #ifndef HEADNAME /* % and ~ */
474: # define HEADNAME "%./.rnhead"
475: /* or alternately #define HEADNAME "/tmp/rnhead.%$" */
476: #endif
477:
478: #ifndef MAKEDIR
479: /* shell script to make n-deep subdirectories */
480: # ifndef DIRMAKER /* % and ~ */
481: # define DIRMAKER "%X/makedir"
482: # endif
483: #endif
484:
485: /* location of newsrc file */
486: #ifndef RCNAME /* % and ~ */
487: # define RCNAME "%./.newsrc"
488: #endif
489:
490: /* temporary newsrc file in case we crash while writing out */
491: #ifndef RCTNAME /* % and ~ */
492: # define RCTNAME "%./.newnewsrc"
493: #endif
494:
495: /* newsrc file at the beginning of this session */
496: #ifndef RCBNAME /* % and ~ */
497: # define RCBNAME "%./.oldnewsrc"
498: #endif
499:
500: /* if existent, contains process number of current or crashed rn */
501: #ifndef LOCKNAME /* % and ~ */
502: # define LOCKNAME "%./.rnlock"
503: #endif
504:
505: /* information from last invocation of rn */
506: #ifndef LASTNAME /* % and ~ */
507: # define LASTNAME "%./.rnlast"
508: #endif
509:
510: /* file with soft pointers into the active file */
511: #ifndef SOFTNAME /* % and ~ */
512: # define SOFTNAME "%./.rnsoft"
513: #endif
514:
515: /* list of article numbers to mark as unread later (see M and Y cmmands) */
516: #ifndef RNDELNAME /* % and ~ */
517: # define RNDELNAME "%./.rndelay"
518: #endif
519:
520: /* a motd-like file for rn */
521: #ifndef NEWSNEWSNAME /* % and ~ */
522: # define NEWSNEWSNAME "%X/newsnews"
523: #endif
524:
525: /* command to send a reply */
526: #ifndef MAILPOSTER /* % and ~ */
527: # define MAILPOSTER "Rnmail -h %h"
528: #endif
529:
530: #ifdef INTERNET
531: # ifndef MAILHEADER /* % */
532: # ifdef CONDSUB
533: # define "To: %t\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
534: # else
535: # define MAILHEADER "To: %t\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
536: # endif
537: # endif
538: #else
539: # ifndef MAILHEADER /* % */
540: # ifdef CONDSUB
541: # define MAILHEADER "To: %T\nSubject: %(%i=^$?:Re: %S\nNewsgroups: %n\nIn-Reply-To: %i)\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
542: # else
543: # define MAILHEADER "To: %T\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
544: # endif
545: # endif
546: #endif
547:
548: #ifndef YOUSAID /* % */
549: # define YOUSAID "In article %i you write:"
550: #endif
551:
552: /* command to submit a followup article */
553: #ifndef NEWSPOSTER /* % and ~ */
554: # define NEWSPOSTER "Pnews -h %h"
555: #endif
556:
557: #ifndef NEWSHEADER /* % */
558: # ifdef CONDSUB
559: # define "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Sender: \nReply-To: %L@%H.UUCP (%N)\nFollowup-To: \nDistribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nKeywords: %[keywords]\n\n"
560: # else
561: # define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nSender: \nReply-To: %L@%H.UUCP (%N)\nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n"
562: # endif
563: #endif
564:
565: #ifndef ATTRIBUTION /* % */
566: # define ATTRIBUTION "In article %i %f writes:"
567: #endif
568:
569: #ifndef PIPESAVER /* % */
570: # ifdef CONDSUB
571: # ifdef SERVER
572: # define PIPESAVER "%(%B=^0$?<%P/rrn%a.%$:tail +%Bc %P/rrn%a.%$ |) %b"
573: # else
574: # define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
575: # endif
576: # else
577: # ifdef SERVER
578: # define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b"
579: # else
580: # define PIPESAVER "tail +%Bc %A | %b"
581: # endif
582: # endif
583: #endif
584:
585: #ifndef NORMSAVER /* % and ~ */
586: # ifdef SERVER
587: # define NORMSAVER "%X/norm.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\""
588: # else
589: # define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\""
590: # endif
591: #endif
592:
593: #ifndef MBOXSAVER /* % and ~ */
594: # ifdef MININACT /* 2.10.2 site? */
595: # ifdef SERVER
596: # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %`date`\""
597: # else
598: # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\""
599: # endif SERVER
600: # else
601: # ifdef CONDSUB
602: # ifdef SERVER
603: # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\
604: " \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?
605: %1 %3 %(%2=..?%2: %2) %5 19%4)\""
606: # else
607: # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
608: # endif
609: /* header munging with a vengeance */
610: # else
611: # ifdef SERVER
612: # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %[posted]\""
613: # else
614: # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
615: # endif
616: # endif
617: # endif
618: #endif
619:
620: #ifdef MKDIRS
621:
622: # ifndef SAVEDIR /* % and ~ */
623: # define SAVEDIR "%p/%c"
624: # endif
625: # ifndef SAVENAME /* % */
626: # define SAVENAME "%a"
627: # endif
628:
629: #else
630:
631: # ifndef SAVEDIR /* % and ~ */
632: # define SAVEDIR "%p"
633: # endif
634: # ifndef SAVENAME /* % */
635: # define SAVENAME "%^C"
636: # endif
637:
638: #endif
639:
640: #ifndef KILLGLOBAL /* % and ~ */
641: # define KILLGLOBAL "%p/KILL"
642: #endif
643:
644: #ifndef KILLLOCAL /* % and ~ */
645: # define KILLLOCAL "%p/%c/KILL"
646: #endif
647:
648: /* how to cancel an article */
649: #ifndef CANCEL
650: # ifdef MININACT /* 2.10.2 ? */
651: # define CANCEL "%x/inews -h < %h"
652: # else
653: # define CANCEL "inews -h < %h"
654: # endif
655: #endif
656:
657: /* how to cancel an article, continued */
658: #ifndef CANCELHEADER
659: # define "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n"
660: #endif
661:
662: /* where to find the mail file */
663: #ifndef MAILFILE
664: # define MAILFILE "/usr/spool/mail/%L"
665: #endif
666:
667: /* some important types */
668:
669: typedef int NG_NUM; /* newsgroup number */
670: typedef long ART_NUM; /* article number */
671: #ifdef pdp11
672: typedef short ART_UNREAD; /* ordinarily this should be long */
673: /* like ART_NUM, but assuming that */
674: /* we stay less than 32767 articles */
675: /* behind saves a lot of space. */
676: /* NOTE: do not make unsigned. */
677: #else
678: typedef long ART_UNREAD;
679: #endif
680: typedef long ART_POS; /* char position in article file */
681: typedef int ART_LINE; /* line position in article file */
682: /* following was short until 6/9/92 */
683: typedef long ACT_POS; /* char position in active file */
684: typedef unsigned int MEM_SIZE; /* for passing to malloc */
685:
686: /* *** end of the machine dependent stuff *** */
687:
688: /* GLOBAL THINGS */
689:
690: /* file statistics area */
691:
692: EXT struct stat filestat;
693:
694: /* various things of type char */
695:
696: char *index();
697: char *rindex();
698: char *getenv();
699: char *strcat();
700: char *strcpy();
701: char *sprintf();
702:
703: EXT char buf[LBUFLEN+1]; /* general purpose line buffer */
704: EXT char cmd_buf[CBUFLEN]; /* buffer for formatting system commands */
705:
706: EXT char *indstr INIT(">"); /* indent for old article embedded in followup */
707:
708: EXT char *cwd INIT(Nullch); /* current working directory */
709: EXT char *dfltcmd INIT(Nullch); /* 1st char is default command */
710:
711: /* switches */
712:
713: #ifdef DEBUGGING
714: EXT int debug INIT(0); /* -D */
715: # define DEB_INNERSRCH 32
716: # define DEB_FILEXP 64
717: # define DEB_HASH 128
718: # define DEB_XREF_MARKER 256
719: # define DEB_CTLAREA_BITMAP 512
720: # define DEB_SOFT_POINTERS 1024
721: # define DEB_NEWSRC_LINE 2048
722: # define DEB_SEARCH_AHEAD 4096
723: # define DEB_CHECKPOINTING 8192
724: # define DEB_FEED_XREF 16384
725: #endif
726:
727: #ifdef ARTSEARCH
728: EXT int scanon INIT(0); /* -S */
729: #endif
730:
731: EXT bool mbox_always INIT(FALSE); /* -M */
732: EXT bool norm_always INIT(FALSE); /* -N */
733: EXT bool checkflag INIT(FALSE); /* -c */
734: EXT bool suppress_cn INIT(FALSE); /* -s */
735: EXT int countdown INIT(5); /* how many lines to list before invoking -s */
736: EXT bool muck_up_clear INIT(FALSE); /* -loco */
737: EXT bool erase_screen INIT(FALSE); /* -e */
738: #ifdef CLEAREOL
739: EXT bool can_home_clear INIT(FALSE); /* fancy -e -- PWP */
740: #endif CLEAREOL
741: EXT bool findlast INIT(FALSE); /* -r */
742: EXT bool typeahead INIT(FALSE); /* -T */
743: #ifdef VERBOSE
744: # ifdef TERSE
745: EXT bool verbose INIT(TRUE); /* +t */
746: # endif
747: #endif
748: #ifdef VERIFY
749: EXT bool verify INIT(FALSE); /* -v */
750: #endif
751:
752: #define NOMARKING 0
753: #define STANDOUT 1
754: #define UNDERLINE 2
755: EXT int marking INIT(NOMARKING); /* -m */
756:
757: EXT ART_LINE initlines INIT(0); /* -i */
758:
759: /* miscellania */
760:
761: long atol(), fseek(), ftell();
762: EXT bool in_ng INIT(FALSE); /* current state of rn */
763: EXT char mode INIT('i'); /* current state of rn */
764:
765: EXT FILE *tmpfp INIT(Nullfp); /* scratch fp used for .rnlock, .rnlast, etc. */
766:
767: EXT NG_NUM nextrcline INIT(0); /* 1st unused slot in rcline array */
768: /* startup to avoid checking twice in a row */
769:
770: extern errno;
771:
772: /* Factored strings */
773:
774: EXT char nullstr[] INIT("");
775: EXT char sh[] INIT(SH);
776: EXT char defeditor[] INIT(DEFEDITOR);
777: EXT char hforhelp[] INIT("Type h for help.\n");
778: #ifdef STRICTCR
779: EXT char badcr[] INIT("\nUnnecessary CR ignored.\n");
780: #endif
781: EXT char readerr[] INIT("rn read error");
782: EXT char unsubto[] INIT("\n\nUnsubscribed to newsgroup %s\n");
783: EXT char cantopen[] INIT("Can't open %s\n");
784: EXT char cantcreate[] INIT("Can't create %s\n");
785:
786: #ifdef VERBOSE
787: EXT char nocd[] INIT("Can't chdir to directory %s\n");
788: #else
789: EXT char nocd[] INIT("Can't find %s\n");
790: #endif
791:
792: #ifdef NOLINEBUF
793: #define FLUSH ,fflush(stdout)
794: #else
795: #define FLUSH
796: #endif
797:
798: #ifdef lint
799: #undef FLUSH
800: #define FLUSH
801: #undef putchar
802: #define putchar(c)
803: #endif