[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] call for help: Managing leafnode's future -



On 16 Mar 2001, Matthias Andree wrote:
> Chris Gray <cgray@xxxxxxxxxxxx> writes:
> 
>> I've got dibs on this.  In fact I've already done it.  I sent a
>> patch to someone, but it was quite a while ago and I haven't heard
>> anything back.  I will port it to the current version and send my
>> patch to the list, I guess.
> 
> That's a good idea.
> 
Here is the patch.  It compiles and I'll be testing it momentarily (it
works with 1.9.17).  The only thing to watch out for is that I'm not
quite sure where to put the freedelaygroup() calls.  I suppose that it
should be anywhere that readconfig() is called, but for right now I
only have it at the end of fetchnews and nntpd.

Cheers,
Chris



diff -urN leafnode-1.9.18/config.example leafnode-1.9.18.new/config.example
--- leafnode-1.9.18/config.example	Thu Nov 30 13:08:31 2000
+++ leafnode-1.9.18.new/config.example	Mon Mar 19 11:23:37 2001
@@ -63,6 +63,10 @@
 ## a fault of Leafnode).
 # delaybody = 0
 
+## If you just want to delay the bodies of certain groups, use this setting
+## (glob(7) wildcard constructs possible)
+# groupdelaybody alt.binaries.* = 1
+
 ## To avoid spam, you can select the maximum number of crosspostings
 ## that are allowed in incoming postings. Setting this below 5 is
 ## probably a bad idea. The default is unlimited crossposting.
diff -urN leafnode-1.9.18/configutil.c leafnode-1.9.18.new/configutil.c
--- leafnode-1.9.18/configutil.c	Thu Nov 30 13:08:30 2000
+++ leafnode-1.9.18.new/configutil.c	Mon Mar 19 10:58:22 2001
@@ -38,6 +38,7 @@
  */
 time_t expire = 0;
 struct expire_entry * expire_base;
+struct delay_entry * delay_base;
 int artlimit = 0;
 int initiallimit = 0;
 int crosspostlimit = 0;
@@ -108,6 +109,7 @@
     struct serverlist *p = 0, *q = 0;
     struct rlimit corelimit ;
     struct expire_entry *ent = NULL, *prev = NULL;
+    struct delay_entry *d_ent = NULL;
     FILE * f;
     char * l;
     char * param, * value ;
@@ -238,6 +240,25 @@
 		if ( debugmode )
 		    syslog( LOG_DEBUG, "config: timeout_active is %d days",
 			    timeout_active );
+	    }
+	    else if ( strncmp( "groupdelaybody", param, 14 ) == 0 ) {
+		    char * m;
+		    d_ent = malloc(sizeof(struct delay_entry));
+		    memset(d_ent, 0, sizeof(struct delay_entry));
+		    m = param;
+		    while ( !(isspace((unsigned char)*m)) )
+			    m++;
+		    while ( isspace((unsigned char)*m) )
+			    m++;
+		    if ( m && *m ) {
+			    d_ent->group = strdup(m);
+			    d_ent->next = delay_base;
+			    delay_base = d_ent;
+			    if ( debugmode )
+				    syslog( LOG_DEBUG,
+					    "config: groupdelaybody for %s",
+					    m );
+		    }
 	    }
 	    else if ( strncmp( "groupexpire", param, 11 ) == 0 ) {
 		char * m;
diff -urN leafnode-1.9.18/fetchnews.c leafnode-1.9.18.new/fetchnews.c
--- leafnode-1.9.18/fetchnews.c	Thu Nov 30 13:08:30 2000
+++ leafnode-1.9.18.new/fetchnews.c	Mon Mar 19 11:44:08 2001
@@ -67,6 +67,8 @@
 int getgroup ( struct newsgroup *g , int server );
 int postarticles( void );
 void fixxover( void );
+int isdelaygroup(char *groupname);
+void freedelaygroup(void);
 
 
 static void tabstospaces(char *s) {
@@ -79,7 +81,6 @@
 
 }
 
-
 #ifdef NOTYET
 static void _ignore_answer( FILE * f ) {
     char * l;
@@ -443,7 +444,7 @@
     unlink( c );	/* make space for new file */
     
     if ( ! ( f = fopen( c, "w" ) ) ) {
-	syslog( LOG_ERR, "%s: cannot open %s for writing", group->name, l );
+	syslog( LOG_ERR, "%s: cannot open %s for writing", group->name, c );
 	link( s, c );	/* if we can't open new file restore old one */
 	return 0;
     }
@@ -1011,7 +1012,8 @@
 				 *hd[6] ? hd[6]+strlen(hnames[6]) : "", 
 				 *hd[7] ? hd[7]+strlen(hnames[7]) : "");
 
-	if ( delaybody ) {
+	g->delaybody = isdelaygroup(g->name);
+	if ( delaybody || g->delaybody ) {
 	    fclose( f );
 	    fetched++;
 	    continue;
@@ -1407,7 +1409,8 @@
 	    if ( g != NULL ) {
 		sprintf( s, "%s ", g->name );
 		l = havefile ? findinlist( ngs, s ) : NULL;
-		if ( delaybody && ( headerbody == 2 ) )
+		g->delaybody = isdelaygroup(g->name);
+		if ( (delaybody || g->delaybody) && ( headerbody == 2 ) )
 		    ;	/* get only bodies, so skip this */
 		else if ( l && *l ) {
 		    l = strchr( l, ' ' );
@@ -1415,7 +1418,7 @@
 		}
 		else
 		    newserver = getgroup( g, 1 );
-		if ( delaybody && ( headerbody != 1 ) )
+		if ( (delaybody || g->delaybody) && ( headerbody != 1 ) )
 		    getmarked( g );
 		if ( f != NULL )
                     fprintf( f, "%s %d\n", g->name, newserver );
@@ -1663,6 +1666,7 @@
 	}
 	default: break;
     }
+    freedelaygroup();
 
     exit(0);
 }
diff -urN leafnode-1.9.18/leafnode.h leafnode-1.9.18.new/leafnode.h
--- leafnode-1.9.18/leafnode.h	Thu Nov 30 13:08:30 2000
+++ leafnode-1.9.18.new/leafnode.h	Mon Mar 19 11:44:47 2001
@@ -82,6 +82,7 @@
     char * name;
     char * desc;
     time_t age;
+    char delaybody;  /* decide to delay the body on a per-newsgroup basis */
 };
 
 int isinteresting( const char * groupname );
@@ -93,6 +94,8 @@
 void readactive( void );
 void writeactive( void );
 void fakeactive( void );
+int isdelaygroup( char *groupname );
+void freedelaygroup( void );
 
 extern struct newsgroup * active;
 
@@ -183,6 +186,11 @@
     char * group;
 };
 
+struct delay_entry {
+    char * group;
+    struct delay_entry *next;
+};
+
 struct serverlist {
     int port ;
     int descriptions ;		/* download descriptions as well */
@@ -196,6 +204,7 @@
 extern time_t expire;	/* articles not touched since this time get deleted */
 extern struct expire_entry * expire_base;
 			/* expire for certain groups */
+extern struct delay_entry * delay_base;
 extern int artlimit;	/* max # of articles to read per group in one go */
 extern int initiallimit;
 			/* max # of articles to read at first time */
diff -urN leafnode-1.9.18/miscutil.c leafnode-1.9.18.new/miscutil.c
--- leafnode-1.9.18/miscutil.c	Thu Nov 30 13:08:30 2000
+++ leafnode-1.9.18.new/miscutil.c	Mon Mar 19 11:47:25 2001
@@ -180,6 +180,29 @@
     return FALSE;
 }
 
+
+int isdelaygroup(char *groupname)
+{
+	struct delay_entry *ent = delay_base;
+	while(ent != NULL){
+		if(!ngmatch(ent->group, groupname))
+			return 1;
+		ent = ent->next;
+	}
+	return 0;
+}
+
+void freedelaygroup(void)
+{
+	struct delay_entry *ent;
+	while(delay_base != NULL){
+		ent = delay_base;
+		free(ent->group);
+		delay_base = delay_base->next;
+		free(ent);
+	}
+}
+
 /* no good but this server isn't going to be scalable so shut up */
 const char * lookup ( const char *msgid ) {
     static char * name = NULL;
diff -urN leafnode-1.9.18/nntpd.c leafnode-1.9.18.new/nntpd.c
--- leafnode-1.9.18/nntpd.c	Thu Nov 30 13:08:30 2000
+++ leafnode-1.9.18.new/nntpd.c	Mon Mar 19 11:45:19 2001
@@ -509,7 +509,8 @@
 	printf("\r\n"); /* empty separator line */
 
     if ( what & 1 ) {
-	if ( delaybody && *s != '\n' ) {
+	group->delaybody = isdelaygroup(group->name);
+	if ( (group->delaybody || delaybody) && *s != '\n' ) {
 	    if ( ! markdownload( localartno ) ) {
 		printf( "\r\n\r\n"
 			"\t[ Leafnode: ]\r\n"
@@ -1479,6 +1480,7 @@
     if ( nntpout )
 	fprintf( nntpout, "QUIT\r\n" );
 */
+    freedelaygroup();
 
     exit(0);
 }



-- 
Got jag?  http://www.tribsoft.com