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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 20 13:14:44 CEST 2009


Author: felix
Date: 2009-10-20 13:14:43 +0200 (Tue, 20 Oct 2009)
New Revision: 5644

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/omp/omp.c
Log:
Use check_response where response entities have no (interesting) content,
avoid duplicate code.

* omp/omp.c (omp_delete_task, omp_create_target, omp_delete_target)
(omp_create_config, omp_delete_config, omp_create_lsc_credential)
(omp_delete_lsc_credential): Call check_response instead of checking
response in place.
(omp_get_nvt_details_503): Minor cosmetic.


Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2009-10-20 10:59:46 UTC (rev 5643)
+++ trunk/openvas-libraries/ChangeLog	2009-10-20 11:14:43 UTC (rev 5644)
@@ -1,5 +1,16 @@
 2009-10-20  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Use check_response where response entities have no (interesting) content,
+	avoid duplicate code.
+
+	* omp/omp.c (omp_delete_task, omp_create_target, omp_delete_target)
+	(omp_create_config, omp_delete_config, omp_create_lsc_credential)
+	(omp_delete_lsc_credential): Call check_response instead of checking
+	response in place.
+	(omp_get_nvt_details_503): Minor cosmetic.
+
+2009-10-20  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Refactored "503" calls.
 
 	* omp/omp.c (get_omp_response_503): New. Extracted from other

Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c	2009-10-20 10:59:46 UTC (rev 5643)
+++ trunk/openvas-libraries/omp/omp.c	2009-10-20 11:14:43 UTC (rev 5644)
@@ -974,28 +974,7 @@
       == -1)
     return -1;
 
-  /* Read the response. */
-
-  entity_t entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  const char* status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1426,8 +1405,6 @@
                    const char* comment)
 {
   int ret;
-  entity_t entity;
-  const char* status;
 
   /* Create the OMP request. */
 
@@ -1455,28 +1432,7 @@
   g_free (new_task_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1492,8 +1448,6 @@
                    const char* name)
 {
   int ret;
-  entity_t entity;
-  const char* status;
 
   /* Create the OMP request. */
 
@@ -1509,28 +1463,7 @@
   g_free (new_task_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1584,28 +1517,7 @@
   g_free (new_config_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity_t entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  const char* status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1663,8 +1575,6 @@
                    const char* name)
 {
   int ret;
-  entity_t entity;
-  const char* status;
 
   /* Create the OMP request. */
 
@@ -1680,28 +1590,7 @@
   g_free (new_task_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1719,8 +1608,6 @@
                            const char* comment)
 {
   int ret;
-  entity_t entity;
-  const char* status;
 
   /* Create the OMP request. */
 
@@ -1744,28 +1631,7 @@
   g_free (new_task_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1781,8 +1647,6 @@
                            const char* name)
 {
   int ret;
-  entity_t entity;
-  const char* status;
 
   /* Create the OMP request. */
 
@@ -1798,28 +1662,7 @@
   g_free (new_task_request);
   if (ret) return -1;
 
-  /* Read the response. */
-
-  entity = NULL;
-  if (read_entity (session, &entity)) return -1;
-
-  /* Check the response. */
-
-  status = entity_attribute (entity, "status");
-  if (status == NULL)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  if (strlen (status) == 0)
-    {
-      free_entity (entity);
-      return -1;
-    }
-  char first = status[0];
-  free_entity (entity);
-  if (first == '2') return 0;
-  return -1;
+  return check_response (session);
 }
 
 /**
@@ -1842,7 +1685,7 @@
   if (oid)
     request = g_strdup_printf ("<get_nvt_details oid=\"%s\"/>", oid);
   else
-    request = g_strdup("<get_nvt_details/>");
+    request = g_strdup ("<get_nvt_details/>");
 
   ret = get_omp_response_503 (session, request, response);
 



More information about the Openvas-commits mailing list