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

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


Author: mattm
Date: 2011-09-01 21:09:35 +0200 (Thu, 01 Sep 2011)
New Revision: 11547

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 (verify_agent_omp, export_config_omp)
	(export_preference_file_omp, export_report_format_omp)
	(verify_report_format_omp): Replace multiple args with one.

	* src/gsad_omp.h: Update headers accordingly.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-01 14:52:03 UTC (rev 11546)
+++ trunk/gsa/ChangeLog	2011-09-01 19:09:35 UTC (rev 11547)
@@ -2,6 +2,18 @@
 
 	Convert more pages to new param mechanism.
 
+	* src/gsad.c (exec_omp_get): Pass single param instead of many.
+
+	* src/gsad_omp.c (verify_agent_omp, export_config_omp)
+	(export_preference_file_omp, export_report_format_omp)
+	(verify_report_format_omp): Replace multiple args with one.
+
+	* src/gsad_omp.h: Update headers accordingly.
+
+2011-09-01  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Convert more pages to new param mechanism.
+
 	* src/gsad.c (exec_omp_get, exec_omp_post): Pass single param instead of
 	many.
 

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-01 14:52:03 UTC (rev 11546)
+++ trunk/gsa/src/gsad.c	2011-09-01 19:09:35 UTC (rev 11547)
@@ -3138,23 +3138,17 @@
   ELSE (edit_task)
   ELSE_OAP (edit_user)
 
-  else if ((!strcmp (cmd, "export_config")) && (config_id != NULL))
-    return export_config_omp (credentials, config_id, content_type,
+  else if (!strcmp (cmd, "export_config"))
+    return export_config_omp (credentials, params, content_type,
                               content_disposition, response_size);
 
-  else if ((!strcmp (cmd, "export_preference_file"))
-           && (config_id != NULL)
-           && (oid != NULL)
-           && (preference_name != NULL))
-    return export_preference_file_omp (credentials, config_id, oid, preference_name,
-                                       content_type, content_disposition,
-                                       response_size);
+  else if (!strcmp (cmd, "export_preference_file"))
+    return export_preference_file_omp (credentials, params, content_type,
+                                       content_disposition, response_size);
 
-  else if ((!strcmp (cmd, "export_report_format"))
-           && (report_format_id != NULL))
-    return export_report_format_omp (credentials, report_format_id,
-                                     content_type, content_disposition,
-                                     response_size);
+  else if (!strcmp (cmd, "export_report_format"))
+    return export_report_format_omp (credentials, params, content_type,
+                                     content_disposition, response_size);
 
   else if (0 == strcmp (cmd, "get_agents")
            && ((agent_id == NULL && agent_format == NULL)
@@ -3344,15 +3338,9 @@
 
   ELSE (new_note)
   ELSE (new_override)
+  ELSE (verify_agent)
+  ELSE (verify_report_format)
 
-  else if ((!strcmp (cmd, "verify_agent"))
-           && (agent_id != NULL))
-    return verify_agent_omp (credentials, agent_id);
-
-  else if ((!strcmp (cmd, "verify_report_format"))
-           && (report_format_id != NULL))
-    return verify_report_format_omp (credentials, report_format_id);
-
   else
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-01 14:52:03 UTC (rev 11546)
+++ trunk/gsa/src/gsad_omp.c	2011-09-01 19:09:35 UTC (rev 11547)
@@ -3077,18 +3077,27 @@
  * @brief Verify agent, get agents, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  agent_id     ID of agent.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-verify_agent_omp (credentials_t * credentials, const char *agent_id)
+verify_agent_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *agent_id;
 
+  agent_id = params_value (params, "agent_id");
+  if (agent_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while verifying an agent. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_agents");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -6277,7 +6286,7 @@
   family = params_value (params, "family");
   nvt = params_value (params, "oid");
 
-  if ((config_id == NULL) || (name == NULL) || (family == NULL))
+  if ((config_id == NULL) || (name == NULL))
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,
                          "An internal error occurred while getting config family. "
@@ -6310,7 +6319,7 @@
                           "</config>",
                           config_id,
                           name,
-                          family);
+                          family ? family : "");
 
   sort_field = params_value (params, "sort_field");
   sort_order = params_value (params, "sort_order");
@@ -6479,7 +6488,7 @@
                   int found = 0;
                   params_t *files;
 
-                  files = params_values (params, "files:");
+                  files = params_values (params, "file:");
                   if (files)
                     {
                       param_t *file;
@@ -6683,7 +6692,7 @@
  * @brief Export a config.
  *
  * @param[in]   credentials          Username and password for authentication.
- * @param[in]   config_id            UUID of config.
+ * @param[in]   params               Request parameters.
  * @param[out]  content_type         Content type return.
  * @param[out]  content_disposition  Content dispositions return.
  * @param[out]  content_length       Content length return.
@@ -6691,7 +6700,7 @@
  * @return Config XML on success.  HTML result of XSL transformation on error.
  */
 char *
-export_config_omp (credentials_t * credentials, const char *config_id,
+export_config_omp (credentials_t * credentials, params_t *params,
                    enum content_type * content_type, char **content_disposition,
                    gsize *content_length)
 {
@@ -6702,7 +6711,16 @@
   int socket;
   char *content = NULL;
   gchar *html;
+  const char *config_id;
 
+  config_id = params_value (params, "config_id");
+  if (config_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a config. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_configs");
+
   *content_length = 0;
 
   switch (manager_connect (credentials, &socket, &session, &html))
@@ -6794,9 +6812,7 @@
  * @brief Export a file preference.
  *
  * @param[in]   credentials          Username and password for authentication.
- * @param[in]   config_id            UUID of config.
- * @param[in]   oid                  OID of NVT.
- * @param[in]   preference_name      Name of preference.
+ * @param[in]   params               Request parameters.
  * @param[out]  content_type         Content type return.
  * @param[out]  content_disposition  Content dispositions return.
  * @param[out]  content_length       Content length return.
@@ -6804,8 +6820,7 @@
  * @return Config XML on success.  HTML result of XSL transformation on error.
  */
 char *
-export_preference_file_omp (credentials_t * credentials, const char *config_id,
-                            const char *oid, const char *preference_name,
+export_preference_file_omp (credentials_t * credentials, params_t *params,
                             enum content_type * content_type, char **content_disposition,
                             gsize *content_length)
 {
@@ -6814,6 +6829,7 @@
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *config_id, *oid, *preference_name;
 
   *content_length = 0;
 
@@ -6834,6 +6850,10 @@
                              "/omp?cmd=get_tasks");
     }
 
+  config_id = params_value (params, "config_id");
+  oid = params_value (params, "oid");
+  preference_name = params_value (params, "preference_name");
+
   xml = g_string_new ("<get_preferences_response>");
 
   if (config_id == NULL || oid == NULL || preference_name == NULL)
@@ -6918,7 +6938,7 @@
  *         on error.
  */
 char *
-export_report_format_omp (credentials_t * credentials, const char *report_format_id,
+export_report_format_omp (credentials_t * credentials, params_t *params,
                           enum content_type * content_type, char **content_disposition,
                           gsize *content_length)
 {
@@ -6929,6 +6949,7 @@
   int socket;
   char *content = NULL;
   gchar *html;
+  const char *report_format_id;
 
   *content_length = 0;
 
@@ -6951,6 +6972,8 @@
 
   xml = g_string_new ("<get_report_formats>");
 
+  report_format_id = params_value (params, "report_format_id");
+
   if (report_format_id == NULL)
     g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Export Scan Report Format"));
   else
@@ -12930,20 +12953,28 @@
 /**
  * @brief Verify report format, get report formats, XSL transform the result.
  *
- * @param[in]  credentials       Username and password for authentication.
- * @param[in]  report_format_id  ID of report format.
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-verify_report_format_omp (credentials_t * credentials,
-                          const char *report_format_id)
+verify_report_format_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  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 verifying a report format. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_report_formats");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2011-09-01 14:52:03 UTC (rev 11546)
+++ trunk/gsa/src/gsad_omp.h	2011-09-01 19:09:35 UTC (rev 11547)
@@ -89,7 +89,7 @@
 char * create_agent_omp (credentials_t *, params_t *);
 char * delete_agent_omp (credentials_t *, params_t *);
 char * delete_trash_agent_omp (credentials_t *, params_t *);
-char * verify_agent_omp (credentials_t *, const char *);
+char * verify_agent_omp (credentials_t *, params_t *);
 
 char * create_schedule_omp (credentials_t *, params_t *);
 
@@ -120,13 +120,12 @@
 char * import_config_omp (credentials_t *, params_t *);
 char * delete_config_omp (credentials_t *, params_t *);
 char * delete_trash_config_omp (credentials_t *, params_t *);
-char * export_config_omp (credentials_t *, const char *, enum content_type*,
+char * export_config_omp (credentials_t *, params_t *, enum content_type*,
                           char **, gsize *);
 
-char * export_preference_file_omp (credentials_t *, const char *, const char *,
-                                   const char *, enum content_type *, char **,
-                                   gsize *);
-char * export_report_format_omp (credentials_t *, const char *,
+char * export_preference_file_omp (credentials_t *, params_t *,
+                                   enum content_type *, char **, gsize *);
+char * export_report_format_omp (credentials_t *, params_t *,
                                  enum content_type *, char **, gsize *);
 
 char * get_notes_omp (credentials_t *);
@@ -165,7 +164,7 @@
 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 *);
+char * verify_report_format_omp (credentials_t *, params_t *);
 
 char * get_trash_omp (credentials_t *, const char *, const char *);
 char * restore_omp (credentials_t *, params_t *);



More information about the Openvas-commits mailing list