📄 nntp.patch
字号:
+ *+ * This command is an extention, and not included in RFC 977.+ */++listgroup(argc, argv)+ int argc;+ char *argv[];+{+ register int i;++ if (argc == 2) {+ ingroup = 0;+ /* This will output a success or failure message */+ group(argc, argv);+ if (!ingroup) {+ return;+ }+ } else if (argc > 2) {+ printf("%d Usage: LISTGROUP [newsgroup].\r\n", ERR_CMDSYN);+ (void) fflush(stdout);+ return;+ } else if (!ingroup) {+ printf("%d You are not currently in a newsgroup.\r\n",+ ERR_NCING);+ (void) fflush(stdout);+ return;+ } else if (!canread) {+ printf("%d You only have permission to transfer, sorry.\r\n",+ ERR_ACCESS);+ (void) fflush(stdout);+ return;+ } else {+ /* output a success message when no group name is given */+ printf("%d %d %d %d (current group)\r\n",+ OK_GROUP,+ num_arts,+ (num_arts > 0 ? art_array[0] : 0),+ (num_arts > 0 ? art_array[num_arts-1] : 0));+ }++#ifdef LOG+ syslog(LOG_INFO, "%s listgroup", hostname);+#endif+ for (i = 0; i < num_arts; i++) {+ printf("%d\r\n", art_array[i]);+ }+ putchar('.');+ putchar('\r');+ putchar('\n');+ (void) fflush(stdout);+}++#endif /* LISTGROUP */Index:server/help.c@@ -21,8 +21,22 @@ printf("NEXT POST QUIT\r\n"); printf("STAT NEWGROUPS HELP\r\n"); printf("IHAVE NEWNEWS SLAVE\r\n");- printf("\r\nAdditionally, the following extention is supported:\r\n\r\n");+ printf("DATE\r\n");+#if defined(XHDR) || defined(XTHREAD) || defined(LISTGROUP) || defined(XOVER)+ printf("\r\nAdditionally, the following extension(s) are supported:\r\n\r\n");+# ifdef LISTGROUP+ printf("LISTGROUP Retrieve a list of valid article-numbers.\r\n");+# endif+# ifdef XHDR printf("XHDR Retrieve a single header line from a range of articles.\r\n");+# endif+# ifdef XOVER+ printf("XOVER Return news overview data\r\n");+# endif+# ifdef XTHREAD+ printf("XTHREAD Retrieve trn thread file for the current group.\r\n");+# endif+#endif printf("\r\n"); printf("Bugs to Stan Barber (Internet: nntp@tmc.edu; UUCP: ...!bcm!nntp)\r\n"); printf(".\r\n");Index:server/misc.c@@ -100,7 +100,7 @@ int lookup; { char line[MAXBUFLEN];- char *tmp;+ char *start, *end; register char *cp; long ltmp; static char path[MAXPATHLEN];@@ -118,6 +118,7 @@ #endif USGHIST static FILE *hfp = NULL; /* history file, text version */ + group_artnum = 0; #ifdef CNEWS cp = rindex(msg_id,'@'); /* look for @ in message id */ if( cp != NULL)@@ -234,17 +235,30 @@ ltmp, msg_id); #endif SYSLOG if (cp == NULL) return(NULL); /* this article has expired */- tmp = cp+1; - if ((cp = index(tmp, ' ')) != NULL)+ if (group_name) {+ end = cp;+ do {+ if ((end = index(start = end+1, ' ')) != NULL)+ *end = '\0';++ if ((cp = index(start, '/')) != NULL) {+ *cp = '\0';+ if (!strcmp(start, group_name))+ group_artnum = atol(cp+1);+ *cp = '/';+ }+ } while (!group_artnum && end != NULL);+ }+ else if ((cp = index(start = cp+1, ' ')) != NULL) *cp = '\0';- - while ((cp = index(tmp, '.')) != NULL)++ while ((cp = index(start, '.')) != NULL) *cp = '/'; (void) strcpy(path, spooldir); (void) strcat(path, "/");- (void) strcat(path, tmp);+ (void) strcat(path, start); #ifdef USGHIST (void) fclose(hfp); #endif@@ -481,9 +495,10 @@ close_crnt() {- if (art_fp != NULL)+ if (art_fp != NULL) { (void) fclose(art_fp);- art_fp = NULL;+ art_fp = NULL;+ } } Index:server/newgroups.c@@ -23,6 +23,7 @@ int i; long date; register FILE *date_fp;+ char *reqlist[2]; if (argc < 3) { printf("%d Usage: NEWGROUPS yymmdd hhmmss [\"GMT\"] [<distributions>].\r\n",@@ -96,6 +97,22 @@ #endif if (distcount == 0) {+#ifdef ACTIVE_TIMES_FILE+ reqlist[0] = line;+#else+ reqlist[0] = cp + 1;+#endif+ reqlist[1] = NULL;++ if (ngpermcount) {+ if (ngmatch(s1strneql, ALLBUT,+ ngpermlist, ngpermcount, reqlist, 1) == 0) {+ continue;+ }+ } else if (ALLBUT == 0) {+ continue;+ }+ #ifdef ACTIVE_TIMES_FILE putline(line); #elseIndex:server/serve.c@@ -24,9 +24,9 @@ #include "timer.h" #endif -extern int ahbs(), group(), help(), ihave();+extern int ahbs(), dodate(), group(), help(), ihave(); extern int list(), newgroups(), newnews(), nextlast(), post();-extern int slave(), stat(), xhdr();+extern int slave(), stat(), listgroup(), xhdr(), doxover(), xthread(); extern int errno; @@ -33,6 +33,9 @@ #ifdef AUTH extern int doauth(); #endif AUTH+#ifdef XOVER+extern int doxover();+#endif static struct cmdent { char *cmd_name;@@ -46,6 +49,7 @@ #endif AUTH "article", 0, ahbs, "body", 0, ahbs,+ "date", 0, dodate, "group", 0, group, "head", 0, ahbs, "help", 0, help,@@ -52,6 +56,9 @@ "ihave", 1, ihave, "last", 0, nextlast, "list", 0, list,+#ifdef LISTGROUP+ "listgroup", 0, listgroup,+#endif LISTGROUP "newgroups", 0, newgroups, "newnews", 0, newnews, "next", 0, nextlast,@@ -61,6 +68,12 @@ #ifdef XHDR "xhdr", 0, xhdr, #endif XHDR+#ifdef XOVER+ "xover", 0, doxover,+#endif+#ifdef XTHREAD+ "xthread", 0, xthread,+#endif }; #define NUMCMDS (sizeof(cmdtbl) / sizeof(struct cmdent)) Index:server/time.c@@ -14,6 +14,28 @@ #include <sys/time.h> #endif not USG +dodate(ac, av)+ int ac;+ char *av[];+{+ struct tm *gmt;+#ifdef USG+ time_t now;++ (void) time(&now);+ gmt = gmtime(&now);+#else /* not USG */+ struct timeval now;++ (void) gettimeofday(&now, (struct timezone *)NULL);+ gmt = gmtime(&now.tv_sec);+#endif /* not USG */+ printf("%d %04.4d%02.2d%02.2d%02.2d%02.2d%02.2d\r\n", INF_DATE,+ gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,+ gmt->tm_hour, gmt->tm_min, gmt->tm_sec);+ (void) fflush(stdout);+}+ /* * dtol -- convert date to long integer. This is not implicitly * local time, or any other kind of time, for that matter. If youIndex:server/xthread.c@@ -0,0 +1,149 @@+/* This file (and only this file - not the entire nntp distribution) is+ * hereby placed in the public domain. Use it as you see fit, but if you+ * manage to find some wonderful use for this code elsewhere, it would be+ * nice to receive mention for it.+ *+ * - Tim Iverson+ * iverson@xstor.com -/- uunet!xstor!iverson+ * 3/28/91+ * modified by Wayne Davison (davison@borland.com) to work with trn 2.0+ * 10/6/91+ */++#include "common.h"++#ifdef XTHREAD++# ifdef __GNUC__+# define alloca __builtin_alloca+# endif++char *thread_name();++/* Usage: XTHREAD [DBINIT|THREAD]+ *+ * DBINIT dump the contents of the db.init file to stdout+ * THREAD dump the contents of the thread file for the current+ * newsgroup to stdout (default if no argument).+ *+ * N.B. These two files are not ascii and no attempt is made at converting+ * native byte size to any type of standard whatsoever. This leaves it+ * up to the receiver (i.e. trn) to translate the data based on db.init.+ *+ * This command is not documented in rfc977.+ */++void+xthread(argc, argv)+int argc;+char *argv[];+{+ register FILE *fp;+ struct stat s;+ char *buf, *file, *what;++ /* can't transfer threads, only read 'em */+ if (!canread)+ {+ printf("%d You only have permission to transfer, sorry.\r\n",+ ERR_ACCESS);+ (void) fflush(stdout);+ return;+ }++ /* "parse" the argument */+ if (argc == 2 && !strcasecmp(argv[1], "dbinit"))+ {+ file = thread_name("*******");+ what = "db.init";+ strcpy(index(file, '*'), what);+ }+ else if (argc == 1 || argc == 2 && !strcasecmp(argv[1], "thread"))+ {+ if (!threadfile)+ {+ printf("%d You are not currently in a newsgroup.\r\n",+ ERR_NCING);+ (void) fflush(stdout);+ return;+ }+ file = threadfile;+ what = "thread";+ }+ else+ {+ printf("%d Usage: XTHREAD [DBINIT|THREAD]\r\n", ERR_CMDSYN);+ (void) fflush(stdout);+ return;+ }++ /* try to open the file to be transfered */+ if (!(fp = fopen(file, "r")))+ {+ printf("%d %s file is not available.\r\n", ERR_FAULT, what);+ (void) fflush(stdout);+#ifdef SYSLOG+ if (!strcmp(what, "db.init"))+ syslog(LOG_ERR, "xthread: fopen %s: %m", file);+#endif+ return;+ }++ /* tell 'em how much binary data is coming down the pike */+ fstat(fileno(fp), &s);+ printf("%d %u bytes of %s file follows verbatim (binary!)\r\n",+ OK_BIN, s.st_size, what);++ /* copy the file verbatim to stdout */+#ifdef __GNUC__+ if (buf = alloca(s.st_size))+ {+ /* ah-so! got lotsa memoree */+ read(fileno(fp), buf, s.st_size);+ fwrite(buf, s.st_size, 1, stdout);+ }+ else+#endif+ {+ int bytes;+ char buf[BUFSIZ];++ while (bytes = fread(buf, 1, sizeof buf, fp))+ fwrite(buf, bytes, 1, stdout);+ }++ fputs("\r\n.\r\n", stdout);+ fflush(stdout);+ fclose(fp);+}++/* Change a newsgroup name into the name of the thread data file. We+** subsitute any '.'s in the group name into '/'s (unless LONG_THREAD_NAMES+** is defined), prepend the path, and append the '/.thread' (or '.th') on to+** the end.+*/+char *+thread_name(group)+char *group;+{+ static char name_buff[MAXPATHLEN];+#ifdef LONG_THREAD_NAMES+ char group_buff[512];+ register char *ptr;++ strcpy(group_buff, group);+ ptr = group = group_buff;+ while ((ptr = index(ptr, '/'))) {+ *ptr = '.';+ }+#endif+#ifdef SUFFIX+ sprintf(name_buff, "%s/%s%s", threaddir, group, SUFFIX);+#else+ sprintf(name_buff, "%s/%s", threaddir, group);+#endif++ return name_buff;+}++#endif /* not XTHREAD */---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -