[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] Downloading only some groups from a slow server
For those interested, patch files are attached bellow.
This patch does one more thing:
- keeps at the end of the file(s) <news-server> pointers (if any) on groups
already acceded but not currently selected. I think (?) this should speed up
e.g. if you change your selected groups in interesting.groups directory.
A blank line will separate those groups for visibility.
Two files are modified: fetchnews.c and miscutil.c
- miscutil.c : findinlist function (only used once)
- fetchnews.c : processupstream function
This patch works for 1.9.13 and 1.9.14.
Do "make" and copy only the new "fetchnews" program in proper place.
(after a strip)
Hope there is no bug :-/
--
no news !... good news ?...
*** fetchnews.c Sun Apr 9 14:05:11 2000
--- fetchnews.c.new Wed May 24 23:03:56 2000
***************
*** 1348,1354 ****
struct newsgroup * g;
int havefile;
int newserver = 0;
! char * l;
char * oldfile ;
struct stringlist * ngs = NULL, * a, *b = NULL;
--- 1348,1355 ----
struct newsgroup * g;
int havefile;
int newserver = 0;
! int flag;
! char * l, * ll;
char * oldfile ;
struct stringlist * ngs = NULL, * a, *b = NULL;
***************
*** 1364,1370 ****
if ( verbose > 1 )
printf( "Read server info from %s\n", s );
syslog( LOG_INFO, "Read server info from %s", s );
! while ( ( ( l = getaline( f ) ) != NULL ) && ( strlen(l) ) ) {
a = (struct stringlist *)critmalloc( sizeof(struct stringlist)
+ strlen(l), "Reading server info" );
strcpy( a->string, l );
--- 1365,1372 ----
if ( verbose > 1 )
printf( "Read server info from %s\n", s );
syslog( LOG_INFO, "Read server info from %s", s );
! while ( ( l = getaline( f ) ) != NULL ) {
! if ( strlen(l) ) {
a = (struct stringlist *)critmalloc( sizeof(struct stringlist)
+ strlen(l), "Reading server info" );
strcpy( a->string, l );
***************
*** 1374,1379 ****
--- 1376,1382 ----
else
b->next = a;
b = a;
+ }
}
havefile = 1;
debug = debugmode;
***************
*** 1396,1416 ****
}
while ( (de=readdir(d)) ) {
if ( isalnum((unsigned char)*(de->d_name)) ) {
g = findgroup( de->d_name );
if ( g != NULL ) {
! sprintf( s, "%s ", g->name );
l = havefile ? findinlist( ngs, s ) : NULL;
if ( delaybody && ( headerbody == 2 ) )
; /* get only bodies, so skip this */
else if ( l && *l ) {
! l = strchr( l, ' ' );
! newserver = getgroup( g, strtol( l, NULL, 10 ) );
}
else
newserver = getgroup( g, 1 );
if ( delaybody && ( headerbody != 1 ) )
getmarked( g );
! if ( f != NULL )
fprintf( f, "%s %d\n", g->name, newserver );
} else {
printf( "%s not found in groupinfo file\n", de->d_name );
--- 1399,1432 ----
}
while ( (de=readdir(d)) ) {
if ( isalnum((unsigned char)*(de->d_name)) ) {
+ flag = 1;
g = findgroup( de->d_name );
if ( g != NULL ) {
! sprintf( s, "%s ", g->name ); /* name + space! */
l = havefile ? findinlist( ngs, s ) : NULL;
if ( delaybody && ( headerbody == 2 ) )
; /* get only bodies, so skip this */
else if ( l && *l ) {
! if (l[0] == '!' ) {
! /* a ! before the group's name enables to skip over */
! flag = 0;
! syslog( LOG_INFO,
! "Don't fetch <%s> on server <%s>", g->name, server );
! if ( verbose > 1 )
! printf( "Don't fetch <%s> on server <%s>\n",
! g->name, server );
! fprintf( f, "%s\n", l ); /* write unmodified record */
! } else {
! ll = strchr( l, ' ' );
! newserver = getgroup( g, strtol( ll, NULL, 10 ) );
! }
! l[0] = ' '; /* mark group as checked */
}
else
newserver = getgroup( g, 1 );
if ( delaybody && ( headerbody != 1 ) )
getmarked( g );
! if ( f != NULL && flag)
fprintf( f, "%s %d\n", g->name, newserver );
} else {
printf( "%s not found in groupinfo file\n", de->d_name );
***************
*** 1421,1427 ****
}
closedir( d );
if ( f != NULL ) {
! fclose(f);
sprintf( s, "%s/leaf.node/%s~", spooldir, server );
rename( s, oldfile );
}
--- 1437,1450 ----
}
closedir( d );
if ( f != NULL ) {
! /* append already stored but unread groups pointers */
! a = ngs;
! fprintf( f, "\n" );
! while (a && a->string ) {
! if (a->string[0] != ' ') fprintf( f, "%s\n", a->string );
! a = a->next;
! }
! fclose(f);
sprintf( s, "%s/leaf.node/%s~", spooldir, server );
rename( s, oldfile );
}
*** miscutil.c Sun Apr 9 14:05:11 2000
--- miscutil.c.new Wed May 24 18:15:21 2000
***************
*** 365,372 ****
a = haystack;
while ( a && a->string ) {
! if ( strncmp( needle, a->string, strlen(needle) ) == 0 )
! return a->string;
a = a->next;
}
return NULL;
--- 365,375 ----
a = haystack;
while ( a && a->string ) {
! if ( a->string[0] == '!' &&
! strncmp( needle, &((a->string)[1]), strlen(needle) ) == 0 )
! return a->string;
! else if ( strncmp( needle, a->string, strlen(needle) ) == 0 )
! return a->string;
a = a->next;
}
return NULL;