37 static GDataInputStream *
41 GFileInputStream *fis = NULL;
42 GDataInputStream *dis = NULL;
45 file = g_file_new_for_path (filename);
46 fis = g_file_read (file, NULL, &error);
52 g_error (
"%s\n\n", error->message);
54 dis = g_data_input_stream_new (G_INPUT_STREAM (fis));
68 g_debug (
"Processing %s", filepath);
69 script_args->
name = (
char *) filepath;
72 g_print (
"Error while processing %s.\n", filepath);
96 g_data_input_stream_read_line (nvt_list, NULL, NULL, &error);
102 g_error (
"%s\n\n", error->message);
113 g_object_unref (nvt_list);
146 const gchar *message, gpointer user_data)
148 gint log_mask = GPOINTER_TO_INT (user_data);
149 if ((log_level & log_mask) != 0)
150 g_log_default_handler (log_domain, log_level, message, user_data);
162 static gboolean debug = FALSE;
163 static gchar *include_dir = NULL;
164 static gchar *nvt_file_list = NULL;
165 static const gchar **nvt_files = NULL;
167 GError *error = NULL;
168 GOptionContext *option_context;
169 static GOptionEntry entries[] = {
170 {
"debug",
'd', 0, G_OPTION_ARG_NONE, &debug,
"Output debug log messages.",
172 {
"nvt-list",
'l', 0, G_OPTION_ARG_STRING, &nvt_file_list,
173 "Process files from <file>",
"<file>"},
174 {
"include-dir",
'i', 0, G_OPTION_ARG_STRING, &include_dir,
175 "Search for includes in <dir>",
"<dir>"},
176 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &nvt_files,
177 "Absolute path to one or more nasl scripts",
"NASL_FILE..."},
178 {NULL, 0, 0, 0, NULL, NULL, NULL}};
181 g_option_context_new (
"- standalone NASL linter for OpenVAS");
182 g_option_context_add_main_entries (option_context, entries, NULL);
183 if (!g_option_context_parse (option_context, &argc, &argv, &error))
185 g_error (
"%s\n\n", error->message);
187 g_option_context_free (option_context);
198 if (include_dir != NULL)
204 GINT_TO_POINTER (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO
205 | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_WARNING
206 | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR));
209 GINT_TO_POINTER (G_LOG_LEVEL_WARNING
210 | G_LOG_LEVEL_CRITICAL
211 | G_LOG_LEVEL_ERROR));
214 if (nvt_file_list != NULL)
218 if (nvt_files != NULL)
221 g_print (
"%d errors found\n", err);