Initialize a NASL context for a NASL file.
2775 char *full_name = NULL, key_path[2048], *checksum, *filename, *check = NULL;
2776 GSList * inc_dir = inc_dirs;
2783 pc->
buffer = g_malloc0 (80);
2787 while (inc_dir != NULL) {
2790 full_name = g_build_filename(inc_dir->data,
name, NULL);
2792 if ((pc->
fp = fopen(full_name,
"r")) != NULL)
2795 inc_dir = g_slist_next(inc_dir);
2799 log_legacy_write (
"%s: Not able to open nor to locate it in include paths",
2813 filename = full_name;
2814 if (strstr (full_name,
".inc"))
2815 filename = basename (full_name);
2816 init_checksum_algorithm ();
2817 if (checksum_algorithm == GCRY_MD_NONE)
2820 snprintf (key_path,
sizeof (key_path),
"checksum:%s", filename);
2821 checksum = kb_item_get_str (pc->
kb, key_path);
2825 check = file_checksum (full_name, checksum_algorithm);
2826 ret = strcmp (check, checksum);
2839 load_checksums (pc->
kb);
2840 if (checksum_algorithm == GCRY_MD_MD5)
2841 snprintf (key_path,
sizeof (key_path),
"md5sums:%s", filename);
2842 else if (checksum_algorithm == GCRY_MD_SHA256)
2843 snprintf (key_path,
sizeof (key_path),
"sha256sums:%s", filename);
2846 checksum = kb_item_get_str (pc->
kb, key_path);
2857 check = file_checksum (full_name, checksum_algorithm);
2858 ret = strcmp (check, checksum);
2863 snprintf (key_path,
sizeof (key_path),
"checksum:%s", filename);
2864 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.