# HG changeset patch # User bears # Date 1097710008 -3600 # Node ID a04c52f87b6eb4022893ac82a84678d3199e5e7d # Parent 0a5dc5f697461e5f91b8f951bb17572724b4b401 [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c: Add new '-U, --uninteresting' option. This removes an article from the list of requested articles and removes its INTERESTING marker. diff -r 0a5dc5f69746 -r a04c52f87b6e ChangeLog --- a/ChangeLog Wed Oct 13 22:59:41 2004 +0100 +++ b/ChangeLog Thu Oct 14 00:26:48 2004 +0100 @@ -2,6 +2,9 @@ * docs/FAQ: Improve X-NOFFLE-Status entry. * src/filter.c: Log filter matches when log category filter is selected. +* docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c: + Add new '-U, --uninteresting' option. This removes an article from the + list of requested articles and removes its INTERESTING marker. Wed Sep 29 2004 Jim Hague diff -r 0a5dc5f69746 -r a04c52f87b6e docs/noffle.1 --- a/docs/noffle.1 Wed Oct 13 22:59:41 2004 +0100 +++ b/docs/noffle.1 Thu Oct 14 00:26:48 2004 +0100 @@ -1,5 +1,5 @@ .TH noffle 1 -.\" $Id: noffle.1 624 2004-07-09 15:27:20Z bears $ +.\" $Id: noffle.1 629 2004-10-13 23:26:48Z bears $ .SH NAME noffle \- Usenet package optimized for dialup connections. @@ -76,6 +76,10 @@ .br .B noffle \-u | \-\-unsubscribe +.B noffle +\-U | \-\-uninteresting +.B noffle +\-v | \-\-version .SH DESCRIPTION @@ -383,6 +387,13 @@ This option is only available to news administrators. .TP +.B \-U, \-\-uninteresting +Remove the article from the list of articles to be fetched from the +server and mark the article as not to be fetched unless read again. +.br +This option is only available to news administrators. + +.TP .B \-v, \-\-version Reports the .B NOFFLE diff -r 0a5dc5f69746 -r a04c52f87b6e src/database.c --- a/src/database.c Wed Oct 13 22:59:41 2004 +0100 +++ b/src/database.c Thu Oct 14 00:26:48 2004 +0100 @@ -1,7 +1,7 @@ /* database.c - $Id: database.c 433 2003-02-13 10:04:01Z bears $ + $Id: database.c 629 2004-10-13 23:26:48Z bears $ Uses GNU gdbm library. Using Berkeley db (included in libc6) was cumbersome. It is based on Berkeley db 1.85, which has severe bugs @@ -772,3 +772,36 @@ return newClose( ! err ); } +/* Utility function. Find the upstream server for a particular message. */ +Bool +Db_findServer( const char *msgId, Str server ) +{ + const char *p, *pColon, *srv; + Str s, grp; + Bool res = FALSE; + + if ( Db_contains( msgId ) ) + { + Utl_cpyStr( s, Db_xref( msgId ) ); + p = strtok( s, " \t" ); + if ( p ) + do + { + pColon = strstr( p, ":" ); + if ( pColon ) + { + Utl_cpyStrN( grp, p, pColon - p ); + srv = Grp_server( grp ); + if ( Cfg_servIsPreferential( srv, server ) ) + { + Utl_cpyStr( server, srv ); + res = TRUE; + } + } + } + while ( ( p = strtok( NULL, " \t" ) ) ); + } + + return res; +} + diff -r 0a5dc5f69746 -r a04c52f87b6e src/database.h --- a/src/database.h Wed Oct 13 22:59:41 2004 +0100 +++ b/src/database.h Thu Oct 14 00:26:48 2004 +0100 @@ -3,7 +3,7 @@ Article database. - $Id: database.h 403 2002-11-10 11:32:17Z bears $ + $Id: database.h 629 2004-10-13 23:26:48Z bears $ */ #ifndef DB_H @@ -115,4 +115,8 @@ Bool Db_rebuild( void ); +/* Utility function - find the upstream server for a particular message */ +Bool +Db_findServer( const char *msgId, Str server ); + #endif diff -r 0a5dc5f69746 -r a04c52f87b6e src/noffle.c --- a/src/noffle.c Wed Oct 13 22:59:41 2004 +0100 +++ b/src/noffle.c Thu Oct 14 00:26:48 2004 +0100 @@ -10,7 +10,7 @@ received for some seconds (to allow multiple clients connect at the same time). - $Id: noffle.c 624 2004-07-09 15:27:20Z bears $ + $Id: noffle.c 629 2004-10-13 23:26:48Z bears $ */ #if HAVE_CONFIG_H @@ -574,6 +574,29 @@ } static void +doUninteresting( const char *msgId ) +{ + unsigned status; + Str server; + + if ( ! Db_contains( msgId ) ) + fprintf( stderr, "Not in database.\n" ); + else + { + /* Remove INTERESTING status */ + status = Db_status( msgId ); + status &= ~DB_INTERESTING; + Db_setStatus( msgId, status ); + + /* And remove from requested articles queue if server is not local */ + if ( ! Db_findServer( msgId, server ) ) + Log_err( "No server for message %s", msgId ); + else if ( strcmp( server, GRP_LOCAL_SERVER_NAME ) != 0 ) + Req_remove( server, msgId ); + } +} + +static void printUsage( void ) { static const char *msg = @@ -604,6 +627,7 @@ " -S | --subscribe-full Add group to fetch list (full)\n" " -t | --subscribe-thread Add group to fetch list (thread)\n" " -u | --unsubscribe Remove group from fetch list\n" + " -U | --uninteresting Article must be read again for download\n" " -v | --version Print version\n"; fprintf( stderr, "%s", msg ); } @@ -869,6 +893,7 @@ { "--subscribe-over", "-s" }, { "--subscribe-full", "-S" }, { "--subscribe-thread", "-t" }, + { "--uninteresting", "-U" }, { "--unsubscribe", "-u" }, { "--version", "-v" }, { NULL, NULL } @@ -1128,6 +1153,15 @@ else doUnsubscribe( *argv ); break; + case 'U': + if ( *argv == NULL ) + { + fprintf( stderr, "Option -U needs argument.\n" ); + result = EXIT_FAILURE; + } + else + doUninteresting( *argv ); + break; case '?': /* Error message already printed by getopt_long */ result = EXIT_FAILURE; diff -r 0a5dc5f69746 -r a04c52f87b6e src/server.c --- a/src/server.c Wed Oct 13 22:59:41 2004 +0100 +++ b/src/server.c Thu Oct 14 00:26:48 2004 +0100 @@ -1,7 +1,7 @@ /* server.c - $Id: server.c 566 2003-06-20 10:46:06Z bears $ + $Id: server.c 629 2004-10-13 23:26:48Z bears $ */ #if HAVE_CONFIG_H @@ -417,42 +417,15 @@ return TRUE; } -static void -findServer( const char *msgId, Str result ) -{ - const char *p, *pColon, *srv; - Str s, grp; - - Utl_cpyStr( result, "(unknown)" ); - if ( Db_contains( msgId ) ) - { - Utl_cpyStr( s, Db_xref( msgId ) ); - p = strtok( s, " \t" ); - if ( p ) - do - { - pColon = strstr( p, ":" ); - if ( pColon ) - { - Utl_cpyStrN( grp, p, pColon - p ); - srv = Grp_server( grp ); - if ( Cfg_servIsPreferential( srv, result ) ) - Utl_cpyStr( result, srv ); - } - } - while ( ( p = strtok( NULL, " \t" ) ) ); - } -} - static Bool retrieveArt( const char *msgId ) { Str s; int stat; + Bool foundServer; - findServer( msgId, s ); - if ( strcmp( s, "(unknown)" ) == 0 - || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 ) + foundServer = Db_findServer( msgId, s ); + if ( ! foundServer || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 ) return FALSE; if ( ! Client_connect( s ) ) { @@ -582,6 +555,7 @@ { unsigned status; Str srv; + Bool foundServer; status = Db_status( msgId ); if ( status & DB_RETRIEVING_FAILED ) @@ -591,15 +565,23 @@ } else if ( status & DB_NOT_DOWNLOADED ) { - findServer( msgId, srv ); if ( Req_contains( srv, msgId ) ) + { putTxtBuf( Pseudo_alreadyMarkedBody() ); - else if ( strcmp( srv, "(unknown)" ) != 0 && - strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 && - Req_add( srv, msgId ) ) - putTxtBuf( Pseudo_markedBody() ); - else - putTxtBuf( Pseudo_markingFailedBody() ); + } + else + { + foundServer = Db_findServer( msgId, srv ); + if ( ! foundServer && strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 ) + { + Log_err( "Can't find server for message %s", msgId ); + putTxtBuf ( Pseudo_markingFailedBody() ); + } + else if ( Req_add( srv, msgId ) ) + putTxtBuf( Pseudo_markedBody() ); + else + putTxtBuf( Pseudo_markingFailedBody() ); + } } else putTxtBuf( Db_body( msgId ) );