OpenVAS Scanner  6.0.0~git
nasl_tree.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 NASLTREE_H_INCLUDED
20 #define NASLTREE_H_INCLUDED
21 
23 {
25  NODE_IF_ELSE, /* [0] = cond, [1] = if_block, [2] = else_block */
26  NODE_INSTR_L, /* Block. [0] = first instr, [1] = tail */
27  NODE_FOR, /* [0] = start expr, [1] = cond, [2] = end_expr, [3] = block */
28  NODE_WHILE, /* [0] = cond, [1] = block */
31  NODE_REPEATED, /* [0] = func call, [1] = repeat nb */
32  NODE_FUN_DEF, /* [0] = argdecl, [1] = block */
33  NODE_FUN_CALL, /* [0] = script_infos */
34  NODE_DECL, /* [0] = next arg in list */
35  NODE_ARG, /* val = name can be NULL, [0] = val, [1] = next arg */
36  NODE_RETURN, /* ret val */
39 
40  NODE_ARRAY_EL, /* val = array name, [0] = index */
41  NODE_AFF, /* [0] = lvalue, [1] = rvalue */
42  NODE_VAR, /* val = variable name */
43  NODE_LOCAL, /* [0] = argdecl */
45 
51 
55 
59 
67 
77 
82 
89 
91  CONST_STR, /* "impure" string */
92 
93  CONST_DATA, /* binary data / "pure" string */
94  CONST_REGEX, /* Compiled regex */
95 
96  ARRAY_ELEM, /* val = char index or NULL if integer,
97  * [0] = value, [1] = next element */
98  /* For exec only */
102 };
103 
104 typedef struct TC
105 {
106  short type;
107  short line_nb;
108  short ref_count; /* Cell is freed when count reaches zero */
109  int size;
110  union
111  {
112  char *str_val;
113  long int i_val;
114  void *ref_val; /* internal reference */
115  } x;
116  struct TC *link[4];
117 } tree_cell;
118 
119 #define FAKE_CELL ((void *) 1)
120 #define EXIT_CELL ((void *) 2)
121 
122 tree_cell *
123 alloc_tree_cell (void);
124 tree_cell *
125 alloc_expr_cell (int, int, tree_cell *, tree_cell *);
126 tree_cell *
127 alloc_RE_cell (int, int, tree_cell *, char *);
128 tree_cell *
129 alloc_typed_cell (int);
130 int
131 nasl_is_leaf (const tree_cell *);
132 char *
133 get_line_nb (const tree_cell *);
134 tree_cell *
135 dup_cell (const tree_cell *);
136 void
137 nasl_dump_tree (const tree_cell *);
138 void
139 ref_cell (tree_cell *);
140 void
142 const char *
143 nasl_type_name (int);
144 int
145 cell_type (const tree_cell *);
146 
147 char *
148 dump_cell_val (const tree_cell *);
149 
150 #endif
Definition: nasl_tree.h:37
struct TC * link[4]
Definition: nasl_tree.h:116
Definition: nasl_tree.h:47
Definition: nasl_tree.h:85
Definition: nasl_tree.h:24
Definition: nasl_tree.h:41
Definition: nasl_tree.h:66
Definition: nasl_tree.h:52
void deref_cell(tree_cell *)
Definition: nasl_tree.c:192
Definition: nasl_tree.h:70
Definition: nasl_tree.h:63
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *)
Definition: nasl_tree.c:48
Definition: nasl_tree.h:30
Definition: nasl_tree.h:40
const char * nasl_type_name(int)
Definition: nasl_tree.c:357
Definition: nasl_tree.h:44
Definition: nasl_tree.h:43
short type
Definition: nasl_tree.h:106
char * str_val
Definition: nasl_tree.h:112
Definition: nasl_tree.h:32
Definition: nasl_tree.h:71
short ref_count
Definition: nasl_tree.h:108
Definition: nasl_tree.h:76
Definition: nasl_tree.h:33
tree_cell * alloc_tree_cell(void)
Definition: nasl_tree.c:34
short line_nb
Definition: nasl_tree.h:107
Definition: nasl_tree.h:96
Definition: nasl_tree.h:101
Definition: nasl_tree.h:73
Definition: nasl_tree.h:28
Definition: nasl_tree.h:36
Definition: nasl_tree.h:49
void * ref_val
Definition: nasl_tree.h:114
Definition: nasl_tree.h:91
Definition: nasl_tree.h:42
void ref_cell(tree_cell *)
Definition: nasl_tree.c:178
Definition: nasl_tree.h:62
Definition: nasl_tree.h:84
Definition: nasl_tree.h:31
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:400
Definition: nasl_tree.h:65
Definition: nasl_tree.h:53
Definition: nasl_tree.h:26
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:377
Definition: nasl_tree.h:29
Definition: nasl_tree.h:75
Definition: nasl_tree.h:104
union TC::@2 x
Definition: nasl_tree.h:60
node_type
Definition: nasl_tree.h:22
Definition: nasl_tree.h:58
Definition: nasl_tree.h:48
Definition: nasl_tree.h:64
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:390
Definition: nasl_tree.h:81
Definition: nasl_tree.h:83
Definition: nasl_tree.h:68
Definition: nasl_tree.h:25
Definition: nasl_tree.h:86
char * dump_cell_val(const tree_cell *)
Definition: nasl_tree.c:245
tree_cell * dup_cell(const tree_cell *)
Definition: nasl_tree.c:86
tree_cell * alloc_typed_cell(int)
Definition: nasl_tree.c:40
long int i_val
Definition: nasl_tree.h:113
Definition: nasl_tree.h:38
Definition: nasl_tree.h:94
Definition: nasl_tree.h:57
Definition: nasl_tree.h:27
Definition: nasl_tree.h:61
Definition: nasl_tree.h:99
Definition: nasl_tree.h:90
Definition: nasl_tree.h:78
Definition: nasl_tree.h:72
Definition: nasl_tree.h:74
Definition: nasl_tree.h:69
Definition: nasl_tree.h:46
Definition: nasl_tree.h:80
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:74
Definition: nasl_tree.h:54
struct TC tree_cell
Definition: nasl_tree.h:88
Definition: nasl_tree.h:100
Definition: nasl_tree.h:93
int cell_type(const tree_cell *)
Definition: nasl_tree.c:418
Definition: nasl_tree.h:79
Definition: nasl_tree.h:34
Definition: nasl_tree.h:87
Definition: nasl_tree.h:35
Definition: nasl_tree.h:56
int size
Definition: nasl_tree.h:109
Definition: nasl_tree.h:50