Coverage Report

Created: 2026-05-30 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/vacation/ext-vacation-seconds.c
Line
Count
Source
1
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
2
 */
3
4
/* Extension vacation-seconds
5
 * --------------------------
6
 *
7
 * Authors: Stephan Bosch <stephan@rename-it.nl>
8
 * Specification: RFC 6131
9
 * Implementation: full
10
 * Status: testing
11
 *
12
 */
13
14
#include "lib.h"
15
16
#include "sieve-common.h"
17
18
#include "sieve-extensions.h"
19
#include "sieve-validator.h"
20
21
#include "ext-vacation-common.h"
22
23
/*
24
 * Extension
25
 */
26
27
struct ext_vacation_seconds_context {
28
  const struct sieve_extension *ext_vacation;
29
};
30
31
static int
32
ext_vacation_seconds_load(const struct sieve_extension *ext, void **context);
33
static void ext_vacation_seconds_unload(const struct sieve_extension *ext);
34
35
static bool
36
ext_vacation_seconds_validator_load(const struct sieve_extension *ext,
37
            struct sieve_validator *valdtr);
38
39
const struct sieve_extension_def vacation_seconds_extension = {
40
  .name = "vacation-seconds",
41
  .load = ext_vacation_seconds_load,
42
  .unload = ext_vacation_seconds_unload,
43
  .validator_load = ext_vacation_seconds_validator_load,
44
};
45
46
static int
47
ext_vacation_seconds_load(const struct sieve_extension *ext, void **context)
48
0
{
49
0
  const struct sieve_extension *ext_vac;
50
0
  struct ext_vacation_seconds_context *extctx;
51
52
0
  if (*context != NULL) {
53
0
    ext_vacation_seconds_unload(ext);
54
0
    *context = NULL;
55
0
  }
56
57
  /* Make sure vacation extension is registered */
58
0
  if (sieve_extension_require(ext->svinst, &vacation_extension,
59
0
            TRUE, &ext_vac) < 0)
60
0
    return -1;
61
62
0
  extctx = i_new(struct ext_vacation_seconds_context, 1);
63
0
  extctx->ext_vacation = ext_vac;
64
65
0
  *context = extctx;
66
0
  return 0;
67
0
}
68
69
static void ext_vacation_seconds_unload(const struct sieve_extension *ext)
70
0
{
71
0
  struct ext_vacation_seconds_context *extctx = ext->context;
72
73
0
  if (extctx == NULL)
74
0
    return;
75
0
  i_free(extctx);
76
0
}
77
78
static bool
79
ext_vacation_seconds_validator_load(
80
  const struct sieve_extension *ext ATTR_UNUSED,
81
  struct sieve_validator *valdtr)
82
0
{
83
0
  const struct sieve_extension *vacation_ext;
84
85
  /* Load vacation extension implicitly */
86
87
0
  vacation_ext = sieve_validator_extension_load_implicit(
88
0
    valdtr, vacation_extension.name);
89
0
  if (vacation_ext == NULL)
90
0
    return FALSE;
91
92
  /* Add seconds tag to vacation command */
93
94
0
  return ext_vacation_register_seconds_tag(valdtr, vacation_ext);
95
0
}