tools: mailutil: Add mailbox remove command

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-05-03 02:05:20 -04:00
parent 67155faed1
commit 0a69f7f4f4
+32
View File
@@ -73,6 +73,34 @@ cmd_mailbox_list(void)
return 0; return 0;
} }
/*
* Parse a "mailbox rm" command
*
* @cmdlist: Command list to parse
* @count: Number of entries inside command list
*
* Returns zero on success
*/
static int
cmd_mailbox_rm(const char *cmdlist[CMD_MAX_CNP], size_t count)
{
char pathbuf[64];
ASSERT_COUNT_N(count, 3);
snprintf(pathbuf, sizeof(pathbuf), "%s/%s",
MAILBOX_PREFIX, cmdlist[2]);
/* Destroy the mailbox */
if (rmdir(pathbuf) < 0) {
perror("rmdir");
return -1;
}
printf("deleted mailbox '%s'\n", cmdlist[2]);
return 0;
}
/* /*
* Parse a "mailbox create" command * Parse a "mailbox create" command
* *
@@ -123,6 +151,10 @@ cmd_mailbox(const char *cmdlist[CMD_MAX_CNP], size_t count)
return cmd_mailbox_list(); return cmd_mailbox_list();
} }
if (strcmp(cmdlist[1], "rm") == 0) {
return cmd_mailbox_rm(cmdlist, count);
}
printf("error: bad parameter\n"); printf("error: bad parameter\n");
return -1; return -1;
} }