[Openvas-commits] r11537 - in trunk/gsa: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 1 09:07:55 CEST 2011


Author: mattm
Date: 2011-09-01 09:07:55 +0200 (Thu, 01 Sep 2011)
New Revision: 11537

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/gsad_omp.h
Log:
	Convert more pages to new param mechanism.

	* src/gsad.c (validator): Remove.  Out of use.
	(exec_omp_post): Pass single param instead of many.

	* src/gsad_omp.c (save_task_omp): Replace multiple args with one.

	* src/gsad_omp.h: Update header accordingly.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-01 07:02:09 UTC (rev 11536)
+++ trunk/gsa/ChangeLog	2011-09-01 07:07:55 UTC (rev 11537)
@@ -2,6 +2,17 @@
 
 	Convert more pages to new param mechanism.
 
+	* src/gsad.c (validator): Remove.  Out of use.
+	(exec_omp_post): Pass single param instead of many.
+
+	* src/gsad_omp.c (save_task_omp): Replace multiple args with one.
+
+	* src/gsad_omp.h: Update header accordingly.
+
+2011-08-31  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Convert more pages to new param mechanism.
+
 	* src/gsad.c (init_validator): Add more rules.
 	(validator_or): Remove.  Out of use.
 	(params_append_mhd): Add more container cases.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-01 07:02:09 UTC (rev 11536)
+++ trunk/gsa/src/gsad.c	2011-09-01 07:07:55 UTC (rev 11537)
@@ -695,33 +695,6 @@
 }
 
 /**
- * @brief Check validity of an input string.
- *
- * Checks whether an input string is valid according to a rule registered with
- * \ref validator.  Frees and NULLs \p string if not.
- *
- * @param[in]      validator       Validator to use.
- * @param[in]      validator_rule  The rule with which to validate \p string.
- * @param[in,out]  string          The string to validate.  If invalid, memory
- *                                 location pointed to will be freed and set
- *                                 to NULL.
- *
- * @return TRUE if \p string was invalid and was freed, FALSE otherwise.
- */
-static gboolean
-validate (validator_t validator, const gchar* validator_rule, char** string)
-{
-  if (openvas_validate (validator, validator_rule, *string))
-    {
-      free (*string);
-      *string = NULL;
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
-/**
  * @brief Frees array and its gchar* contents.
  *
  * @param[in,out]  array  The GArray containing gchar*s to free.
@@ -2455,76 +2428,7 @@
   ELSE (save_override)
   ELSE (save_report_format)
   ELSE_OAP (save_settings)
-  else if ((!strcmp (con_info->req_parms.cmd, "save_task"))
-           && (con_info->req_parms.task_id != NULL)
-           && (con_info->req_parms.next != NULL)
-           && ((strcmp (con_info->req_parms.next, "get_tasks") == 0)
-               || (strcmp (con_info->req_parms.next, "get_task") == 0)))
-    {
-      if ((con_info->req_parms.target_id == NULL)
-          || (strcmp (con_info->req_parms.target_id, "--")))
-        {
-          validate (validator, "task_id", &con_info->req_parms.task_id);
-          validate (validator, "name", &con_info->req_parms.name);
-          validate (validator, "comment", &con_info->req_parms.comment);
-          validate (validator, "escalator_id",
-                    &con_info->req_parms.escalator_id);
-          validate (validator, "schedule_id", &con_info->req_parms.schedule_id);
-          validate (validator, "slave_id", &con_info->req_parms.slave_id);
-          validate (validator, "page", &con_info->req_parms.next);
-          validate (validator, "refresh_interval",
-                    &con_info->req_parms.refresh_interval);
-          validate (validator, "sort_field", &con_info->req_parms.sort_field);
-          validate (validator, "sort_order", &con_info->req_parms.sort_order);
-          validate (validator, "overrides", &con_info->req_parms.overrides);
-          validate (validator, "max_checks", &con_info->req_parms.max_checks);
-          validate (validator, "max_hosts", &con_info->req_parms.max_hosts);
-
-          con_info->response =
-            save_task_omp (credentials,
-                           con_info->req_parms.task_id,
-                           con_info->req_parms.name,
-                           con_info->req_parms.comment,
-                           con_info->req_parms.escalator_id,
-                           con_info->req_parms.schedule_id,
-                           con_info->req_parms.slave_id,
-                           con_info->req_parms.next,
-                           con_info->req_parms.refresh_interval,
-                           con_info->req_parms.sort_field,
-                           con_info->req_parms.sort_order,
-                           con_info->req_parms.overrides
-                            ? strcmp (con_info->req_parms.overrides, "0")
-                            : 0,
-                           con_info->req_parms.max_checks,
-                           con_info->req_parms.max_hosts);
-        }
-      else
-        {
-          validate (validator, "task_id", &con_info->req_parms.task_id);
-          validate (validator, "name", &con_info->req_parms.name);
-          validate (validator, "comment", &con_info->req_parms.comment);
-          validate (validator, "page", &con_info->req_parms.next);
-          validate (validator, "refresh_interval",
-                    &con_info->req_parms.refresh_interval);
-          validate (validator, "sort_field", &con_info->req_parms.sort_field);
-          validate (validator, "sort_order", &con_info->req_parms.sort_order);
-          validate (validator, "overrides", &con_info->req_parms.overrides);
-
-          con_info->response =
-            save_container_task_omp (credentials,
-                                     con_info->req_parms.task_id,
-                                     con_info->req_parms.name,
-                                     con_info->req_parms.comment,
-                                     con_info->req_parms.next,
-                                     con_info->req_parms.refresh_interval,
-                                     con_info->req_parms.sort_field,
-                                     con_info->req_parms.sort_order,
-                                     con_info->req_parms.overrides
-                                      ? strcmp (con_info->req_parms.overrides,
-                                                "0")
-                                      : 0);
-        }
-    }
+  ELSE (save_task)
   ELSE_OAP (save_user)
   ELSE (start_task)
   ELSE (stop_task)

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-01 07:02:09 UTC (rev 11536)
+++ trunk/gsa/src/gsad_omp.c	2011-09-01 07:07:55 UTC (rev 11537)
@@ -1047,41 +1047,43 @@
 /**
  * @brief Save task, get next page, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  task_id           ID of task.
- * @param[in]  name              New name for task.
- * @param[in]  comment           New comment for task.
- * @param[in]  escalator_id      New escalator for task.
- * @param[in]  schedule_id       New schedule for task.
- * @param[in]  slave_id          New slave for task.
- * @param[in]  next              Name of next page.
- * @param[in]  refresh_interval  Refresh interval (parsed to int).
- * @param[in]  sort_field        Field to sort on, or NULL.
- * @param[in]  sort_order        "ascending", "descending", or NULL.
- * @param[in]  apply_overrides   Whether to apply overrides.
- * @param[in]  max_checks        Max checks task preference.
- * @param[in]  max_hosts         Max hosts task preference.
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-save_task_omp (credentials_t * credentials, const char *task_id,
-               const char *name, const char *comment, const char *escalator_id,
-               const char *schedule_id, const char *slave_id,
-               const char *next,
-               /* Parameters for get_tasks. */
-               const char *refresh_interval, const char *sort_field,
-               const char *sort_order, int apply_overrides,
-               const char *max_checks, const char *max_hosts)
+save_task_omp (credentials_t * credentials, params_t *params)
 {
   gchar *modify_task;
+  const char *comment, *name, *next, *refresh_interval, *sort_field;
+  const char *sort_order, *overrides, *escalator_id, *schedule_id;
+  const char *slave_id, *task_id, *max_checks, *max_hosts;
+  int apply_overrides;
 
+  comment = params_value (params, "comment");
+  name = params_value (params, "name");
+  task_id = params_value (params, "task_id");
+  next = params_value (params, "next");
+  refresh_interval = params_value (params, "refresh_interval");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+  overrides = params_value (params, "overrides");
+
+  apply_overrides = overrides ? strcmp (overrides, "0") : 0;
+
   if (comment == NULL || name == NULL)
     return edit_task (credentials, task_id,
                       GSAD_MESSAGE_INVALID_PARAM ("Save Task"), next,
                       refresh_interval, sort_field, sort_order,
                       apply_overrides);
 
+  escalator_id = params_value (params, "escalator_id");
+  schedule_id = params_value (params, "schedule_id");
+  slave_id = params_value (params, "slave_id");
+  max_checks = params_value (params, "max_checks");
+  max_hosts = params_value (params, "max_hosts");
+
   if (escalator_id == NULL || schedule_id == NULL || slave_id == NULL
       || next == NULL || sort_field == NULL || sort_order == NULL
       || task_id == NULL || max_checks == NULL || max_hosts == NULL)

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2011-09-01 07:02:09 UTC (rev 11536)
+++ trunk/gsa/src/gsad_omp.h	2011-09-01 07:07:55 UTC (rev 11537)
@@ -46,10 +46,7 @@
 char * edit_task_omp (credentials_t *, const char *, const char *, const char *,
                       const char *, const char *, int);
 char * new_task_omp (credentials_t *, const char *, int);
-char * save_task_omp (credentials_t *, const char *, const char *, const char *,
-                      const char *, const char *, const char *, const char *,
-                      const char *, const char *, const char *, int,
-                      const char *, const char *);
+char * save_task_omp (credentials_t *, params_t *);
 char * save_container_task_omp (credentials_t *, const char *, const char *,
                                 const char *, const char *, const char *,
                                 const char *, const char *, int);



More information about the Openvas-commits mailing list