summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/plugins/vacation/ext-vacation-seconds.c
blob: 41c0f06629f5e950dc993a92b8afca272584d23c (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
 */

/* Extension vacation-seconds
 * --------------------------
 *
 * Authors: Stephan Bosch <stephan@rename-it.nl>
 * Specification: RFC 6131
 * Implementation: full
 * Status: testing
 *
 */

#include "lib.h"

#include "sieve-common.h"

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

#include "ext-vacation-common.h"

/*
 * Extension
 */

bool ext_vacation_seconds_load
	(const struct sieve_extension *ext, void **context);
static bool ext_vacation_seconds_validator_load
	(const struct sieve_extension *ext, struct sieve_validator *valdtr);

const struct sieve_extension_def vacation_seconds_extension = {
	.name = "vacation-seconds",
	.load = ext_vacation_seconds_load,
	.validator_load = ext_vacation_seconds_validator_load,
};

bool ext_vacation_seconds_load
(const struct sieve_extension *ext, void **context)
{
	if ( *context == NULL ) {
		/* Make sure vacation extension is registered */
		*context = (void *)
			sieve_extension_require(ext->svinst, &vacation_extension, TRUE);
	}

	return TRUE;
}

static bool ext_vacation_seconds_validator_load
(const struct sieve_extension *ext ATTR_UNUSED, struct sieve_validator *valdtr)
{
	const struct sieve_extension *vacation_ext;

	/* Load vacation extension implicitly */

	vacation_ext = sieve_validator_extension_load_implicit
		(valdtr, vacation_extension.name);

	if ( vacation_ext == NULL )
		return FALSE;

	/* Add seconds tag to vacation command */

	return ext_vacation_register_seconds_tag(valdtr, vacation_ext);
}