diff src/server.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 466b42bb776e
children a02417000b7b
line wrap: on
line diff
--- 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 ) );