view src/imap/cmd-x-cancel.c @ 19552:0f22db71df7a

global: freshen copyright git ls-files | xargs perl -p -i -e 's/(\d+)-201[0-5]/$1-2016/g;s/ (201[0-5]) Dovecot/ $1-2016 Dovecot/'
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 13 Jan 2016 12:24:03 +0200
parents 3009a1a6f6d5
children 2e2563132d5f
line wrap: on
line source

/* Copyright (c) 2006-2016 Dovecot authors, see the included COPYING file */

#include "imap-common.h"
#include "imap-commands.h"

bool cmd_x_cancel(struct client_command_context *cmd)
{
	struct client_command_context *cancel_cmd;
	const char *tag;

	/* <tag> */
	if (!client_read_string_args(cmd, 1, &tag))
		return FALSE;

	cancel_cmd = cmd->client->command_queue;
	for (; cancel_cmd != NULL; cancel_cmd = cancel_cmd->next) {
		if (cancel_cmd->tag != NULL && cancel_cmd != cmd &&
		    strcmp(cancel_cmd->tag, tag) == 0) {
			client_command_cancel(&cancel_cmd);
			client_send_tagline(cmd, "OK Command cancelled.");
			return TRUE;
		}
	}

	client_send_tagline(cmd, "NO Command tag not found.");
	return TRUE;
}