Coverage Report

Created: 2026-08-31 07:00

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