sob@lib.tmc.edu (Stan Barber) (12/18/89)
Description: This is an official patch for rn 4.3. It is the first official to originate from someone other than the author of rn, Larry Wall. Larry has agreed to allow me (Stan Barber) to maintain patches to this version of rn until such time that a new release of rn is available. This one logical patch is actually composed of three physical patches numbered 41,42 and 43. Please install all of them if you intend to install any of them. This is the 3rd and final part, patch #43. If you missed the other parts, you can get them via the Archive Server by sending mail to "archive-server@bcm.tmc.edu" with the subject line "send public rn.41.patch" for patch #41 or "send public rn.42.patch" for patch #42. Please see patch #41 for a list of fixes. Comments or other fixes should be sent to rrn@lib.tmc.edu. NOTE: Even if you don't intented to use RRN, you will still want to apply this patch to take advantage of all the bug fixes. Fix: cd to your rn source directory and patch away NOTE: You must be running patch 2.0 with patches up though #12 to insure this will patch correctly. It is known for a fact that patch 2.0 with patches up to #7 will fail. Index: patchlevel Prereq: 42 *** patchlevel Mon Feb 2 17:24:23 1987 --- ../rn/patchlevel Mon Nov 6 00:51:21 1989 *************** *** 1 ! Patch #: 42 --- 1 ----- ! Patch #: 43 Index: common.h Prereq: 4.3.1.4 *** common.h Fri Nov 21 16:49:45 1986 --- ../rn/common.h Fri Dec 8 22:43:36 1989 *************** *** 1,4 ! /* $Header: common.h,v 4.3.1.4 86/10/31 15:46:09 lwall Exp $ * * $Log: common.h,v $ * Revision 4.3.1.4 86/10/31 15:46:09 lwall --- 1,4 ----- ! /* $Header: common.h,v 4.3.2.7 89/12/08 22:43:12 sob Exp $ * * $Log: common.h,v $ * Revision 4.3.2.7 89/12/08 22:43:12 sob *************** *** 1,6 /* $Header: common.h,v 4.3.1.4 86/10/31 15:46:09 lwall Exp $ * * $Log: common.h,v $ * Revision 4.3.1.4 86/10/31 15:46:09 lwall * Expanded maximum number of .newsrc lines for net reorganization. * --- 1,29 ----- /* $Header: common.h,v 4.3.2.7 89/12/08 22:43:12 sob Exp $ * * $Log: common.h,v $ + * Revision 4.3.2.7 89/12/08 22:43:12 sob + * Corrected typo pointed out by weening@gang-of-four.stanford.edu + * + * Revision 4.3.2.6 89/11/28 01:57:31 sob + * Added initlines_specified variable for use with SIGWINCH support. + * + * Revision 4.3.2.5 89/11/28 00:30:56 sob + * Reversed the CANCELHEADER definitions. + * + * Revision 4.3.2.4 89/11/27 01:29:23 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.3 89/11/26 19:32:06 sob + * Increased the size of MAXRCLINE from 1000 to 1500 + * Increated HASHSIZ from 1103 to 1693 + * + * Revision 4.3.2.2 89/11/07 23:18:49 sob + * Repaired NEWSHEADER and CANCEL to work correctly with NNTP and INTERNET. + * + * Revision 4.3.2.1 89/11/06 00:12:33 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3.1.4 86/10/31 15:46:09 lwall * Expanded maximum number of .newsrc lines for net reorganization. * *************** *** 213,219 /* Space conservation section */ /* To save D space, cut down size of MAXRCLINE, NGMAX, VARYSIZE. */ ! #define MAXRCLINE 1000 /* number of lines allowed in .newsrc */ /* several parallel arrays affected. */ /* (You can have more lines in the active file, */ /* just not in the .newsrc) */ --- 236,242 ----- /* Space conservation section */ /* To save D space, cut down size of MAXRCLINE, NGMAX, VARYSIZE. */ ! #define MAXRCLINE 1500 /* number of lines allowed in .newsrc */ /* several parallel arrays affected. */ /* (You can have more lines in the active file, */ /* just not in the .newsrc) */ *************** *** 217,223 /* several parallel arrays affected. */ /* (You can have more lines in the active file, */ /* just not in the .newsrc) */ ! #define HASHSIZ 1103 /* should be prime, and at least MAXRCLINE + 10% */ #define NGMAX 100 /* number of newsgroups allowed on command line */ /* undefine ONLY symbol to disable "only" feature */ #define VARYSIZE 256 /* this makes a block 1024 bytes long in DECville */ --- 240,246 ----- /* several parallel arrays affected. */ /* (You can have more lines in the active file, */ /* just not in the .newsrc) */ ! #define HASHSIZ 1693 /* should be prime, and at least MAXRCLINE + 10% */ #define NGMAX 100 /* number of newsgroups allowed on command line */ /* undefine ONLY symbol to disable "only" feature */ #define VARYSIZE 256 /* this makes a block 1024 bytes long in DECville */ *************** *** 555,560 #ifndef NEWSHEADER /* % */ # ifdef CONDSUB # define NEWSHEADER "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" # else # 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" --- 578,586 ----- #ifndef NEWSHEADER /* % */ # ifdef CONDSUB + #ifdef INTERNET + # define NEWSHEADER "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Sender: \nFollowup-To: \nDistribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nKeywords: %[keywords]\n\n" + #else # define NEWSHEADER "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" #endif # else *************** *** 556,561 #ifndef NEWSHEADER /* % */ # ifdef CONDSUB # define NEWSHEADER "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" # else # 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" # endif --- 582,588 ----- # define NEWSHEADER "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Sender: \nFollowup-To: \nDistribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nKeywords: %[keywords]\n\n" #else # define NEWSHEADER "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" + #endif # else # ifdef INTERNET # define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nSender: \nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n" *************** *** 557,563 # ifdef CONDSUB # define NEWSHEADER "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" # else ! # 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" # endif #endif --- 584,594 ----- # define NEWSHEADER "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" #endif # else ! # ifdef INTERNET ! # define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nSender: \nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n" ! # else ! # 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" ! # endif # endif #endif *************** *** 567,573 #ifndef PIPESAVER /* % */ # ifdef CONDSUB ! # define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b" # else # define PIPESAVER "tail +%Bc %A | %b" # endif --- 598,608 ----- #ifndef PIPESAVER /* % */ # ifdef CONDSUB ! # ifdef SERVER ! # define PIPESAVER "%(%B=^0$?<%P/rrn%a.%$:tail +%Bc %P/rrn%a.%$ |) %b" ! # else ! # define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b" ! # endif # else # ifdef SERVER # define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b" *************** *** 569,575 # ifdef CONDSUB # define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b" # else ! # define PIPESAVER "tail +%Bc %A | %b" # endif #endif --- 604,614 ----- # define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b" # endif # else ! # ifdef SERVER ! # define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b" ! # else ! # define PIPESAVER "tail +%Bc %A | %b" ! # endif # endif #endif *************** *** 574,580 #endif #ifndef NORMSAVER /* % and ~ */ ! # define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\"" #endif #ifndef MBOXSAVER /* % and ~ */ --- 613,623 ----- #endif #ifndef NORMSAVER /* % and ~ */ ! # ifdef SERVER ! # define NORMSAVER "%X/norm.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\"" ! # else ! # define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\"" ! # endif #endif #ifndef MBOXSAVER /* % and ~ */ *************** *** 579,585 #ifndef MBOXSAVER /* % and ~ */ # ifdef MININACT /* 2.10.2 site? */ ! # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\"" # else # ifdef CONDSUB # 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)\"" --- 622,632 ----- #ifndef MBOXSAVER /* % and ~ */ # ifdef MININACT /* 2.10.2 site? */ ! # ifdef SERVER ! # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %`date`\"" ! # else ! # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\"" ! # endif SERVER # else # ifdef CONDSUB # ifdef SERVER *************** *** 582,588 # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\"" # else # ifdef CONDSUB ! # 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)\"" /* header munging with a vengeance */ # else # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\"" --- 629,641 ----- # endif SERVER # else # ifdef CONDSUB ! # ifdef SERVER ! # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\ ! " \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)? ! %1 %3 %(%2=..?%2: %2) %5 19%4)\"" ! # else ! # 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)\"" ! # endif /* header munging with a vengeance */ # else # ifdef SERVER *************** *** 585,591 # 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)\"" /* header munging with a vengeance */ # else ! # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\"" # endif # endif #endif --- 638,648 ----- # endif /* header munging with a vengeance */ # else ! # ifdef SERVER ! # define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %[posted]\"" ! # else ! # define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\"" ! # endif # endif # endif #endif *************** *** 629,634 /* how to cancel an article, continued */ #ifndef CANCELHEADER # define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n" #endif --- 686,694 ----- /* how to cancel an article, continued */ #ifndef CANCELHEADER + #ifdef INTERNET + # define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nDistribution: %D\nOrganization: %o\n" + #else # define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n" #endif #endif *************** *** 631,636 #ifndef CANCELHEADER # define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n" #endif /* where to find the mail file */ #ifndef MAILFILE --- 691,697 ----- #else # define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nReply-To: %L@%H.UUCP (%N)\nDistribution: %D\nOrganization: %o\n" #endif + #endif /* where to find the mail file */ #ifndef MAILFILE *************** *** 650,655 #else typedef long ART_UNREAD; #endif typedef long ART_POS; /* char position in article file */ typedef int ART_LINE; /* line position in article file */ typedef short ACT_POS; /* char position in active file */ --- 711,719 ----- #else typedef long ART_UNREAD; #endif + #ifdef SERVER + typedef int ART_PART; /* for passing to nntpopen() */ + #endif typedef long ART_POS; /* char position in article file */ typedef int ART_LINE; /* line position in article file */ typedef short ACT_POS; /* char position in active file */ *************** *** 655,660 typedef short ACT_POS; /* char position in active file */ typedef unsigned int MEM_SIZE; /* for passing to malloc */ /* *** end of the machine dependent stuff *** */ /* GLOBAL THINGS */ --- 719,725 ----- typedef short ACT_POS; /* char position in active file */ typedef unsigned int MEM_SIZE; /* for passing to malloc */ + /* *** end of the machine dependent stuff *** */ /* GLOBAL THINGS */ *************** *** 727,732 EXT int marking INIT(NOMARKING); /* -m */ EXT ART_LINE initlines INIT(0); /* -i */ /* miscellania */ --- 792,798 ----- EXT int marking INIT(NOMARKING); /* -m */ EXT ART_LINE initlines INIT(0); /* -i */ + EXT bool initlines_specified INIT(FALSE); /* miscellania */ Index: head.c Prereq: 4.3.1.2 *** head.c Fri Nov 21 16:21:29 1986 --- ../rn/head.c Mon Nov 27 01:30:37 1989 *************** *** 1,4 ! /* $Header: head.c,v 4.3.1.2 85/05/10 13:47:25 lwall Exp $ * * $Log: head.c,v $ * Revision 4.3.1.2 85/05/10 13:47:25 lwall --- 1,4 ----- ! /* $Header: head.c,v 4.3.2.4 89/11/27 01:30:35 sob Locked $ * * $Log: head.c,v $ * Revision 4.3.2.4 89/11/27 01:30:35 sob *************** *** 1,6 /* $Header: head.c,v 4.3.1.2 85/05/10 13:47:25 lwall Exp $ * * $Log: head.c,v $ * Revision 4.3.1.2 85/05/10 13:47:25 lwall * Added debugging stuff. * --- 1,20 ----- /* $Header: head.c,v 4.3.2.4 89/11/27 01:30:35 sob Locked $ * * $Log: head.c,v $ + * Revision 4.3.2.4 89/11/27 01:30:35 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.3 89/11/26 22:53:52 sob + * Add new patches to make RRN be faster. + * + * Revision 4.3.2.2 89/11/08 01:17:46 sob + * Added changes to insure that this will compile for RN or RRN with no + * changes to the source code. + * + * Revision 4.3.2.1 89/11/06 00:37:18 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3.1.2 85/05/10 13:47:25 lwall * Added debugging stuff. * *************** *** 16,21 #include "common.h" #include "artio.h" #include "bits.h" #include "util.h" #include "INTERN.h" #include "head.h" --- 30,38 ----- #include "common.h" #include "artio.h" #include "bits.h" + #ifdef SERVER + #include "server.h" + #endif #include "util.h" #include "INTERN.h" #include "head.h" *************** *** 156,161 if (parsed_art == artnum) return 0; /* no maybe about it now */ if (artopen(artnum) == Nullfp) { return -1; } --- 173,181 ----- if (parsed_art == artnum) return 0; /* no maybe about it now */ + #ifdef SERVER + if (nntpopen(artnum,HEAD) == Nullfp) { + #else if (artopen(artnum) == Nullfp) { #endif return -1; *************** *** 157,162 return 0; /* no maybe about it now */ if (artopen(artnum) == Nullfp) { return -1; } start_header(artnum); --- 177,183 ----- if (nntpopen(artnum,HEAD) == Nullfp) { #else if (artopen(artnum) == Nullfp) { + #endif return -1; } start_header(artnum); *************** *** 180,185 bool copy; /* do you want it savestr()ed? */ { char *s = Nullch, *t; #ifdef CACHESUBJ if (!subj_list) { --- 201,211 ----- bool copy; /* do you want it savestr()ed? */ { char *s = Nullch, *t; + #ifdef SERVER + static int xhdr = 1; /* Can we use xhdr command? */ + int eoo; /* End of server output */ + char ser_line[256]; + #endif SERVER #ifdef CACHESUBJ if (!subj_list) { *************** *** 208,213 else { s = safemalloc((MEM_SIZE)256); *s = '\0'; if (artopen(artnum) != Nullfp) { do { if (fgets(s,256,artfp) == Nullch) --- 234,288 ----- else { s = safemalloc((MEM_SIZE)256); *s = '\0'; + #ifdef SERVER + if (xhdr) { + sprintf(ser_line, "XHDR subject %ld", artnum); + put_server(ser_line); + if (get_server(ser_line, sizeof (ser_line)) >= 0) { + if (ser_line[0] == CHAR_FATAL) { + xhdr = 0; + } else { + while (get_server(ser_line, sizeof (ser_line)) >= 0) { + if (ser_line[0] == '.') + break; + else { + t = index(ser_line, ' '); + if (t++) { + strcpy(s, t); + if (t = index(s, '\r')) + *t = '\0'; + } + } + } + } + } else { + fprintf(stderr, + "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + } + + if (!xhdr) { + sprintf(ser_line, "HEAD %ld", artnum); + put_server(ser_line); + eoo = 0; + if (get_server(ser_line, 256) >= 0 && ser_line[0] == CHAR_OK) { + do { + if (get_server(s, 256) < 0 || (*s == '.')) { + strcpy(s, "Title: \n"); + eoo = 1; + } + } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8)); + + if (!eoo) + while (get_server(ser_line, sizeof (ser_line)) >= 0 && + ser_line[0] != '.'); + t = index(s,':')+1; + while (*t == ' ') t++; + strcpy(s, t); + } + } + #else not SERVER if (artopen(artnum) != Nullfp) { do { if (fgets(s,256,artfp) == Nullch) *************** *** 213,218 if (fgets(s,256,artfp) == Nullch) strcpy(s, "Title: \n"); } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8)); s[strlen(s)-1] = '\0'; t = index(s,':')+1; while (*t == ' ') t++; --- 288,294 ----- if (fgets(s,256,artfp) == Nullch) strcpy(s, "Title: \n"); } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8)); + s[strlen(s)-1] = '\0'; t = index(s,':')+1; while (*t == ' ') t++; *************** *** 218,223 while (*t == ' ') t++; strcpy(s, t); } s = saferealloc(s, (MEM_SIZE)strlen(s)+1); #ifdef CACHESUBJ subj_list[OFFSET(artnum)] = s; --- 294,300 ----- while (*t == ' ') t++; strcpy(s, t); } + #endif s = saferealloc(s, (MEM_SIZE)strlen(s)+1); #ifdef CACHESUBJ subj_list[OFFSET(artnum)] = s; *************** *** 261,266 #endif firstpos = htype[which_line].ht_minpos; lastpos = htype[which_line].ht_maxpos; if (!artnum || firstpos < 0 || artopen(artnum) == Nullfp) { newbuf = safemalloc((unsigned int)1); *newbuf = '\0'; --- 338,346 ----- #endif firstpos = htype[which_line].ht_minpos; lastpos = htype[which_line].ht_maxpos; + #ifdef SERVER + if (!artnum || firstpos < 0 || nntpopen(artnum,HEAD) == Nullfp) { + #else if (!artnum || firstpos < 0 || artopen(artnum) == Nullfp) { #endif newbuf = safemalloc((unsigned int)1); *************** *** 262,267 firstpos = htype[which_line].ht_minpos; lastpos = htype[which_line].ht_maxpos; if (!artnum || firstpos < 0 || artopen(artnum) == Nullfp) { newbuf = safemalloc((unsigned int)1); *newbuf = '\0'; return newbuf; --- 342,348 ----- if (!artnum || firstpos < 0 || nntpopen(artnum,HEAD) == Nullfp) { #else if (!artnum || firstpos < 0 || artopen(artnum) == Nullfp) { + #endif newbuf = safemalloc((unsigned int)1); *newbuf = '\0'; return newbuf; Index: init.c Prereq: 4.3.1.4 *** init.c Fri Nov 21 16:45:18 1986 --- ../rn/init.c Wed Nov 8 01:17:50 1989 *************** *** 1,4 ! /* $Header: init.c,v 4.3.1.4 86/09/05 14:24:02 lwall Exp $ * * $Log: init.c,v $ * Revision 4.3.1.4 86/09/05 14:24:02 lwall --- 1,4 ----- ! /* $Header: init.c,v 4.3.2.2 89/11/08 01:17:48 sob Locked $ * * $Log: init.c,v $ * Revision 4.3.2.2 89/11/08 01:17:48 sob *************** *** 1,6 /* $Header: init.c,v 4.3.1.4 86/09/05 14:24:02 lwall Exp $ * * $Log: init.c,v $ * Revision 4.3.1.4 86/09/05 14:24:02 lwall * Removed net.announce dependency. * --- 1,13 ----- /* $Header: init.c,v 4.3.2.2 89/11/08 01:17:48 sob Locked $ * * $Log: init.c,v $ + * Revision 4.3.2.2 89/11/08 01:17:48 sob + * Added changes to insure that this will compile for RN or RRN with no + * changes to the source code. + * + * Revision 4.3.2.1 89/11/06 00:39:14 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3.1.4 86/09/05 14:24:02 lwall * Removed net.announce dependency. * *************** *** 44,49 #include "ngstuff.h" #include "rcln.h" #include "respond.h" #include "ng.h" #include "INTERN.h" #include "init.h" --- 51,59 ----- #include "ngstuff.h" #include "rcln.h" #include "respond.h" + #ifdef SERVER + #include "server.h" + #endif #include "ng.h" #include "INTERN.h" #include "init.h" *************** *** 56,61 char *tcbuf; register bool foundany = FALSE; long time(); #ifdef NOLINEBUF static char std_out_buf[BUFSIZ]; /* must be static or malloced */ --- 66,75 ----- char *tcbuf; register bool foundany = FALSE; long time(); + #ifdef SERVER + char *server; + int response; + #endif SERVER #ifdef NOLINEBUF static char std_out_buf[BUFSIZ]; /* must be static or malloced */ *************** *** 123,128 if (!checkflag) newsnews_check(); /* open active file, etc. */ --- 137,168 ----- if (!checkflag) newsnews_check(); + + #ifdef SERVER + + /* open connection to server if appropriate */ + + server = getserverbyfile(SERVER_FILE); + if (server == NULL) { + fprintf(stderr, "Can't get the name of the news server from %s\n", + SERVER_FILE); + fprintf(stderr, + "Either fix this file, or put NNTPSERVER in your environment.\n"); + finalize(1); + } + + response = server_init(server); + if (response < 0) { + fprintf(stderr, + "Couldn't connect to %s news server, try again later.\n", + server); + finalize(1); + } + + if (handle_server_response(response, server) < 0) + finalize(1); + + #endif SERVER /* open active file, etc. */ Index: ng.c Prereq: 4.3.1.6 *** ng.c Fri Nov 21 16:39:09 1986 --- ../rn/ng.c Sat Dec 9 01:18:59 1989 *************** *** 1,4 ! /* $Header: ng.c,v 4.3.1.6 85/09/10 11:03:42 lwall Exp $ * * $Log: ng.c,v $ * Revision 4.3.1.6 85/09/10 11:03:42 lwall --- 1,4 ----- ! /* $Header: ng.c,v 4.3.2.5 89/12/09 01:18:42 sob Exp $ * * $Log: ng.c,v $ * Revision 4.3.2.5 89/12/09 01:18:42 sob *************** *** 1,6 /* $Header: ng.c,v 4.3.1.6 85/09/10 11:03:42 lwall Exp $ * * $Log: ng.c,v $ * Revision 4.3.1.6 85/09/10 11:03:42 lwall * Improved %m in in_char(). * --- 1,22 ----- /* $Header: ng.c,v 4.3.2.5 89/12/09 01:18:42 sob Exp $ * * $Log: ng.c,v $ + * Revision 4.3.2.5 89/12/09 01:18:42 sob + * Fixed a bad call to nntpopen(). + * + * Revision 4.3.2.4 89/11/28 01:51:20 sob + * Removed redundant #include directive. + * + * Revision 4.3.2.3 89/11/27 01:31:03 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.2 89/11/26 22:53:35 sob + * Add new patches to make RRN be faster. + * + * Revision 4.3.2.1 89/11/06 00:54:27 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3.1.6 85/09/10 11:03:42 lwall * Improved %m in in_char(). * *************** *** 36,42 #include "kfile.h" #include "rcstuff.h" #include "head.h" - #include "artstate.h" #include "bits.h" #include "art.h" #include "artio.h" --- 52,57 ----- #include "kfile.h" #include "rcstuff.h" #include "head.h" #include "bits.h" #include "art.h" #include "artio.h" *************** *** 48,53 #include "rcln.h" #include "last.h" #include "search.h" #include "INTERN.h" #include "ng.h" #include "artstate.h" /* somebody has to do it */ --- 63,71 ----- #include "rcln.h" #include "last.h" #include "search.h" + #ifdef SERVER + #include "server.h" + #endif #include "INTERN.h" #include "ng.h" #include "artstate.h" /* somebody has to do it */ *************** *** 110,115 do_newsgroup(start_command) char *start_command; /* command to fake up first */ { char oldmode = mode; register long i; /* scratch */ int skipstate; /* how many unavailable articles */ --- 128,138 ----- do_newsgroup(start_command) char *start_command; /* command to fake up first */ { + #ifdef SERVER + char ser_line[256]; + char artname[32]; + static long our_pid; + #endif SERVER char oldmode = mode; register long i; /* scratch */ int skipstate; /* how many unavailable articles */ *************** *** 117,122 char *whatnext = "%sWhat next? [%s]"; #ifdef ARTSEARCH srchahead = (scanon && ((ART_NUM)toread[ng]) >= scanon ? -1 : 0); /* did they say -S? */ --- 140,150 ----- char *whatnext = "%sWhat next? [%s]"; + #ifdef SERVER + if (our_pid == 0) /* Agreed, this is gross */ + our_pid = getpid(); + #endif SERVER + #ifdef ARTSEARCH srchahead = (scanon && ((ART_NUM)toread[ng]) >= scanon ? -1 : 0); /* did they say -S? */ *************** *** 125,130 mode = 'a'; recent_art = curr_art = 0; exit_code = NG_NORM; if (eaccess(ngdir,5)) { /* directory read protected? */ if (eaccess(ngdir,0)) { #ifdef VERBOSE --- 153,173 ----- mode = 'a'; recent_art = curr_art = 0; exit_code = NG_NORM; + + #ifdef SERVER + sprintf(ser_line, "GROUP %s", ngname); + put_server(ser_line); + if (get_server(ser_line, sizeof(ser_line)) < 0) { + fprintf(stderr, "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + if (*ser_line != CHAR_OK) { + if (atoi(ser_line) != ERR_NOGROUP) + fprintf(stderr, "rrn: server response to GROUP %s:\n%s\n", + ngname, ser_line); + return (-1); + } + #else not SERVER if (eaccess(ngdir,5)) { /* directory read protected? */ if (eaccess(ngdir,0)) { #ifdef VERBOSE *************** *** 165,170 mode = oldmode; return -1; } #ifdef CACHESUBJ subj_list = Null(char **); /* no subject list till needed */ --- 208,214 ----- mode = oldmode; return -1; } + #endif SERVER #ifdef CACHESUBJ subj_list = Null(char **); /* no subject list till needed */ *************** *** 292,298 } else if (!reread && !was_read(art) ! && artopen(art) == Nullfp) { /* never read it, & cannot find it? */ if (errno != ENOENT) { /* has it not been deleted? */ #ifdef VERBOSE IF(verbose) --- 336,345 ----- } else if (!reread && !was_read(art) ! #ifdef SERVER ! && nntpopen(art,HEAD) == Nullfp) { ! #else ! && artopen(art) == Nullfp) { /* never read it, & cannot find it? */ if (errno != ENOENT) { /* has it not been deleted? */ #ifdef VERBOSE IF(verbose) *************** *** 306,311 skipstate = 0; sleep(2); } switch(skipstate++) { case 0: clear(); --- 353,359 ----- skipstate = 0; sleep(2); } + #endif switch(skipstate++) { case 0: clear(); *************** *** 329,334 default: putchar('.'); fflush(stdout); #define READDIR #ifdef READDIR { /* fast skip patch */ --- 377,383 ----- default: putchar('.'); fflush(stdout); + #ifndef SERVER #define READDIR #ifdef READDIR { /* fast skip patch */ *************** *** 341,346 art = newart - 1; } #endif break; } oneless(art); /* mark deleted as read */ --- 390,415 ----- art = newart - 1; } #endif + #else + { + char ser_line[256]; + ART_NUM newart; + + put_server("NEXT"); + if (get_server(ser_line, sizeof (ser_line)) < 0) { + fprintf(stderr, + "rrn: unexpected close of server socket.\n"); + finalize(1); + } + if (ser_line[0] != CHAR_OK) + newart = lastart + 1; + else + newart = atoi(ser_line+4); + for (i=art; i<newart; i++) + oneless(i); + art = newart - 1; + } + #endif SERVER break; } oneless(art); /* mark deleted as read */ *************** *** 450,455 if (artfp != Nullfp) { /* article still open? */ fclose(artfp); /* close it */ artfp = Nullfp; /* and tell the world */ openart = 0; } putchar('\n') FLUSH; --- 519,528 ----- if (artfp != Nullfp) { /* article still open? */ fclose(artfp); /* close it */ artfp = Nullfp; /* and tell the world */ + #ifdef SERVER + sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid); + UNLINK(artname); + #endif SERVER openart = 0; } putchar('\n') FLUSH; *************** *** 500,505 if (art <= firstart) break; art--; } while (was_read(art) || artopen(art) == Nullfp); #ifdef ARTSEARCH srchahead = 0; --- 573,581 ----- if (art <= firstart) break; art--; + #ifdef SERVER + } while (was_read(art) || nntpopen(art,HEAD) == Nullfp); + #else } while (was_read(art) || artopen(art) == Nullfp); #endif #ifdef ARTSEARCH *************** *** 501,506 break; art--; } while (was_read(art) || artopen(art) == Nullfp); #ifdef ARTSEARCH srchahead = 0; #endif --- 577,583 ----- } while (was_read(art) || nntpopen(art,HEAD) == Nullfp); #else } while (was_read(art) || artopen(art) == Nullfp); + #endif #ifdef ARTSEARCH srchahead = 0; #endif Index: ngdata.c Prereq: 4.3 *** ngdata.c Mon Feb 2 17:24:26 1987 --- ../rn/ngdata.c Fri Dec 8 22:43:07 1989 *************** *** 1,4 ! /* $Header: ngdata.c,v 4.3 85/05/01 11:44:38 lwall Exp $ * * $Log: ngdata.c,v $ * Revision 4.3 85/05/01 11:44:38 lwall --- 1,4 ----- ! /* $Header: ngdata.c,v 4.3.2.6 89/12/08 22:42:04 sob Exp $ * * $Log: ngdata.c,v $ * Revision 4.3.2.6 89/12/08 22:42:04 sob *************** *** 1,6 /* $Header: ngdata.c,v 4.3 85/05/01 11:44:38 lwall Exp $ * * $Log: ngdata.c,v $ * Revision 4.3 85/05/01 11:44:38 lwall * Baseline for release with 4.3bsd. * --- 1,26 ----- /* $Header: ngdata.c,v 4.3.2.6 89/12/08 22:42:04 sob Exp $ * * $Log: ngdata.c,v $ + * Revision 4.3.2.6 89/12/08 22:42:04 sob + * Corrected typo in an #ifdef statement pointed out by + * jik@pit-manager.mit.edu + * + * Revision 4.3.2.5 89/11/28 01:51:14 sob + * Removed redundant #include directive. + * + * Revision 4.3.2.4 89/11/27 01:31:07 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.3 89/11/08 02:41:40 sob + * Removed unneeded subroutine. + * + * Revision 4.3.2.2 89/11/08 02:24:31 sob + * Integrated modifications from other RRN patches colleceted from USENET + * + * Revision 4.3.2.1 89/11/06 00:42:43 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3 85/05/01 11:44:38 lwall * Baseline for release with 4.3bsd. * *************** *** 15,20 #include "final.h" #include "rcln.h" #include "util.h" #include "INTERN.h" #include "ngdata.h" --- 35,43 ----- #include "final.h" #include "rcln.h" #include "util.h" + #ifdef SERVER + #include "server.h" + #endif #include "INTERN.h" #include "ngdata.h" *************** *** 18,23 #include "INTERN.h" #include "ngdata.h" void ngdata_init() { --- 41,50 ----- #include "INTERN.h" #include "ngdata.h" + #ifdef SERVER + char active_name[256]; + #endif SERVER + void ngdata_init() { *************** *** 21,26 void ngdata_init() { /* The following is only for systems that do not zero globals properly */ #ifdef ZEROGLOB # ifdef CACHEFIRST --- 48,57 ----- void ngdata_init() { + #ifdef SERVER + char ser_line[256]; + char *cp; + #endif /* The following is only for systems that do not zero globals properly */ #ifdef ZEROGLOB # ifdef CACHEFIRST *************** *** 31,36 /* open the active file */ actfp = fopen(filexp(ACTIVE),"r"); if (actfp == Nullfp) { printf(cantopen,filexp(ACTIVE)) FLUSH; --- 62,95 ----- /* open the active file */ + #ifdef SERVER + + put_server("LIST"); /* tell server we want the active file */ + (void) get_server(ser_line, sizeof(ser_line)); + if (*ser_line != CHAR_OK) { /* and then see if that's ok */ + fprintf(stdout, "Can't get active file from server: \n%s\n", ser_line); + finalize(1); + } + + cp = filexp("/tmp/rrnact.%$"); /* make a temporary name */ + strcpy(active_name, cp); + actfp = fopen(active_name, "w+"); /* and get ready */ + if (actfp == Nullfp) { + printf(cantopen,filexp(ACTIVE)) FLUSH; + finalize(1); + } + + while (get_server(ser_line, sizeof(ser_line)) >= 0) { /* while */ + if (ser_line[0] == '.') /* there's another line */ + break; /* get it and write it to */ + fputs(ser_line, actfp); + putc('\n', actfp); + } + + fseek(actfp,0L,0); /* just get to the beginning */ + + #else not SERVER + actfp = fopen(filexp(ACTIVE),"r"); if (actfp == Nullfp) { printf(cantopen,filexp(ACTIVE)) FLUSH; *************** *** 36,41 printf(cantopen,filexp(ACTIVE)) FLUSH; finalize(1); } } /* find the maximum article number of a newsgroup */ --- 95,101 ----- printf(cantopen,filexp(ACTIVE)) FLUSH; finalize(1); } + #endif SERVER } /* find the maximum article number of a newsgroup */ *************** *** 143,148 } /* determine the absolutely first existing article number */ ART_NUM getabsfirst(ngnum,ngsize) --- 203,219 ----- } /* determine the absolutely first existing article number */ + #ifdef SERVER + ART_NUM + getabsfirst(ngnum,ngsize) + register NG_NUM ngnum; + ART_NUM ngsize; + { + register ART_NUM a1st; + #ifndef MININACT + char ser_line[256]; + ART_NUM x,y; + #endif #ifdef CACHEFIRST if (a1st = abs1st[ngnum]) *************** *** 144,149 /* determine the absolutely first existing article number */ ART_NUM getabsfirst(ngnum,ngsize) register NG_NUM ngnum; --- 215,249 ----- ART_NUM x,y; #endif + #ifdef CACHEFIRST + if (a1st = abs1st[ngnum]) + return a1st; + #endif + #ifdef MININACT + getngsize(ngnum); + # ifdef CACHEFIRST + return abs1st[ngnum]; + # else + return abs1st; + # endif + #else + sprintf(cp,"GROUP %s",rcline[ngnum]); + put_server(cp); + if (get_server(ser_line, sizeof(ser_line)) < 0) { + fprintf(stderr, "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + if (*ser_line != CHAR_OK) { /* and then see if that's ok */ + a1st = ngsize+1; /* nothing there */ + } + (void) sscanf(ser_line,"%d%d%d",&x,&y,&a1st); + # ifdef CACHEFIRST + abs1st[ngnum] = a1st; + # endif + return a1st; + #endif + } + /* we already know the lowest article number with NNTP */ ART_NUM getngmin(dirname,floor) char *dirname; *************** *** 145,150 /* determine the absolutely first existing article number */ ART_NUM getabsfirst(ngnum,ngsize) register NG_NUM ngnum; ART_NUM ngsize; --- 245,258 ----- } /* we already know the lowest article number with NNTP */ ART_NUM + getngmin(dirname,floor) + char *dirname; + ART_NUM floor; + { + return(floor); + } + #else + ART_NUM getabsfirst(ngnum,ngsize) register NG_NUM ngnum; ART_NUM ngsize; *************** *** 214,217 closedir(dirp); return min==1000000 ? 0 : min; } ! --- 322,325 ----- closedir(dirp); return min==1000000 ? 0 : min; } ! #endif Index: ngdata.h Prereq: 4.3 *** ngdata.h Mon Feb 2 17:24:27 1987 --- ../rn/ngdata.h Mon Nov 6 00:41:34 1989 *************** *** 1,4 ! /* $Header: ngdata.h,v 4.3 85/05/01 11:44:48 lwall Exp $ * * $Log: ngdata.h,v $ * Revision 4.3 85/05/01 11:44:48 lwall --- 1,4 ----- ! /* $Header: ngdata.h,v 4.3.2.1 89/11/06 00:41:21 sob Locked $ * * $Log: ngdata.h,v $ * Revision 4.3.2.1 89/11/06 00:41:21 sob *************** *** 1,6 /* $Header: ngdata.h,v 4.3 85/05/01 11:44:48 lwall Exp $ * * $Log: ngdata.h,v $ * Revision 4.3 85/05/01 11:44:48 lwall * Baseline for release with 4.3bsd. * --- 1,9 ----- /* $Header: ngdata.h,v 4.3.2.1 89/11/06 00:41:21 sob Locked $ * * $Log: ngdata.h,v $ + * Revision 4.3.2.1 89/11/06 00:41:21 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3 85/05/01 11:44:48 lwall * added to local RCS * *************** *** 2,7 * * $Log: ngdata.h,v $ * Revision 4.3 85/05/01 11:44:48 lwall * Baseline for release with 4.3bsd. * */ --- 5,13 ----- * Added RRN support from NNTP 1.5 * * Revision 4.3 85/05/01 11:44:48 lwall + * added to local RCS + * + * Revision 4.3 85/05/01 11:44:48 lwall * Baseline for release with 4.3bsd. * */ *************** *** 9,14 EXT FILE *actfp INIT(Nullfp); /* the active file */ EXT bool writesoft INIT(FALSE); /* rewrite the soft pointer file? */ EXT int softtries INIT(0), softmisses INIT(0); #ifdef CACHEFIRST EXT ART_NUM abs1st[MAXRCLINE]; /* 1st real article in newsgroup */ --- 15,24 ----- EXT FILE *actfp INIT(Nullfp); /* the active file */ EXT bool writesoft INIT(FALSE); /* rewrite the soft pointer file? */ EXT int softtries INIT(0), softmisses INIT(0); + + #ifdef SERVER + EXT char active_name[256]; + #endif #ifdef CACHEFIRST EXT ART_NUM abs1st[MAXRCLINE]; /* 1st real article in newsgroup */ Index: rcstuff.c Prereq: 4.3.1.5 *** rcstuff.c Fri Nov 21 16:40:13 1986 --- ../rn/rcstuff.c Sun Nov 26 18:24:17 1989 *************** *** 1,4 ! /* $Header: rcstuff.c,v 4.3.1.5 86/07/24 14:09:10 lwall Exp $ * * $Log: rcstuff.c,v $ * Revision 4.3.1.5 86/07/24 14:09:10 lwall --- 1,4 ----- ! /* $Header: rcstuff.c,v 4.3.2.2 89/11/26 18:22:26 sob Locked $ * * $Log: rcstuff.c,v $ * Revision 4.3.2.2 89/11/26 18:22:26 sob *************** *** 1,6 /* $Header: rcstuff.c,v 4.3.1.5 86/07/24 14:09:10 lwall Exp $ * * $Log: rcstuff.c,v $ * Revision 4.3.1.5 86/07/24 14:09:10 lwall * Removed check for spool directory existence in get_ng. * --- 1,14 ----- /* $Header: rcstuff.c,v 4.3.2.2 89/11/26 18:22:26 sob Locked $ * * $Log: rcstuff.c,v $ + * Revision 4.3.2.2 89/11/26 18:22:26 sob + * Added changes to addnewgroup() to cause rn to ask once and only once + * to add a new group to .newsrc. + * Fix provided by Fletcher Mattox <fletcher@cs.utexas.edu> + * + * Revision 4.3.2.1 89/11/06 00:58:29 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3.1.5 86/07/24 14:09:10 lwall * Removed check for spool directory existence in get_ng. * *************** *** 31,36 #include "intrp.h" #include "only.h" #include "rcln.h" #include "INTERN.h" #include "rcstuff.h" --- 39,47 ----- #include "intrp.h" #include "only.h" #include "rcln.h" + #ifdef SERVER + #include "server.h" + #endif #include "INTERN.h" #include "rcstuff.h" *************** *** 53,58 register bool foundany = FALSE; char *some_buf; long length; #ifdef HASHNG for (i=0; i<HASHSIZ; i++) --- 64,72 ----- register bool foundany = FALSE; char *some_buf; long length; + #ifdef SERVER + char *cp; + #endif SERVER #ifdef HASHNG for (i=0; i<HASHSIZ; i++) *************** *** 61,66 /* make filenames */ rcname = savestr(filexp(RCNAME)); rctname = savestr(filexp(RCTNAME)); rcbname = savestr(filexp(RCBNAME)); --- 75,89 ----- /* make filenames */ + #ifdef SERVER + + if (cp = getenv("NEWSRC")) + rcname = savestr(filexp(cp)); + else + rcname = savestr(filexp(RCNAME)); + + #else not SERVER + rcname = savestr(filexp(RCNAME)); #endif SERVER *************** *** 62,67 /* make filenames */ rcname = savestr(filexp(RCNAME)); rctname = savestr(filexp(RCTNAME)); rcbname = savestr(filexp(RCBNAME)); softname = savestr(filexp(SOFTNAME)); --- 85,93 ----- #else not SERVER rcname = savestr(filexp(RCNAME)); + + #endif SERVER + rctname = savestr(filexp(RCTNAME)); rcbname = savestr(filexp(RCBNAME)); softname = savestr(filexp(SOFTNAME)); *************** *** 224,229 /* returns TRUE if found or added, FALSE if not. */ /* assumes that we are chdir'ed to SPOOL */ bool get_ng(what,do_reloc) char *what; --- 250,259 ----- /* returns TRUE if found or added, FALSE if not. */ /* assumes that we are chdir'ed to SPOOL */ + #ifdef SERVER + static int addnewbydefault = 0; + #endif SERVER + bool get_ng(what,do_reloc) char *what; *************** *** 231,236 { char *ntoforget; char promptbuf[128]; #ifdef VERBOSE IF(verbose) --- 261,269 ----- { char *ntoforget; char promptbuf[128]; + #ifdef SERVER + char ser_line[256]; + #endif SERVER #ifdef VERBOSE IF(verbose) *************** *** 248,253 set_ngname(what); ng = find_ng(ngname); if (ng == nextrcline) { /* not in .newsrc? */ if ((softptr[ng] = findact(buf,ngname,strlen(ngname),0L)) < 0 ) { dingaling(); #ifdef VERBOSE --- 281,301 ----- set_ngname(what); ng = find_ng(ngname); if (ng == nextrcline) { /* not in .newsrc? */ + + #ifdef SERVER + sprintf(ser_line, "GROUP %s", ngname); + put_server(ser_line); + if (get_server(ser_line, sizeof(ser_line)) < 0) { + fprintf(stderr, "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + if (*ser_line != CHAR_OK) { + if (atoi(ser_line) != ERR_NOGROUP) { + fprintf(stderr, "Server response to GROUP %s:\n%s\n", + ngname, ser_line); + } + #else not SERVER + if ((softptr[ng] = findact(buf,ngname,strlen(ngname),0L)) < 0 ) { #endif SERVER *************** *** 249,254 ng = find_ng(ngname); if (ng == nextrcline) { /* not in .newsrc? */ if ((softptr[ng] = findact(buf,ngname,strlen(ngname),0L)) < 0 ) { dingaling(); #ifdef VERBOSE IF(verbose) --- 297,305 ----- #else not SERVER if ((softptr[ng] = findact(buf,ngname,strlen(ngname),0L)) < 0 ) { + + #endif SERVER + dingaling(); #ifdef VERBOSE IF(verbose) *************** *** 261,266 sleep(2); return FALSE; } #ifdef VERBOSE IF(verbose) sprintf(promptbuf,"\nNewsgroup %s not in .newsrc--add? [yn] ",ngname); --- 312,324 ----- sleep(2); return FALSE; } + #ifdef SERVER + if (addnewbydefault) { + printf("(Adding %s to end of your .newsrc)\n", ngname); + ng = add_newsgroup(ngname); + do_reloc = FALSE; + } else { + #endif SERVER #ifdef VERBOSE IF(verbose) sprintf(promptbuf,"\nNewsgroup %s not in .newsrc--add? [yn] ",ngname); *************** *** 290,295 goto reask_add; } else if (*buf == 'n' || *buf == 'q') { return FALSE; } else if (*buf == 'y') { --- 348,354 ----- goto reask_add; } else if (*buf == 'n' || *buf == 'q') { + ng = add_newsgroup(ngname, '!'); return FALSE; } else if (*buf == 'y') { *************** *** 293,298 return FALSE; } else if (*buf == 'y') { ng = add_newsgroup(ngname); do_reloc = FALSE; } --- 352,366 ----- return FALSE; } else if (*buf == 'y') { + ng = add_newsgroup(ngname, ':'); + do_reloc = FALSE; + } + #ifdef SERVER + else if (*buf == 'Y') { + fputs( + "(I'll add all new newsgroups to the end of your .newsrc.)\n", stdout); + addnewbydefault = 1; + printf("(Adding %s to end of your .newsrc)\n", ngname); ng = add_newsgroup(ngname); do_reloc = FALSE; } *************** *** 296,301 ng = add_newsgroup(ngname); do_reloc = FALSE; } else { fputs(hforhelp,stdout) FLUSH; settle_down(); --- 364,370 ----- ng = add_newsgroup(ngname); do_reloc = FALSE; } + #endif SERVER else { fputs(hforhelp,stdout) FLUSH; settle_down(); *************** *** 301,306 settle_down(); goto reask_add; } } else if (rcchar[ng] == NEGCHAR) { /* unsubscribed? */ #ifdef VERBOSE --- 370,378 ----- settle_down(); goto reask_add; } + #ifdef SERVER + } + #endif SERVER } else if (rcchar[ng] == NEGCHAR) { /* unsubscribed? */ #ifdef VERBOSE *************** *** 359,366 /* add a newsgroup to the .newsrc file (eventually) */ NG_NUM ! add_newsgroup(ngn) ! char *ngn; { register NG_NUM newng = nextrcline++; /* increment max rcline index */ --- 431,438 ----- /* add a newsgroup to the .newsrc file (eventually) */ NG_NUM ! add_newsgroup(ngn, c) ! char *ngn, c; { register NG_NUM newng = nextrcline++; /* increment max rcline index */ *************** *** 369,375 rcline[newng] = safemalloc((MEM_SIZE)(rcnums[newng] + 1)); strcpy(rcline[newng],ngn); /* and copy over the name */ *(rcline[newng] + rcnums[newng]) = '\0'; ! rcchar[newng] = ':'; /* call it subscribed */ toread[newng] = TR_NONE; /* just for prettiness */ #ifdef HASHNG sethash(newng); /* so we can find it again */ --- 441,447 ----- rcline[newng] = safemalloc((MEM_SIZE)(rcnums[newng] + 1)); strcpy(rcline[newng],ngn); /* and copy over the name */ *(rcline[newng] + rcnums[newng]) = '\0'; ! rcchar[newng] = c; /* subscribe or unsubscribe */ toread[newng] = TR_NONE; /* just for prettiness */ #ifdef HASHNG sethash(newng); /* so we can find it again */ *************** *** 375,381 sethash(newng); /* so we can find it again */ #endif #ifdef RELOCATE ! return relocate_newsgroup(newng,-1); #else return newng; #endif --- 447,453 ----- sethash(newng); /* so we can find it again */ #endif #ifdef RELOCATE ! return c=='!' ? newng : relocate_newsgroup(newng,-1); #else return newng; #endif *************** *** 453,458 if (newng < 0) { reask_reloc: unflush_output(); /* disable any ^O in effect */ #ifdef VERBOSE IF(verbose) printf("\nPut newsgroup where? [%s] ", dflt); --- 525,536 ----- if (newng < 0) { reask_reloc: unflush_output(); /* disable any ^O in effect */ + #ifdef SERVER + if (addnewbydefault) { + buf[0] = '$'; + buf[1] = '\0'; + } else { + #endif SERVER #ifdef VERBOSE IF(verbose) printf("\nPut newsgroup where? [%s] ", dflt); *************** *** 465,470 reinp_reloc: eat_typeahead(); getcmd(buf); if (errno || *buf == '\f') { /* if return from stop signal */ goto reask_reloc; /* give them a prompt again */ --- 543,551 ----- reinp_reloc: eat_typeahead(); getcmd(buf); + #ifdef SERVER + } + #endif SERVER if (errno || *buf == '\f') { /* if return from stop signal */ goto reask_reloc; /* give them a prompt again */ Index: getactive.c *** getactive.c Sun Dec 17 12:45:24 1989 --- ../rn/getactive.c Tue Nov 28 01:50:46 1989 *************** *** 0 --- 1,80 ----- + /* $Header: getactive.c,v 1.2 89/11/28 01:50:22 sob Locked $ + * + * $Log: getactive.c,v $ + * Revision 1.2 89/11/28 01:50:22 sob + * Changed so that it won't give makedepend problems with SERVER is not defined. + * + * Revision 1.1 89/11/06 00:50:14 sob + * Initial revision + * + * + */ + #include <stdio.h> + #include "config.h" + #include "EXTERN.h" + #ifdef SERVER + #include "server.h" + #endif + + main(argc, argv) + int argc; + char *argv[]; + { + char ser_line[256]; + int response; + register char *server; + register FILE *actfp; + + if (argc != 2) { + fprintf(stderr, "Usage: getactive filename\n"); + exit(1); + } + + server = getserverbyfile(SERVER_FILE); + if (server == NULL) { + fprintf(stderr, "Couldn't get name of news server from %s\n", + SERVER_FILE); + fprintf(stderr, + "Either fix this file, or put NNTPSERVER in your environment.\n"); + exit(1); + } + + response = server_init(server); + if (response < 0) { + fprintf(stderr, + "getactive: Can't get active file from server %s.\n", + server); + exit(1); + } + + if (handle_server_response(response, server) < 0) + exit(1); + + put_server("LIST"); /* tell server we want the active file */ + (void) get_server(ser_line, sizeof(ser_line)); + if (*ser_line != CHAR_OK) { /* and then see if that's ok */ + fprintf(stderr, + "getactive: Can't get active file from server.\n"); + fprintf(stderr, "Server said: %s\n", ser_line); + exit(1); + } + + actfp = fopen(argv[1], "w"); /* and get ready */ + if (actfp == NULL) { + close_server(); + perror(argv[1]); + exit(1); + } + + while (get_server(ser_line, sizeof(ser_line)) >= 0) { /* while */ + if (ser_line[0] == '.') /* there's another line */ + break; /* get it and write it to */ + if (actfp != NULL) { /* the temporary active file */ + fputs(ser_line, actfp); + putc('\n', actfp); + } + } + + (void) fclose(actfp); + close_server(); + } Index: artio.h Prereq: 4.3 *** artio.h Fri Nov 21 15:43:13 1986 --- ../rn/artio.h Mon Nov 27 01:29:10 1989 *************** *** 1,4 ! /* $Header: artio.h,v 4.3 85/05/01 11:35:43 lwall Exp $ * * $Log: artio.h,v $ * Revision 4.3 85/05/01 11:35:43 lwall --- 1,4 ----- ! /* $Header: artio.h,v 4.3.2.2 89/11/27 01:27:53 sob Locked $ * * $Log: artio.h,v $ * Revision 4.3.2.2 89/11/27 01:27:53 sob *************** *** 1,6 /* $Header: artio.h,v 4.3 85/05/01 11:35:43 lwall Exp $ * * $Log: artio.h,v $ * Revision 4.3 85/05/01 11:35:43 lwall * Baseline for release with 4.3bsd. * --- 1,13 ----- /* $Header: artio.h,v 4.3.2.2 89/11/27 01:27:53 sob Locked $ * * $Log: artio.h,v $ + * Revision 4.3.2.2 89/11/27 01:27:53 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.1 89/11/26 22:41:24 sob + * Added RRN support + * * Revision 4.3 85/05/01 11:35:43 lwall * Baseline for release with 4.3bsd. * *************** *** 14,19 #ifdef LINKART EXT char *linkartname INIT(nullstr);/* real name of article for Eunice */ #endif void artio_init(); FILE *artopen(); /* open an article unless already opened */ --- 21,29 ----- #ifdef LINKART EXT char *linkartname INIT(nullstr);/* real name of article for Eunice */ #endif + #ifdef SERVER + EXT ART_PART openpart INIT(0); /* how much of that article do we have? */ + FILE *nntpopen(); /* get an article unless already retrieved */ void nntpclose(); /* MUST be in increasing order of completeness! */ *************** *** 15,19 EXT char *linkartname INIT(nullstr);/* real name of article for Eunice */ #endif void artio_init(); FILE *artopen(); /* open an article unless already opened */ --- 25,36 ----- EXT ART_PART openpart INIT(0); /* how much of that article do we have? */ FILE *nntpopen(); /* get an article unless already retrieved */ + void nntpclose(); + /* MUST be in increasing order of completeness! */ + #define STAT 1 /* test for existence only */ + #define HEAD 2 /* if only header items are desired */ + #define ARTICLE 3 /* retreive full article */ + #endif + void artio_init(); FILE *artopen(); /* open an article unless already opened */ *************** *** 16,19 #endif void artio_init(); ! FILE *artopen(); /* open an article unless already opened */ --- 33,36 ----- #endif void artio_init(); ! FILE *artopen(); /* open an article unless already opened */ Index: artsrch.c Prereq: 4.3 *** artsrch.c Fri Nov 21 15:41:36 1986 --- ../rn/artsrch.c Mon Nov 27 01:30:03 1989 *************** *** 1,4 ! /* $Header: artsrch.c,v 4.3 85/05/01 11:35:47 lwall Exp $ * * $Log: artsrch.c,v $ * Revision 4.3 85/05/01 11:35:47 lwall --- 1,4 ----- ! /* $Header: artsrch.c,v 4.3.2.4 89/11/27 01:30:00 sob Locked $ * * $Log: artsrch.c,v $ * Revision 4.3.2.4 89/11/27 01:30:00 sob *************** *** 1,6 /* $Header: artsrch.c,v 4.3 85/05/01 11:35:47 lwall Exp $ * * $Log: artsrch.c,v $ * Revision 4.3 85/05/01 11:35:47 lwall * Baseline for release with 4.3bsd. * --- 1,19 ----- /* $Header: artsrch.c,v 4.3.2.4 89/11/27 01:30:00 sob Locked $ * * $Log: artsrch.c,v $ + * Revision 4.3.2.4 89/11/27 01:30:00 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.3 89/11/26 22:54:37 sob + * Added new patches to make rrn faster. + * + * Revision 4.3.2.2 89/11/26 22:20:57 sob + * Added better NNTP support. + * + * Revision 4.3.2.1 89/11/26 22:13:10 sob + * Added support for NNTP + * * Revision 4.3 85/05/01 11:35:47 lwall * Baseline for release with 4.3bsd. * *************** *** 17,22 #include "head.h" #include "final.h" #include "cheat.h" #include "ng.h" #include "artio.h" #include "INTERN.h" --- 30,38 ----- #include "head.h" #include "final.h" #include "cheat.h" + #ifdef SERVER + #include "server.h" + #endif #include "ng.h" #include "artio.h" #include "INTERN.h" *************** *** 271,276 fetchsubj(artnum,FALSE,FALSE);/* might as well get subject handy */ #endif if (artopen(artnum) == Nullfp) /* ensure that article is open */ return FALSE; /* if not, return NO MATCH */ scope--; --- 287,299 ----- fetchsubj(artnum,FALSE,FALSE);/* might as well get subject handy */ #endif + #ifdef SERVER + if (scope == 1){ + if (nntpopen(artnum,HEAD) == Nullfp) /* we only need the header */ + return FALSE; + } + else + #endif if (artopen(artnum) == Nullfp) /* ensure that article is open */ return FALSE; /* if not, return NO MATCH */ *************** *** 272,277 #endif if (artopen(artnum) == Nullfp) /* ensure that article is open */ return FALSE; /* if not, return NO MATCH */ scope--; while (fgets(buf,LBUFLEN,artfp) != Nullch) { --- 295,301 ----- else #endif if (artopen(artnum) == Nullfp) /* ensure that article is open */ + return FALSE; /* if not, return NO MATCH */ scope--; while (fgets(buf,LBUFLEN,artfp) != Nullch) { Index: cheat.c Prereq: 4.3 *** cheat.c Fri Nov 21 15:42:19 1986 --- ../rn/cheat.c Mon Nov 27 01:30:23 1989 *************** *** 1,4 ! /* $Header: cheat.c,v 4.3 85/05/01 11:36:46 lwall Exp $ * * $Log: cheat.c,v $ * Revision 4.3 85/05/01 11:36:46 lwall --- 1,4 ----- ! /* $Header: cheat.c,v 4.3.2.2 89/11/27 01:30:18 sob Locked $ * * $Log: cheat.c,v $ * Revision 4.3.2.2 89/11/27 01:30:18 sob *************** *** 1,6 /* $Header: cheat.c,v 4.3 85/05/01 11:36:46 lwall Exp $ * * $Log: cheat.c,v $ * Revision 4.3 85/05/01 11:36:46 lwall * Baseline for release with 4.3bsd. * --- 1,13 ----- /* $Header: cheat.c,v 4.3.2.2 89/11/27 01:30:18 sob Locked $ * * $Log: cheat.c,v $ + * Revision 4.3.2.2 89/11/27 01:30:18 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.1 89/11/26 22:54:21 sob + * Added RRN support + * * Revision 4.3 85/05/01 11:36:46 lwall * Baseline for release with 4.3bsd. * *************** *** 91,96 if (debug) printf("(%ld)",(long)srchahead); #endif artopen(srchahead); break; } --- 98,106 ----- if (debug) printf("(%ld)",(long)srchahead); #endif + #ifdef SERVER + nntpopen(srchahead,HEAD); + #else artopen(srchahead); #endif break; *************** *** 92,97 printf("(%ld)",(long)srchahead); #endif artopen(srchahead); break; } if (input_pending()) --- 102,108 ----- nntpopen(srchahead,HEAD); #else artopen(srchahead); + #endif break; } if (input_pending()) *************** *** 104,109 #endif { if (art+1 <= lastart)/* how about a pre-fetch? */ artopen(art+1); /* look for the next article */ } } --- 115,123 ----- #endif { if (art+1 <= lastart)/* how about a pre-fetch? */ + #ifdef SERVER + nntpopen(art+1,HEAD); /* look for the next article */ + #else artopen(art+1); /* look for the next article */ #endif } *************** *** 105,110 { if (art+1 <= lastart)/* how about a pre-fetch? */ artopen(art+1); /* look for the next article */ } } #endif --- 119,125 ----- nntpopen(art+1,HEAD); /* look for the next article */ #else artopen(art+1); /* look for the next article */ + #endif } } #endif Index: artio.c Prereq: 4.3 *** artio.c Fri Nov 21 15:42:46 1986 --- ../rn/artio.c Mon Nov 27 01:30:00 1989 *************** *** 1,4 ! /* $Header: artio.c,v 4.3 85/05/01 11:35:39 lwall Exp $ * * $Log: artio.c,v $ * Revision 4.3 85/05/01 11:35:39 lwall --- 1,4 ----- ! /* $Header: artio.c,v 4.3.2.4 89/11/27 01:29:57 sob Locked $ * * $Log: artio.c,v $ * Revision 4.3.2.4 89/11/27 01:29:57 sob *************** *** 1,6 /* $Header: artio.c,v 4.3 85/05/01 11:35:39 lwall Exp $ * * $Log: artio.c,v $ * Revision 4.3 85/05/01 11:35:39 lwall * Baseline for release with 4.3bsd. * --- 1,20 ----- /* $Header: artio.c,v 4.3.2.4 89/11/27 01:29:57 sob Locked $ * * $Log: artio.c,v $ + * Revision 4.3.2.4 89/11/27 01:29:57 sob + * Altered NNTP code per ideas suggested by Bela Lubkin + * <filbo@gorn.santa-cruz.ca.us> + * + * Revision 4.3.2.3 89/11/26 22:55:31 sob + * Add nntpopen() and nntpclose() routines to cut down on size of rrn + * + * Revision 4.3.2.2 89/11/08 01:17:12 sob + * Added changes to insure that this will compile for RN or RRN with no + * changes to the source code. + * + * Revision 4.3.2.1 89/11/06 00:07:25 sob + * Added RRN support from NNTP 1.5 + * * Revision 4.3 85/05/01 11:35:39 lwall * Baseline for release with 4.3bsd. * *************** *** 8,13 #include "EXTERN.h" #include "common.h" #include "INTERN.h" #include "artio.h" --- 22,30 ----- #include "EXTERN.h" #include "common.h" + #ifdef SERVER + #include "server.h" + #endif #include "INTERN.h" #include "artio.h" *************** *** 23,29 artopen(artnum) ART_NUM artnum; { ! char artname[8]; /* filename of current article */ if (artnum < 1) return Nullfp; --- 40,49 ----- artopen(artnum) ART_NUM artnum; { ! #ifdef SERVER ! nntpopen(artnum,ARTICLE); ! #else ! char artname[32]; /* filename of current article */ if (artnum < 1) return Nullfp; *************** *** 39,44 /* produce the name of the article */ if (artfp = fopen(artname,"r")) /* if we can open it */ openart = artnum; /* remember what we did here */ #ifdef LINKART { char tmpbuf[256]; --- 59,65 ----- /* produce the name of the article */ if (artfp = fopen(artname,"r")) /* if we can open it */ openart = artnum; /* remember what we did here */ + #endif SERVER #ifdef LINKART { char tmpbuf[256]; *************** *** 68,70 return artfp; /* and return either fp or NULL */ } --- 89,171 ----- return artfp; /* and return either fp or NULL */ } + #ifdef SERVER + static long our_pid; + + FILE * + nntpopen(artnum,function) + ART_NUM artnum; + ART_PART function; + { + char ser_line[256]; + char artname[32]; /* filename of current article */ + if (our_pid == 0) + our_pid = getpid(); + if (artnum < 1) + return Nullfp; + if ((openart == artnum) && (openpart >= function)) + { /* this article is already open? */ + fseek(artfp,0L,0); /* just get to the beginning */ + return artfp; /* and say we succeeded */ + } + if (artfp != Nullfp) { /* it was somebody else? */ + fclose(artfp); /* put them out of their misery */ + nntpclose(); + openart = 0; /* and remember them no more */ + } + sprintf(artname,"/tmp/rrn%ld.%ld", (long) artnum, our_pid); + artfp = fopen(artname, "w+"); /* create the temporary article */ + if (artfp == Nullfp) { + UNLINK(artname); + return Nullfp; + } + switch (function){ + case STAT: + function = HEAD; /* fall through */ + case HEAD: + sprintf(ser_line, "HEAD %ld", (long)artnum); + break; + case ARTICLE: + sprintf(ser_line, "ARTICLE %ld", (long)artnum); + break; + } + put_server(ser_line); /* ask the server for the article */ + if (get_server(ser_line, sizeof(ser_line)) < 0) { + fprintf(stderr, "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + if (*ser_line != CHAR_OK) { /* and get it's reaction */ + fclose(artfp); + artfp = Nullfp; + UNLINK(artname); + return Nullfp; + } + + for (;;) { + if (get_server(ser_line, sizeof(ser_line)) < 0) { + fprintf(stderr, "rrn: Unexpected close of server socket.\n"); + finalize(1); + } + if (ser_line[0] == '.' && ser_line[1] == '\0') + break; + fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp); + putc('\n', artfp); + } + openpart = function; + if (function == HEAD) + putc('\n', artfp); /* req'd blank line after header */ + fseek(artfp, 0L, 0); /* Then get back to the start */ + openart = artnum; + return artfp; /* and return either fp or NULL */ + } + + void + nntpclose() + { + char artname[32]; /* filename of current article */ + if (our_pid == 0) + our_pid = getpid(); + sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid); + UNLINK(artname); + } + #endif Index: NEW *** NEW Fri Nov 21 15:39:34 1986 --- ../rn/NEW Sun Nov 26 18:19:18 1989 *************** *** 1,4 ! NEW FEATURES WITH RN 4.3 New commands TAB (pager) scan for end of quoted text. --- 1,4 ----- ! NEW FEATURES WITH RN/RRN 4.3 New commands TAB (pager) scan for end of quoted text.