31 for (p = s; *p !=
'\0'; p++)
32 h = (h << 3) + (
unsigned char) *p;
50 nasl_perror (ctxt,
"Negative integer index %d are not supported yet!\n",
57 if (v != NULL || !create)
110 for (c = ctxt; c != NULL; c = c->
up_ctxt)
144 nasl_perror (ctxt,
"Negative index %d is invalid for array\n", num);
181 if (strcmp (
name,
"_FCT_ANON_ARGS") == 0)
199#ifdef ALL_VARIABLES_NAMED
200 if (v->av_name != NULL)
203 snprintf (str,
sizeof (str),
"[%p]", (
void *) v);
215 if (strcmp (
name,
"_FCT_ANON_ARGS") == 0)
236 memset (&idx0,
'\0',
sizeof (idx0));
253 strcmp (
name,
"_FCT_ANON_ARGS"));
259 return var2cell (nv != NULL ? &nv->
u : NULL);
263 "get_array_elem: unhandled index type 0x%x for "
271 nasl_perror (ctxt,
"get_array_elem: variable %s is an integer\n",
name);
283 "get_array_elem: requesting character after end "
284 "of string %s (%d >= %d)\n",
297 "get_array_elem: Negative index (%d) passed to "
314 "get_array_elem: Cannot use a non integer index"
315 " (type 0x%x) in string. Variable: %s\n",
322 nasl_perror (ctxt,
"Severe bug: unknown variable type 0x%x %s\n",
347 for (i = 0; i < a->
max_idx; i++)
501 if (a1 == NULL || a2 == NULL)
503 nasl_perror (NULL,
"Internal inconsistency - null array\n");
513 for (i = 0; i < a2->
max_idx; i++)
516 if (copy_named && a2->
hash_elt != NULL)
607 nasl_perror (NULL,
"Cannot affect rvalue 0x%x to variable\n",
620 memset (v1, 0,
sizeof (*v1));
640 p = g_malloc0 (rval->
size + 1);
703 nasl_perror (NULL,
"nasl_effect: invalid lvalue\n");
709 nasl_perror (NULL,
"nasl_affect: cannot affect to non variable %s\n",
762 for (t = vars; t != NULL; t = t->
link[0])
764 nasl_perror (lexic,
"decl_local_variables: null name!\n");
792 nasl_perror (lexic,
"Cannot add existing variable %d\n", num);
840 "nasl_read_var_ref: cannot read NULL or FAKE cell\n");
846 "nasl_read_var_ref: argument (type=%d) is not REF_VAR %s\n",
874 nasl_perror (lexic,
"nasl_read_var_ref: Bad string length fixed\n");
907 nasl_perror (lexic,
"nasl_read_var_ref: unhandled variable type %d\n",
910 nasl_trace (lexic,
"NASL> %s -> ???? (Var type %d)\n",
922 int old_val = 0, new_val;
928 lexic,
"nasl_incr_variable: argument (type=%d) is not REF_VAR %s\n",
951 "nasl_incr_variable: variable %s has bad type %d %s\n",
955 new_val = old_val +
val;
962 retc->
x.
i_val = pre ? new_val : old_val;
1000 str = g_string_new (
"[ ");
1002 for (i = 0; i < a->
max_idx; i++)
1006 g_string_append (str,
", ");
1011 g_string_append_printf (str,
"%d: %ld", i, u->
v.
v_int);
1016 g_string_append_printf (str,
"%d: '%s'", i, u->
v.
v_str.
s_val);
1018 g_string_append_printf (str,
"%d: '%s'...", i,
1022 g_string_append_printf (str,
"%d: ????", i);
1034 g_string_append (str,
", ");
1039 g_string_append_printf (str,
"%s: %ld", v->
var_name,
1045 g_string_append_printf (str,
"%s: '%s'", v->
var_name,
1048 g_string_append_printf (str,
"%s: '%s'...", v->
var_name,
1052 g_string_append_printf (str,
"%s: ????", v->
var_name);
1057 g_string_append (str,
" ]");
1058 return g_string_free (str, FALSE);
1197 nasl_perror (ctxt,
"nasl_array_iterator: unhandled type %d (0x%x)\n",
1209 if (it == NULL || it->
a == NULL)
1230 while (it->
v == NULL)
1239 while (it->
v == NULL);
1252 NULL,
"add_var_to_list: negative index are not (yet) supported\n");
1306 for (i = a->
max_idx - 1; i >= 0; i--)
1335 for (n = 0, c = el; c != NULL; c = c->
link[1])
1347 for (n = 0, c = el; c != NULL; c = c->
link[1])
1374 "make_array_from_list: unhandled cell type %s at "
int nasl_trace_enabled(void)
Checks if the nasl_trace_fp is set.
void nasl_trace(lex_ctxt *lexic, char *msg,...)
Prints debug message in printf fashion to nasl_trace_fp if it exists.
void nasl_perror(lex_ctxt *lexic, char *msg,...)
struct struct_lex_ctxt lex_ctxt
const char * nasl_type_name(int t)
tree_cell * alloc_expr_cell(int lnb, int t, tree_cell *l, tree_cell *r)
tree_cell * alloc_typed_cell(int typ)
char * get_line_nb(const tree_cell *c)
void deref_cell(tree_cell *c)
static void copy_array(nasl_array *, const nasl_array *, int)
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *lexic, const char *name, tree_cell *val)
int hash_str2(const char *s, int n)
int get_var_type_by_num(lex_ctxt *lexic, int num)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
static anon_nasl_var * create_anon_var(tree_cell *val)
tree_cell * decl_global_variables(lex_ctxt *lexic, tree_cell *vars)
static long int get_var_size(const anon_nasl_var *v)
static anon_nasl_var * get_var_ref_by_num(lex_ctxt *ctxt, int num)
static named_nasl_var * get_var_ref_by_name(lex_ctxt *ctxt, const char *name, int climb)
This function climbs up in the context list.
static void free_var_chain(named_nasl_var *)
static void free_anon_var(anon_nasl_var *)
int add_var_to_array(nasl_array *a, char *name, const anon_nasl_var *v)
static int hash_str(const char *s)
named_nasl_var * get_var_by_name(nasl_array *a, const char *s)
tree_cell * decl_local_variables(lex_ctxt *lexic, tree_cell *vars)
nasl_iterator nasl_array_iterator(void *ctxt, tree_cell *c)
static void clear_anon_var(anon_nasl_var *v)
const char * var2str(anon_nasl_var *v)
anon_nasl_var * nasl_get_var_by_num(void *ctxt, nasl_array *a, int num, int create)
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *lexic, int num, tree_cell *val)
static named_nasl_var * create_named_var(const char *name, tree_cell *val)
static anon_nasl_var * dup_anon_var(const anon_nasl_var *v)
tree_cell * nasl_read_var_ref(lex_ctxt *lexic, tree_cell *tc)
tree_cell * get_variable_by_name(lex_ctxt *ctxt, const char *name)
long int get_int_var_by_num(lex_ctxt *lexic, int num, int defval)
tree_cell * make_array_from_elems(tree_cell *el)
int array_max_index(nasl_array *a)
int add_var_to_list(nasl_array *a, int i, const anon_nasl_var *v)
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 * copy_ref_array(const tree_cell *c1)
char * get_str_var_by_num(lex_ctxt *lexic, int num)
tree_cell * nasl_affect(tree_cell *lval, tree_cell *rval)
tree_cell * var2cell(anon_nasl_var *v)
static const char * get_var_name(anon_nasl_var *v)
static tree_cell * affect_to_anon_var(anon_nasl_var *v1, tree_cell *rval)
char * array2str(const nasl_array *a)
int get_var_type_by_name(lex_ctxt *lexic, const char *name)
static named_nasl_var * dup_named_var(const named_nasl_var *v)
char * get_str_var_by_name(lex_ctxt *lexic, const char *name)
void free_array(nasl_array *a)
long int get_int_var_by_name(lex_ctxt *lexic, const char *name, int defval)
static void copy_anon_var(anon_nasl_var *v1, const anon_nasl_var *v2)
long int get_var_size_by_name(lex_ctxt *lexic, const char *name)
long int get_var_size_by_num(lex_ctxt *lexic, int num)
tree_cell * get_array_elem(lex_ctxt *ctxt, const char *name, tree_cell *idx)
static long int var2int(anon_nasl_var *v, int defval)
struct st_a_nasl_var anon_nasl_var
struct st_nasl_array nasl_array
struct st_n_nasl_var named_nasl_var
union TC::@332262321161220155002104006201360276211317150140 x
union st_a_nasl_var::@154137074032032170165360023270032033276061363156 v
struct st_n_nasl_var * next_var
struct st_n_nasl_var ** hash_elt
struct st_a_nasl_var ** num_elt
struct struct_lex_ctxt * up_ctxt