[Openvas-commits] r6178 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Dec 17 17:51:35 CET 2009
Author: mattm
Date: 2009-12-17 17:51:32 +0100 (Thu, 17 Dec 2009)
New Revision: 6178
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.h
trunk/openvas-manager/src/omp.c
trunk/openvas-manager/src/tasks_sql.h
Log:
* src/tasks_sql.h (init_config_task_iterator, config_task_iterator_name)
(config_task_iterator_uuid): New functions.
* src/manage.h: Add headers.
* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_STATUS send
config and target with task. In CLIENT_GET_CONFIGS send list of tasks
that use the config.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-12-17 15:17:40 UTC (rev 6177)
+++ trunk/openvas-manager/ChangeLog 2009-12-17 16:51:32 UTC (rev 6178)
@@ -1,5 +1,16 @@
2009-12-17 Matthew Mundell <matthew.mundell at intevation.de>
+ * src/tasks_sql.h (init_config_task_iterator, config_task_iterator_name)
+ (config_task_iterator_uuid): New functions.
+
+ * src/manage.h: Add headers.
+
+ * src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_STATUS send
+ config and target with task. In CLIENT_GET_CONFIGS send list of tasks
+ that use the config.
+
+2009-12-17 Matthew Mundell <matthew.mundell at intevation.de>
+
* src/omp.c (omp_xml_handle_end_element): In CLIENT_GET_STATUS send sort
information back with task list.
Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h 2009-12-17 15:17:40 UTC (rev 6177)
+++ trunk/openvas-manager/src/manage.h 2009-12-17 16:51:32 UTC (rev 6178)
@@ -361,6 +361,15 @@
int
config_file_iterator_length (iterator_t*);
+void
+init_config_task_iterator (iterator_t*, const char *, int);
+
+const char*
+config_task_iterator_name (iterator_t*);
+
+const char*
+config_task_iterator_uuid (iterator_t*);
+
/* General task facilities. */
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2009-12-17 15:17:40 UTC (rev 6177)
+++ trunk/openvas-manager/src/omp.c 2009-12-17 16:51:32 UTC (rev 6178)
@@ -5730,7 +5730,7 @@
{
int ret, maximum_hosts;
gchar *response, *progress_xml;
- char *name, *target, *hosts;
+ char *name, *config, *target, *hosts;
gchar *first_report_id, *first_report;
char* description;
gchar *description64, *last_report_id, *last_report;
@@ -5740,7 +5740,6 @@
target = task_target (task);
hosts = target ? target_hosts (target) : NULL;
maximum_hosts = hosts ? max_hosts (hosts) : 0;
- free (target);
first_report_id = task_first_report_id (task);
if (first_report_id)
@@ -5952,12 +5951,15 @@
description64 = g_strdup ("");
name = task_name (task);
+ config = task_config (task);
response = g_strdup_printf
("<get_status_response"
" status=\"" STATUS_OK "\""
" status_text=\"" STATUS_OK_TEXT "\">"
"<task id=\"%s\">"
"<name>%s</name>"
+ "<config><name>%s</name></config>"
+ "<target><name>%s</name></target>"
"<status>%s</status>"
"<progress>%s</progress>"
"%s"
@@ -5974,6 +5976,8 @@
"%s%s%s",
tsk_uuid,
name,
+ config ? config : "",
+ target ? target : "",
task_run_status_name (task),
progress_xml,
description64,
@@ -5987,6 +5991,8 @@
first_report,
last_report,
second_last_report);
+ free (config);
+ free (target);
g_free (progress_xml);
g_free (last_report);
g_free (second_last_report);
@@ -6050,7 +6056,7 @@
{
gchar *line, *progress_xml;
char *name = task_name (index);
- char *tsk_uuid, *target, *hosts;
+ char *tsk_uuid, *config, *target, *hosts;
gchar *first_report_id, *first_report;
char *description;
gchar *description64, *last_report_id, *last_report;
@@ -6064,7 +6070,6 @@
target = task_target (index);
hosts = target ? target_hosts (target) : NULL;
maximum_hosts = hosts ? max_hosts (hosts) : 0;
- free (target);
first_report_id = task_first_report_id (index);
if (first_report_id)
@@ -6269,9 +6274,12 @@
else
progress_xml = g_strdup ("-1");
+ config = task_config (index);
line = g_strdup_printf ("<task"
" id=\"%s\">"
"<name>%s</name>"
+ "<config><name>%s</name></config>"
+ "<target><name>%s</name></target>"
"<status>%s</status>"
"<progress>%s</progress>"
"%s"
@@ -6289,6 +6297,8 @@
"</task>",
tsk_uuid,
name,
+ config ? config : "",
+ target ? target : "",
task_run_status_name (index),
progress_xml,
description64,
@@ -6302,6 +6312,8 @@
first_report,
last_report,
second_last_report);
+ free (config);
+ free (target);
g_free (progress_xml);
g_free (last_report);
g_free (second_last_report);
@@ -6340,6 +6352,7 @@
{
int config_nvts_growing, config_families_growing;
const char *selector, *config_name;
+ iterator_t tasks;
selector = config_iterator_nvt_selector (&configs);
config_name = config_iterator_name (&configs);
@@ -6358,7 +6371,8 @@
"<nvt_count>"
"%i<growing>%i</growing>"
"</nvt_count>"
- "<in_use>%i</in_use>",
+ "<in_use>%i</in_use>"
+ "<tasks>",
config_name,
config_iterator_comment (&configs),
config_family_count (config_name),
@@ -6367,6 +6381,19 @@
config_nvts_growing,
config_in_use (config_name));
+ init_config_task_iterator (&tasks,
+ config_name,
+ /* Attribute sort_order. */
+ current_int_2);
+ while (next (&tasks))
+ SENDF_TO_CLIENT_OR_FAIL ("<task id=\"%s\">"
+ "<name>%s</name>"
+ "</task>",
+ config_task_iterator_uuid (&tasks),
+ config_task_iterator_name (&tasks));
+ cleanup_iterator (&tasks);
+ SEND_TO_CLIENT_OR_FAIL ("</tasks>");
+
if (current_int_1)
{
iterator_t families;
Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h 2009-12-17 15:17:40 UTC (rev 6177)
+++ trunk/openvas-manager/src/tasks_sql.h 2009-12-17 16:51:32 UTC (rev 6178)
@@ -6286,6 +6286,31 @@
return 0;
}
+/**
+ * @brief Initialise a config task iterator.
+ *
+ * Iterates over all tasks that use the config.
+ *
+ * @param[in] iterator Iterator.
+ * @param[in] name Name of config.
+ * @param[in] ascending Whether to sort ascending or descending.
+ */
+void
+init_config_task_iterator (iterator_t* iterator, const char *name,
+ int ascending)
+{
+ gchar *quoted_name = sql_quote (name);
+ init_iterator (iterator,
+ "SELECT name, uuid FROM tasks WHERE config = '%s'"
+ " ORDER BY name %s;",
+ quoted_name,
+ ascending ? "ASC" : "DESC");
+ g_free (quoted_name);
+}
+
+DEF_ACCESS (config_task_iterator_name, 0);
+DEF_ACCESS (config_task_iterator_uuid, 1);
+
/* NVT's. */
More information about the Openvas-commits
mailing list