]> code.citadel.org Git - citadel.git/commitdiff
* Fixed a bug in CtdlRenameRoom() that caused the old room record not to be
authorArt Cancro <ajc@citadel.org>
Fri, 18 Oct 2002 03:44:14 +0000 (03:44 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 18 Oct 2002 03:44:14 +0000 (03:44 +0000)
  deleted when there was a mailbox namespace attached.
* Reworked imap_rename() and imap_rename_backend() to not use nested functions

citadel/ChangeLog
citadel/msgbase.c
citadel/room_ops.c
citadel/serv_imap.c

index 2aae852e295daf767bd720653cb29d38fc7fd987..cc2343c09950efe11e574ef9c11c236471834ef4 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 601.34  2002/10/18 03:44:13  ajc
+ * Fixed a bug in CtdlRenameRoom() that caused the old room record not to be
+   deleted when there was a mailbox namespace attached.
+ * Reworked imap_rename() and imap_rename_backend() to not use nested functions
+
  Revision 601.33  2002/10/17 12:56:44  error
  * Bug fixes:  Fix numerous char array size mismatches, signed/unsigned
    mismatches, and const correctness problems (though not nearly all)
@@ -4097,4 +4102,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 98563d64e66b6d3ac47bf49354a74b17aa59e42c..5d6c5833c9cf0e9a1b4381be16acaa26b735badd 100644 (file)
@@ -2965,14 +2965,10 @@ void CtdlWriteObject(char *req_room,            /* Room to stuff it in */
                        )
 {
 
-       FILE *fp, *tempfp;
-       char filename[PATH_MAX];
-       char cmdbuf[SIZ];
-       char ch;
+       FILE *fp;
        struct quickroom qrbuf;
        char roomname[ROOMNAMELEN];
        struct CtdlMessage *msg;
-       size_t len;
 
        char *raw_message = NULL;
        char *encoded_message = NULL;
index aab6583e1cfdeb017138c4c7ed1214e4c1e72a6c..a6b225f492e3c45b9798f3ba7f71e90a7db497ae 100644 (file)
@@ -1072,6 +1072,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
        struct floor *fl;
        struct floor flbuf;
        long owner = 0L;
+       char actual_old_name[SIZ];
 
        lprintf(9, "CtdlRenameRoom(%s, %s, %d)\n",
                old_name, new_name, new_floor);
@@ -1106,6 +1107,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
 
        else {
                /* Rename it */
+               strcpy(actual_old_name, qrbuf.QRname);
                if (qrbuf.QRflags & QR_MAILBOX) {
                        owner = atol(qrbuf.QRname);
                }
@@ -1150,7 +1152,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
                 * records, so we have to delete the old one.
                 */
                if (strcasecmp(new_name, old_name)) {
-                       b_deleteroom(old_name);
+                       b_deleteroom(actual_old_name);
                }
 
                ret = crr_ok;
index 3e21b8cadde0e787629e676527dc456775682e2d..67b8ca16705428a128a7b2950fc58c49f59615a0 100644 (file)
@@ -11,7 +11,6 @@
  *
  * WARNING: Mark Crispin is an idiot.  IMAP is the most brain-damaged protocol
  * you will ever have the profound lack of pleasure to encounter.
- * 
  */
 
 #include "sysdep.h"
 #include "imap_store.h"
 #include "imap_misc.h"
 
+/* imap_rename() uses this struct containing list of rooms to rename */
+struct irl {
+       struct irl *next;
+       char irl_oldroom[ROOMNAMELEN];
+       char irl_newroom[ROOMNAMELEN];
+       int irl_newfloor;
+};
+
+/* Data which is passed between imap_rename() and imap_rename_backend() */
+struct irlparms { 
+       char *oldname;
+       char *newname;
+       struct irl **irl;
+};
 
 long SYM_IMAP;
 
@@ -894,6 +907,43 @@ void imap_delete(int num_parms, char *parms[]) {
 }
 
 
+/*
+ * Back end function for imap_rename()
+ */
+void imap_rename_backend(struct quickroom *qrbuf, void *data) {
+       char foldername[SIZ];
+       char newfoldername[SIZ];
+       char newroomname[ROOMNAMELEN];
+       int newfloor = 0;
+       struct irl *irlp = NULL;        /* scratch pointer */
+       struct irlparms *irlparms;
+
+       irlparms = (struct irlparms *)data;
+       imap_mailboxname(foldername, sizeof foldername, qrbuf);
+
+       /* Rename subfolders */
+       if ( (!strncasecmp(foldername, irlparms->oldname,
+          strlen(irlparms->oldname))
+          && (foldername[strlen(irlparms->oldname)] == '|')) ) {
+
+               sprintf(newfoldername, "%s|%s",
+                       irlparms->newname,
+                       &foldername[strlen(irlparms->oldname)+1]
+               );
+
+               newfloor = imap_roomname(newroomname,
+                       sizeof newroomname, newfoldername) & 0xFF;
+
+               irlp = (struct irl *) mallok(sizeof(struct irl));
+               strcpy(irlp->irl_newroom, newroomname);
+               strcpy(irlp->irl_oldroom, qrbuf->QRname);
+               irlp->irl_newfloor = newfloor;
+               irlp->next = *(irlparms->irl);
+               *(irlparms->irl) = irlp;
+       }
+}
+       
+
 /*
  * Implements the RENAME command
  *
@@ -904,49 +954,10 @@ void imap_rename(int num_parms, char *parms[]) {
        int oldr, newr;
        int new_floor;
        int r;
-
-       /* struct containing list of rooms to rename */
-       struct irl {
-               struct irl *next;
-               char irl_oldroom[ROOMNAMELEN];
-               char irl_newroom[ROOMNAMELEN];
-               int irl_newfloor;
-       };
        struct irl *irl = NULL;         /* the list */
        struct irl *irlp = NULL;        /* scratch pointer */
+       struct irlparms irlparms;
 
-       /*
-        * Back end function for imap_rename()
-        */
-       void imap_rename_backend(struct quickroom *qrbuf, void *data) {
-               char foldername[SIZ];
-               char newfoldername[SIZ];
-               char newroomname[ROOMNAMELEN];
-               int newfloor;
-       
-               imap_mailboxname(foldername, sizeof foldername, qrbuf);
-       
-               if ( (!strncasecmp(foldername, parms[2], strlen(parms[2]))
-                  && (foldername[strlen(parms[2])] == '|')) ) {
-       
-                       sprintf(newfoldername, "%s|%s",
-                               parms[3],
-                               &foldername[strlen(parms[2])+1]
-                       );
-       
-                       newfloor = imap_roomname(newroomname,
-                               sizeof newroomname, newfoldername) & 0xFF;
-
-                       irlp = (struct irl *) mallok(sizeof(struct irl));
-                       strcpy(irlp->irl_newroom, newroomname);
-                       strcpy(irlp->irl_oldroom, qrbuf->QRname);
-                       irlp->irl_newfloor = newfloor;
-                       irlp->next = irl;
-                       irl = irlp;
-
-               }
-       }
-       
        oldr = imap_roomname(old_room, sizeof old_room, parms[2]);
        newr = imap_roomname(new_room, sizeof new_room, parms[3]);
        new_floor = (newr & 0xFF);
@@ -991,7 +1002,10 @@ void imap_rename(int num_parms, char *parms[]) {
 
        /* Otherwise, do the subfolders.  Build a list of rooms to rename... */
        else {
-               ForEachRoom(imap_rename_backend, NULL);
+               irlparms.oldname = parms[2];
+               irlparms.newname = parms[3];
+               irlparms.irl = &irl;
+               ForEachRoom(imap_rename_backend, (void *)&irlparms);
 
                /* ... and now rename them. */
                while (irl != NULL) {