view src/imap/cmd-copy.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 925d6eb5f8be
children 40a327d356de
line wrap: on
line source

/* Copyright (C) 2002 Timo Sirainen */

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

int cmd_copy(struct client *client)
{
	struct mailbox *destbox;
	const char *messageset, *mailbox;

	/* <message set> <mailbox> */
	if (!client_read_string_args(client, 2, &messageset, &mailbox))
		return FALSE;

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

	/* open the destination mailbox */
	if (!client_verify_mailbox_name(client, mailbox, TRUE, FALSE))
		return TRUE;

	destbox = client->storage->open_mailbox(client->storage,
						mailbox, FALSE, TRUE);
	if (destbox == NULL) {
		client_send_storage_error(client);
		return TRUE;
	}

	/* copy the mail */
	if (client->mailbox->copy(client->mailbox, destbox,
				  messageset, client->cmd_uid)) {
                client_sync_full(client);
		client_send_tagline(client, "OK Copy completed.");
	} else
		client_send_storage_error(client);

	destbox->close(destbox);
	return TRUE;
}