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

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


Author: mattm
Date: 2011-09-02 22:21:41 +0200 (Fri, 02 Sep 2011)
New Revision: 11554

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

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

	* src/gsad_oap.c (get_user_oap, get_users_oap, get_feed_oap): Replace
	multiple args with one.

	* src/gsad_omp.c (get_nvts_omp, get_target_omp, get_targets_omp)
	(get_configs_omp, get_trash_omp): Replace multiple args with one.

	* src/gsad_omp.h, src/gsad_oap.h: Update headers accordingly.

	* src/html/oap.xsl (user): Match param name to validator.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/ChangeLog	2011-09-02 20:21:41 UTC (rev 11554)
@@ -1,5 +1,21 @@
 2011-09-02  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	Convert last pages to new param mechanism.
+
+	* src/gsad.c (exec_omp_get): Pass single param instead of many.
+
+	* src/gsad_oap.c (get_user_oap, get_users_oap, get_feed_oap): Replace
+	multiple args with one.
+
+	* src/gsad_omp.c (get_nvts_omp, get_target_omp, get_targets_omp)
+	(get_configs_omp, get_trash_omp): Replace multiple args with one.
+
+	* src/gsad_omp.h, src/gsad_oap.h: Update headers accordingly.
+
+	* src/html/oap.xsl (user): Match param name to validator.
+
+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.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/gsad.c	2011-09-02 20:21:41 UTC (rev 11554)
@@ -3239,39 +3239,18 @@
   ELSE (get_slave)
   ELSE (get_slaves)
   ELSE (get_system_reports)
-
-  else if ((!strcmp (cmd, "get_target")) && (target_id != NULL))
-    return get_target_omp (credentials, target_id, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_targets"))
-    return get_targets_omp (credentials, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_trash"))
-    return get_trash_omp (credentials, sort_field, sort_order);
-
-  else if ((!strcmp (cmd, "get_user")) && (name != NULL))
-    return get_user_oap (credentials, name);
-
-  else if (!strcmp (cmd, "get_users"))
-    return get_users_oap (credentials, sort_field, sort_order);
-
-  else if (!strcmp (cmd, "get_feed"))
-    return get_feed_oap (credentials, sort_field, sort_order);
-
+  ELSE (get_target)
+  ELSE (get_targets)
+  ELSE (get_trash)
+  ELSE_OAP (get_user)
+  ELSE_OAP (get_users)
+  ELSE_OAP (get_feed)
   ELSE (get_config)
-
-  else if (!strcmp (cmd, "get_configs"))
-    return get_configs_omp (credentials, sort_field, sort_order);
-
+  ELSE (get_configs)
   ELSE (get_config_family)
   ELSE (get_config_nvt)
-
-  else if ((!strcmp (cmd, "get_nvts")) && (oid != NULL))
-    return get_nvts_omp (credentials, oid);
-
-  else if (!strcmp (cmd, "get_settings"))
-    return get_settings_oap (credentials, sort_field, sort_order);
-
+  ELSE (get_nvts)
+  ELSE_OAP (get_settings)
   ELSE (new_note)
   ELSE (new_override)
   ELSE (verify_agent)

Modified: trunk/gsa/src/gsad_oap.c
===================================================================
--- trunk/gsa/src/gsad_oap.c	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/gsad_oap.c	2011-09-02 20:21:41 UTC (rev 11554)
@@ -657,21 +657,29 @@
  * @brief Get a user and XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication
- * @param[in]  name         User name.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-get_user_oap (credentials_t * credentials, const char * name)
+get_user_oap (credentials_t * credentials, params_t *params)
 {
   tracef ("In get_users_oap\n");
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *name;
 
-  assert (name);
+  name = params_value (params, "login");
 
+  if (name == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a user. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_users");
+
   switch (administrator_connect (credentials, &socket, &session, &html))
     {
       case -1:
@@ -726,14 +734,12 @@
  * @brief Get all users and 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_users_oap (credentials_t * credentials, const char * sort_field,
-               const char * sort_order)
+get_users_oap (credentials_t * credentials, params_t *params)
 {
   tracef ("In get_users_oap\n");
   entity_t entity;
@@ -741,7 +747,11 @@
   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 (administrator_connect (credentials, &socket, &session, &html))
     {
       case -1:
@@ -802,14 +812,12 @@
  * @brief Get descriptions of the feed(s) connected to the administrator.
  *
  * @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_feed_oap (credentials_t * credentials, const char * sort_field,
-              const char * sort_order)
+get_feed_oap (credentials_t * credentials, params_t *params)
 {
   tracef ("In get_feed_oap\n");
   entity_t entity;

Modified: trunk/gsa/src/gsad_oap.h
===================================================================
--- trunk/gsa/src/gsad_oap.h	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/gsad_oap.h	2011-09-02 20:21:41 UTC (rev 11554)
@@ -38,16 +38,16 @@
 void oap_init (const gchar *, int);
 
 char * edit_user_oap (credentials_t *, params_t *);
-char * get_user_oap (credentials_t *, const char *);
-char * get_users_oap (credentials_t *, const char *, const char *);
+char * get_user_oap (credentials_t *, params_t *);
+char * get_users_oap (credentials_t *, params_t *);
 char * create_user_oap (credentials_t *, params_t *);
 char * delete_user_oap (credentials_t *, params_t *);
 char * save_user_oap (credentials_t *, params_t *);
-char * get_feed_oap (credentials_t *, const char *, const char *);
+char * get_feed_oap (credentials_t *, params_t *);
 char * sync_feed_oap (credentials_t *, params_t *);
-char * get_settings_oap (credentials_t *, const char *, const char *);
+char * get_settings_oap (credentials_t *, params_t *);
 char * edit_settings_oap (credentials_t *, params_t *);
-char * save_settings_oap (credentials_t * credentials, params_t *);
-char * modify_auth_oap (credentials_t * credentials, params_t *);
+char * save_settings_oap (credentials_t *, params_t *);
+char * modify_auth_oap (credentials_t *, params_t *);
 
 #endif /* not _GSAD_OAP_H */

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/gsad_omp.c	2011-09-02 20:21:41 UTC (rev 11554)
@@ -1551,13 +1551,23 @@
  * @brief Requests NVT details, accepting extra commands.
  *
  * @param[in]  credentials  Credentials for the manager connection.
- * @param[in]  oid          OID of NVT.
+ * @param[in]  params       Request parameters.
  *
  * @return XSL transformed NVT details response or error message.
  */
 char*
-get_nvts_omp (credentials_t *credentials, const char *oid)
+get_nvts_omp (credentials_t *credentials, params_t *params)
 {
+  const char *oid;
+
+  oid = params_value (params, "oid");
+  if (oid == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting an NVT. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_tasks");
+
   return get_nvts (credentials, oid, NULL);
 }
 
@@ -5189,21 +5199,30 @@
  * @brief Get one target, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  target_id    UUID of target.
- * @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_target_omp (credentials_t * credentials, const char * target_id,
-                const char * sort_field, const char * sort_order)
+get_target_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *target_id, *sort_field, *sort_order;
 
+  target_id = params_value (params, "target_id");
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
+  if (target_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a target. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_targets");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -5269,20 +5288,22 @@
  * @brief Get all targets, 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_targets_omp (credentials_t * credentials, const char * sort_field,
-                 const char * sort_order)
+get_targets_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:
@@ -5625,21 +5646,23 @@
  * @brief Get one or all configs, 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_configs_omp (credentials_t * credentials, const char * sort_field,
-                 const char * sort_order)
+get_configs_omp (credentials_t * credentials, params_t *params)
 {
   entity_t entity;
   char *text = NULL;
   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:
@@ -13497,16 +13520,15 @@
  * @brief Get all trash, 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_trash_omp (credentials_t * credentials, const char * sort_field,
-               const char * sort_order)
+get_trash_omp (credentials_t * credentials, params_t *params)
 {
-  return get_trash (credentials, sort_field, sort_order, NULL);
+  return get_trash (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 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/gsad_omp.h	2011-09-02 20:21:41 UTC (rev 11554)
@@ -91,16 +91,15 @@
 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 *);
-char * get_targets_omp (credentials_t *, const char *, const char *);
+char * get_target_omp (credentials_t *, params_t *params);
+char * get_targets_omp (credentials_t *, params_t *params);
 char * create_target_omp (credentials_t *, params_t *);
 char * delete_target_omp (credentials_t *, params_t *);
 char * delete_trash_target_omp (credentials_t *, params_t *);
 
 char * edit_config_omp (credentials_t *, params_t *);
 char * get_config_omp (credentials_t *, params_t *);
-char * get_configs_omp (credentials_t *, const char *, const char *);
+char * get_configs_omp (credentials_t *, params_t *);
 char * save_config_omp (credentials_t *, params_t *);
 char * edit_config_family_omp (credentials_t *, params_t *);
 char * get_config_family_omp (credentials_t *, params_t *);
@@ -156,12 +155,12 @@
 char * save_report_format_omp (credentials_t *, params_t *);
 char * verify_report_format_omp (credentials_t *, params_t *);
 
-char * get_trash_omp (credentials_t *, const char *, const char *);
+char * get_trash_omp (credentials_t *, params_t *params);
 char * restore_omp (credentials_t *, params_t *);
 char * empty_trashcan_omp (credentials_t *, params_t *);
 
 int authenticate_omp (const gchar *, const gchar *);
 
-char * get_nvts_omp (credentials_t *, const char *);
+char * get_nvts_omp (credentials_t *, params_t *);
 
 #endif /* not _GSAD_OMP_H */

Modified: trunk/gsa/src/html/oap.xsl
===================================================================
--- trunk/gsa/src/html/oap.xsl	2011-09-02 19:50:19 UTC (rev 11553)
+++ trunk/gsa/src/html/oap.xsl	2011-09-02 20:21:41 UTC (rev 11554)
@@ -227,7 +227,7 @@
           </div>
         </xsl:otherwise>
       </xsl:choose>
-      <a href="/oap?cmd=get_user&amp;name={name}&amp;token={/envelope/token}"
+      <a href="/oap?cmd=get_user&amp;login={name}&amp;token={/envelope/token}"
          title="Details"
          style="margin-left:3px;">
         <img src="/img/details.png" border="0" alt="Details"/>



More information about the Openvas-commits mailing list