view src/imap/cmd-create.c @ 903:fd8888f6f037 HEAD

Naming style changes, finally got tired of most of the typedefs. Also the previous enum -> macro change reverted so that we don't use the highest bit anymore, that's incompatible with old indexes so they will be rebuilt.
author Timo Sirainen <tss@iki.fi>
date Sun, 05 Jan 2003 15:09:51 +0200
parents 986e89b61520
children 9562ba6af1f1
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 ignore;

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

	ignore = mailbox[strlen(mailbox)-1] == client->storage->hierarchy_sep;
	if (ignore) {
		/* name ends with hierarchy separator - client is just
		   informing us that it wants to create a mailbox under
		   this name. we don't need that information, but verify
		   that the mailbox name is valid */
		mailbox = t_strndup(mailbox, strlen(mailbox)-1);
	}

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

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

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