File: ext-vnd-report-common.c

package info (click to toggle)
dovecot 1%3A2.2.27-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 48,308 kB
  • sloc: ansic: 430,242; sh: 17,401; makefile: 6,581; cpp: 1,557; perl: 295; xml: 44; pascal: 27; python: 27
file content (51 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (3)
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
48
49
50
51
/* Copyright (c) 2016 Pigeonhole authors, see the included COPYING file
 */

#include "lib.h"
#include "str.h"
#include "rfc822-parser.h"

#include "sieve-common.h"
#include "sieve-extensions.h"

#include "ext-vnd-report-common.h"

bool ext_report_load
(const struct sieve_extension *ext, void **context)
{
	struct sieve_instance *svinst = ext->svinst;
	struct ext_report_config *config;

	config = p_new(svinst->pool, struct ext_report_config, 1);

	(void)sieve_address_source_parse_from_setting(svinst,
		svinst->pool, "sieve_report_from", &config->report_from);

	*context = (void *) config;
	return TRUE;
}

const char *
ext_vnd_report_parse_feedback_type(const char *feedback_type)
{
	struct rfc822_parser_context parser;
	string_t *token;

	/* Initialize parsing */
	rfc822_parser_init(&parser,
		(const unsigned char *)feedback_type, strlen(feedback_type), NULL);
	(void)rfc822_skip_lwsp(&parser);

	/* Parse MIME token */
	token = t_str_new(64);
	if (rfc822_parse_mime_token(&parser, token) < 0)
		return NULL;

	/* Content-type value must end here, otherwise it is invalid after all */
	(void)rfc822_skip_lwsp(&parser);
	if ( parser.data != parser.end )
		return NULL;

	/* Success */
	return str_c(token);
}