OpenVAS Libraries
4.0+rc3.SVN
|
00001 /* Nessus Attack Scripting Language 00002 * 00003 * Copyright (C) 2002 - 2003 Michel Arboi and Renaud Deraison 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2, 00007 * as published by the Free Software Foundation 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef _NASL_LEX_CTXT_H 00020 #define _NASL_LEX_CTXT_H 00021 00022 /* for tree_cell */ 00023 #include "nasl_tree.h" 00024 00025 /* for nasl_array */ 00026 #include "nasl_var.h" 00027 00028 /* for nasl_func */ 00029 #include "nasl_func.h" 00030 00031 typedef struct struct_lex_ctxt 00032 { 00033 struct struct_lex_ctxt *up_ctxt; 00034 tree_cell *ret_val; /* return value or exit flag */ 00035 unsigned fct_ctxt:1; /* This is a function context */ 00036 unsigned break_flag:1; /* Break from loop */ 00037 unsigned cont_flag:1; /* Next iteration in loop */ 00038 unsigned authenticated:1; /* Authenticated script */ 00039 unsigned always_authenticated:1; 00040 struct arglist *script_infos; 00041 int recv_timeout; 00042 /* Named variables hash set + anonymous variables array */ 00043 nasl_array ctx_vars; 00044 /* Functions hash set */ 00045 nasl_func *functions[FUNC_NAME_HASH]; 00046 } lex_ctxt; 00047 00048 #define NASL_COMPAT_LEX_CTXT "NASL compat lex context" 00049 00050 lex_ctxt *init_empty_lex_ctxt (void); 00051 void free_lex_ctxt (lex_ctxt *); 00052 lex_ctxt *get_top_level_ctxt (lex_ctxt *); 00053 00054 void dump_ctxt (lex_ctxt *); 00055 00056 nasl_func *get_func_ref_by_name (lex_ctxt *, const char *); 00057 tree_cell *decl_nasl_func (lex_ctxt *, tree_cell *); 00058 nasl_func *insert_nasl_func (lex_ctxt *, const char *, tree_cell *); 00059 tree_cell *nasl_func_call (lex_ctxt *, const nasl_func *, tree_cell *); 00060 00061 tree_cell *get_variable_by_name (lex_ctxt *, const char *); 00062 tree_cell *get_array_elem (lex_ctxt *, const char * /*array name */ , 00063 tree_cell *); 00064 anon_nasl_var *add_numbered_var_to_ctxt (lex_ctxt *, int, tree_cell *); 00065 named_nasl_var *add_named_var_to_ctxt (lex_ctxt *, const char *, tree_cell *); 00066 tree_cell *nasl_read_var_ref (lex_ctxt *, tree_cell *); 00067 tree_cell *nasl_incr_variable (lex_ctxt *, tree_cell *, int, int); 00068 tree_cell *nasl_return (lex_ctxt *, tree_cell *); 00069 00070 tree_cell *decl_local_variables (lex_ctxt *, tree_cell *); 00071 tree_cell *decl_global_variables (lex_ctxt *, tree_cell *); 00072 00073 tree_cell *cell2atom (lex_ctxt *, tree_cell *); 00074 00075 00076 int get_int_var_by_num (lex_ctxt *, int, int); 00077 char *get_str_var_by_num (lex_ctxt *, int); 00078 int get_int_var_by_name (lex_ctxt *, const char *, int); 00079 int get_int_local_var_by_name (lex_ctxt *, const char *, int); 00080 char *get_str_var_by_name (lex_ctxt *, const char *); 00081 char *get_str_local_var_by_name (lex_ctxt *, const char *); 00082 00083 int get_var_size_by_name (lex_ctxt *, const char *); 00084 int get_local_var_size_by_name (lex_ctxt *, const char *); 00085 int get_local_var_type_by_name (lex_ctxt *, const char *); 00086 00087 00088 int get_var_size_by_num (lex_ctxt *, int); 00089 int get_var_type_by_num (lex_ctxt *, int); 00090 #endif