view src/imap/cmd-create.c @ 1290:9562ba6af1f1 HEAD

mbox: CREATE mailbox/ now mkdir()s it.
author Timo Sirainen <tss@iki.fi>
date Sun, 09 Mar 2003 11:56:05 +0200
parents fd8888f6f037
children 31c4bb26a1e9
line wrap: on
line source

/* Copyright (C) 2002 Timo Sirainen */

#include "common.h"
#include "commands.h"

int cmd_create(struct client *client)
{
	const char *mailbox;
	int only_hiearchy;
	size_t len;

	/* <mailbox> */
	if (!client_read_string_args(client, 1, &mailbox))
		return FALSE;

	len = strlen(mailbox);
	if (mailbox[len-1] != client->storage->hierarchy_sep)
		only_hiearchy = FALSE;
	else {
		/* name ends with hierarchy separator - client is just
		   informing us that it wants to create a mailbox under
		   this name. */
                only_hiearchy = TRUE;
		mailbox = t_strndup(mailbox, len-1);
	}

	if (!client_verify_mailbox_name(client, mailbox, FALSE, TRUE))
		return TRUE;

	if (!client->storage->create_mailbox(client->storage, mailbox,
					     only_hiearchy)) {
		client_send_storage_error(client);
		return TRUE;
	}

	client_send_tagline(client, "OK Create completed.");
	return TRUE;
}