Mailing List Archive

NessusClient/nessus context.h,1.7,1.7.2.1 context.c,1.6,1.6.2.1
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv89732

Modified Files:
Tag: release-1-0
context.h context.c
Log Message:
Backport from HEAD:
Factored out the sync routine for plugin prefs from
comm.c:gui_comm_send_preferences()
to context.c:context_sync_plugin_prefs()


Index: context.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.h,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -d -r1.7 -r1.7.2.1
--- context.h 19 Dec 2005 17:20:00 -0000 1.7
+++ context.h 22 May 2006 12:35:57 -0000 1.7.2.1
@@ -78,6 +78,18 @@
void context_init(struct context**, struct context*);
struct context *context_by_type(struct context*, context_type);
void context_reset_plugin_tree(struct context*);
+
+/* This function sync the plugin preferences (for plugins and scanners)
+ * for the given context.
+ * In fact, the plugin preferences are copied from
+ * context->plugins[plugin][plugin-pref]
+ * and
+ * context->scanners->[plugin][plugin-pref]
+ * to
+ * context->prefs["PLUGINS_PREFS"][plugin]
+ */
+void context_sync_plugin_prefs(struct context *);
+
#ifdef USE_GTK
void context_collect(struct context*);
void context_rename(struct context*, const char*);

Index: context.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- context.c 19 Dec 2005 17:27:42 -0000 1.6
+++ context.c 22 May 2006 12:35:57 -0000 1.6.2.1
@@ -416,6 +416,80 @@
return context;
}

+/* This function sync the plugin preferences (for plugins and scanners)
+ * for the given context.
+ * In fact, the plugin preferences are copied from
+ * context->plugins[plugin][plugin-pref]
+ * and
+ * context->scanners->[plugin][plugin-pref]
+ * to
+ * context->prefs["PLUGINS_PREFS"][plugin]
+ */
+void
+context_sync_plugin_prefs(context)
+ struct context * context;
+{
+ struct arglist * plugins_prefs = arg_get_value(context->prefs, "PLUGINS_PREFS");
+ struct nessus_plugin * plugins[2];
+ int i;
+
+ /* If there is yet no entry "PLUGINS_PREFS", add it now */
+ if(!plugins_prefs)
+ {
+ plugins_prefs = emalloc(sizeof(struct arglist));
+ arg_add_value(context->prefs, "PLUGINS_PREFS", ARG_ARGLIST, -1, plugins_prefs);
+ }
+
+ plugins[0] = context->plugins;
+ plugins[1] = context->scanners;
+
+ /* iterate over the two plugin sets */
+ for (i = 0; i < 2; i++)
+ {
+ struct nessus_plugin * plugin = plugins[i];
+
+ /* iterate over plugins */
+ while (plugin != NULL)
+ {
+ struct arglist * plugin_prefs = plugin->plugin_prefs;
+
+ /* iterate over the prefs of the plugin */
+ while (plugin_prefs && plugin_prefs->next)
+ {
+ char * value = arg_get_value(plugin_prefs->value, "value");
+ char * fullname = arg_get_value(plugin_prefs->value, "fullname");
+
+ /* is this pref already in the plugins_prefs? */
+ if ((arg_get_type(plugins_prefs, fullname)) >= 0)
+ { /* yes, then just copy the value */
+ if ((arg_get_type(plugins_prefs, fullname)) == ARG_INT)
+ {
+ if (!strcmp(value, "yes"))
+ arg_set_value(plugins_prefs, fullname, sizeof(int), (void *)1);
+ else
+ arg_set_value(plugins_prefs, fullname, sizeof(int), NULL);
+ }
+ else
+ arg_set_value(plugins_prefs, fullname, strlen(value), strdup(value));
+ }
+ else
+ { /* no, then create a new pref */
+ if (!strcmp(value, "yes"))
+ arg_add_value(plugins_prefs, fullname, ARG_INT, sizeof(int), (void *)1);
+ else if (!strcmp(value, "no"))
+ arg_add_value(plugins_prefs, fullname, ARG_INT, sizeof(int), NULL);
+ else
+ arg_add_value(plugins_prefs, fullname, ARG_STRING, strlen(value),
+ strdup(value));
+ }
+
+ plugin_prefs = plugin_prefs->next;
+ }
+ plugin = plugin->next;
+ }
+ }
+}
+

void
context_delete_directory(dir)

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs