File: cmd-noop.c

package info (click to toggle)
dovecot 1%3A1.2.15-7%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 30,340 kB
  • ctags: 20,012
  • sloc: ansic: 191,443; sh: 21,091; makefile: 3,330; cpp: 526; perl: 108; xml: 44
file content (47 lines) | stat: -rw-r--r-- 990 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright (c) 2002-2010 Dovecot Sieve authors, see the included COPYING file
 */

/* FIXME: Duplicate! */

#include "common.h"
#include "str.h"

#include "managesieve-parser.h"
#include "managesieve-quote.h"

#include "client.h"
#include "commands.h"

int cmd_noop(struct managesieve_client *client)
{
	struct managesieve_arg *args;
	const char *text;
	string_t *resp_code;
	int ret;

	/* [<echo string>] */
	if (!(ret=client_read_args(client, 0, 0, &args)))
		return FALSE;

	if ( ret > 1 ) {
		client_send_no(client, "Too many arguments");
		return TRUE;
	}

	if ( args[0].type == MANAGESIEVE_ARG_EOL ) {
		client_send_ok(client, "NOOP Completed");
		return TRUE;
	}

	if ( (text = managesieve_arg_string(&args[0])) == NULL ) {
		client_send_no(client, "Invalid echo tag.");
		return TRUE;
	}

	resp_code = t_str_new(256);
	str_append(resp_code, "TAG ");
	managesieve_quote_append_string(resp_code, text, FALSE);

	client_send_okresp(client, str_c(resp_code), "Done");
	return TRUE;
}