changeset 124:cfad9678e286 noffle

[svn] Applied patch from M.Nalis: Modify Req_add() to append to requested/news.serv.er file each MsgID (and do not clean dirty flag, because otherwise writeRequestfile() would nuke us when overwriting file!).
author enz
date Sat, 22 Jul 2000 10:04:20 +0100
parents ec190bad201b
children dfa34d15f2d0
files ChangeLog src/request.c
diffstat 2 files changed, 41 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jul 22 07:21:11 2000 +0100
+++ b/ChangeLog	Sat Jul 22 10:04:20 2000 +0100
@@ -2,6 +2,13 @@
 NOFFLE ChangeLog
 -------------------------------------------------------------------------------
 
+Sat Jul 22 2000 Markus Enzenberger <markus.enzenberger@t-online.de> 
+
+ * request.c: Applied patch from M.Nalis:
+   Modify Req_add() to append to requested/news.serv.er file each MsgID (and
+   do not clean dirty flag, because otherwise writeRequestfile() would nuke us
+   when overwriting file!).
+
 Wed Jul 19 2000 Markus Enzenberger <markus.enzenberger@t-online.de>
 
  * Applied patch from M.Nalis for fixing a small problem with
--- a/src/request.c	Sat Jul 22 07:21:11 2000 +0100
+++ b/src/request.c	Sat Jul 22 10:04:20 2000 +0100
@@ -3,7 +3,7 @@
 
   Collection of articles that are marked for download.
 
-  $Id: request.c 60 2000-05-09 22:28:38Z uh1763 $
+  $Id: request.c 178 2000-07-22 09:04:20Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -65,7 +65,7 @@
 static Bool     getReqserv      (const char* serv, Reqserv** rsz);
 static void     fileRequest     (Str file, const char *serv);
 static char**   searchMsgId     (const Reqserv * rs, const char *msgId);
-static void     storeMsgId      (Reqserv* rs, const char* msgId);
+static Bool     storeMsgId      (Reqserv* rs, const char* msgId);
 static Bool     readRequestfile (const char* serv, Reqserv** rsz);
 static time_t   get_mtime       (const char* serv);
 
@@ -178,13 +178,13 @@
 }
 
 
-static void storeMsgId(Reqserv* rs, const char* msgId)
+static Bool storeMsgId(Reqserv* rs, const char* msgId)
 {
   char* msgid;
 
   if (searchMsgId(rs, msgId))
     /* already recorded */
-    return;
+    return FALSE;
 
   msgid = strcpy(malloc(strlen(msgId)+1), msgId);
 
@@ -196,6 +196,34 @@
 
   *(rs->reql + rs->reql_length++) = msgid;
   rs->dirty = TRUE;
+  return TRUE;
+}
+
+static Bool
+appRequest (Reqserv* rs, const char *msgId)
+{
+    Str filename;
+    FILE*  file;
+
+    fileRequest(filename, rs->serv);
+    Log_dbg("appending to request file %s", filename);
+
+    if (Log_check((file = fopen(filename, "a")) != 0,
+            "could not open %s for appending: %s", 
+            filename, strerror(errno)))
+      return FALSE;
+    
+    if (Log_check(    fputs(msgId, file) != EOF
+                  &&  fputs("\n", file) != EOF,
+                  "write error: %s", strerror(errno)))
+      return FALSE;
+
+    if (Log_check(fclose(file) != EOF, 
+                "could not close %s properly: %s\n", 
+                filename, strerror(errno)))
+      return FALSE;
+
+    return TRUE;
 }
 
 
@@ -210,8 +238,9 @@
 
     if (getReqserv(serv, &rs) == FALSE) 
       return FALSE;
-    storeMsgId(rs, msgId);
+    if (storeMsgId(rs, msgId) == FALSE) /* already recorded */
     return TRUE;
+    return appRequest(rs, msgId);
 }
 
 static Bool