]> code.citadel.org Git - citadel.git/commitdiff
The DELE command now accepts multiple message numbers
authorArt Cancro <ajc@citadel.org>
Thu, 17 Aug 2006 15:20:56 +0000 (15:20 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 17 Aug 2006 15:20:56 +0000 (15:20 +0000)
separated by commas.

citadel/msgbase.c
citadel/techdoc/protocol.txt

index c91ead1c1bd3cdbc58c4d432759205d1148c9aff..bdee54e1ef4ed50ac94469979d0a06c50c0b4373 100644 (file)
@@ -3431,25 +3431,45 @@ int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void) {
 /*
  * Delete message from current room
  */
-void cmd_dele(char *delstr)
+void cmd_dele(char *args)
 {
-       long delnum;
        int num_deleted;
+       int i;
+       char msgset[SIZ];
+       char msgtok[32];
+       long *msgs;
+       int num_msgs = 0;
+
+       extract_token(msgset, args, 0, '|', sizeof msgset);
+       num_msgs = num_tokens(msgset, ',');
+       if (num_msgs < 1) {
+               cprintf("%d Nothing to do.\n", CIT_OK);
+               return;
+       }
 
        if (CtdlDoIHavePermissionToDeleteMessagesFromThisRoom() == 0) {
                cprintf("%d Higher access required.\n",
                        ERROR + HIGHER_ACCESS_REQUIRED);
                return;
        }
-       delnum = extract_long(delstr, 0);
 
-       num_deleted = CtdlDeleteMessages(CC->room.QRname, &delnum, 1, "", 1);
+       /*
+        * Build our message set to be moved/copied
+        */
+       msgs = malloc(num_msgs * sizeof(long));
+       for (i=0; i<num_msgs; ++i) {
+               extract_token(msgtok, msgset, i, ',', sizeof msgtok);
+               msgs[i] = atol(msgtok);
+       }
+
+       num_deleted = CtdlDeleteMessages(CC->room.QRname, msgs, num_msgs, "", 1);
+       free(msgs);
 
        if (num_deleted) {
                cprintf("%d %d message%s deleted.\n", CIT_OK,
                        num_deleted, ((num_deleted != 1) ? "s" : ""));
        } else {
-               cprintf("%d Message %ld not found.\n", ERROR + MESSAGE_NOT_FOUND, delnum);
+               cprintf("%d Message not found.\n", ERROR + MESSAGE_NOT_FOUND);
        }
 }
 
index 9fb0e3e80e039a11ead4b89405035b16119a87f9..8038fcf8fc26646cff55b56c8f1c012793e82549 100644 (file)
@@ -892,12 +892,14 @@ which will tell the client whether the file needs to be read (see GOTO above).
 
  DELE   (DELEte a message)
 
- Delete a message from the current room.  The one argument that should be
-passed to this command is the message number of the message to be deleted.
-The return value will be OK if the message was deleted, or an ERROR code.
-If the delete is successful, the message's reference count is decremented, and
-if the reference count reaches zero, the message is removed from the message
-base.
+ Delete one or more messages from the current room.  The one argument that
+should be passed to this command is a message number, or a list of message
+numbers separated by commas, to be deleted.
+
+ The return value will be OK if one or more messages were deleted, or an ERROR
+code.  If the delete is successful, the messages' reference counts are
+decremented, and if the reference count reaches zero, the messages are removed
+from the message base.
 
 
  MOVE   (MOVE or copy a message to a different room)