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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Oct 10 12:29:25 CEST 2009


Author: mattm
Date: 2009-10-10 12:29:24 +0200 (Sat, 10 Oct 2009)
New Revision: 5472

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/omp/omp.c
   trunk/openvas-libraries/omp/omp.h
Log:
	* omp/omp.c (omp_modify_task_file): New function.
	* omp/omp.h: Add header.

Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2009-10-10 09:30:08 UTC (rev 5471)
+++ trunk/openvas-libraries/ChangeLog	2009-10-10 10:29:24 UTC (rev 5472)
@@ -1,3 +1,8 @@
+2009-10-10  Matthew Mundell <matthew.mundell at intevation.de>
+
+	* omp/omp.c (omp_modify_task_file): New function.
+	* omp/omp.h: Add header.
+
 2009-10-09  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
 	* omp/omp.c (omp_get_nvt_details_503): New.

Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c	2009-10-10 09:30:08 UTC (rev 5471)
+++ trunk/openvas-libraries/omp/omp.c	2009-10-10 10:29:24 UTC (rev 5472)
@@ -967,6 +967,68 @@
 }
 
 /**
+ * @brief Modify a file on a task.
+ *
+ * @param[in]  session   Pointer to GNUTLS session.
+ * @param[in]  id        ID of task.
+ * @param[in]  name      Name of file.
+ * @param[in]  content   New content.  NULL to remove file.
+ *
+ * @return 0 on success, -1 or OMP response code on error.
+ */
+int
+omp_modify_task_file (gnutls_session_t* session, const char* id,
+                      const char* name, const char* content)
+{
+  entity_t response;
+
+  if (name == NULL) return -1;
+
+  if (openvas_server_sendf (session, "<modify_task task_id=\"%s\">", id))
+    return -1;
+
+  if (content)
+    {
+      if (openvas_server_sendf (session,
+                                "<file name=\"%s\" action=\"update\">",
+                                name))
+        return -1;
+
+      if (strlen (content))
+        {
+          gchar *base64_rc = g_base64_encode ((guchar*) content,
+                                              strlen (content));
+          int ret = openvas_server_sendf (session,
+                                          "%s",
+                                          base64_rc);
+          g_free (base64_rc);
+          if (ret) return -1;
+        }
+
+      if (openvas_server_sendf (session, "</file>"))
+        return -1;
+    }
+  else
+    {
+      if (openvas_server_sendf (session,
+                                "<file name=\"%s\" action=\"remove\" />",
+                                name))
+        return -1;
+    }
+
+  if (openvas_server_send (session, "</modify_task>"))
+    return -1;
+
+  response = NULL;
+  if (read_entity (session, &response)) return -1;
+
+  // FIX check status
+
+  free_entity (response);
+  return 0;
+}
+
+/**
  * @brief Get the manager preferences.
  *
  * @param[in]  session   Pointer to GNUTLS session.

Modified: trunk/openvas-libraries/omp/omp.h
===================================================================
--- trunk/openvas-libraries/omp/omp.h	2009-10-10 09:30:08 UTC (rev 5471)
+++ trunk/openvas-libraries/omp/omp.h	2009-10-10 10:29:24 UTC (rev 5472)
@@ -83,6 +83,10 @@
                  const char*, const char*, const char*);
 
 int
+omp_modify_task_file (gnutls_session_t*, const char*,
+                      const char*, const char*);
+
+int
 omp_get_preferences (gnutls_session_t*, entity_t*);
 
 int



More information about the Openvas-commits mailing list