diff src/database.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 994e9ab2c24f
children
line wrap: on
line diff
--- 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;
+}
+