OpenVAS Libraries  9.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 */
102  DYN_ARRAY
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  long int i_val;
115  void *ref_val; /* internal reference */
116  } x;
117  struct TC *link[4];
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
NODE_LOCAL
@ NODE_LOCAL
Definition: nasl_tree.h:44
EXPR_AND
@ EXPR_AND
Definition: nasl_tree.h:57
deref_cell
void deref_cell(tree_cell *)
Definition: nasl_tree.c:202
EXPR_BIT_XOR
@ EXPR_BIT_XOR
Definition: nasl_tree.h:71
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:94
nasl_type_name
const char * nasl_type_name(int)
Definition: nasl_tree.c:420
alloc_typed_cell
tree_cell * alloc_typed_cell(int)
Definition: nasl_tree.c:53
NODE_MINUS_EQ
@ NODE_MINUS_EQ
Definition: nasl_tree.h:48
NODE_WHILE
@ NODE_WHILE
Definition: nasl_tree.h:29
NODE_DECL
@ NODE_DECL
Definition: nasl_tree.h:35
NODE_RETURN
@ NODE_RETURN
Definition: nasl_tree.h:37
TC::str_val
char * str_val
Definition: nasl_tree.h:113
NODE_GLOBAL
@ NODE_GLOBAL
Definition: nasl_tree.h:45
NODE_AFF
@ NODE_AFF
Definition: nasl_tree.h:42
NODE_DIV_EQ
@ NODE_DIV_EQ
Definition: nasl_tree.h:50
NODE_L_SHIFT_EQ
@ NODE_L_SHIFT_EQ
Definition: nasl_tree.h:53
EXPR_R_USHIFT
@ EXPR_R_USHIFT
Definition: nasl_tree.h:77
CONST_STR
@ CONST_STR
Definition: nasl_tree.h:92
dup_cell
tree_cell * dup_cell(const tree_cell *)
Definition: nasl_tree.c:96
NODE_REPEAT_UNTIL
@ NODE_REPEAT_UNTIL
Definition: nasl_tree.h:31
nasl_dump_tree
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:439
NODE_ARRAY_EL
@ NODE_ARRAY_EL
Definition: nasl_tree.h:41
DYN_ARRAY
@ DYN_ARRAY
Definition: nasl_tree.h:102
alloc_tree_cell
tree_cell * alloc_tree_cell(int, char *)
Definition: nasl_tree.c:37
get_line_nb
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:452
nasl_is_leaf
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:463
EXPR_BIT_NOT
@ EXPR_BIT_NOT
Definition: nasl_tree.h:72
dump_cell_val
char * dump_cell_val(const tree_cell *)
Definition: nasl_tree.c:301
NODE_FUN_DEF
@ NODE_FUN_DEF
Definition: nasl_tree.h:33
EXPR_U_MINUS
@ EXPR_U_MINUS
Definition: nasl_tree.h:63
NODE_R_SHIFT_EQ
@ NODE_R_SHIFT_EQ
Definition: nasl_tree.h:54
EXPR_MODULO
@ EXPR_MODULO
Definition: nasl_tree.h:66
NODE_FUN_CALL
@ NODE_FUN_CALL
Definition: nasl_tree.h:34
COMP_LE
@ COMP_LE
Definition: nasl_tree.h:85
ARRAY_ELEM
@ ARRAY_ELEM
Definition: nasl_tree.h:97
NODE_FOREACH
@ NODE_FOREACH
Definition: nasl_tree.h:30
EXPR_DECR
@ EXPR_DECR
Definition: nasl_tree.h:74
NODE_VAR
@ NODE_VAR
Definition: nasl_tree.h:43
TC::size
int size
Definition: nasl_tree.h:110
EXPR_PLUS
@ EXPR_PLUS
Definition: nasl_tree.h:61
NODE_INSTR_L
@ NODE_INSTR_L
Definition: nasl_tree.h:27
alloc_expr_cell
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:86
cell_type
int cell_type(const tree_cell *)
Definition: nasl_tree.c:481
TC::line_nb
short line_nb
Definition: nasl_tree.h:108
NODE_REPEATED
@ NODE_REPEATED
Definition: nasl_tree.h:32
EXPR_R_SHIFT
@ EXPR_R_SHIFT
Definition: nasl_tree.h:76
EXPR_NOT
@ EXPR_NOT
Definition: nasl_tree.h:59
EXPR_DIV
@ EXPR_DIV
Definition: nasl_tree.h:65
TC::x
union TC::@7 x
TC::ref_val
void * ref_val
Definition: nasl_tree.h:115
TC::ref_count
short ref_count
Definition: nasl_tree.h:109
COMP_RE_NOMATCH
@ COMP_RE_NOMATCH
Definition: nasl_tree.h:82
CONST_REGEX
@ CONST_REGEX
Definition: nasl_tree.h:95
EXPR_L_SHIFT
@ EXPR_L_SHIFT
Definition: nasl_tree.h:75
EXPR_BIT_AND
@ EXPR_BIT_AND
Definition: nasl_tree.h:69
TC
Definition: nasl_tree.h:106
COMP_MATCH
@ COMP_MATCH
Definition: nasl_tree.h:79
TC::type
short type
Definition: nasl_tree.h:107
TC::link
struct TC * link[4]
Definition: nasl_tree.h:117
NODE_R_USHIFT_EQ
@ NODE_R_USHIFT_EQ
Definition: nasl_tree.h:55
tree_cell
struct TC tree_cell
COMP_GE
@ COMP_GE
Definition: nasl_tree.h:89
NODE_MULT_EQ
@ NODE_MULT_EQ
Definition: nasl_tree.h:49
EXPR_MINUS
@ EXPR_MINUS
Definition: nasl_tree.h:62
REF_VAR
@ REF_VAR
Definition: nasl_tree.h:100
EXPR_INCR
@ EXPR_INCR
Definition: nasl_tree.h:73
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:91
COMP_LT
@ COMP_LT
Definition: nasl_tree.h:84
NODE_IF_ELSE
@ NODE_IF_ELSE
Definition: nasl_tree.h:26
COMP_NE
@ COMP_NE
Definition: nasl_tree.h:87
alloc_RE_cell
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *)
Definition: nasl_tree.c:61
EXPR_OR
@ EXPR_OR
Definition: nasl_tree.h:58
NODE_CONTINUE
@ NODE_CONTINUE
Definition: nasl_tree.h:39
NODE_FOR
@ NODE_FOR
Definition: nasl_tree.h:28
COMP_RE_MATCH
@ COMP_RE_MATCH
Definition: nasl_tree.h:81
NODE_MODULO_EQ
@ NODE_MODULO_EQ
Definition: nasl_tree.h:51
node_type
node_type
Definition: nasl_tree.h:24
REF_ARRAY
@ REF_ARRAY
Definition: nasl_tree.h:101
NODE_BREAK
@ NODE_BREAK
Definition: nasl_tree.h:38
NODE_PLUS_EQ
@ NODE_PLUS_EQ
Definition: nasl_tree.h:47
ref_cell
void ref_cell(tree_cell *)
Definition: nasl_tree.c:188
COMP_NOMATCH
@ COMP_NOMATCH
Definition: nasl_tree.h:80
NODE_EMPTY
@ NODE_EMPTY
Definition: nasl_tree.h:25
NODE_ARG
@ NODE_ARG
Definition: nasl_tree.h:36
EXPR_EXPO
@ EXPR_EXPO
Definition: nasl_tree.h:67
EXPR_BIT_OR
@ EXPR_BIT_OR
Definition: nasl_tree.h:70
EXPR_MULT
@ EXPR_MULT
Definition: nasl_tree.h:64
COMP_EQ
@ COMP_EQ
Definition: nasl_tree.h:86
TC::i_val
long int i_val
Definition: nasl_tree.h:114
COMP_GT
@ COMP_GT
Definition: nasl_tree.h:88