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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 1 16:51:48 CEST 2011


Author: mattm
Date: 2011-09-01 16:51:47 +0200 (Thu, 01 Sep 2011)
New Revision: 11545

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

	* src/gsad.c (exec_omp_get, exec_omp_post): Pass single param instead of
	many.

	* src/gsad_omp.c (edit_task, edit_report_format): Replace multiple args
	with one.  Update caller.
	(edit_task_omp, save_container_task_omp, edit_report_format_omp): Replace
	multiple args with one.

	* src/gsad_omp.h: Update headers accordingly.

	* src/html/omp.xsl (html-edit-task-form): Separate into two commands.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-01 12:18:49 UTC (rev 11544)
+++ trunk/gsa/ChangeLog	2011-09-01 14:51:47 UTC (rev 11545)
@@ -2,6 +2,22 @@
 
 	Convert more pages to new param mechanism.
 
+	* src/gsad.c (exec_omp_get, exec_omp_post): Pass single param instead of
+	many.
+
+	* src/gsad_omp.c (edit_task, edit_report_format): Replace multiple args
+	with one.  Update caller.
+	(edit_task_omp, save_container_task_omp, edit_report_format_omp): Replace
+	multiple args with one.
+
+	* src/gsad_omp.h: Update headers accordingly.
+
+	* src/html/omp.xsl (html-edit-task-form): Separate into two commands.
+
+2011-09-01  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Convert more pages to new param mechanism.
+
 	* src/gsad.c (exec_omp_get): Pass single param instead of many.
 
 	* src/gsad_omp.c (new_task): New function.  Body from new_task_omp.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-01 12:18:49 UTC (rev 11544)
+++ trunk/gsa/src/gsad.c	2011-09-01 14:51:47 UTC (rev 11545)
@@ -2429,6 +2429,7 @@
   ELSE (save_report_format)
   ELSE_OAP (save_settings)
   ELSE (save_task)
+  ELSE (save_container_task)
   ELSE_OAP (save_user)
   ELSE (start_task)
   ELSE (stop_task)
@@ -3132,27 +3133,9 @@
   ELSE (edit_lsc_credential)
   ELSE (edit_note)
   ELSE (edit_override)
-
-  else if ((!strcmp (cmd, "edit_report_format"))
-           && (report_format_id != NULL)
-           && (next != NULL)
-           && ((strcmp (next, "get_report_formats") == 0)
-               || (strcmp (next, "get_report_format") == 0)))
-    return edit_report_format_omp (credentials, report_format_id, next,
-                                   sort_field, sort_order);
-
+  ELSE (edit_report_format)
   ELSE_OAP (edit_settings)
-
-  else if ((!strcmp (cmd, "edit_task"))
-           && (task_id != NULL)
-           && (next != NULL)
-           && (overrides != NULL)
-           && ((strcmp (next, "get_tasks") == 0)
-               || (strcmp (next, "get_task") == 0)))
-    return edit_task_omp (credentials, task_id, next, refresh_interval,
-                          sort_field, sort_order,
-                          overrides ? strcmp (overrides, "0") : 0);
-
+  ELSE (edit_task)
   ELSE_OAP (edit_user)
 
   else if ((!strcmp (cmd, "export_config")) && (config_id != NULL))

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-01 12:18:49 UTC (rev 11544)
+++ trunk/gsa/src/gsad_omp.c	2011-09-01 14:51:47 UTC (rev 11545)
@@ -920,29 +920,32 @@
 /**
  * @brief Setup edit_task XML, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  task_id           UUID of task.
- * @param[in]  extra_xml         Extra XML to insert inside page element.
- * @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]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ * @param[in]  extra_xml    Extra XML to insert inside page element.
  *
  * @return Result of XSL transformation.
  */
 char *
-edit_task (credentials_t * credentials, const char *task_id,
-           const char *extra_xml, const char *next,
-           /* Parameters for get_tasks. */
-           const char *refresh_interval, const char *sort_field,
-           const char *sort_order, int apply_overrides)
+edit_task (credentials_t * credentials, params_t *params, const char *extra_xml)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *task_id, *next, *refresh_interval, *sort_field, *sort_order;
+  const char *overrides;
+  int apply_overrides;
 
+  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 (task_id == NULL || next == NULL)
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,
@@ -1053,14 +1056,9 @@
  * @return Result of XSL transformation.
  */
 char *
-edit_task_omp (credentials_t * credentials, const char *task_id,
-               const char *next,
-               /* Parameters for get_tasks. */
-               const char *refresh_interval, const char *sort_field,
-               const char *sort_order, int apply_overrides)
+edit_task_omp (credentials_t * credentials, params_t *params)
 {
-  return edit_task (credentials, task_id, NULL, next, refresh_interval,
-                    sort_field, sort_order, apply_overrides);
+  return edit_task (credentials, params, NULL);
 }
 
 /**
@@ -1092,10 +1090,8 @@
   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);
+    return edit_task (credentials, params,
+                      GSAD_MESSAGE_INVALID_PARAM ("Save Task"));
 
   escalator_id = params_value (params, "escalator_id");
   schedule_id = params_value (params, "schedule_id");
@@ -1169,33 +1165,33 @@
 /**
  * @brief Save container 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]  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]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-save_container_task_omp (credentials_t * credentials, const char *task_id,
-                         const char *name, const char *comment,
-                         const char *next,
-                         /* Parameters for get_tasks. */
-                         const char *refresh_interval, const char *sort_field,
-                         const char *sort_order, int apply_overrides)
+save_container_task_omp (credentials_t * credentials, params_t *params)
 {
   gchar *modify_task;
+  const char *comment, *name, *next, *sort_field, *sort_order, *task_id;
+  const char *overrides, *refresh_interval;
+  int apply_overrides;
 
+  comment = params_value (params, "comment");
+  name = params_value (params, "name");
+  next = params_value (params, "next");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+  task_id = params_value (params, "task_id");
+  overrides = params_value (params, "overrides");
+  refresh_interval = params_value (params, "refresh_interval");
+
+  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);
+    return edit_task (credentials, params,
+                      GSAD_MESSAGE_INVALID_PARAM ("Save Task"));
 
   if (next == NULL || sort_field == NULL || sort_order == NULL
       || task_id == NULL)
@@ -12542,26 +12538,29 @@
 /**
  * @brief Setup edit_report_format XML, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  report_format_id  UUID of report_format.
- * @param[in]  extra_xml         Extra XML to insert inside page element.
- * @param[in]  next              Name of next page.
- * @param[in]  sort_field        Field to sort on, or NULL.
- * @param[in]  sort_order        "ascending", "descending", or NULL.
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ * @param[in]  extra_xml    Extra XML to insert inside page element.
  *
  * @return Result of XSL transformation.
  */
 static char *
-edit_report_format (credentials_t * credentials, const char *report_format_id,
-                    const char *extra_xml, const char *next,
-                    const char *sort_field, const char *sort_order)
+edit_report_format (credentials_t * credentials, params_t *params,
+                    const char *extra_xml)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *next, *report_format_id, *sort_field, *sort_order;
 
-  if (report_format_id == NULL || next == NULL)
+  next = params_value (params, "next");
+  report_format_id = params_value (params, "report_format_id");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
+  if (report_format_id == NULL || next == NULL || sort_field == NULL
+      || sort_order == NULL)
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,
                          "An internal error occurred while editing a report format. "
@@ -12569,6 +12568,15 @@
                          "Diagnostics: Required parameter was NULL.",
                          "/omp?cmd=get_report_formats");
 
+  if (strcmp (next, "get_report_formats")
+      && strcmp (next, "get_report_format"))
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while editing a report "
+                         "format. "
+                         "Diagnostics: next must name a valid page.",
+                         "/omp?cmd=get_report_formats");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -12644,22 +12652,15 @@
 /**
  * @brief Setup edit_report_format XML, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  report_format_id  UUID of report_format.
- * @param[in]  next              Name of next page.
- * @param[in]  sort_field        Field to sort on, or NULL.
- * @param[in]  sort_order        "ascending", "descending", or NULL.
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-edit_report_format_omp (credentials_t * credentials,
-                        const char *report_format_id, const char *next,
-                        /* Parameters for get_report_formats. */
-                        const char *sort_field, const char *sort_order)
+edit_report_format_omp (credentials_t * credentials, params_t *params)
 {
-  return edit_report_format (credentials, report_format_id, NULL, next,
-                             sort_field, sort_order);
+  return edit_report_format (credentials, params, NULL);
 }
 
 /**
@@ -12784,13 +12785,9 @@
 
   if (params_value (params, "comment") == NULL
       || params_value (params, "name") == NULL)
-    return edit_report_format (credentials,
-                               params_value (params, "report_format_id"),
+    return edit_report_format (credentials, params,
                                GSAD_MESSAGE_INVALID_PARAM
-                                ("Save Report Format"),
-                               params_value (params, "next"),
-                               params_value (params, "sort_field"),
-                               params_value (params, "sort_order"));
+                                ("Save Report Format"));
 
   if (params_value (params, "next") == NULL
       || params_value (params, "sort_field") == NULL

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2011-09-01 12:18:49 UTC (rev 11544)
+++ trunk/gsa/src/gsad_omp.h	2011-09-01 14:51:47 UTC (rev 11545)
@@ -43,13 +43,10 @@
 char * create_task_omp (credentials_t *, params_t *);
 char * delete_task_omp (credentials_t *, params_t *);
 char * delete_trash_task_omp (credentials_t *, params_t *);
-char * edit_task_omp (credentials_t *, const char *, const char *, const char *,
-                      const char *, const char *, int);
+char * edit_task_omp (credentials_t *, params_t *);
 char * new_task_omp (credentials_t *, params_t *);
 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);
+char * save_container_task_omp (credentials_t *, params_t *);
 char * pause_task_omp (credentials_t *, params_t *);
 char * resume_paused_task_omp (credentials_t *, params_t *);
 char * resume_stopped_task_omp (credentials_t *, params_t *);
@@ -165,8 +162,7 @@
 char * get_report_formats_omp (credentials_t *, const char *, const char *);
 char * delete_report_format_omp (credentials_t *, params_t *);
 char * delete_trash_report_format_omp (credentials_t *, params_t *);
-char * edit_report_format_omp (credentials_t *, const char *, const char *,
-                               const char *, const char *);
+char * edit_report_format_omp (credentials_t *, params_t *);
 char * import_report_format_omp (credentials_t *, params_t *);
 char * save_report_format_omp (credentials_t *, params_t *);
 char * verify_report_format_omp (credentials_t *, const char *);

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-09-01 12:18:49 UTC (rev 11544)
+++ trunk/gsa/src/html/omp.xsl	2011-09-01 14:51:47 UTC (rev 11545)
@@ -2745,7 +2745,6 @@
     <div class="gb_window_part_content">
       <form action="" method="post" enctype="multipart/form-data">
         <input type="hidden" name="token" value="{/envelope/token}"/>
-        <input type="hidden" name="cmd" value="save_task"/>
         <input type="hidden" name="caller" value="{/envelope/caller}"/>
         <input type="hidden"
                name="task_id"
@@ -2778,11 +2777,13 @@
           <xsl:choose>
             <xsl:when test="commands_response/get_tasks_response/task/target/@id = ''">
               <input type="hidden" name="target_id" value="--"/>
+              <input type="hidden" name="cmd" value="save_container_task"/>
             </xsl:when>
             <xsl:otherwise>
               <tr>
                 <td valign="top">Scan Config (immutable)</td>
                 <td>
+                  <input type="hidden" name="cmd" value="save_task"/>
                   <select name="scanconfig" disabled="1">
                     <xsl:choose>
                       <xsl:when



More information about the Openvas-commits mailing list