OpenVAS Scanner  7.0.1~git
nasl_init.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_nasl_library (lex_ctxt *)
 Adds "built-in" variable and function definitions to a context. More...
 
void add_nasl_library (GSList **)
 Add "built-in" variables to a list. More...
 

Function Documentation

◆ add_nasl_library()

void add_nasl_library ( GSList **  )

Add "built-in" variables to a list.

Definition at line 514 of file nasl_init.c.

515 {
516  int i;
517  for (i = 0; libivars[i].name != NULL; i++)
518  *list = g_slist_append (*list, g_strdup (libivars[i].name));
519  for (i = 0; libsvars[i].name != NULL; i++)
520  *list = g_slist_append (*list, g_strdup (libsvars[i].name));
521 }

References libivars, libsvars, and name.

Referenced by add_predef_varname().

Here is the caller graph for this function:

◆ init_nasl_library()

void init_nasl_library ( lex_ctxt )

Adds "built-in" variable and function definitions to a context.

Definition at line 446 of file nasl_init.c.

447 {
448  tree_cell tc;
449  unsigned i;
450 
451  memset (&tc, 0, sizeof (tc));
452 
453  // Initialize constant integer terms
454  tc.type = CONST_INT;
455  for (i = 0; i < sizeof (libivars) / sizeof (libivars[0]) - 1; i++)
456  {
457  tc.x.i_val = libivars[i].val;
458  if (add_named_var_to_ctxt (lexic, libivars[i].name, &tc) == NULL)
459  {
460  nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
461  libivars[i].name);
462  continue;
463  }
464  }
465 
466  // Initialize constant string terms
467  tc.type = CONST_DATA;
468  for (i = 0; i < sizeof (libsvars) / sizeof (libsvars[0]) - 1; i++)
469  {
470  tc.x.str_val = (char *) libsvars[i].val;
471  tc.size = strlen (libsvars[i].val);
472  if (add_named_var_to_ctxt (lexic, libsvars[i].name, &tc) == NULL)
473  {
474  nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
475  libsvars[i].name);
476  continue;
477  }
478  }
479 
480  // Add the "NULL" variable
481  if (add_named_var_to_ctxt (lexic, "NULL", NULL) == NULL)
482  nasl_perror (lexic, "init_nasl_library: could not define var 'NULL'\n");
483 }
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:93
add_named_var_to_ctxt
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:825
libivars
static struct @1 libivars[]
libsvars
static struct @0 libsvars[]
TC::str_val
char * str_val
Definition: nasl_tree.h:112
TC::x
union TC::@2 x
name
const char * name
Definition: nasl_init.c:377
nasl_perror
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:120
TC::size
int size
Definition: nasl_tree.h:109
TC
Definition: nasl_tree.h:104
TC::type
short type
Definition: nasl_tree.h:106
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:90
val
const char * val
Definition: nasl_init.c:378
list
Definition: nasl_builtin_synscan.c:259
TC::i_val
long int i_val
Definition: nasl_tree.h:113