]> code.citadel.org Git - citadel.git/commitdiff
* Began implementing IMAP APPEND
authorArt Cancro <ajc@citadel.org>
Tue, 3 Apr 2001 00:47:23 +0000 (00:47 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 3 Apr 2001 00:47:23 +0000 (00:47 +0000)
citadel/ChangeLog
citadel/imap_misc.c
citadel/imap_misc.h
citadel/serv_imap.c
citadel/serv_imap.h

index c25afc5422b0e002eb82fee30c5c06ce536c4555..47d9f79dca8847893126f2f202f418427a97d5a8 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.123  2001/04/03 00:47:23  ajc
+ * Began implementing IMAP APPEND
+
  Revision 573.122  2001/04/01 22:05:44  cough
  * *Actually* fixed a botched ChangeLog entry.
 
@@ -2482,5 +2485,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
-
index a0e7a7a7a70bb5b06dccd0555c1d30abc665d44f..84f6854946ad3b088bb1b3b84c523fd7a1b16fdf 100644 (file)
@@ -175,3 +175,45 @@ void imap_print_express_messages(void) {
 
 
 
+/*
+ * This function is called by the main command loop.
+ */
+void imap_append(int num_parms, char *parms[]) {
+       size_t literal_length;
+       int ret;
+
+       if (num_parms < 4) {
+               cprintf("%s BAD usage error\r\n", parms[0]);
+               return;
+       }
+
+       if ( (parms[num_parms-1][0] != '{')
+          || (parms[num_parms-1][strlen(parms[num_parms-1])-1] != '}') )  {
+               cprintf("%s BAD no message literal supplied\r\n", parms[0]);
+               return;
+       }
+
+       literal_length = (size_t) atol(&parms[num_parms-1][1]);
+       if (literal_length < 1) {
+               cprintf("%s BAD Message length must be at least 1.\r\n",
+                       parms[0]);
+               return;
+       }
+
+       imap_free_transmitted_message();        /* just in case. */
+       IMAP->transmitted_message = mallok(literal_length);
+       if (IMAP->transmitted_message == NULL) {
+               cprintf("%s NO Cannot allocate memory.\r\n", parms[0]);
+               return;
+       }
+       IMAP->transmitted_length = literal_length;
+
+       cprintf("+ Transmit message now.\r\n");
+       ret = client_read(IMAP->transmitted_message, literal_length);
+       if (ret != 1) {
+               cprintf("%s NO Read failed.\r\n", parms[0]);
+               return;
+       }
+
+       cprintf("%s NO not implemented yet ** FIXME ** \r\n", parms[0]);
+}
index d46d0357e99db0e13c82f9828ab8a611f453086b..27f1d3260ad28d5e90998901cebecf196bcc4218 100644 (file)
@@ -6,3 +6,4 @@
 void imap_copy(int num_parms, char *parms[]);
 void imap_uidcopy(int num_parms, char *parms[]);
 void imap_print_express_messages(void);
+void imap_append(int num_parms, char *parms[]);
index d0f189165d1f8da6d5192299a5c61890518c0169..241da1d88e7b8887d7301e266413fd0abbb20b5b 100644 (file)
@@ -69,6 +69,18 @@ void imap_free_msgids(void) {
 }
 
 
+/*
+ * If there is a transmitted message in memory, free it
+ */
+void imap_free_transmitted_message(void) {
+       if (IMAP->transmitted_message != NULL) {
+               phree(IMAP->transmitted_message);
+               IMAP->transmitted_message = NULL;
+               IMAP->transmitted_length = 0;
+       }
+}
+
+
 /*
  * Back end for imap_load_msgids()
  *
@@ -203,6 +215,7 @@ void imap_cleanup_function(void) {
 
        lprintf(9, "Performing IMAP cleanup hook\n");
        imap_free_msgids();
+       imap_free_transmitted_message();
        lprintf(9, "Finished IMAP cleanup hook\n");
 }
 
@@ -993,6 +1006,10 @@ void imap_command_loop(void) {
                imap_unsubscribe(num_parms, parms);
        }
 
+       else if (!strcasecmp(parms[1], "APPEND")) {
+               imap_append(num_parms, parms);
+       }
+
        else if (IMAP->selected == 0) {
                cprintf("%s BAD no folder selected\r\n", parms[0]);
        }
@@ -1051,6 +1068,8 @@ void imap_command_loop(void) {
                cprintf("%s BAD command unrecognized\r\n", parms[0]);
        }
 
+       /* If the client transmitted a message we can free it now */
+       imap_free_transmitted_message();
 }
 
 
index 0308f41cf7f428315e24ac863e96b0d0ae751fd5..0769cbcc2f894b5841317f2ad8aaa4b66b6cf6d0 100644 (file)
@@ -8,6 +8,7 @@ void imap_cleanup_function(void);
 void imap_greeting(void);
 void imap_command_loop(void);
 int imap_grabroom(char *returned_roomname, char *foldername);
+void imap_free_transmitted_message(void);
 
 
 
@@ -19,6 +20,8 @@ struct citimap {
        int num_msgs;           /* Number of messages being mapped */
        long *msgids;
        unsigned int *flags;
+       char *transmitted_message;      /* for APPEND command... */
+       size_t transmitted_length;
 };
 
 /*