37 hash_str (
const char *s)
52 for (c = ctxt; c != NULL; c = c->
up_ctxt)
62 typedef int(*
qsortcmp)(
const void *,
const void *);
67 int h = hash_str (fname);
72 if (get_func (lexic, fname, h) != NULL)
75 "insert_nasl_func: function '%s' is already defined\n",
82 if (decl_node != NULL && decl_node !=
FAKE_CELL)
84 for (pc = decl_node->
link[0]; pc != NULL; pc = pc->
link[0])
91 for (i = 0, pc = decl_node->
link[0]; pc != NULL; pc = pc->
link[0])
102 if (decl_node != NULL)
113 if (decl_node == NULL || decl_node ==
FAKE_CELL)
115 nasl_perror (lexic,
"Cannot insert NULL or FAKE cell as function\n");
128 int h = hash_str (
name);
131 if ((f = get_func (ctxt,
name, h)) != NULL)
138 stringcompare (
const void *a,
const void *b)
140 char **s1 = (
char **) a, **s2 = (
char **) b;
141 return strcmp (*s1, *s2);
152 int nb_u = 0, nb_n = 0, nb_a = 0;
153 tree_cell *pc = NULL, *pc2 = NULL, *retc = NULL;
155 char *trace_buf = NULL;
156 char *temp_funname = NULL, *tmp_filename = NULL;
157 int trace_buf_len = 0, tn;
158 #define TRACE_BUF_SZ 255 181 for (pc = arg_list; pc != NULL; pc = pc->
link[1])
189 stringcompare) != NULL)
195 "Too many args for function '%s' [%dN+%dU > %dN+%dU]\n",
203 for (nb_u = 0, pc = arg_list; pc != NULL; pc = pc->
link[1])
226 tn = snprintf (trace_buf + trace_buf_len,
228 nb_a > 0 ?
", " :
"", nb_u,
242 tn = snprintf (trace_buf + trace_buf_len,
244 nb_a > 0 ?
", " :
"", pc->
x.
str_val,
259 nasl_trace (lexic,
"NASL> %s ...)\n", trace_buf);
281 g_free (temp_funname);
285 g_free (tmp_filename);
291 "nasl_func_call: nasl_exec(%s) returns NULL or FAKE value, but context disagrees. Fixing...\n",
306 "nasl_func_call: return value from %s is not atomic!\n",
tree_cell * nasl_return(lex_ctxt *ctxt, tree_cell *retv)
int nasl_trace_enabled(void)
Checks if the nasl_trace_fp is set.
const char * nasl_get_filename(const char *function)
void ref_cell(tree_cell *c)
tree_cell * copy_ref_array(const tree_cell *c1)
void nasl_dump_tree(const tree_cell *c)
tree_cell * cell2atom(lex_ctxt *lexic, tree_cell *c1)
void deref_cell(tree_cell *c)
struct st_nasl_func * next_func
void nasl_set_filename(const char *filename)
const char * nasl_get_function_name()
void free_lex_ctxt(lex_ctxt *c)
void nasl_trace(lex_ctxt *lexic, char *msg,...)
Prints debug message in printf fashion to nasl_trace_fp if it exists.
nasl_func * insert_nasl_func(lex_ctxt *lexic, const char *fname, tree_cell *decl_node)
nasl_func * functions[FUNC_NAME_HASH]
#define FUNC_FLAG_INTERNAL
lex_ctxt * init_empty_lex_ctxt()
int nasl_is_leaf(const tree_cell *pc)
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
char * dump_cell_val(const tree_cell *c)
void nasl_perror(lex_ctxt *lexic, char *msg,...)
tree_cell * nasl_func_call(lex_ctxt *lexic, const nasl_func *f, tree_cell *arg_list)
void free_func_chain(nasl_func *f)
void nasl_set_function_name(const char *funname)
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
int hash_str2(const char *s, int n)
struct arglist * script_infos
int(* qsortcmp)(const void *, const void *)
nasl_func * get_func_ref_by_name(lex_ctxt *ctxt, const char *name)
tree_cell * nasl_exec(lex_ctxt *lexic, tree_cell *st)
Execute a parse tree.
struct struct_lex_ctxt * up_ctxt
tree_cell * decl_nasl_func(lex_ctxt *lexic, tree_cell *decl_node)