OpenVAS Libraries  8.0.3
nasl_lex_ctxt.h
Go to the documentation of this file.
1 /* Nessus Attack Scripting Language
2  *
3  * Copyright (C) 2002 - 2003 Michel Arboi and Renaud Deraison
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2,
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _NASL_LEX_CTXT_H
20 #define _NASL_LEX_CTXT_H
21 
22 /* for tree_cell */
23 #include "nasl_tree.h"
24 
25 /* for nasl_array */
26 #include "nasl_var.h"
27 
28 /* for nasl_func */
29 #include "nasl_func.h"
30 
31 typedef struct struct_lex_ctxt
32 {
34  tree_cell *ret_val; /* return value or exit flag */
35  unsigned fct_ctxt:1; /* This is a function context */
36  unsigned break_flag:1; /* Break from loop */
37  unsigned cont_flag:1; /* Next iteration in loop */
40  const char *oid;
42  int line_nb;
43  /* Named variables hash set + anonymous variables array */
45  /* Functions hash set */
47 } lex_ctxt;
48 
49 #define NASL_COMPAT_LEX_CTXT "NASL compat lex context"
50 
52 void free_lex_ctxt (lex_ctxt *);
53 
54 void dump_ctxt (lex_ctxt *);
55 
56 nasl_func *get_func_ref_by_name (lex_ctxt *, const char *);
58 nasl_func *insert_nasl_func (lex_ctxt *, const char *, tree_cell *);
60 
61 tree_cell *get_variable_by_name (lex_ctxt *, const char *);
62 tree_cell *get_array_elem (lex_ctxt *, const char * /*array name */ ,
63  tree_cell *);
69 
72 
74 
75 
76 int get_int_var_by_num (lex_ctxt *, int, int);
77 char *get_str_var_by_num (lex_ctxt *, int);
78 int get_int_var_by_name (lex_ctxt *, const char *, int);
79 int get_int_local_var_by_name (lex_ctxt *, const char *, int);
80 char *get_str_var_by_name (lex_ctxt *, const char *);
81 char *get_str_local_var_by_name (lex_ctxt *, const char *);
82 
83 int get_var_size_by_name (lex_ctxt *, const char *);
84 int get_local_var_size_by_name (lex_ctxt *, const char *);
85 int get_local_var_type_by_name (lex_ctxt *, const char *);
86 
87 
88 int get_var_size_by_num (lex_ctxt *, int);
89 int get_var_type_by_num (lex_ctxt *, int);
90 #endif
nasl_array ctx_vars
Definition: nasl_lex_ctxt.h:44
int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1271
Definition: nasl_var.h:66
int get_int_local_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1278
unsigned always_authenticated
Definition: nasl_lex_ctxt.h:38
tree_cell * nasl_func_call(lex_ctxt *, const nasl_func *, tree_cell *)
Definition: nasl_func.c:147
Definition: nasl_func.h:30
void dump_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:64
#define FUNC_NAME_HASH
Definition: nasl_func.h:22
Definition: nasl_var.h:52
lex_ctxt * init_empty_lex_ctxt(void)
Definition: nasl_lex_ctxt.c:29
int line_nb
Definition: nasl_lex_ctxt.h:42
int recv_timeout
Definition: nasl_lex_ctxt.h:41
int get_local_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1336
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1300
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1293
tree_cell * nasl_incr_variable(lex_ctxt *, tree_cell *, int, int)
Definition: nasl_var.c:1030
nasl_func * functions[FUNC_NAME_HASH]
Definition: nasl_lex_ctxt.h:46
tree_cell * decl_local_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:849
tree_cell * get_variable_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:205
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:904
Definition: nasl_tree.h:105
int get_var_size_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1343
Definition: nasl_lex_ctxt.h:31
tree_cell * decl_nasl_func(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:111
unsigned fct_ctxt
Definition: nasl_lex_ctxt.h:35
unsigned break_flag
Definition: nasl_lex_ctxt.h:36
int get_local_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1360
nasl_func * insert_nasl_func(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_func.c:65
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1286
Definition: arglists.h:29
struct struct_lex_ctxt lex_ctxt
nasl_func * get_func_ref_by_name(lex_ctxt *, const char *)
Definition: nasl_func.c:126
int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1264
tree_cell * get_array_elem(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:237
tree_cell * ret_val
Definition: nasl_lex_ctxt.h:34
tree_cell * nasl_return(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:316
unsigned cont_flag
Definition: nasl_lex_ctxt.h:37
tree_cell * nasl_read_var_ref(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:931
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
Definition: nasl_var.c:872
const char * oid
Definition: nasl_lex_ctxt.h:40
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Definition: nasl_var.h:41
tree_cell * cell2atom(lex_ctxt *, tree_cell *)
Definition: exec.c:192
int get_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1329
tree_cell * decl_global_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:862
struct struct_lex_ctxt * up_ctxt
Definition: nasl_lex_ctxt.h:33
void free_lex_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:46
int get_var_type_by_num(lex_ctxt *, int)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
Definition: nasl_var.c:1353