OpenVAS Libraries  7.0.7
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