OpenVAS Libraries  7.0.4
Functions
nvticache.c File Reference

Implementation of API to handle NVT Info Cache. More...

#include <sys/stat.h>
#include "nvticache.h"
#include <string.h>

Functions

nvticache_tnvticache_new (const gchar *cache_path, const gchar *src_path)
 Create a new nvticache structure initialized with a path. More...
 
void nvticache_free (const nvticache_t *cache)
 Free memory of a nvticache structure. More...
 
nvti_tnvticache_get (const nvticache_t *cache, const gchar *filename)
 Retrieve NVT Information from a cache for the given filename. More...
 
int nvticache_add (const nvticache_t *cache, nvti_t *nvti, gchar *filename)
 Add a NVT Information to the cache. More...
 
nvti_tnvticache_get_by_oid (const nvticache_t *cache, const gchar *oid)
 Get a NVT Information from the cache by OID. More...
 
gchar * nvticache_get_src_by_oid (const nvticache_t *cache, const gchar *oid)
 Get the src element of a NVT Information from the cache by OID. More...
 

Detailed Description

Implementation of API to handle NVT Info Cache.

This file contains all methods to handle NVT Information Cache (nvticache_t).

The module consequently uses glib datatypes and api for memory management etc.

Function Documentation

int nvticache_add ( const nvticache_t cache,
nvti_t nvti,
gchar *  filename 
)

Add a NVT Information to the cache.

Parameters
cacheThe NVTI Cache to use
nvtiThe NVT Information to add
filenameThe name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )
Returns
0 in case of success, anything else indicates an error.
void nvticache_free ( const nvticache_t cache)

Free memory of a nvticache structure.

Parameters
cacheThe structure to be freed.
nvti_t* nvticache_get ( const nvticache_t cache,
const gchar *  filename 
)

Retrieve NVT Information from a cache for the given filename.

Parameters
cacheThe NVTI Cache to use
filenameThe name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )
Returns
NULL in case the data could not be delivered. Else a nvti structure which needs to be released using nvti_free .
nvti_t* nvticache_get_by_oid ( const nvticache_t cache,
const gchar *  oid 
)

Get a NVT Information from the cache by OID.

Parameters
cacheThe NVTI Cache to use
oidThe OID to look up
Returns
A copy of the NVTI object or NULL if not found.
gchar* nvticache_get_src_by_oid ( const nvticache_t cache,
const gchar *  oid 
)

Get the src element of a NVT Information from the cache by OID.

Parameters
cacheThe NVTI Cache to use
oidThe OID to look up
Returns
A copy of the src or NULL if not found. This needs to to be free'd.
nvticache_t* nvticache_new ( const gchar *  cache_path,
const gchar *  src_path 
)

Create a new nvticache structure initialized with a path.

Parameters
pathThe directory where the cache is to be stored.
Returns
NULL in case the memory could not be allocated. Else a nvticache structure which needs to be released using nvticache_free .