OpenVAS Libraries  8.0.3
Macros | Functions | Variables
nasl_var.c File Reference
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "nasl_tree.h"
#include "nasl_global_ctxt.h"
#include "nasl_func.h"
#include "nasl_var.h"
#include "nasl_lex_ctxt.h"
#include "exec.h"
#include "nasl_debug.h"

Macros

#define NASL_DEBUG   0
 

Functions

int hash_str2 (const char *s, int n)
 
anon_nasl_varnasl_get_var_by_num (nasl_array *a, int num, int create)
 
tree_cellvar2cell (anon_nasl_var *v)
 
tree_cellget_variable_by_name (lex_ctxt *ctxt, const char *name)
 
tree_cellget_array_elem (lex_ctxt *ctxt, const char *name, tree_cell *idx)
 
void free_array (nasl_array *a)
 
void clear_anon_var (anon_nasl_var *v)
 
tree_cellcopy_ref_array (const tree_cell *c1)
 
tree_cellnasl_affect (tree_cell *lval, tree_cell *rval)
 
tree_celldecl_local_variables (lex_ctxt *lexic, tree_cell *vars)
 
tree_celldecl_global_variables (lex_ctxt *lexic, tree_cell *vars)
 
anon_nasl_varadd_numbered_var_to_ctxt (lex_ctxt *lexic, int num, tree_cell *val)
 
named_nasl_varadd_named_var_to_ctxt (lex_ctxt *lexic, const char *name, tree_cell *val)
 
tree_cellnasl_read_var_ref (lex_ctxt *lexic, tree_cell *tc)
 
tree_cellnasl_incr_variable (lex_ctxt *lexic, tree_cell *tc, int pre, int val)
 
const char * array2str (const nasl_array *a)
 
const char * var2str (const anon_nasl_var *v)
 
int get_int_var_by_num (lex_ctxt *lexic, int num, int defval)
 
int get_int_var_by_name (lex_ctxt *lexic, const char *name, int defval)
 
int get_int_local_var_by_name (lex_ctxt *lexic, const char *name, int defval)
 
char * get_str_var_by_num (lex_ctxt *lexic, int num)
 
char * get_str_var_by_name (lex_ctxt *lexic, const char *name)
 
char * get_str_local_var_by_name (lex_ctxt *lexic, const char *name)
 
int get_var_size_by_name (lex_ctxt *lexic, const char *name)
 
int get_local_var_size_by_name (lex_ctxt *lexic, const char *name)
 
int get_var_size_by_num (lex_ctxt *lexic, int num)
 
int get_var_type_by_num (lex_ctxt *lexic, int num)
 Returns NASL variable/cell type, VAR2_UNDEF if value is NULL. More...
 
int get_local_var_type_by_name (lex_ctxt *lexic, const char *name)
 
nasl_iterator nasl_array_iterator (tree_cell *c)
 
tree_cellnasl_iterate_array (nasl_iterator *it)
 
int add_var_to_list (nasl_array *a, int i, const anon_nasl_var *v)
 
int add_var_to_array (nasl_array *a, char *name, const anon_nasl_var *v)
 
int array_max_index (nasl_array *a)
 
tree_cellmake_array_from_elems (tree_cell *el)
 

Variables

FILE * nasl_trace_fp
 

Macro Definition Documentation

#define NASL_DEBUG   0

Function Documentation

named_nasl_var* add_named_var_to_ctxt ( lex_ctxt lexic,
const char *  name,
tree_cell val 
)
anon_nasl_var* add_numbered_var_to_ctxt ( lex_ctxt lexic,
int  num,
tree_cell val 
)
int add_var_to_array ( nasl_array a,
char *  name,
const anon_nasl_var v 
)
int add_var_to_list ( nasl_array a,
int  i,
const anon_nasl_var v 
)
const char* array2str ( const nasl_array a)
int array_max_index ( nasl_array a)

The name is not great: this function does not returns the index of the last element, but the index of the next free slot

void clear_anon_var ( anon_nasl_var v)
tree_cell* copy_ref_array ( const tree_cell c1)
tree_cell* decl_global_variables ( lex_ctxt lexic,
tree_cell vars 
)
tree_cell* decl_local_variables ( lex_ctxt lexic,
tree_cell vars 
)
void free_array ( nasl_array a)

Note: the function does not free the nasl_array structure. Do it if necessary

tree_cell* get_array_elem ( lex_ctxt ctxt,
const char *  name,
tree_cell idx 
)
int get_int_local_var_by_name ( lex_ctxt lexic,
const char *  name,
int  defval 
)
int get_int_var_by_name ( lex_ctxt lexic,
const char *  name,
int  defval 
)
int get_int_var_by_num ( lex_ctxt lexic,
int  num,
int  defval 
)
int get_local_var_size_by_name ( lex_ctxt lexic,
const char *  name 
)
int get_local_var_type_by_name ( lex_ctxt lexic,
const char *  name 
)
char* get_str_local_var_by_name ( lex_ctxt lexic,
const char *  name 
)
char* get_str_var_by_name ( lex_ctxt lexic,
const char *  name 
)
char* get_str_var_by_num ( lex_ctxt lexic,
int  num 
)
int get_var_size_by_name ( lex_ctxt lexic,
const char *  name 
)
int get_var_size_by_num ( lex_ctxt lexic,
int  num 
)
int get_var_type_by_num ( lex_ctxt lexic,
int  num 
)

Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.

tree_cell* get_variable_by_name ( lex_ctxt ctxt,
const char *  name 
)
int hash_str2 ( const char *  s,
int  n 
)
Todo:
Consider using GLibs string hash function.
tree_cell* make_array_from_elems ( tree_cell el)

make_array_from_list is used by the parser only The list of elements is freed after use

tree_cell* nasl_affect ( tree_cell lval,
tree_cell rval 
)
nasl_iterator nasl_array_iterator ( tree_cell c)
anon_nasl_var* nasl_get_var_by_num ( nasl_array a,
int  num,
int  create 
)
tree_cell* nasl_incr_variable ( lex_ctxt lexic,
tree_cell tc,
int  pre,
int  val 
)
tree_cell* nasl_iterate_array ( nasl_iterator it)
tree_cell* nasl_read_var_ref ( lex_ctxt lexic,
tree_cell tc 
)
tree_cell* var2cell ( anon_nasl_var v)
const char* var2str ( const anon_nasl_var v)

Variable Documentation

FILE* nasl_trace_fp