[Openvas-commits] r5466 - in trunk/openvas-client: . openvas
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 9 19:46:44 CEST 2009
Author: jan
Date: 2009-10-09 19:46:42 +0200 (Fri, 09 Oct 2009)
New Revision: 5466
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/openvas/cli.c
trunk/openvas-client/openvas/filter.c
trunk/openvas-client/openvas/openvas_plugin.c
trunk/openvas-client/openvas/openvas_plugin.h
trunk/openvas-client/openvas/pdf_output.c
trunk/openvas-client/openvas/plugin_cache.c
trunk/openvas-client/openvas/plugin_infos.c
trunk/openvas-client/openvas/xml_output_ng.c
Log:
Start to replace struct openvas_plugin by nvti.
* openvas/openvas_plugin.h (openvas_plugin): Added nvti_t
element ni and removed description and summary.
Removed proto for openvas_plugin_get_description().
* openvas/openvas_plugin.c (ni_store): New. Static store for NVTIs.
(interned_strings, intern_string, openvas_plugin_get_description): Removed.
(openvas_plugin_new): Handle summary and description via a nvti_t
structure.
(openvas_plugin_duplicate): Apply new method to access summary
and description.
* openvas/pdf_output.c (print_plugin_information),
openvas/plugin_infos.c (plugin_info_window_setup),
openvas/plugin_cache.c (write_plugin), openvas/filter.c (filter_plugin),
openvas/xml_output_ng.c (xml_plugins_plugin),
openvas/cli.c (_cli_sql_dump_plugins, _cli_dump_plugins):
Apply new method to access summary and description.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/ChangeLog 2009-10-09 17:46:42 UTC (rev 5466)
@@ -1,5 +1,27 @@
2009-10-09 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+ Start to replace struct openvas_plugin by nvti.
+
+ * openvas/openvas_plugin.h (openvas_plugin): Added nvti_t
+ element ni and removed description and summary.
+ Removed proto for openvas_plugin_get_description().
+
+ * openvas/openvas_plugin.c (ni_store): New. Static store for NVTIs.
+ (interned_strings, intern_string, openvas_plugin_get_description): Removed.
+ (openvas_plugin_new): Handle summary and description via a nvti_t
+ structure.
+ (openvas_plugin_duplicate): Apply new method to access summary
+ and description.
+
+ * openvas/pdf_output.c (print_plugin_information),
+ openvas/plugin_infos.c (plugin_info_window_setup),
+ openvas/plugin_cache.c (write_plugin), openvas/filter.c (filter_plugin),
+ openvas/xml_output_ng.c (xml_plugins_plugin),
+ openvas/cli.c (_cli_sql_dump_plugins, _cli_dump_plugins):
+ Apply new method to access summary and description.
+
+2009-10-09 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
* openvas/comm.c (omp_get_nvt_details): Removed. Functionality is
now in libopenvas_omp.
(fetch_new_plugins, client_omp_read_plugins): Adjusted call
Modified: trunk/openvas-client/openvas/cli.c
===================================================================
--- trunk/openvas-client/openvas/cli.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/cli.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -441,11 +441,11 @@
printf("'%s', ", m);
efree(&m);
- m = sql_addslashes(p->summary);
+ m = sql_addslashes(nvti_summary(p->ni));
printf("'%s', ", m);
efree(&m);
- n = openvas_plugin_get_description(p);
+ n = nvti_description(p->ni);
m = sql_addslashes(n);
printf("'%s',", m);
efree(&m);
@@ -503,7 +503,7 @@
printf("%s|", var);
efree(&var);
- var = addslashes(p->summary);
+ var = addslashes(nvti_summary(p->ni));
printf("%s|", var);
efree(&var);
@@ -523,7 +523,7 @@
printf("%s|", var);
efree(&var);
- n = openvas_plugin_get_description(p);
+ n = nvti_description(p->ni);
var = addslashes(n);
printf("%s\n", var);
efree(&var);
Modified: trunk/openvas-client/openvas/filter.c
===================================================================
--- trunk/openvas-client/openvas/filter.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/filter.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -260,8 +260,8 @@
#ifdef USE_GTK
char * name = plugin->name;
- char * description = openvas_plugin_get_description(plugin);
- char * summary = plugin->summary;
+ char * description = nvti_description(plugin->ni);
+ char * summary = nvti_summary(plugin->ni);
char * author = plugin->copyright;
char * oid = plugin->oid;
char * category = plugin->category;
Modified: trunk/openvas-client/openvas/openvas_plugin.c
===================================================================
--- trunk/openvas-client/openvas/openvas_plugin.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/openvas_plugin.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -20,8 +20,7 @@
*
* Module that deals with representation of (collections of) NVTs.
*
- * Uses a GHashTable to 'intern' strings (uniqes the string in memory) and
- * the cache mechanism of arglists.
+ * Uses the cache mechanism of arglists.
*
* @TODO Partly obsoleted by nvti.h/c (although some fields do not correspond).
*/
@@ -31,38 +30,13 @@
#include "openvas_plugin.h"
/**
- * @brief Static hash table to keep 'interned' strings.
+ * @brief Static store of NVTIs.
+ *
+ * It is never free'd.
*/
-static GHashTable* interned_strings = NULL;
+static nvtis_t * ni_store = NULL;
/**
- * @brief 'Interns' a string by adding a duplicate of it to a static hash table.
- *
- * @param s The string to 'intern'.
- *
- * @return A pointer pointing to the interned string s (different then s).
- */
-static char *
-intern_string (const char * s)
-{
- char *interned;
-
- if (!interned_strings)
- {
- interned_strings = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- interned = g_hash_table_lookup (interned_strings, s);
- if (interned)
- return interned;
-
- interned = estrdup (s);
-
- g_hash_table_insert (interned_strings, interned, interned);
- return interned;
-}
-
-/**
* @brief Initializes a new plugin struct.
*/
struct openvas_plugin *
@@ -87,13 +61,25 @@
bzero (np, sizeof(*np));
+ if (! ni_store) ni_store = nvtis_new();
+
+ np->ni = nvtis_lookup(ni_store, oid);
+ if (! np->ni)
+ {
+ np->ni = nvti_new();
+
+ nvti_set_oid(np->ni, oid);
+ nvti_set_description(np->ni, description);
+ nvti_set_summary(np->ni, summary);
+
+ nvtis_add(ni_store, np->ni);
+ }
+
np->oid = cache_inc (oid);
np->md5sum = NULL;
np->name = cache_inc (name);
np->category = cache_inc (category);
np->copyright = cache_inc (copyright);
- np->description = intern_string (description);
- np->summary = intern_string (summary);
np->family = cache_inc (family);
np->version = cache_inc (version);
np->cve = cache_inc (cve);
@@ -168,16 +154,9 @@
return NULL;
}
-char *
-openvas_plugin_get_description (struct openvas_plugin * plugin)
-{
- return plugin->description;
-}
-
/**
* @brief Returns a duplicate of a plugin.
*
- * Properties will be 'interned' and included in the cache.
* Preferences are deep- copied.
*
* @param plugin The plugin to duplicate.
@@ -189,7 +168,7 @@
{
struct openvas_plugin * copy = openvas_plugin_new(plugin->oid,
plugin->name, plugin->category, plugin->copyright,
- openvas_plugin_get_description(plugin), plugin->summary, plugin->family,
+ nvti_description(plugin->ni), nvti_summary(plugin->ni), plugin->family,
plugin->version, plugin->cve, plugin->bid, plugin->xrefs,
plugin->sign_key_ids, plugin->script_tags);
copy->enabled = plugin->enabled;
Modified: trunk/openvas-client/openvas/openvas_plugin.h
===================================================================
--- trunk/openvas-client/openvas/openvas_plugin.h 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/openvas_plugin.h 2009-10-09 17:46:42 UTC (rev 5466)
@@ -18,6 +18,8 @@
#ifndef _OPENVAS_OPENVAS_PLUGIN
#define _OPENVAS_OPENVAS_PLUGIN
+#include <openvas/base/nvti.h> /* for nvti_t */
+
/**
* @brief Basic openvas_plugin struct, describing a NVT and eventual preferences
* in their user-modified state.
@@ -25,6 +27,7 @@
* Implements a single-linked list (through a 'next' pointer).
*/
struct openvas_plugin {
+ nvti_t * ni;
char * oid;
char * name;
char * md5sum;
@@ -32,10 +35,6 @@
char * category;
char * copyright;
- char * description;
-
- char * summary;
-
char * family;
char * version;
@@ -63,6 +62,4 @@
struct openvas_plugin* openvas_plugin_duplicate(struct openvas_plugin *);
-char * openvas_plugin_get_description(struct openvas_plugin * plugin);
-
#endif /* _OPENVAS_OPENVAS_PLUGIN */
Modified: trunk/openvas-client/openvas/pdf_output.c
===================================================================
--- trunk/openvas-client/openvas/pdf_output.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/pdf_output.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -835,7 +835,7 @@
plugin_oid, plugin_oid, plugin->name);
fprintf(file, "<table>\n");
- print_plugin_table_row(file, _("Summary"), plugin->summary);
+ print_plugin_table_row(file, _("Summary"), nvti_summary(plugin->ni));
print_plugin_table_row(file, _("Category"), plugin->category);
print_plugin_table_row(file, _("Family"), plugin->family);
print_plugin_table_row(file, _("Version"), plugin->version);
@@ -848,7 +848,7 @@
print_plugin_information_signatures(file, plugin, context);
fprintf(file, "</table>");
- description = openvas_plugin_get_description(plugin);
+ description = nvti_description(plugin->ni);
html_description = html_output_convert_cr_to_html(description);
PRINT1(file, "<p></p>\n<h4>%s</h4>\n", _("Description"));
fputs(html_description, file);
Modified: trunk/openvas-client/openvas/plugin_cache.c
===================================================================
--- trunk/openvas-client/openvas/plugin_cache.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/plugin_cache.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -238,7 +238,7 @@
md5sum = "";
return write_record(file, "kssssssssssssss", NVT_KEYWORD,
plugin->oid, md5sum, plugin->name, plugin->category, plugin->copyright,
- openvas_plugin_get_description(plugin), plugin->summary, plugin->family,
+ nvti_description(plugin->ni), nvti_summary(plugin->ni), plugin->family,
plugin->version, plugin->cve, plugin->bid, plugin->xrefs,
plugin->sign_key_ids, plugin->script_tags);
}
Modified: trunk/openvas-client/openvas/plugin_infos.c
===================================================================
--- trunk/openvas-client/openvas/plugin_infos.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/plugin_infos.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -479,7 +479,7 @@
gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
{
- char * s = openvas_plugin_get_description(plugin);
+ char * s = nvti_description(plugin->ni);
if ( s != NULL )
gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)),s, -1);
}
Modified: trunk/openvas-client/openvas/xml_output_ng.c
===================================================================
--- trunk/openvas-client/openvas/xml_output_ng.c 2009-10-09 15:25:03 UTC (rev 5465)
+++ trunk/openvas-client/openvas/xml_output_ng.c 2009-10-09 17:46:42 UTC (rev 5466)
@@ -402,7 +402,7 @@
static void
xml_plugins_plugin (FILE* fd, int indent, struct openvas_plugin * u)
{
- char * s = openvas_plugin_get_description(u);
+ char * s = nvti_description(u->ni);
xml_fprintf (fd, indent, "<nvt oid=\"%s\">\n", u->oid);
xml_fprintf_element (fd, indent+1, "name", u->name);
@@ -412,7 +412,7 @@
xml_fprintf_element (fd, indent+1, "bugtraq_id", u->bid);
xml_fprintf_element (fd, indent+1, "category", u->category);
xml_fprintf_element (fd, indent+1, "risk", getrisk(s));
- xml_fprintf_element (fd, indent+1, "summary", u->summary);
+ xml_fprintf_element (fd, indent+1, "summary", nvti_summary(u->ni));
xml_fprintf_element (fd, indent+1, "copyright", u->copyright);
xml_fprintf (fd, indent, "</nvt>\n");
} /* xml_plugins_plugin */
More information about the Openvas-commits
mailing list