OpenVAS Libraries
4.0+rc3.SVN
|
#include <stdlib.h>
#include <string.h>
#include <fnmatch.h>
#include <glib.h>
#include "arglists.h"
#include "kb.h"
#include "system_internal.h"
Defines | |
#define | HASH_MAX 65537 |
Functions | |
struct kb_item ** | kb_new () |
Allocates memory for an array of kb_items with max length of HASH_MAX. | |
struct kb_item * | kb_item_get_single (struct kb_item **kb, char *name, int type) |
READ the knowledge base. | |
char * | kb_item_get_str (struct kb_item **kb, char *name) |
Get the value of a kb_item with type KB_TYPE_STR and name name. | |
int | kb_item_get_int (struct kb_item **kb, char *name) |
Get the value of a kb_item with type KB_TYPE_INT and name name. | |
struct kb_item * | kb_item_get_all (struct kb_item **kb, char *name) |
Returns a list of copies of kb_items with name name in a knowledge base. | |
struct kb_item * | kb_item_get_pattern (struct kb_item **kb, char *expr) |
Returns a list of copies of kb_items that match a pattern. | |
void | kb_item_get_all_free (struct kb_item *items) |
Frees a list of kb_items. | |
int | kb_item_add_str (struct kb_item **kb, char *name, char *value) |
Adds a string to the knowledge base. In contrast to kb_item_set_str the item will not be replaced (useful for list creation). | |
int | kb_item_set_str (struct kb_item **kb, char *name, char *value) |
int | kb_item_set_int (struct kb_item **kb, char *name, int value) |
int | kb_item_add_int (struct kb_item **kb, char *name, int value) |
void | kb_item_rm_all (struct kb_item **kb, char *name) |
struct arglist * | plug_get_oldstyle_kb (struct arglist *desc) |
Knowledge base management API.
Knowledge bases collect information and can be used to share information between NVTs.
A knowledge base is an array of knowledge base items (kb_item). An item is defined by its name and has a value (either int or char*), a type flag (indicating whether the value shall be interpreted as int or char*) and a pointer to the "next" item.
A knowledge base (kb_item**) stores single items at a position according to a hash of the items name (function mkkey). Because of that, a knwoledge base has a fixed size of 65537 items and kb_items are implemented as lists.
int kb_item_add_str | ( | struct kb_item ** | kb, |
char * | name, | ||
char * | value | ||
) |
Adds a string to the knowledge base. In contrast to kb_item_set_str the item will not be replaced (useful for list creation).
kb | The knowledge base. |
name | Key of the entry. |
value | Value of the entry. |
Returns a list of copies of kb_items with name name in a knowledge base.
The result has to be freed (kb_item_get_all_free). Use kb_item_get_pattern if you want to get all items matching a pattern, rather than a single name.
kb | The knowledge base. |
name | Name of the item(s) of interest. |
void kb_item_get_all_free | ( | struct kb_item * | items | ) |
Frees a list of kb_items.
Can be used to free the results of querying the kb with kb_item_get_all() or kb_item_get_pattern().
items | The list of kb_items to free. |
int kb_item_get_int | ( | struct kb_item ** | kb, |
char * | name | ||
) |
Returns a list of copies of kb_items that match a pattern.
The items have to be freed, e.g. with kb_item_get_all_free.
kb | The knowledge base. |
expr | A pattern that can be used with fnmatch (e.g. "www/serv*"). |
READ the knowledge base.
char* kb_item_get_str | ( | struct kb_item ** | kb, |
char * | name | ||
) |
struct kb_item** kb_new | ( | ) | [read] |
Allocates memory for an array of kb_items with max length of HASH_MAX.