Mailing List Archive

NessusClient/nessus context.h, 1.7, 1.8 context.c, 1.6, 1.7 comm.c, 1.10, 1.11
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv19272/nessus

Modified Files:
context.h context.c comm.c
Log Message:
Refactoring in preparation for the plugin cache:

Turn comm_add_plugin into a "method" of the context,
context_add_plugin. Also put the decision on whether the added
plugin is a scanner or a plugin into context_add_plugin.


Index: context.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- context.h 19 Dec 2005 17:20:00 -0000 1.7
+++ context.h 2 Feb 2006 19:26:25 -0000 1.8
@@ -85,6 +85,8 @@
struct context *context_new(struct context*, const char*, const char*);
void context_delete(struct context*);
void context_save_recurse(struct context*);
+void context_add_plugin(struct context*, struct nessus_plugin*);
+

int check_exists(const char *);
int check_is_file(const char *);

Index: context.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- context.c 19 Dec 2005 17:27:42 -0000 1.6
+++ context.c 2 Feb 2006 19:26:25 -0000 1.7
@@ -97,6 +97,48 @@
}


+/*
+ * Add a plugin to the context. If the plugin is a scanner, it's added
+ * to context->scanners and the corresponding scanner set. Otherwise
+ * it's a normal plugin and is added to context->plugins list and the
+ * plugin set.
+ *
+ * XXX: do we need hashing for pluginset?
+ */
+void
+context_add_plugin(struct context *context, struct nessus_plugin *plugin)
+{
+ char *category = plugin->category;
+ char *asc_id = plugin->asc_id;
+ int is_scanner = (strcmp(category, "scanner") == 0);
+ struct nessus_plugin *plugins = is_scanner ? context->scanners
+ : context->plugins;
+ struct arglist *pluginset = prefs_get_pluginset(context,
+ is_scanner ? "SCANNER_SET" : "PLUGIN_SET", NULL);
+ int in_pluginset = (int)(arg_get_type(pluginset, asc_id) >= 0);
+ int enabled = 0;
+
+ if (in_pluginset)
+ {
+ if (arg_get_value(pluginset, asc_id))
+ enabled = 1;
+ }
+ else if (!is_scanner)
+ enabled = 1;
+
+ plugin->enabled = enabled;
+ plugin->next = plugins;
+
+ if (!in_pluginset)
+ arg_add_value(pluginset, asc_id, ARG_INT, sizeof(int), (void *)enabled);
+
+ if (is_scanner)
+ context->scanners = plugin;
+ else
+ context->plugins = plugin;
+}
+
+
#ifdef USE_GTK
struct context **
context_find_child_ptr(context, child)

Index: comm.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/comm.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- comm.c 13 Jan 2006 00:08:28 -0000 1.10
+++ comm.c 2 Feb 2006 19:26:26 -0000 1.11
@@ -816,37 +816,6 @@
}


-/*
- * Add plugin (or scanner) to plugins list and plugin set
- * XXX: do we need hashing for pluginset?
- */
-static struct nessus_plugin *
-comm_add_plugin(plugins, pluginset, plugin)
- struct nessus_plugin *plugins;
- struct arglist *pluginset;
- struct nessus_plugin *plugin;
-{
- char *category = plugin->category;
- char *asc_id = plugin->asc_id;
- int in_pluginset = (int)(arg_get_type(pluginset, asc_id) >= 0);
- int enabled = 0;
-
- if(in_pluginset)
- {
- if(arg_get_value(pluginset, asc_id))
- enabled = 1;
- }
- else if(strcmp(category, "scanner"))
- enabled = 1;
-
- plugin->enabled = enabled;
- plugin->next = plugins;
-
- if(!in_pluginset)
- arg_add_value(pluginset, asc_id, ARG_INT, sizeof(int), (void *)enabled);
-
- return plugin;
-}

int
comm_get_plugins(context)
@@ -894,10 +863,7 @@
continue;
}

- if( strcmp(plugin->category, "scanner" ) == 0 )
- context->scanners = comm_add_plugin(context->scanners, scanner_set, plugin);
- else
- context->plugins = comm_add_plugin(context->plugins, plugin_set, plugin);
+ context_add_plugin(context, plugin);
}
}


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