Coverage Report

Created: 2026-08-13 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/ihave/ext-ihave-common.c
Line
Count
Source
1
/* Copyright (c) Pigeonhole authors, see top-level COPYING file */
2
3
#include "lib.h"
4
#include "array.h"
5
6
#include "sieve-common.h"
7
#include "sieve-ast.h"
8
9
#include "ext-ihave-common.h"
10
11
/*
12
 * AST context management
13
 */
14
15
struct ext_ihave_ast_context *
16
ext_ihave_get_ast_context(const struct sieve_extension *this_ext,
17
        struct sieve_ast *ast)
18
0
{
19
0
  struct ext_ihave_ast_context *actx =
20
0
    (struct ext_ihave_ast_context *)
21
0
      sieve_ast_extension_get_context(ast, this_ext);
22
0
  pool_t pool;
23
24
0
  if (actx != NULL)
25
0
    return actx;
26
27
0
  pool = sieve_ast_pool(ast);
28
0
  actx = p_new(pool, struct ext_ihave_ast_context, 1);
29
0
  p_array_init(&actx->missing_extensions, pool, 64);
30
31
0
  sieve_ast_extension_set_context(ast, this_ext, actx);
32
0
  return actx;
33
0
}
34
35
void ext_ihave_ast_add_missing_extension(const struct sieve_extension *this_ext,
36
           struct sieve_ast *ast,
37
           const char *ext_name)
38
0
{
39
0
  struct ext_ihave_ast_context *actx =
40
0
    ext_ihave_get_ast_context(this_ext, ast);
41
0
  const char *const *exts;
42
0
  unsigned int i, count;
43
44
0
  exts = array_get(&actx->missing_extensions, &count);
45
0
  for (i = 0; i < count; i++) {
46
0
    if (strcmp(exts[i], ext_name) == 0)
47
0
      return;
48
0
  }
49
50
0
  array_append(&actx->missing_extensions, &ext_name, 1);
51
0
}