]> code.citadel.org Git - citadel.git/blobdiff - citadel/imap_misc.c
fix all the <time.h> vs. <sys/time.h> issues, hopefully
[citadel.git] / citadel / imap_misc.c
index 40c1cd62815a51c5bc5c3d278bc82b267e846106..add72d2fb87c2ae9763ea54d57b3aaeeca3e425f 100644 (file)
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #include <sys/wait.h>
 #include <ctype.h>
 #include <string.h>
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include <time.h>
 #include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
@@ -207,7 +217,7 @@ void imap_append(int num_parms, char *parms[]) {
        }
 
        imap_free_transmitted_message();        /* just in case. */
-       IMAP->transmitted_message = mallok(literal_length);
+       IMAP->transmitted_message = mallok(literal_length + 1);
        if (IMAP->transmitted_message == NULL) {
                cprintf("%s NO Cannot allocate memory.\r\n", parms[0]);
                return;
@@ -216,6 +226,7 @@ void imap_append(int num_parms, char *parms[]) {
 
        cprintf("+ Transmit message now.\r\n");
        ret = client_read(IMAP->transmitted_message, literal_length);
+       IMAP->transmitted_message[literal_length] = 0;
        if (ret != 1) {
                cprintf("%s NO Read failed.\r\n", parms[0]);
                return;
@@ -223,9 +234,12 @@ void imap_append(int num_parms, char *parms[]) {
 
        lprintf(9, "Converting message...\n");
         msg = convert_internet_message(IMAP->transmitted_message);
+       IMAP->transmitted_message = NULL;
+       IMAP->transmitted_length = 0;
 
         /* If the user is locally authenticated, FORCE the From: header to
          * show up as the real sender.  FIXME do we really want to do this?
+        * Probably should make it site-definable or even room-definable.
          */
         if (CC->logged_in) {
                 if (msg->cm_fields['A'] != NULL) phree(msg->cm_fields['A']);