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