OpenVAS Libraries  7.0.6
nasl_var.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_VAR_H_INCLUDED
20 #define NASL_VAR_H_INCLUDED
21 
22 enum
23 {
29 };
30 
31 #define VAR_NAME_HASH 17
32 
33 typedef struct st_nasl_string
34 {
35  unsigned char *s_val;
36  int s_siz;
38 
39 struct st_a_nasl_var;
40 
41 typedef struct st_nasl_array
42 {
43  int max_idx; /* max index - 1! */
44  struct st_a_nasl_var **num_elt; /* max_idx elements */
45  struct st_n_nasl_var **hash_elt; /* VAR_NAME_HASH elements */
46 } nasl_array;
47 
48 #if NASL_DEBUG > 0
49 #define ALL_VARIABLES_NAMED
50 #endif
51 
52 typedef struct st_a_nasl_var
53 {
54  int var_type;
55 #ifdef ALL_VARIABLES_NAMED
56  char *av_name;
57 #endif
58  union
59  {
60  nasl_string_t v_str; /* character string / data */
61  int v_int; /* integer */
62  nasl_array v_arr; /* array */
63  } v;
65 
66 typedef struct st_n_nasl_var
67 {
68  struct st_a_nasl_var u;
69 #ifndef ALL_VARIABLES_NAMED
70  char *var_name;
71 #else
72 #define var_name u.av_name
73 #endif
74  struct st_n_nasl_var *next_var; /* next variable with same name hash */
76 
77 typedef struct
78 {
79  nasl_array *a; /* array */
80  int i1; /* index of numbered elements */
81  int iH; /* index of hash */
82  named_nasl_var *v; /* current variable in hash */
84 
86 
88 const char *var2str (const anon_nasl_var *);
89 
91 
94 int add_var_to_list (nasl_array *, int, const anon_nasl_var *);
95 int add_var_to_array (nasl_array *, char *, const anon_nasl_var *);
97 void free_array (nasl_array *);
98 
100 int hash_str2 (const char *, int);
102 
104 const char *array2str (const nasl_array *);
105 
106 
107 
108 #endif