⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nntp.patch

📁 早期freebsd实现
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
Here's my latest patch to modify NNTP 1.5.11 to support the transmissionof thread databases.  This patch supports both mthread's .thread file format (XTHREAD) and NewsOVerview's .overfile file format (XOVER).  It also adds the LISTGROUPcommand for listing the numbers in a group, and the DATE command forfinding out the time on the server.  Finally, the NEWGROUPS command isfiltered based the user's access privileges.Apply this patch from the root directory of your NNTP source.  While itonly affects your server (the clientlib is no longer modified), it doesmodify things in the common directory.To apply this:	cd nntp-1.5.11	patch -p < xthread.patch  OR	unipatch < xthread.patch | patch -pThis patch changes the conf.h.dist file, so you will need to edit yourconf.h file to add the new defines.  For example, you could:	cd common	diff -c conf.h.dist.orig conf.h.dist | patch conf.hand then edit conf.h to make sure the new stuff is configured properly.Then you are ready to compile the new server with "make server" as usual.Wayne Davison                                        davison@borland.com---8<------8<------8<------8<---cut here--->8------>8------>8------>8---Index:common/version.cPrereq: "1.5.11@@ -2,4 +2,4 @@  * Provide the version number of this release.  */ -char	nntp_version[] = "1.5.11 (10 February 1991)";+char	nntp_version[] = "1.5.11t3 (10 February 1993)";Index:CHANGES@@ -2,6 +2,22 @@ since the initial release.  Individuals who either reported the bug or inspired the bug fix are in square brackets. +1.5.11+XOVER1   (Wayne Davison <davison@borland.com> 18 Jan 93)+	Fixes, optimizations, and enhancements to the first patch.++1.5.11+XOVER0	(Rich $alz <rsalz@uunet.uu.net> 23 dec 92)+	This adds the XOVER command to the server.  The XOVER command+	is used to retrieve data from the .overview file that is part+	of Geoff Collyer's "nov" package (that package is not provided+	here; the official archive for it is+	world.std.com:pub/src/news/nov.dist.tar.Z).  This command+	has the following syntax:+		XOVER [first[-last]]+	Where first and last are article numbers; the default is to+	return data for the current article.  This command is only+	valid after a GROUP command.  It returns a 224 code followed+	by a multi-line response.+ 1.5.11 	Fixes to spawn.c and batch.c for those system that need 	execle() to specifically call /bin/sh to exectute a sh script.Index:common/README@@ -340,6 +340,10 @@ Authorization process. Read the file AUTHORIZATION in the root directory of the NNTP distribution for more information. +XOVER		(defined)+     Defines whether we want to include the XOVER command, described+in the top-level README file of this distribution.+ SERVER_FILE	("/usr/local/lib/rn/server")       This file contains the name of the machine which runs theIndex:common/conf.h.dist@@ -94,6 +94,21 @@ 			/* the server more.  If your server is heavily */ 			/* loaded already, defining this may be a bad idea */ +/* XTHREAD defines:  if XTHREAD is defined, THREAD_DIR controls where the+ * thread files will be read from.+ */+#define XTHREAD		/* Optional XTHREAD command.  This allows trn to+			 * keep all data on the server. */++/* Leave this undefined to indicate that thread files go in the spool+ * directory.  However, if you want a separate hierarchy of thread files,+ * define it here.+ */+/*#define THREAD_DIR	"/usr/spool/threads"		/* base directory */++/* if LONG_THREAD_NAMES & THREAD_DIR are defined, create threads in one dir */+#undef LONG_THREAD_NAMES		/* not for short-name systems */+ /* Things that vary in network implementations */ #define	SUBNET		/* If you have 4.3 subnetting */ #undef	DAMAGED_NETMASK	/* If your subnet mask is not a multiple of */@@ -201,6 +216,10 @@ /* Things that relate to authentication and access */ /* Define AUTH to use the proposed NNTP Version 2 authentication protocol. */ #define	AUTH	++/* Various protocol extensions */+#define XOVER		/* xover -- Return .overview data */+ /*  * A file containing the name of the host which is running  * the news server.  This will have to match what rrn thinks,@@ -332,6 +351,24 @@ #			endif #		endif #	endif+#endif++#ifdef XTHREAD+# ifdef THREAD_DIR+#   ifdef LONG_THREAD_NAMES+#	undef SUFFIX+#   else+#     ifndef SUFFIX+#	define SUFFIX ".th"+#     endif+#   endif+# else+#   define THREAD_DIR	SPOOLDIR+#   ifndef SUFFIX+#     define SUFFIX	"/.thread"+#   endif+#   undef LONG_THREAD_NAMES+# endif #endif  /*Index:common/nntp.h@@ -20,6 +20,7 @@  *	x2x	Article selection  *	x3x	Distribution  *	x4x	Posting+ *	x8x	Authorization  */  #define	CHAR_INF	'1'@@ -29,6 +30,7 @@ #define	CHAR_FATAL	'5'  #define	INF_HELP	100	/* Help text on way */+#define	INF_DATE	111	/* Date */ #define	INF_AUTH	180	/* Authorization capabilities */ #define	INF_DEBUG	199	/* Debug output */ @@ -42,6 +44,7 @@ #define	OK_HEAD		221	/* Head follows */ #define	OK_BODY		222	/* Body follows */ #define	OK_NOTEXT	223	/* No text sent -- stat, next, last */+#define	OK_OVER		224	/* Overview data follows */ #define	OK_NEWNEWS	230	/* New articles by message-id follow */ #define	OK_NEWGROUPS	231	/* New newsgroups follow */ #define	OK_XFERED	235	/* Article transferred successfully */@@ -48,6 +51,7 @@ #define	OK_POSTED	240	/* Article posted successfully */ #define	OK_AUTHSYS	280	/* Authorization system ok */ #define	OK_AUTH		281	/* Authorization (user/pass) ok */+#define	OK_BIN		282	/* binary data follows */  #define	CONT_XFER	335	/* Continue to send article */ #define	CONT_POST	340	/* Continue to post article */Index:server/Makefile@@ -6,13 +6,13 @@ 	ahbs.o globals.o group.o help.o ihave.o list.o misc.o netaux.o \ 	newgroups.o newnews.o nextlast.o ngmatch.o post.o parsit.o scandir.o \ 	slave.o spawn.o strcasecmp.o subnet.o time.o xhdr.o fakesyslog.o \-	batch.o auth.o timer.o ../common/version.o+	batch.o auth.o timer.o xthread.o ../common/version.o  SRVRSRC = main.c serve.c access.c access_inet.c access_dnet.c active.c \ 	ahbs.c globals.c group.c help.c ihave.c list.c misc.c netaux.c \ 	newgroups.c newnews.c nextlast.c ngmatch.c post.c parsit.c scandir.c \ 	slave.c spawn.c strcasecmp.c subnet.c time.c xhdr.c fakesyslog.c \-	batch.c auth.c timer.c ../common/version.c+	batch.c auth.c timer.c xthread.c ../common/version.c  SRVRINC = common.h ../common/conf.h ../common/nntp.h timer.h Index:server/ahbs.c@@ -56,8 +56,9 @@ 			(void) fclose(fp); 			return; 		}-		printf("%d 0 %s Article retrieved, %s.\r\n",-			OK_ARTICLE + method, argv[1], verbiage[method]);+		printf("%d %ld %s Article retrieved, %s.\r\n",+			OK_ARTICLE + method, group_artnum, argv[1],+			verbiage[method]); 		spew(fp, method); 		(void) fclose(fp); #ifdef LOGIndex:server/batch.c@@ -461,7 +461,7 @@ #ifdef POSTER 	sprintf(user, "USER=%s", POSTER); 	sprintf(logname, "LOGNAME=%s", POSTER);-	if ((home = (char *)malloc(strlen(home_poster)+5)) != NULL)+	if ((home = (char *)malloc(strlen(home_poster)+5+1)) != NULL) 		sprintf(home, "HOME=%s", home_poster); 	envp[0] = user; 	envp[1] = logname;Index:server/common.h@@ -164,11 +164,18 @@ extern	char	inews[]; extern	char	rnews[]; +#ifdef	XTHREAD+extern	char	*threaddir;+extern	char	*threadfile;+#endif+ extern	char	**group_array; extern	char	*actbuf; extern	int	num_groups; extern	char	*homedir; extern	int	ingroup;+extern	char	*group_name;+extern	long	group_artnum; extern	int	maxgroups; #ifdef DYNAMIC_ART_ARRAY extern	int	*art_array;Index:server/globals.c@@ -26,6 +26,11 @@ char	inews[] = INEWS; char	rnews[] = RNEWS; +#ifdef	XTHREAD+char	*threaddir = THREAD_DIR;+char	*threadfile = NULL;+#endif+ /*  * Other random externals.  */@@ -34,6 +39,8 @@ char 	*actbuf; int	num_groups; int	ingroup = 0;+char	*group_name = NULL;+long	group_artnum = 0; int	art_ptr; int	num_arts; #ifdef DYNAMIC_ART_ARRAYIndex:server/group.c@@ -4,6 +4,12 @@  #include "common.h" +#ifdef	XTHREAD+extern char *thread_name();+#endif++extern char *malloc();+ /*  * GROUP newsgroup  *@@ -67,8 +73,15 @@ 		return; 	} +#ifdef XOVER+	close_xover();+#endif 	close_crnt();+	if (group_name)+		free(group_name); 	(void) chdir(spooldir);+	if ((group_name = malloc(strlen(argv[1])+1)) != NULL)+		strcpy(group_name, argv[1]);  #ifdef LOG 	syslog(LOG_INFO, "%s group %s", hostname, argv[1]);@@ -97,6 +110,10 @@  	ingroup = 1; +#ifdef	XTHREAD+	threadfile = thread_name(argv[1]);+#endif+ 	while ((cp = index(argv[1], '/')) != (char *) NULL) 		*cp = '.'; @@ -108,3 +125,177 @@ 		argv[1]); 	(void) fflush(stdout); }+++#ifdef XOVER+static FILE *xover_fp;+static int xover_num;++doxover(argc, argv)+	int		argc;+	char		*argv[];+{+	register FILE	*fp;+	register int	c, first, last;+	int		artnum, artp;+	char		*p;++	if (!canread) {+		printf("%d You only have permission to transfer, sorry.\r\n",+			ERR_ACCESS);+		(void) fflush(stdout);+		return;+	}++	if (!ingroup) {+		printf("%d You are not currently in a newsgroup.\r\n",+			ERR_NCING);+		(void) fflush(stdout);+		return;+	}+	if (argc != 1 && argc != 2) {+		printf("%d Usage: XOVER [first[-last]].\r\n", ERR_CMDSYN);+		(void) fflush(stdout);+		return;+	}++	if (xover_fp)+		fp = xover_fp;+	else {+		fp = xover_fp = fopen(".overview", "r");+		if (fp == NULL) {+			printf("%d No overview available.\r\n", ERR_FAULT);+			(void) fflush(stdout);+#ifdef SYSLOG+			syslog(LOG_ERR, "xover: fopen %s: %m", ".overview");+#endif+			return;+		}+		xover_num = 0;+	}++	if (argc == 1) {+		if (art_ptr < 0 || art_ptr >= num_arts) {+			printf("%d No article is currently selected.\r\n",+				ERR_NOCRNT);+			(void) fflush(stdout);+			return;+		}+		first = last = art_array[art_ptr];+	} else {+		p = index(argv[1], '-');+		if (p == NULL)+			first = last = atoi(argv[1]);+		else {+			*p++ = '\0';+			first = atoi(argv[1]);+			last = atoi(p);+		}+		if (first < 1)+		    first = 1;+		if (last > art_array[num_arts-1])+		    last = art_array[num_arts-1];+	}+	/* Return the desired data.  This is written carefully to avoid+	 * over-long lines. */+	printf("%d overview data follows\r\n", OK_OVER);+	if (first < xover_num || !xover_num) {+		fseek(fp, 0L, 0);+		xover_num = 0;+	}+	if (xover_num) {+		artnum = xover_num;+		xover_num = 0;+	} else+		fscanf(fp, "%d", &artnum);+	artp = 0;+	while (!feof(fp)) {+		if (artnum > last) {+			xover_num = artnum;+			break;+		}+		while (art_array[artp] < artnum)+		    artp++;+		if (artnum >= first && artnum == art_array[artp]) {+			printf("%d", artnum);+			while ((c = getc(fp)) != EOF && c != '\n')+				putchar(c);+			printf("\r\n");+		} else+			while ((c = getc(fp)) != EOF && c != '\n')+				continue;+		fscanf(fp, "%d", &artnum);+	}+	printf(".\r\n");+	(void) fflush(stdout);+}++close_xover()+{+	if (xover_fp) {+		fclose(xover_fp);+		xover_fp = NULL;+	}+}+#endif++#ifdef LISTGROUP+/*+ * LISTGROUP [group]+ *+ * Lists all article numbers (filenames) in the given group. Used by+ * newsreaders such as nn and trn for fast validation of a database.+ * If a group name is given it becomes the current group.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -