diff src/noffle.c @ 482:a04c52f87b6e noffle

[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.
author bears
date Thu, 14 Oct 2004 00:26:48 +0100
parents 48be71391b9d
children
line wrap: on
line diff
--- 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 <grp>      Add group to fetch list (full)\n"
       " -t | --subscribe-thread <grp>    Add group to fetch list (thread)\n"
       " -u | --unsubscribe <grp>         Remove group from fetch list\n"
+      " -U | --uninteresting <msg id>    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;