OpenVAS Scanner  22.7.9
nasl_init.h File Reference
#include "nasl_lex_ctxt.h"
#include <glib.h>
Include dependency graph for nasl_init.h:
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 554 of file nasl_init.c.

555 {
556  int i;
557  for (i = 0; libivars[i].name != NULL; i++)
558  *list = g_slist_append (*list, g_strdup (libivars[i].name));
559  for (i = 0; libsvars[i].name != NULL; i++)
560  *list = g_slist_append (*list, g_strdup (libsvars[i].name));
561 }

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 486 of file nasl_init.c.

487 {
488  tree_cell tc;
489  unsigned i;
490 
491  memset (&tc, 0, sizeof (tc));
492 
493  // Initialize constant integer terms
494  tc.type = CONST_INT;
495  for (i = 0; i < sizeof (libivars) / sizeof (libivars[0]) - 1; i++)
496  {
497  tc.x.i_val = libivars[i].val;
498  if (add_named_var_to_ctxt (lexic, libivars[i].name, &tc) == NULL)
499  {
500  nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
501  libivars[i].name);
502  continue;
503  }
504  }
505 
506  // Initialize constant string terms
507  tc.type = CONST_DATA;
508  for (i = 0; i < sizeof (libsvars) / sizeof (libsvars[0]) - 1; i++)
509  {
510  tc.x.str_val = (char *) libsvars[i].val;
511  tc.size = strlen (libsvars[i].val);
512  if (add_named_var_to_ctxt (lexic, libsvars[i].name, &tc) == NULL)
513  {
514  nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
515  libsvars[i].name);
516  continue;
517  }
518  }
519 
520  // Add the "NULL" variable
521  if (add_named_var_to_ctxt (lexic, "NULL", NULL) == NULL)
522  nasl_perror (lexic, "init_nasl_library: could not define var 'NULL'\n");
523 }
libivars
static struct @4 libivars[]
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:82
add_named_var_to_ctxt
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:813
TC::str_val
char * str_val
Definition: nasl_tree.h:103
TC::x
union TC::@5 x
libsvars
static struct @3 libsvars[]
name
const char * name
Definition: nasl_init.c:411
nasl_perror
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:111
TC::size
int size
Definition: nasl_tree.h:99
TC
Definition: nasl_tree.h:94
TC::type
short type
Definition: nasl_tree.h:95
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:79
val
const char * val
Definition: nasl_init.c:412
list
Definition: nasl_builtin_synscan.c:249
TC::i_val
long int i_val
Definition: nasl_tree.h:104