OpenVAS Scanner  7.0.1~git
nasl_lex_ctxt.h
Go to the documentation of this file.
1 /* Based on work Copyright (C) 2002 - 2003 Michel Arboi and Renaud Deraison
2  *
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 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 St, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _NASL_LEX_CTXT_H
20 #define _NASL_LEX_CTXT_H
21 
22 #include <glib.h>
23 
24 /* for tree_cell */
25 #include "nasl_tree.h"
26 
27 /* for nasl_array */
28 #include "nasl_var.h"
29 
30 /* for nasl_func */
31 #include "nasl_func.h"
32 
33 typedef struct struct_lex_ctxt
34 {
36  tree_cell *ret_val; /* return value or exit flag */
37  unsigned fct_ctxt : 1; /* This is a function context */
38  unsigned break_flag : 1; /* Break from loop */
39  unsigned cont_flag : 1; /* Next iteration in loop */
40  unsigned always_signed : 1;
42  const char *oid;
44  int line_nb;
45  /* Named variables hash set + anonymous variables array */
47  /* Functions hash table */
48  GHashTable *functions;
49 } lex_ctxt;
50 
51 #define NASL_COMPAT_LEX_CTXT "NASL compat lex context"
52 
53 lex_ctxt *
54 init_empty_lex_ctxt (void);
55 
56 void
58 
59 void
61 
62 nasl_func *
63 get_func_ref_by_name (lex_ctxt *, const char *);
64 
65 tree_cell *
67 
68 nasl_func *
69 insert_nasl_func (lex_ctxt *, const char *, tree_cell *, int);
70 
71 tree_cell *
73 
74 tree_cell *
75 get_variable_by_name (lex_ctxt *, const char *);
76 
77 tree_cell *
78 get_array_elem (lex_ctxt *, const char * /*array name */, tree_cell *);
79 
82 
84 add_named_var_to_ctxt (lex_ctxt *, const char *, tree_cell *);
85 
86 tree_cell *
88 
89 tree_cell *
90 nasl_incr_variable (lex_ctxt *, tree_cell *, int, int);
91 
92 tree_cell *
94 
95 tree_cell *
97 
98 tree_cell *
100 
101 tree_cell *
103 
104 long int
105 get_int_var_by_num (lex_ctxt *, int, int);
106 
107 char *
109 
110 long int
111 get_int_var_by_name (lex_ctxt *, const char *, int);
112 
113 char *
114 get_str_var_by_name (lex_ctxt *, const char *);
115 
116 int
117 get_var_size_by_name (lex_ctxt *, const char *);
118 
119 int
120 get_var_type_by_name (lex_ctxt *, const char *);
121 
122 int
124 
125 int
127 
128 #endif
get_func_ref_by_name
nasl_func * get_func_ref_by_name(lex_ctxt *, const char *)
Definition: nasl_func.c:94
struct_lex_ctxt::always_signed
unsigned always_signed
Definition: nasl_lex_ctxt.h:40
st_a_nasl_var
Definition: nasl_var.h:50
nasl_return
tree_cell * nasl_return(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:239
struct_lex_ctxt::ctx_vars
nasl_array ctx_vars
Definition: nasl_lex_ctxt.h:46
script_infos
Definition: scanneraux.h:43
struct_lex_ctxt::line_nb
int line_nb
Definition: nasl_lex_ctxt.h:44
get_var_size_by_name
int get_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1147
add_named_var_to_ctxt
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:825
add_numbered_var_to_ctxt
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
Definition: nasl_var.c:796
insert_nasl_func
nasl_func * insert_nasl_func(lex_ctxt *, const char *, tree_cell *, int)
Definition: nasl_func.c:53
struct_lex_ctxt::cont_flag
unsigned cont_flag
Definition: nasl_lex_ctxt.h:39
st_n_nasl_var
Definition: nasl_var.h:65
struct_lex_ctxt::functions
GHashTable * functions
Definition: nasl_lex_ctxt.h:48
st_nasl_func
Definition: nasl_func.h:25
decl_global_variables
tree_cell * decl_global_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:786
decl_nasl_func
tree_cell * decl_nasl_func(lex_ctxt *, tree_cell *, int)
Definition: nasl_func.c:78
nasl_read_var_ref
tree_cell * nasl_read_var_ref(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:847
dump_ctxt
void dump_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:64
get_str_var_by_name
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1127
nasl_func_call
tree_cell * nasl_func_call(lex_ctxt *, const nasl_func *, tree_cell *)
Definition: nasl_func.c:107
st_nasl_array
Definition: nasl_var.h:43
struct_lex_ctxt::up_ctxt
struct struct_lex_ctxt * up_ctxt
Definition: nasl_lex_ctxt.h:35
get_var_type_by_name
int get_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1171
struct_lex_ctxt::break_flag
unsigned break_flag
Definition: nasl_lex_ctxt.h:38
struct_lex_ctxt::oid
const char * oid
Definition: nasl_lex_ctxt.h:42
get_int_var_by_name
long int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1113
struct_lex_ctxt::fct_ctxt
unsigned fct_ctxt
Definition: nasl_lex_ctxt.h:37
nasl_func.h
get_int_var_by_num
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1106
get_str_var_by_num
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1120
struct_lex_ctxt::script_infos
struct script_infos * script_infos
Definition: nasl_lex_ctxt.h:41
get_array_elem
tree_cell * get_array_elem(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:223
TC
Definition: nasl_tree.h:104
struct_lex_ctxt
Definition: nasl_lex_ctxt.h:33
nasl_var.h
get_var_size_by_num
int get_var_size_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1154
struct_lex_ctxt::recv_timeout
int recv_timeout
Definition: nasl_lex_ctxt.h:43
get_var_type_by_num
int get_var_type_by_num(lex_ctxt *, int)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
Definition: nasl_var.c:1164
nasl_incr_variable
tree_cell * nasl_incr_variable(lex_ctxt *, tree_cell *, int, int)
Definition: nasl_var.c:933
get_variable_by_name
tree_cell * get_variable_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:191
nasl_tree.h
decl_local_variables
tree_cell * decl_local_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:773
init_empty_lex_ctxt
lex_ctxt * init_empty_lex_ctxt(void)
Definition: nasl_lex_ctxt.c:32
free_lex_ctxt
void free_lex_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:55
cell2atom
tree_cell * cell2atom(lex_ctxt *, tree_cell *)
Definition: exec.c:205
lex_ctxt
struct struct_lex_ctxt lex_ctxt
struct_lex_ctxt::ret_val
tree_cell * ret_val
Definition: nasl_lex_ctxt.h:36