OpenVAS Libraries  8.0.3
Functions
prefs.c File Reference

Implementation of API to handle globally stored preferences. More...

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include "../base/settings.h"
#include "arglists.h"

Functions

struct arglistpreferences_get (void)
 Get the pointer to the global preferences structure. Eventually this function should not be used anywhere. More...
 
const gchar * prefs_get (const gchar *key)
 Get a string preference value via a key. More...
 
int prefs_get_bool (const gchar *key)
 Get a boolean expression of a preference value via a key. More...
 
void prefs_set (const gchar *key, const gchar *value)
 Set a string preference value via a key. More...
 
void prefs_init (void)
 Initializes the preferences structure. If it was already initialized, remove old settings and start from scratch. More...
 
void prefs_config (const char *config)
 Apply the configs from given file as preferences. More...
 
void prefs_dump (void)
 Dump the preferences to stdout. More...
 
int prefs_nvt_timeout (const char *oid)
 Returns the timeout defined by the client or 0 if none was set. More...
 

Detailed Description

Implementation of API to handle globally stored preferences.

A gloabl store of preferences to scanner and NVTs is handled by this module.

The module is currently using arglist, but eventually once the all of the Scanner uses the preferences via this module, it cann be replaced by a better technology and then be moved to base. Possibly a consolidation with the settings iterator make sense.

Function Documentation

struct arglist* preferences_get ( void  )

Get the pointer to the global preferences structure. Eventually this function should not be used anywhere.

void prefs_config ( const char *  config)

Apply the configs from given file as preferences.

Parameters
configFilename of the configuration file.
void prefs_dump ( void  )

Dump the preferences to stdout.

const gchar* prefs_get ( const gchar *  key)

Get a string preference value via a key.

Parameters
keyThe identifier for the preference.
Returns
A pointer to a string with the value for the preference. NULL in case for the key no preference was found or the preference is not of type string.
int prefs_get_bool ( const gchar *  key)

Get a boolean expression of a preference value via a key.

Parameters
keyThe identifier for the preference.
Returns
1 if the value is considered to represent "true" and 0 if the value is considered to represent "false". If the preference is of type string, value "yes" is true, anything else is false. Any other type or non-existing key is false.
void prefs_init ( void  )

Initializes the preferences structure. If it was already initialized, remove old settings and start from scratch.

int prefs_nvt_timeout ( const char *  oid)

Returns the timeout defined by the client or 0 if none was set.

Parameters
oidOID of NVT to ask timeout value of.
Returns
0 if no timeout for the NVT oid was found, timeout in seconds otherwise.
void prefs_set ( const gchar *  key,
const gchar *  value 
)

Set a string preference value via a key.

Parameters
keyThe identifier for the preference. A copy of this will be created if necessary.
valueThe value to set. A copy of this will be created.