OpenVAS Scanner 23.32.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 582 of file nasl_init.c.

583{
584 int i;
585 for (i = 0; libivars[i].name != NULL; i++)
586 *list = g_slist_append (*list, g_strdup (libivars[i].name));
587 for (i = 0; libsvars[i].name != NULL; i++)
588 *list = g_slist_append (*list, g_strdup (libsvars[i].name));
589}
static struct @260365312376163127012272224246062244353077307342 libsvars[]
const char * name
Definition nasl_init.c:439
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 514 of file nasl_init.c.

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