Coverage Report

Created: 2026-10-17 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/storage/data/sieve-data-script.c
Line
Count
Source
1
/* Copyright (c) Pigeonhole authors, see top-level COPYING file */
2
3
#include "lib.h"
4
#include "str.h"
5
#include "strfuncs.h"
6
#include "istream.h"
7
8
#include "sieve-common.h"
9
#include "sieve-error.h"
10
#include "sieve-dump.h"
11
#include "sieve-binary.h"
12
13
#include "sieve-data-storage.h"
14
15
/*
16
 * Script data implementation
17
 */
18
19
static struct sieve_data_script *sieve_data_script_alloc(void)
20
0
{
21
0
  struct sieve_data_script *dscript;
22
0
  pool_t pool;
23
24
0
  pool = pool_alloconly_create("sieve_data_script", 1024);
25
0
  dscript = p_new(pool, struct sieve_data_script, 1);
26
0
  dscript->script = sieve_data_script;
27
0
  dscript->script.pool = pool;
28
29
0
  return dscript;
30
0
}
31
32
struct sieve_script *
33
sieve_data_script_create_from_input(struct sieve_instance *svinst,
34
            const char *cause, const char *name,
35
            struct istream *input)
36
0
{
37
0
  struct sieve_storage *storage;
38
0
  struct sieve_data_script *dscript = NULL;
39
0
  int ret;
40
41
0
  ret = sieve_storage_alloc(svinst, svinst->event, &sieve_data_storage,
42
0
          cause, "data", "data", "data", 0, &storage,
43
0
          NULL, NULL);
44
0
  i_assert(ret >= 0);
45
46
0
  dscript = sieve_data_script_alloc();
47
0
  sieve_script_init(&dscript->script, storage, &sieve_data_script, name);
48
49
0
  dscript->data = input;
50
0
  i_stream_ref(dscript->data);
51
52
0
  sieve_storage_unref(&storage);
53
54
0
  dscript->script.open = TRUE;
55
56
0
  return &dscript->script;
57
0
}
58
59
static void sieve_data_script_destroy(struct sieve_script *script)
60
0
{
61
0
  struct sieve_data_script *dscript =
62
0
    container_of(script, struct sieve_data_script, script);
63
64
0
  i_stream_unref(&dscript->data);
65
0
}
66
67
static int
68
sieve_data_script_get_stream(struct sieve_script *script,
69
           struct istream **stream_r)
70
0
{
71
0
  struct sieve_data_script *dscript =
72
0
    container_of(script, struct sieve_data_script, script);
73
74
0
  i_stream_ref(dscript->data);
75
0
  i_stream_seek(dscript->data, 0);
76
77
0
  *stream_r = dscript->data;
78
0
  return 0;
79
0
}
80
81
const struct sieve_script sieve_data_script = {
82
  .driver_name = SIEVE_DATA_STORAGE_DRIVER_NAME,
83
  .v = {
84
    .destroy = sieve_data_script_destroy,
85
86
    .get_stream = sieve_data_script_get_stream,
87
  },
88
};