tools: mailutil: Add mailbox remove command
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
@@ -73,6 +73,34 @@ cmd_mailbox_list(void)
|
||||
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
|
||||
*
|
||||
@@ -123,6 +151,10 @@ cmd_mailbox(const char *cmdlist[CMD_MAX_CNP], size_t count)
|
||||
return cmd_mailbox_list();
|
||||
}
|
||||
|
||||
if (strcmp(cmdlist[1], "rm") == 0) {
|
||||
return cmd_mailbox_rm(cmdlist, count);
|
||||
}
|
||||
|
||||
printf("error: bad parameter\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user