Search for errors in a nasl script.
812{
815 int lint_mode = 1;
816 GHashTable *include_files = NULL;
817 GHashTable *func_fnames_tab = NULL;
818 GSList *unusedfiles = NULL;
819 GSList *called_funcs = NULL;
820 GSList *def_func_tree = NULL;
821 gchar *err_fname = NULL;
824
826 include_files =
827 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
828 func_fnames_tab =
829 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
830
833 lexic_aux->
oid = lexic->
oid;
834
835
837 if (desc_block != NULL && desc_block !=
FAKE_CELL)
838 {
839
841 {
843 }
844 }
845
847
848
849 if (
nasl_lint_def (lexic_aux, st, lint_mode, &include_files, &func_fnames_tab,
850 err_fname, &called_funcs, &def_func_tree)
851 == NULL)
852 {
854 }
855
856
857 if (
nasl_lint_call (lexic_aux, st, &include_files, &func_fnames_tab,
858 err_fname, &called_funcs, &def_func_tree)
859 == NULL)
860 {
862 }
863
864
866 &unusedfiles);
867 if (unusedfiles != NULL)
869 if ((g_slist_length (unusedfiles)) > 0)
870 {
872 }
873
874
875 lint_mode = 0;
876 if (
nasl_lint_def (lexic, st, lint_mode, &include_files, &func_fnames_tab,
877 err_fname, &called_funcs, &def_func_tree)
878 == NULL)
879 {
881 }
882
883
884 GSList *defined_var = NULL;
887 err_fname, &defined_var, &called_funcs);
888 g_slist_free (defined_var);
889 defined_var = NULL;
890
891 g_slist_free (called_funcs);
892 called_funcs = NULL;
893 g_slist_free_full (def_func_tree, (GDestroyNotify)
free_list_func);
894 def_func_tree = NULL;
895 g_hash_table_destroy (include_files);
896 include_files = NULL;
897 g_hash_table_destroy (func_fnames_tab);
898 func_fnames_tab = NULL;
899 g_free (err_fname);
900 g_slist_free (unusedfiles);
901 unusedfiles = NULL;
903
905 {
908 }
909
910 return ret;
911}
static tree_cell * nasl_lint_def(lex_ctxt *lexic, tree_cell *st, int lint_mode, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **called_funcs, GSList **def_func_tree)
Loads all defined functions. Also, It constructs a tree of called functions to help recognize a not d...
static void inc_errors_cnt()
static void init_errors_cnt()
static int get_errors_cnt()
static void print_uncall_files(gpointer filename, gpointer lexic)
It shows a msg for unused included files.
static void free_list_func(func_info *data)
Free a func_info structure.
static void add_predef_varname(GSList **defined_var)
Add keywords to the varnames list.
static tree_cell * check_description_block(lex_ctxt *lexic, tree_cell *st)
Sanity check of the description block.
static tree_cell * nasl_lint_call(lex_ctxt *lexic, tree_cell *st, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **called_funcs, GSList **def_func_tree)
Check if a called function was defined.
static void check_called_files(gpointer key, gpointer value, GSList **unusedfiles)
This function is called by g_hash_table_foreach to check if an include file was used or not....
static tree_cell * find_description_block(lex_ctxt *lexic, tree_cell *st)
Sanity check of the description block.
static tree_cell * make_call_func_list(lex_ctxt *lexic, tree_cell *st, GSList **called_funcs)
Make a list of all called functions.
static tree_cell * nasl_lint_defvar(lex_ctxt *lexic, tree_cell *st, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **defined_var, GSList **called_funcs)
Consider all cases in which a variable is set, and add it to a list. If a variable is read,...
const char * nasl_get_filename(const char *function)
void free_lex_ctxt(lex_ctxt *c)
lex_ctxt * init_empty_lex_ctxt()
struct struct_lex_ctxt lex_ctxt
tree_cell * alloc_typed_cell(int typ)
union TC::@332262321161220155002104006201360276211317150140 x
struct script_infos * script_infos