[Openvas-commits] r13212 - in trunk/openvas-manager: . src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Apr 9 10:59:24 CEST 2012
Author: mattm
Date: 2012-04-09 10:59:24 +0200 (Mon, 09 Apr 2012)
New Revision: 13212
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.h
trunk/openvas-manager/src/manage_sql.c
trunk/openvas-manager/src/omp.c
Log:
* src/manage_sql.c (init_target_iterator): If max is -2 then get max from
Rows Per Page setting.
(setting_value_int): New function.
* src/manage.h: Add header accordingly.
* src/omp.c (omp_xml_handle_start_element): Let GET_TARGETS max be any
negative.
(omp_xml_handle_end_element): If GET_TARGETS max is -2 then set is from
Rows Per Page setting.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2012-04-08 15:18:21 UTC (rev 13211)
+++ trunk/openvas-manager/ChangeLog 2012-04-09 08:59:24 UTC (rev 13212)
@@ -1,5 +1,18 @@
2012-04-06 Matthew Mundell <matthew.mundell at greenbone.net>
+ * src/manage_sql.c (init_target_iterator): If max is -2 then get max from
+ Rows Per Page setting.
+ (setting_value_int): New function.
+
+ * src/manage.h: Add header accordingly.
+
+ * src/omp.c (omp_xml_handle_start_element): Let GET_TARGETS max be any
+ negative.
+ (omp_xml_handle_end_element): If GET_TARGETS max is -2 then set is from
+ Rows Per Page setting.
+
+2012-04-06 Matthew Mundell <matthew.mundell at greenbone.net>
+
Add OMP GET_SETTINGS.
* src/manage_sql.c (create_tables): Add settings.
Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h 2012-04-08 15:18:21 UTC (rev 13211)
+++ trunk/openvas-manager/src/manage.h 2012-04-09 08:59:24 UTC (rev 13212)
@@ -2182,6 +2182,9 @@
setting_iterator_value (iterator_t*);
int
+setting_value_int (const char *, int *);
+
+int
manage_set_setting (const gchar *, const gchar *);
Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c 2012-04-08 15:18:21 UTC (rev 13211)
+++ trunk/openvas-manager/src/manage_sql.c 2012-04-09 08:59:24 UTC (rev 13212)
@@ -23166,7 +23166,8 @@
* @param[in] trash Whether to iterate over trashcan targets.
* @param[in] filter Filter term.
* @param[in] first First target.
- * @param[in] max Maximum number of targets returned.
+ * @param[in] max Maximum number of targets returned. If -2 then
+ * Rows Per Page targets.
* @param[in] ascending Whether to sort ascending or descending.
* @param[in] sort_field Field to sort on, or NULL for "ROWID".
* @param[in] actions_string Actions.
@@ -23184,7 +23185,10 @@
if (first < 0)
first = 0;
- if (max < 1)
+
+ if (max == -2)
+ setting_value_int ("5f5a8712-8017-11e1-8556-406186ea4fc5", &max);
+ else if (max < 1)
max = -1;
if (actions_string == NULL || strlen (actions_string) == 0)
@@ -37293,6 +37297,57 @@
DEF_ACCESS (setting_iterator_value, 4);
/**
+ * @brief Get the value of a setting.
+ *
+ * @param[in] uuid UUID of setting.
+ * @param[out] value Value.
+ *
+ * @return 0 success, -1 error.
+ */
+int
+setting_value_int (const char *uuid, int *value)
+{
+ gchar *quoted_uuid;
+
+ if (value == NULL || uuid == NULL)
+ return -1;
+
+ quoted_uuid = sql_quote (uuid);
+
+ if (sql_int (0, 0,
+ "SELECT count (*)"
+ " FROM settings"
+ " WHERE uuid = '%s'"
+ " AND (owner IS NULL)"
+ " OR (owner ="
+ " (SELECT ROWID FROM users WHERE users.uuid = '%s'));",
+ quoted_uuid,
+ current_credentials.uuid)
+ == 0)
+ {
+ *value = -1;
+ g_free (quoted_uuid);
+ return -1;
+ }
+
+ *value = sql_int (0, 0,
+ "SELECT value"
+ " FROM settings"
+ " WHERE uuid = '%s'"
+ " AND (owner IS NULL)"
+ " OR (owner ="
+ " (SELECT ROWID FROM users WHERE users.uuid = '%s'))"
+ /* Force the user's setting to come before the default. */
+ " ORDER BY owner DESC;",
+ quoted_uuid,
+ current_credentials.uuid);
+
+ g_free (quoted_uuid);
+
+ return 0;
+}
+
+/**
* @brief Set the value of a setting.
*
* @param[in] name Setting name.
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2012-04-08 15:18:21 UTC (rev 13211)
+++ trunk/openvas-manager/src/omp.c 2012-04-09 08:59:24 UTC (rev 13212)
@@ -4990,7 +4990,7 @@
get_targets_data->max = atoi (attribute);
else
get_targets_data->max = -1;
- if (get_targets_data->max < 1)
+ if (get_targets_data->max == 0)
get_targets_data->max = -1;
append_attribute (attribute_names, attribute_values, "sort_field",
@@ -15085,6 +15085,9 @@
get_targets_data->filter
? get_targets_data->filter
: "");
+ if (get_targets_data->max == -2)
+ setting_value_int ("5f5a8712-8017-11e1-8556-406186ea4fc5",
+ &get_targets_data->max);
SENDF_TO_CLIENT_OR_FAIL ("<targets start=\"%i\" max=\"%i\"/>",
/* Add 1 for 1 indexing. */
get_targets_data->first + 1,
More information about the Openvas-commits
mailing list