1 /* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
2  */
3 
4 #include "lib.h"
5 #include "str.h"
6 
7 #include "managesieve-quote.h"
8 
9 #include "managesieve-common.h"
10 #include "managesieve-commands.h"
11 
12 
cmd_noop(struct client_command_context * cmd)13 bool cmd_noop(struct client_command_context *cmd)
14 {
15 	struct client *client = cmd->client;
16 	const struct managesieve_arg *args;
17 	const char *text;
18 	string_t *resp_code;
19 
20 	/* [<echo string>] */
21 	if (!client_read_args(cmd, 0, 0, FALSE, &args))
22 		return FALSE;
23 
24 	if (MANAGESIEVE_ARG_IS_EOL(&args[0])) {
25 		client_send_ok(client, "NOOP Completed");
26 		return TRUE;
27 	}
28 
29 	if (!managesieve_arg_get_string(&args[0], &text)) {
30 		client_send_no(client, "Invalid echo tag.");
31 		return TRUE;
32 	}
33 
34 	if (!MANAGESIEVE_ARG_IS_EOL(&args[1])) {
35 		client_send_command_error(cmd, "Too many arguments.");
36 		return TRUE;
37 	}
38 
39 	resp_code = t_str_new(256);
40 	str_append(resp_code, "TAG ");
41 	managesieve_quote_append_string(resp_code, text, FALSE);
42 
43 	client_send_okresp(client, str_c(resp_code), "Done");
44 	return TRUE;
45 }
46 
47