Coverage Report

Created: 2025-08-29 06:53

/src/opensips/cachedb/cachedb_cap.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2011 OpenSIPS Solutions
3
 *
4
 * This file is part of opensips, a free SIP server.
5
 *
6
 * opensips is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * opensips is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 *
21
 * history:
22
 * ---------
23
 *  2011-09-xx  created (vlad-paiu)
24
 */
25
26
#ifndef _CACHEDB_CAP_H
27
#define _CACHEDB_CAP_H
28
29
#include "cachedb.h"
30
#include"../dprint.h"
31
32
#include <stdlib.h>
33
34
typedef enum {
35
  CACHEDB_CAP_GET = 1<<0,
36
  CACHEDB_CAP_SET = 1<<1,
37
  CACHEDB_CAP_REMOVE = 1<<2,
38
  CACHEDB_CAP_ADD = 1<<3,
39
  CACHEDB_CAP_SUB = 1<<4,
40
  CACHEDB_CAP_BINARY_VALUE = 1<<5,
41
  CACHEDB_CAP_RAW = 1<<6,
42
  CACHEDB_CAP_TRUNCATE = 1<<7,
43
  CACHEDB_CAP_ITER_KEYS = 1<<8,
44
45
  CACHEDB_CAP_QUERY = 1<<9,
46
  CACHEDB_CAP_UPDATE = 1<<10,
47
  CACHEDB_CAP_COL_ORIENTED = (CACHEDB_CAP_QUERY|CACHEDB_CAP_UPDATE),
48
49
  CACHEDB_CAP_MAP_GET = 1<<10,
50
  CACHEDB_CAP_MAP_SET = 1<<11,
51
  CACHEDB_CAP_MAP_REMOVE = 1<<12,
52
  CACHEDB_CAP_MAP =
53
    (CACHEDB_CAP_MAP_GET|CACHEDB_CAP_MAP_SET|CACHEDB_CAP_MAP_REMOVE),
54
} cachedb_cap;
55
56
0
#define CACHEDB_CAPABILITY(cdbf,cpv) (((cdbf)->capability & (cpv)) == (cpv))
57
58
static inline int check_cachedb_api(cachedb_engine *cde)
59
0
{
60
0
  if (cde == NULL)
61
0
    return -1;
62
63
0
  if (cde->cdb_func.init == 0) {
64
0
    LM_ERR("module %.*s does not export init func\n",
65
0
        cde->name.len,cde->name.s);
66
0
    return -1;
67
0
  }
68
69
0
  if (cde->cdb_func.destroy == 0) {
70
0
    LM_ERR("module %.*s doesn't export destroy func\n",
71
0
        cde->name.len,cde->name.s);
72
0
    return -1;
73
0
  }
74
75
0
  if (cde->cdb_func.get)
76
0
    cde->cdb_func.capability |= CACHEDB_CAP_GET;
77
0
  if (cde->cdb_func.set)
78
0
    cde->cdb_func.capability |= CACHEDB_CAP_SET;
79
0
  if (cde->cdb_func.remove)
80
0
    cde->cdb_func.capability |= CACHEDB_CAP_REMOVE;
81
0
  if (cde->cdb_func.add)
82
0
    cde->cdb_func.capability |= CACHEDB_CAP_ADD;
83
0
  if (cde->cdb_func.sub)
84
0
    cde->cdb_func.capability |= CACHEDB_CAP_SUB;
85
0
  if (cde->cdb_func.raw_query)
86
0
    cde->cdb_func.capability |= CACHEDB_CAP_RAW;
87
0
  if (cde->cdb_func.truncate)
88
0
    cde->cdb_func.capability |= CACHEDB_CAP_TRUNCATE;
89
0
  if (cde->cdb_func.iter_keys)
90
0
    cde->cdb_func.capability |= CACHEDB_CAP_ITER_KEYS;
91
92
0
  if (cde->cdb_func.query)
93
0
    cde->cdb_func.capability |= CACHEDB_CAP_QUERY;
94
0
  if (cde->cdb_func.update)
95
0
    cde->cdb_func.capability |= CACHEDB_CAP_UPDATE;
96
97
0
  if (cde->cdb_func.query && cde->cdb_func.update)
98
0
    cde->cdb_func.capability |= CACHEDB_CAP_COL_ORIENTED;
99
100
0
  if (cde->cdb_func.map_get)
101
0
    cde->cdb_func.capability |= CACHEDB_CAP_MAP_GET;
102
0
  if (cde->cdb_func.map_set)
103
0
    cde->cdb_func.capability |= CACHEDB_CAP_MAP_SET;
104
0
  if (cde->cdb_func.map_remove)
105
0
    cde->cdb_func.capability |= CACHEDB_CAP_MAP_REMOVE;
106
107
0
  if (cde->cdb_func.map_get && cde->cdb_func.map_set && cde->cdb_func.map_remove)
108
0
    cde->cdb_func.capability |= CACHEDB_CAP_MAP;
109
110
0
  return 0;
111
0
}
Unexecuted instantiation: core_cmds.c:check_cachedb_api
Unexecuted instantiation: cachedb.c:check_cachedb_api
112
113
#endif