OpenVAS Scanner  7.0.1~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_expr_cell (int, int, tree_cell *, tree_cell *);
124 tree_cell *
125 alloc_RE_cell (int, int, tree_cell *, char *);
126 tree_cell *
127 alloc_typed_cell (int);
128 int
129 nasl_is_leaf (const tree_cell *);
130 char *
131 get_line_nb (const tree_cell *);
132 tree_cell *
133 dup_cell (const tree_cell *);
134 void
135 nasl_dump_tree (const tree_cell *);
136 void
137 ref_cell (tree_cell *);
138 void
140 const char *
141 nasl_type_name (int);
142 int
143 cell_type (const tree_cell *);
144 
145 char *
146 dump_cell_val (const tree_cell *);
147 
148 #endif
struct TC * link[4]
Definition: nasl_tree.h:116
void deref_cell(tree_cell *)
Definition: nasl_tree.c:192
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *)
Definition: nasl_tree.c:48
const char * nasl_type_name(int)
Definition: nasl_tree.c:357
short type
Definition: nasl_tree.h:106
char * str_val
Definition: nasl_tree.h:112
short ref_count
Definition: nasl_tree.h:108
short line_nb
Definition: nasl_tree.h:107
void * ref_val
Definition: nasl_tree.h:114
void ref_cell(tree_cell *)
Definition: nasl_tree.c:178
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:400
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:377
Definition: nasl_tree.h:104
union TC::@2 x
node_type
Definition: nasl_tree.h:22
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:390
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
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:74
struct TC tree_cell
int cell_type(const tree_cell *)
Definition: nasl_tree.c:418
int size
Definition: nasl_tree.h:109