OpenVAS Libraries  7.0.7
nasl_lex_ctxt.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 _NASL_LEX_CTXT_H
20 #define _NASL_LEX_CTXT_H
21 
22 /* for tree_cell */
23 #include "nasl_tree.h"
24 
25 /* for nasl_array */
26 #include "nasl_var.h"
27 
28 /* for nasl_func */
29 #include "nasl_func.h"
30 
31 typedef struct struct_lex_ctxt
32 {
34  tree_cell *ret_val; /* return value or exit flag */
35  unsigned fct_ctxt:1; /* This is a function context */
36  unsigned break_flag:1; /* Break from loop */
37  unsigned cont_flag:1; /* Next iteration in loop */
41  int line_nb;
42  /* Named variables hash set + anonymous variables array */
44  /* Functions hash set */
46 } lex_ctxt;
47 
48 #define NASL_COMPAT_LEX_CTXT "NASL compat lex context"
49 
51 void free_lex_ctxt (lex_ctxt *);
52 
53 void dump_ctxt (lex_ctxt *);
54 
55 nasl_func *get_func_ref_by_name (lex_ctxt *, const char *);
57 nasl_func *insert_nasl_func (lex_ctxt *, const char *, tree_cell *);
59 
60 tree_cell *get_variable_by_name (lex_ctxt *, const char *);
61 tree_cell *get_array_elem (lex_ctxt *, const char * /*array name */ ,
62  tree_cell *);
68 
71 
73 
74 
75 int get_int_var_by_num (lex_ctxt *, int, int);
76 char *get_str_var_by_num (lex_ctxt *, int);
77 int get_int_var_by_name (lex_ctxt *, const char *, int);
78 int get_int_local_var_by_name (lex_ctxt *, const char *, int);
79 char *get_str_var_by_name (lex_ctxt *, const char *);
80 char *get_str_local_var_by_name (lex_ctxt *, const char *);
81 
82 int get_var_size_by_name (lex_ctxt *, const char *);
83 int get_local_var_size_by_name (lex_ctxt *, const char *);
84 int get_local_var_type_by_name (lex_ctxt *, const char *);
85 
86 
87 int get_var_size_by_num (lex_ctxt *, int);
88 int get_var_type_by_num (lex_ctxt *, int);
89 #endif
nasl_array ctx_vars
Definition: nasl_lex_ctxt.h:43
int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1289
Definition: nasl_var.h:66
int get_int_local_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1296
unsigned always_authenticated
Definition: nasl_lex_ctxt.h:38
tree_cell * nasl_func_call(lex_ctxt *, const nasl_func *, tree_cell *)
Definition: nasl_func.c:148
Definition: nasl_func.h:30
void dump_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:63
#define FUNC_NAME_HASH
Definition: nasl_func.h:22
Definition: nasl_var.h:52
lex_ctxt * init_empty_lex_ctxt(void)
Definition: nasl_lex_ctxt.c:29
int line_nb
Definition: nasl_lex_ctxt.h:41
int recv_timeout
Definition: nasl_lex_ctxt.h:40
int get_local_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1354
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1318
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1311
tree_cell * nasl_incr_variable(lex_ctxt *, tree_cell *, int, int)
Definition: nasl_var.c:1048
nasl_func * functions[FUNC_NAME_HASH]
Definition: nasl_lex_ctxt.h:45
tree_cell * decl_local_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:867
tree_cell * get_variable_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:204
named_nasl_var * add_named_var_to_ctxt(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:922
Definition: nasl_tree.h:105
int get_var_size_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1361
Definition: nasl_lex_ctxt.h:31
tree_cell * decl_nasl_func(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:112
unsigned fct_ctxt
Definition: nasl_lex_ctxt.h:35
unsigned break_flag
Definition: nasl_lex_ctxt.h:36
int get_local_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1378
nasl_func * insert_nasl_func(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_func.c:66
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1304
Definition: arglists.h:29
struct struct_lex_ctxt lex_ctxt
nasl_func * get_func_ref_by_name(lex_ctxt *, const char *)
Definition: nasl_func.c:127
int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1282
tree_cell * get_array_elem(lex_ctxt *, const char *, tree_cell *)
Definition: nasl_var.c:236
tree_cell * ret_val
Definition: nasl_lex_ctxt.h:34
tree_cell * nasl_return(lex_ctxt *, tree_cell *)
Definition: nasl_func.c:317
unsigned cont_flag
Definition: nasl_lex_ctxt.h:37
tree_cell * nasl_read_var_ref(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:949
anon_nasl_var * add_numbered_var_to_ctxt(lex_ctxt *, int, tree_cell *)
Definition: nasl_var.c:890
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Definition: nasl_var.h:41
tree_cell * cell2atom(lex_ctxt *, tree_cell *)
Definition: exec.c:249
int get_var_size_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1347
tree_cell * decl_global_variables(lex_ctxt *, tree_cell *)
Definition: nasl_var.c:880
struct struct_lex_ctxt * up_ctxt
Definition: nasl_lex_ctxt.h:33
void free_lex_ctxt(lex_ctxt *)
Definition: nasl_lex_ctxt.c:45
int get_var_type_by_num(lex_ctxt *, int)
Returns NASL variable/cell type, VAR2_UNDEF if value is NULL.
Definition: nasl_var.c:1371