File: kb_cache.c

package info (click to toggle)
openvas-scanner 23.35.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,416 kB
  • sloc: ansic: 41,615; xml: 6,251; pascal: 3,723; yacc: 1,250; sh: 1,068; makefile: 333; sql: 273; javascript: 12
file content (45 lines) | stat: -rw-r--r-- 955 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* SPDX-FileCopyrightText: 2023 Greenbone AG
 * SPDX-FileCopyrightText: 1998-2003 Renaud Deraison
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/**
 * @file kb_cache.c
 * @brief kb_cache.h implementation.
 */

#include "kb_cache.h"

// shared database between openvas and ospd.
kb_t main_kb = NULL;

/**
 * @brief sets the shared database between ospd and openvas as a main_kb for
 * further usage.
 * @description this sets the given kb as a main_kb global variable. It is NOT
 * threadsafe and must be called after each reconnect or fork.
 *
 * @param main_kb Current main kb.
 *
 */
void
set_main_kb (kb_t kb)
{
  main_kb = kb;
}

/**
 * @brief gets the main_kb.
 * @description returns the previously set main_kb; when asserts are enabled it
 * will abort when main_kb is not set. However each usage must check if the
 * return is NULL or not.
 *
 * @return the set main_kb
 */
kb_t
get_main_kb (void)
{
  assert (main_kb);
  return main_kb;
}