Initialize a NASL context for a NASL file.
2774 char *full_name = NULL, key_path[2048], *checksum, *filename, *check = NULL;
2775 GSList * inc_dir = inc_dirs;
2782 pc->
buffer = g_malloc0 (80);
2786 while (inc_dir != NULL) {
2789 full_name = g_build_filename(inc_dir->data,
name, NULL);
2791 if ((pc->
fp = fopen(full_name,
"r")) != NULL)
2794 inc_dir = g_slist_next(inc_dir);
2798 log_legacy_write (
"%s: Not able to open nor to locate it in include paths",
2812 filename = full_name;
2813 if (strstr (full_name,
".inc"))
2814 filename = basename (full_name);
2815 init_checksum_algorithm ();
2816 if (checksum_algorithm == GCRY_MD_NONE)
2819 snprintf (key_path,
sizeof (key_path),
"checksum:%s", filename);
2820 checksum = kb_item_get_str (pc->
kb, key_path);
2824 check = file_checksum (full_name, checksum_algorithm);
2825 ret = strcmp (check, checksum);
2838 load_checksums (pc->
kb);
2839 if (checksum_algorithm == GCRY_MD_MD5)
2840 snprintf (key_path,
sizeof (key_path),
"md5sums:%s", filename);
2841 else if (checksum_algorithm == GCRY_MD_SHA256)
2842 snprintf (key_path,
sizeof (key_path),
"sha256sums:%s", filename);
2845 checksum = kb_item_get_str (pc->
kb, key_path);
2856 check = file_checksum (full_name, checksum_algorithm);
2857 ret = strcmp (check, checksum);
2862 snprintf (key_path,
sizeof (key_path),
"checksum:%s", filename);
2863 kb_item_set_str (pc->
kb, key_path, check);
void nasl_set_filename(const char *filename)
void log_legacy_write(const char *format,...)
Legacy function to write a log message.
int add_nasl_inc_dir(const char *dir)
Adds the given string as directory for searching for includes.