summaryrefslogtreecommitdiffstats
path: root/src/imap/cmd-x-cancel.c
blob: 3f4945117246d4ede363361b2ff573d9db94855c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Copyright (c) 2006-2018 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;
}