]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
Networker reordering; remove / change dependencies
[citadel.git] / citadel / msgbase.c
index a02f7cd242beb94422e36f3019ec9f452c98f8c9..db65460a2a5ef8cf8231e7e7171b270ce591395b 100644 (file)
@@ -64,7 +64,6 @@
 #include "journaling.h"
 #include "citadel_dirs.h"
 #include "clientsocket.h"
-#include "serv_network.h"
 #include "threads.h"
 
 #include "ctdl_module.h"
@@ -75,13 +74,6 @@ struct addresses_to_be_filed *atbf = NULL;
 /* This temp file holds the queue of operations for AdjRefCount() */
 static FILE *arcfp = NULL;
 
-/* 
- * This really belongs in serv_network.c, but I don't know how to export
- * symbols between modules.
- */
-struct FilterList *filterlist = NULL;
-
-
 /*
  * These are the four-character field headers we use when outputting
  * messages in Citadel format (as opposed to RFC822 format).
@@ -1106,6 +1098,10 @@ void mime_download(char *name, char *filename, char *partnum, char *disp,
                        return;
        
                rv = fwrite(content, length, 1, CC->download_fp);
+               if (rv == -1) {
+                       syslog(LOG_EMERG, "mime_download(): Couldn't write: %s\n",
+                              strerror(errno));
+               }
                fflush(CC->download_fp);
                rewind(CC->download_fp);
        
@@ -2068,7 +2064,6 @@ void Dump_RFC822HeadersBody(
        int outlen = 0;
        int nllen = strlen(nl);
        char *mptr;
-       int rc;
 
        mptr = TheMessage->cm_fields['M'];
 
@@ -2128,7 +2123,7 @@ void Dump_RFC822HeadersBody(
                }
        }
        if (outlen > 0) {
-               rc = client_write(outbuf, outlen);
+               client_write(outbuf, outlen);
                outlen = 0;
        }
 }
@@ -2934,7 +2929,6 @@ void serialize_message(struct ser_ret *ret,               /* return values */
 void dump_message(struct CtdlMessage *msg,     /* unserialized msg */
                  long Siz)                     /* how many chars ? */
 {
-       size_t wlen;
        int i;
        static char *forder = FORDER;
        char *buf;
@@ -2949,8 +2943,6 @@ void dump_message(struct CtdlMessage *msg,        /* unserialized msg */
 
        buf = (char*) malloc (Siz + 1);
 
-       wlen = 3;
-       
        for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) {
                        snprintf (buf, Siz, " msg[%c] = %s ...\n", (char) forder[i], 
                                   msg->cm_fields[(int)forder[i]]);
@@ -3308,6 +3300,10 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
                        network_fp = fopen(submit_filename, "wb+");
                        if (network_fp != NULL) {
                                rv = fwrite(smr.ser, smr.len, 1, network_fp);
+                               if (rv == -1) {
+                                       syslog(LOG_EMERG, "CtdlSubmitMsg(): Couldn't write network spool file: %s\n",
+                                              strerror(errno));
+                               }
                                fclose(network_fp);
                        }
                        free(smr.ser);
@@ -3877,6 +3873,10 @@ struct CtdlMessage *CtdlMakeMessage(
        return(msg);
 }
 
+extern int netconfig_check_roomaccess(
+       char *errmsgbuf, 
+       size_t n,
+       const char* RemoteIdentifier); /* TODO: find a smarter way */
 
 /*
  * Check to see whether we have permission to post a message in the current
@@ -3911,36 +3911,8 @@ int CtdlDoIHavePermissionToPostInThisRoom(
                        return (ERROR + NOT_LOGGED_IN);
                }
                if ((PostPublic!=POST_LMTP) &&(CC->room.QRflags2 & QR2_SMTP_PUBLIC) == 0) {
-                       SpoolControl *sc;
-                       char filename[SIZ];
-                       int found;
 
-                       if (RemoteIdentifier == NULL)
-                       {
-                               snprintf(errmsgbuf, n, "Need sender to permit access.");
-                               return (ERROR + USERNAME_REQUIRED);
-                       }
-
-                       assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
-                       begin_critical_section(S_NETCONFIGS);
-                       if (!read_spoolcontrol_file(&sc, filename))
-                       {
-                               end_critical_section(S_NETCONFIGS);
-                               snprintf(errmsgbuf, n,
-                                       "This mailing list only accepts posts from subscribers.");
-                               return (ERROR + NO_SUCH_USER);
-                       }
-                       end_critical_section(S_NETCONFIGS);
-                       found = is_recipient (sc, RemoteIdentifier);
-                       free_spoolcontrol_struct(&sc);
-                       if (found) {
-                               return (0);
-                       }
-                       else {
-                               snprintf(errmsgbuf, n,
-                                       "This mailing list only accepts posts from subscribers.");
-                               return (ERROR + NO_SUCH_USER);
-                       }
+                       return netconfig_check_roomaccess(errmsgbuf, n, RemoteIdentifier);
                }
                return (0);
 
@@ -4968,6 +4940,11 @@ void AdjRefCount(long msgnum, int incr)
        new_arcq.arcq_msgnum = msgnum;
        new_arcq.arcq_delta = incr;
        rv = fwrite(&new_arcq, sizeof(struct arcq), 1, arcfp);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Couldn't write Refcount Queue File %s: %s\n",
+                      file_arcq,
+                      strerror(errno));
+       }
        fflush(arcfp);
 
        return;