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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 2 21:50:21 CEST 2011


Author: mattm
Date: 2011-09-02 21:50:19 +0200 (Fri, 02 Sep 2011)
New Revision: 11553

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 (exec_omp_get): Pass single param instead of many.

	* src/gsad_omp.c (get_slave_omp, get_slaves_omp, get_schedule_omp)
	(get_schedules_omp, get_system_reports_omp, get_report_format_omp)
	(get_report_formats_omp): Replace multiple args with one.

	* src/gsad_omp.h: Update headers accordingly.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-02 18:51:57 UTC (rev 11552)
+++ trunk/gsa/ChangeLog	2011-09-02 19:50:19 UTC (rev 11553)
@@ -4,6 +4,18 @@
 
 	* src/gsad.c (exec_omp_get): Pass single param instead of many.
 
+	* src/gsad_omp.c (get_slave_omp, get_slaves_omp, get_schedule_omp)
+	(get_schedules_omp, get_system_reports_omp, get_report_format_omp)
+	(get_report_formats_omp): Replace multiple args with one.
+
+	* src/gsad_omp.h: Update headers accordingly.
+
+2011-09-02  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 (get_result): New function.  Body from get_result_omp.
 	(get_result_omp): Call through to get_result.  Update callers to call
 	get_result.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-02 18:51:57 UTC (rev 11552)
+++ trunk/gsa/src/gsad.c	2011-09-02 19:50:19 UTC (rev 11553)
@@ -3232,33 +3232,14 @@
     }
 
   ELSE (get_result)
+  ELSE (get_report_format)
+  ELSE (get_report_formats)
+  ELSE (get_schedule)
+  ELSE (get_schedules)
+  ELSE (get_slave)
+  ELSE (get_slaves)
+  ELSE (get_system_reports)
 
-  else if ((!strcmp (cmd, "get_report_format")) && (report_format_id != NULL))
-    return get_report_format_omp (credentials, report_format_id, sort_field,
-                                  sort_order);
-
-  else if (!strcmp (cmd, "get_report_formats"))
-    return get_report_formats_omp (credentials, sort_field, sort_order);
-
-  else if ((!strcmp (cmd, "get_schedule")) && (schedule_id != NULL))
-    return get_schedule_omp (credentials, schedule_id, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_schedules"))
-    return get_schedules_omp (credentials, sort_field, sort_order);
-
-  else if ((!strcmp (cmd, "get_slave")) && (slave_id != NULL))
-    return get_slave_omp (credentials, slave_id, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_slaves"))
-    return get_slaves_omp (credentials, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_system_reports"))
-    return get_system_reports_omp (credentials,
-                                   ((duration == NULL || (*duration == '\0'))
-                                     ? "86400" : duration),
-                                   ((slave_id == NULL || (*slave_id == '\0'))
-                                     ? "0" : slave_id));
-
   else if ((!strcmp (cmd, "get_target")) && (target_id != NULL))
     return get_target_omp (credentials, target_id, sort_field, sort_order);
 

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-02 18:51:57 UTC (rev 11552)
+++ trunk/gsa/src/gsad_omp.c	2011-09-02 19:50:19 UTC (rev 11553)
@@ -11539,21 +11539,30 @@
  * @brief Get one slave, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  slave_id     UUID of slave.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_slave_omp (credentials_t * credentials, const char * slave_id,
-               const char * sort_field, const char * sort_order)
+get_slave_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *slave_id, *sort_field, *sort_order;
 
+  slave_id = params_value (params, "slave_id");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
+  if (slave_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a slave. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_slaves");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -11619,20 +11628,22 @@
  * @brief Get all slaves, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_slaves_omp (credentials_t * credentials, const char * sort_field,
-                 const char * sort_order)
+get_slaves_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *sort_field, *sort_order;
 
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -11695,21 +11706,30 @@
  * @brief Get one schedule, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  schedule_id  UUID of schedule.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_schedule_omp (credentials_t * credentials, const char * schedule_id,
-                  const char * sort_field, const char * sort_order)
+get_schedule_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *schedule_id, *sort_field, *sort_order;
 
+  schedule_id = params_value (params, "schedule_id");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
+  if (schedule_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a schedule. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_schedules");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -11772,14 +11792,12 @@
  * @brief Get all schedules, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_schedules_omp (credentials_t * credentials, const char * sort_field,
-                   const char * sort_order)
+get_schedules_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
@@ -11787,7 +11805,11 @@
   time_t now;
   struct tm *now_broken;
   gchar *html;
+  const char *sort_field, *sort_order;
 
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -12160,20 +12182,22 @@
  * @brief Get all system reports, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  duration     Duration of reports, in seconds.
- * @param[in]  slave_id     ID of slave.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_system_reports_omp (credentials_t * credentials, const char * duration,
-                        const char * slave_id)
+get_system_reports_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *duration, *slave_id;
 
+  duration = params_value (params, "duration");
+  slave_id = params_value (params, "slave_id");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -12453,20 +12477,27 @@
 /**
  * @brief Get one report format, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  report_format_id  UUID of report_format.
- * @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 *
-get_report_format_omp (credentials_t * credentials,
-                       const char * report_format_id, const char * sort_field,
-                       const char * sort_order)
+get_report_format_omp (credentials_t * credentials, params_t *params)
 {
-  return get_report_format (credentials, report_format_id, sort_field,
-                            sort_order, NULL);
+  const char *report_format_id;
+  report_format_id = params_value (params, "report_format_id");
+  if (report_format_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a report format. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_report_formats");
+  return get_report_format (credentials,
+                            report_format_id,
+                            params_value (params, "sort_field"),
+                            params_value (params, "sort_order"),
+                            NULL);
 }
 
 /**
@@ -12554,16 +12585,17 @@
  * @brief Get all report formats, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_report_formats_omp (credentials_t * credentials, const char * sort_field,
-                        const char * sort_order)
+get_report_formats_omp (credentials_t * credentials, params_t *params)
 {
-  return get_report_formats (credentials, sort_field, sort_order, NULL);
+  return get_report_formats (credentials,
+                             params_value (params, "sort_field"),
+                             params_value (params, "sort_order"),
+                             NULL);
 }
 
 /**

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2011-09-02 18:51:57 UTC (rev 11552)
+++ trunk/gsa/src/gsad_omp.h	2011-09-02 19:50:19 UTC (rev 11553)
@@ -88,9 +88,8 @@
 
 char * delete_schedule_omp (credentials_t *, params_t *);
 char * delete_trash_schedule_omp (credentials_t *, params_t *);
-char * get_schedule_omp (credentials_t *, const char *, const char *,
-                         const char *);
-char * get_schedules_omp (credentials_t *, const char *, const char *);
+char * get_schedule_omp (credentials_t *, params_t *);
+char * get_schedules_omp (credentials_t *, params_t *);
 
 char * get_target_omp (credentials_t *, const char *, const char *,
                        const char *);
@@ -137,21 +136,19 @@
 char * edit_override_omp (credentials_t *, params_t *);
 char * save_override_omp (credentials_t *, params_t *);
 
-char * get_slave_omp (credentials_t *, const char *, const char *,
-                      const char *);
-char * get_slaves_omp (credentials_t *, const char *, const char *);
+char * get_slave_omp (credentials_t *, params_t *);
+char * get_slaves_omp (credentials_t *, params_t *);
 char * create_slave_omp (credentials_t *, params_t *);
 char * delete_slave_omp (credentials_t *, params_t *);
 char * delete_trash_slave_omp (credentials_t *, params_t *);
 
-char * get_system_reports_omp (credentials_t *, const char *, const char *);
+char * get_system_reports_omp (credentials_t *, params_t *);
 char * get_system_report_omp (credentials_t *, const char *, const char *,
                               const char *, enum content_type*, char **,
                               gsize *);
 
-char * get_report_format_omp (credentials_t *, const char *, const char *,
-                              const char *);
-char * get_report_formats_omp (credentials_t *, const char *, const char *);
+char * get_report_format_omp (credentials_t *, params_t *);
+char * get_report_formats_omp (credentials_t *, params_t *);
 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 *, params_t *);



More information about the Openvas-commits mailing list