OpenVAS Libraries  6.0+beta5
Data Structures | Macros | Functions
kb.h File Reference

Go to the source code of this file.

Data Structures

struct  kb_item
 

Macros

#define KB_TYPE_INT   ARG_INT
 
#define KB_TYPE_STR   ARG_STRING
 

Functions

struct kb_item ** kb_new ()
 Allocates memory for an array of kb_items with max length of HASH_MAX. More...
 
struct kb_itemkb_item_get_single (struct kb_item **, char *, int)
 READ the knowledge base. More...
 
char * kb_item_get_str (struct kb_item **, char *)
 Get the value of a kb_item with type KB_TYPE_STR and name name. More...
 
int kb_item_get_int (struct kb_item **, char *)
 Get the value of a kb_item with type KB_TYPE_INT and name name. More...
 
struct kb_itemkb_item_get_all (struct kb_item **, char *)
 Returns a list of copies of kb_items with name name in a knowledge base. More...
 
struct kb_itemkb_item_get_pattern (struct kb_item **, char *)
 Returns a list of copies of kb_items that match a pattern. More...
 
void kb_item_get_all_free (struct kb_item *)
 Frees a list of kb_items. More...
 
int kb_item_add_str (struct kb_item **, char *, char *)
 Adds a string to the knowledge base. In contrast to kb_item_set_str the item will not be replaced (useful for list creation). More...
 
int kb_item_set_str (struct kb_item **, char *, char *)
 
int kb_item_add_int (struct kb_item **, char *, int)
 
int kb_item_set_int (struct kb_item **, char *, int)
 
void kb_item_rm_all (struct kb_item **, char *)
 
struct arglistplug_get_oldstyle_kb (struct arglist *)
 

Macro Definition Documentation

#define KB_TYPE_INT   ARG_INT

Possible type of a kb_item. The kb_items v should then be interpreted as int.

#define KB_TYPE_STR   ARG_STRING

Possible type of a kb_item. The kb_items v should then be interpreted as char*.

Function Documentation

int kb_item_add_int ( struct kb_item **  ,
char *  ,
int   
)
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).

Parameters
kbThe knowledge base.
nameKey of the entry.
valueValue of the entry.
struct kb_item* kb_item_get_all ( struct kb_item **  kb,
char *  name 
)
read

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.

Parameters
kbThe knowledge base.
nameName of the item(s) of interest.
Returns
A kb_item list (has to be freed) with kb_items of name name.
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().

Parameters
itemsThe list of kb_items to free.
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.

Returns
Value of the kb_item name with type KB_TYPE_INT or -1 if it does not exist.
struct kb_item* kb_item_get_pattern ( struct kb_item **  kb,
char *  expr 
)
read

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.

Parameters
kbThe knowledge base.
exprA pattern that can be used with fnmatch (e.g. "www/serv*").
Returns
A list of kb_items (has to be freed) whose name matches the pattern exp.
struct kb_item* kb_item_get_single ( struct kb_item **  kb,
char *  name,
int  type 
)
read

READ the knowledge base.

Returns
kb_item in knowledge base with name name and type type or NULL if none found.
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.

Returns
(char*) value of the kb_item name with type KB_TYPE_STR.
void kb_item_rm_all ( struct kb_item **  ,
char *   
)
int kb_item_set_int ( struct kb_item **  ,
char *  ,
int   
)
int kb_item_set_str ( struct kb_item **  ,
char *  ,
char *   
)
struct kb_item** kb_new ( )
read

Allocates memory for an array of kb_items with max length of HASH_MAX.

Returns
Pointer to first item in knowledge base item array.
struct arglist* plug_get_oldstyle_kb ( struct arglist desc)
read

Backward compatibilty