[Openvas-commits] r5582 - in trunk/openvas-libraries: . omp

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 16 17:27:33 CEST 2009


Author: mattm
Date: 2009-10-16 17:27:32 +0200 (Fri, 16 Oct 2009)
New Revision: 5582

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/omp/omp.c
   trunk/openvas-libraries/omp/omp.h
Log:
	* omp/omp.c (omp_start_task_report): New function.  Body of
	omp_start_task adjusted to return the associated report ID if requested.
	(omp_start_task): Call omp_start_task_report.

	* omp/omp.h (omp_start_task_report): New header.

Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2009-10-16 15:19:24 UTC (rev 5581)
+++ trunk/openvas-libraries/ChangeLog	2009-10-16 15:27:32 UTC (rev 5582)
@@ -1,3 +1,11 @@
+2009-10-16  Matthew Mundell <matthew.mundell at intevation.de>
+
+	* omp/omp.c (omp_start_task_report): New function.  Body of
+	omp_start_task adjusted to return the associated report ID if requested.
+	(omp_start_task): Call omp_start_task_report.
+
+	* omp/omp.h (omp_start_task_report): New header.
+
 2009-10-16  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
 	* omp/xml.c, omp/xml.h (print_entity_format),

Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c	2009-10-16 15:19:24 UTC (rev 5581)
+++ trunk/openvas-libraries/omp/omp.c	2009-10-16 15:27:32 UTC (rev 5582)
@@ -363,17 +363,19 @@
 /**
  * @brief Start a task and read the manager response.
  *
- * @param[in]  session  Pointer to GNUTLS session.
- * @param[in]  id       ID of task.
+ * @param[in]   session    Pointer to GNUTLS session.
+ * @param[in]   task_id    ID of task.
+ * @param[out]  report_id  ID of report.
  *
  * @return 0 on success, -1 on error.
  */
 int
-omp_start_task (gnutls_session_t* session, const char* id)
+omp_start_task_report (gnutls_session_t* session, const char* task_id,
+                       char** report_id)
 {
   if (openvas_server_sendf (session,
                             "<start_task task_id=\"%s\"/>",
-                            id)
+                            task_id)
       == -1)
     return -1;
 
@@ -396,11 +398,40 @@
       return -1;
     }
   char first = status[0];
+  if (first == '2')
+    {
+      if (report_id)
+        {
+          entity_t report_id_xml = entity_child (entity, "report_id");
+          if (report_id_xml)
+            *report_id = g_strdup (entity_text (report_id_xml));
+          else
+            {
+              free_entity (entity);
+              return -1;
+            }
+        }
+      free_entity (entity);
+      return 0;
+    }
   free_entity (entity);
-  if (first == '2') return 0;
   return -1;
 }
 
+/**
+ * @brief Start a task and read the manager response.
+ *
+ * @param[in]   session    Pointer to GNUTLS session.
+ * @param[in]   task_id    ID of task.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int
+omp_start_task (gnutls_session_t* session, const char* task_id)
+{
+  return omp_start_task_report (session, task_id, NULL);
+}
+
 /** @todo Use this in the other functions. */
 /**
  * @brief Read response and convert status of response to a return value.

Modified: trunk/openvas-libraries/omp/omp.h
===================================================================
--- trunk/openvas-libraries/omp/omp.h	2009-10-16 15:19:24 UTC (rev 5581)
+++ trunk/openvas-libraries/omp/omp.h	2009-10-16 15:27:32 UTC (rev 5582)
@@ -52,9 +52,12 @@
                          const char*, char**);
 
 int
-omp_start_task (gnutls_session_t* , const char*);
+omp_start_task_report (gnutls_session_t* , const char*, char**);
 
 int
+omp_start_task (gnutls_session_t*, const char*);
+
+int
 omp_abort_task (gnutls_session_t*, const char*);
 
 int



More information about the Openvas-commits mailing list