OpenVAS Scanner 23.40.3
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.
void add_nasl_library (GSList **)
 Add "built-in" variables to a list.

Function Documentation

◆ add_nasl_library()

void add_nasl_library ( GSList ** list)

Add "built-in" variables to a list.

Definition at line 583 of file nasl_init.c.

584{
585 int i;
586 for (i = 0; libivars[i].name != NULL; i++)
587 *list = g_slist_append (*list, g_strdup (libivars[i].name));
588 for (i = 0; libsvars[i].name != NULL; i++)
589 *list = g_slist_append (*list, g_strdup (libsvars[i].name));
590}
static struct @260365312376163127012272224246062244353077307342 libsvars[]
const char * name
Definition nasl_init.c:440
static struct @002143073300314243041325344242175301040162155246 libivars[]

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 * lexic)

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

Definition at line 515 of file nasl_init.c.

516{
517 tree_cell tc;
518 unsigned i;
519
520 memset (&tc, 0, sizeof (tc));
521
522 // Initialize constant integer terms
523 tc.type = CONST_INT;
524 for (i = 0; i < sizeof (libivars) / sizeof (libivars[0]) - 1; i++)
525 {
526 tc.x.i_val = libivars[i].val;
527 if (add_named_var_to_ctxt (lexic, libivars[i].name, &tc) == NULL)
528 {
529 nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
530 libivars[i].name);
531 continue;
532 }
533 }
534
535 // Initialize constant string terms
536 tc.type = CONST_DATA;
537 for (i = 0; i < sizeof (libsvars) / sizeof (libsvars[0]) - 1; i++)
538 {
539 tc.x.str_val = (char *) libsvars[i].val;
540 tc.size = strlen (libsvars[i].val);
541 if (add_named_var_to_ctxt (lexic, libsvars[i].name, &tc) == NULL)
542 {
543 nasl_perror (lexic, "init_nasl_library: could not define var '%s'\n",
544 libsvars[i].name);
545 continue;
546 }
547 }
548
549 // Add the "NULL" variable
550 if (add_named_var_to_ctxt (lexic, "NULL", NULL) == NULL)
551 nasl_perror (lexic, "init_nasl_library: could not define var 'NULL'\n");
552}
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition nasl_debug.c:105
const char * val
Definition nasl_init.c:441
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition nasl_var.c:810
@ CONST_DATA
Definition nasl_tree.h:82
@ CONST_INT
Definition nasl_tree.h:79
struct TC tree_cell
long int i_val
Definition nasl_tree.h:104
long int size
Definition nasl_tree.h:99
union TC::@332262321161220155002104006201360276211317150140 x
char * str_val
Definition nasl_tree.h:103
short type
Definition nasl_tree.h:95