cmd-create.c revision e59faf65ce864fe95dc00f5d52b8323cdbd0608a
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
aacf2a69acc59e9382578d6f4e030788abc79706Timo Sirainenbool cmd_create(struct client_command_context *cmd)
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* <mailbox> */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch if (!client_read_string_args(cmd, 1, &mailbox))
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch ns = client_find_namespace(cmd, &mailbox, CLIENT_VERIFY_MAILBOX_NONE);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch if (len == 0 || full_mailbox[len-1] != ns->sep)
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch client_send_tagline(cmd, "NO ["IMAP_RESP_CODE_ALREADYEXISTS
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch "] Namespace already exists.");
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* name ends with hierarchy separator - client is just
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch informing us that it wants to create children under this
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch mailbox = t_strndup(mailbox, strlen(mailbox)-1);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch full_mailbox = t_strndup(full_mailbox, len-1);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch box = mailbox_alloc(ns->list, mailbox, NULL, 0);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch client_send_storage_error(cmd, mailbox_get_storage(box));
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch client_send_tagline(cmd, "OK Create completed.");