OpenVAS Scanner  6.0.1
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
int get_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1175
nasl_func * insert_nasl_func(lex_ctxt *, const char *, tree_cell *, int)
Definition: nasl_func.c:53
nasl_array ctx_vars
Definition: nasl_lex_ctxt.h:46
Definition: nasl_var.h:65
tree_cell * nasl_func_call(lex_ctxt *, const nasl_func *, tree_cell *)
Definition: nasl_func.c:107
Definition: nasl_func.h:25
void dump_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:64
Definition: nasl_var.h:50
lex_ctxt * init_empty_lex_ctxt(void)
Definition: nasl_lex_ctxt.c:32
int line_nb
Definition: nasl_lex_ctxt.h:44
int recv_timeout
Definition: nasl_lex_ctxt.h:43
struct script_infos * script_infos
Definition: nasl_lex_ctxt.h:41
tree_cell * decl_nasl_func(lex_ctxt *, tree_cell *, int)
Definition: nasl_func.c:78
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1131
tree_cell * nasl_incr_variable(lex_ctxt *, tree_cell *, int, int)
Definition: nasl_var.c:936
tree_cell * decl_local_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:776
tree_cell * get_variable_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:193
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:828
Definition: nasl_tree.h:104
int get_var_size_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1158
Definition: nasl_lex_ctxt.h:33
unsigned fct_ctxt
Definition: nasl_lex_ctxt.h:37
unsigned break_flag
Definition: nasl_lex_ctxt.h:38
unsigned always_signed
Definition: nasl_lex_ctxt.h:40
GHashTable * functions
Definition: nasl_lex_ctxt.h:48
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1110
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1124
struct struct_lex_ctxt lex_ctxt
nasl_func * get_func_ref_by_name(lex_ctxt *, const char *)
Definition: nasl_func.c:94
long int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1117
tree_cell * get_array_elem(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:225
tree_cell * ret_val
Definition: nasl_lex_ctxt.h:36
tree_cell * nasl_return(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:239
unsigned cont_flag
Definition: nasl_lex_ctxt.h:39
tree_cell * nasl_read_var_ref(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:850
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
Definition: nasl_var.c:799
const char * oid
Definition: nasl_lex_ctxt.h:42
Definition: nasl_var.h:43
Definition: scanneraux.h:44
tree_cell * cell2atom(lex_ctxt *, tree_cell *)
Definition: exec.c:205
int get_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1151
tree_cell * decl_global_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:789
struct struct_lex_ctxt * up_ctxt
Definition: nasl_lex_ctxt.h:35
void free_lex_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:55
int get_var_type_by_num(lex_ctxt *, int)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
Definition: nasl_var.c:1168