diff --git a/src/gmp.c b/src/gmp.c index 4c31124ea..492c39920 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -8162,31 +8162,41 @@ buffer_notes_xml (GString *buffer, iterator_t *notes, int include_notes_details, if (include_notes_details == 0) { - const char *text = note_iterator_text (notes); - gchar *excerpt = utf8_substring (text, 0, - setting_excerpt_size_int ()); + gchar *excerpt; + const char *text; + + text = note_iterator_text (notes); + excerpt = utf8_substring (text, 0, setting_excerpt_size_int ()); + /* This must match send_get_common. */ + buffer_xml_append_printf (buffer, "%s" "" "%s" "%s" - "" - "%s" - "%s" - "1" - "0" - "%i" - "%s" - "%i", + "", get_iterator_owner_name (notes) ? get_iterator_owner_name (notes) : "", note_iterator_nvt_oid (notes), note_iterator_nvt_name (notes), - note_iterator_nvt_type (notes), - get_iterator_creation_time (notes), - get_iterator_modification_time (notes), + note_iterator_nvt_type (notes)); + + buffer_xml_append_printf (buffer, + "%s", + iso_if_time (get_iterator_creation_time (notes))); + + buffer_xml_append_printf (buffer, + "%s", + iso_if_time (get_iterator_modification_time (notes))); + + buffer_xml_append_printf (buffer, + "1" + "0" + "%i" + "%s" + "%i", note_iterator_active (notes), strlen (excerpt) < strlen (text), excerpt, @@ -8229,15 +8239,33 @@ buffer_notes_xml (GString *buffer, iterator_t *notes, int include_notes_details, end_time = note_iterator_end_time (notes); /* This must match send_get_common. */ + buffer_xml_append_printf (buffer, "%s" "" "%s" "%s" - "" - "%s" - "%s" + "", + get_iterator_owner_name (notes) + ? get_iterator_owner_name (notes) + : "", + note_iterator_nvt_oid (notes), + note_iterator_nvt_name (notes), + note_iterator_nvt_type (notes)); + + buffer_xml_append_printf + (buffer, + "%s", + iso_if_time (get_iterator_creation_time (notes))); + + buffer_xml_append_printf + (buffer, + "%s", + iso_if_time (get_iterator_modification_time (notes))); + + buffer_xml_append_printf + (buffer, "1" "0" "%i" @@ -8248,14 +8276,6 @@ buffer_notes_xml (GString *buffer, iterator_t *notes, int include_notes_details, "%s" "%s%i" "%i", - get_iterator_owner_name (notes) - ? get_iterator_owner_name (notes) - : "", - note_iterator_nvt_oid (notes), - note_iterator_nvt_name (notes), - note_iterator_nvt_type (notes), - get_iterator_creation_time (notes), - get_iterator_modification_time (notes), note_iterator_active (notes), end_time > 1 ? iso_time (&end_time) : "", note_iterator_text (notes), @@ -8426,18 +8446,36 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides, if (include_overrides_details == 0) { - const char *text = override_iterator_text (overrides); - gchar *excerpt = utf8_substring (text, 0, - setting_excerpt_size_int ()); + gchar *excerpt; + const char *text; + + text = override_iterator_text (overrides); + excerpt = utf8_substring (text, 0, setting_excerpt_size_int ()); + /* This must match send_get_common. */ + buffer_xml_append_printf (buffer, "%s" "" "%s" "%s" - "" - "%s" - "%s" + "", + get_iterator_owner_name (overrides) + ? get_iterator_owner_name (overrides) + : "", + override_iterator_nvt_oid (overrides), + override_iterator_nvt_name (overrides), + override_iterator_nvt_type (overrides)); + + buffer_xml_append_printf (buffer, + "%s", + iso_if_time (get_iterator_creation_time (overrides))); + + buffer_xml_append_printf (buffer, + "%s", + iso_if_time (get_iterator_modification_time (overrides))); + + buffer_xml_append_printf (buffer, "1" "0" "%i" @@ -8447,14 +8485,6 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides, "%s" "%s" "%i", - get_iterator_owner_name (overrides) - ? get_iterator_owner_name (overrides) - : "", - override_iterator_nvt_oid (overrides), - override_iterator_nvt_name (overrides), - override_iterator_nvt_type (overrides), - get_iterator_creation_time (overrides), - get_iterator_modification_time (overrides), override_iterator_active (overrides), strlen (excerpt) < strlen (text), excerpt, @@ -8505,15 +8535,33 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides, end_time = override_iterator_end_time (overrides); /* This must match send_get_common. */ + buffer_xml_append_printf (buffer, "%s" "" "%s" "%s" - "" - "%s" - "%s" + "", + get_iterator_owner_name (overrides) + ? get_iterator_owner_name (overrides) + : "", + override_iterator_nvt_oid (overrides), + override_iterator_nvt_name (overrides), + override_iterator_nvt_type (overrides)); + + buffer_xml_append_printf + (buffer, + "%s", + iso_if_time (get_iterator_creation_time (overrides))); + + buffer_xml_append_printf + (buffer, + "%s", + iso_if_time (get_iterator_modification_time (overrides))); + + buffer_xml_append_printf + (buffer, "1" "0" "%i" @@ -8527,14 +8575,6 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides, "%s" "%s%i" "%i", - get_iterator_owner_name (overrides) - ? get_iterator_owner_name (overrides) - : "", - override_iterator_nvt_oid (overrides), - override_iterator_nvt_name (overrides), - override_iterator_nvt_type (overrides), - get_iterator_creation_time (overrides), - get_iterator_modification_time (overrides), override_iterator_active (overrides), end_time > 1 ? iso_time (&end_time) : "", override_iterator_text (overrides), @@ -9334,7 +9374,7 @@ buffer_results_xml (GString *buffer, iterator_t *results, task_t task, int changed, int cert_loaded, int lean, int use_delta_fields) { - const char *descr, *name, *comment, *creation_time; + const char *descr, *name, *comment; const char *severity, *original_severity, *original_level; const char *host, *hostname, *result_id, *port, *path, *asset_id, *qod, *qod_type; char *detect_oid, *detect_ref, *detect_cpe, *detect_loc, *detect_name; @@ -9343,6 +9383,7 @@ buffer_results_xml (GString *buffer, iterator_t *results, task_t task, result_t result; report_t report; task_t selected_task; + time_t creation_time; comment = get_iterator_comment (results); name = get_iterator_name (results); @@ -9414,7 +9455,8 @@ buffer_results_xml (GString *buffer, iterator_t *results, task_t task, if (lean == 0) { - const char *owner_name, *modification_time; + const char *owner_name; + time_t modification_time; if (use_delta_fields) { @@ -9435,7 +9477,7 @@ buffer_results_xml (GString *buffer, iterator_t *results, task_t task, if (modification_time) buffer_xml_append_printf (buffer, "%s", - modification_time); + iso_time (&modification_time) ?: ""); } if (comment @@ -9447,7 +9489,7 @@ buffer_results_xml (GString *buffer, iterator_t *results, task_t task, if (creation_time) buffer_xml_append_printf (buffer, "%s", - creation_time); + iso_time (&creation_time) ?: ""); if (include_details) { @@ -11671,20 +11713,26 @@ handle_get_assets (gmp_parser_t *gmp_parser, GError **error) xml_string_append (result, "" "%s" - "%s" - "%s" - "%s" + "%s", + get_iterator_uuid (&identifiers), + get_iterator_name (&identifiers), + host_identifier_iterator_value (&identifiers)); + + xml_string_append (result, + "%s", + iso_if_time (get_iterator_creation_time (&identifiers))); + + xml_string_append (result, + "%s", + iso_if_time (get_iterator_modification_time (&identifiers))); + + xml_string_append (result, "" "%s" "%s" "%i" "%s" "", - get_iterator_uuid (&identifiers), - get_iterator_name (&identifiers), - host_identifier_iterator_value (&identifiers), - get_iterator_creation_time (&identifiers), - get_iterator_modification_time (&identifiers), host_identifier_iterator_source_id (&identifiers), source_type, @@ -14717,17 +14765,12 @@ handle_get_reports (gmp_parser_t *gmp_parser, GError **error) task_t task; /* Send the standard elements. Should match send_get_common. */ + buffer_xml_append_printf (prefix, "%s" "%s" - "%s" - "%s" - "" - "%s" - "" - "0" - "0", + "%s", get_iterator_owner_name (&reports) ? get_iterator_owner_name (&reports) : "", @@ -14736,13 +14779,20 @@ handle_get_reports (gmp_parser_t *gmp_parser, GError **error) : "", get_iterator_comment (&reports) ? get_iterator_comment (&reports) - : "", - get_iterator_creation_time (&reports) - ? get_iterator_creation_time (&reports) - : "", - get_iterator_modification_time (&reports) - ? get_iterator_modification_time (&reports) : ""); + + buffer_xml_append_printf + (prefix, + "%s", + iso_if_time (get_iterator_creation_time (&reports))); + + buffer_xml_append_printf + (prefix, + "%s" + "0" + "0", + iso_if_time (get_iterator_modification_time (&reports))); + /* Send short task and report format info */ report_task (report, &task); if (task) @@ -18627,16 +18677,19 @@ handle_get_vulns (gmp_parser_t *gmp_parser, GError **error) count ++; SENDF_TO_CLIENT_OR_FAIL ("" "%s" - "%s" - "%s" - "%s" - "%1.1f" - "%d", + "%s", get_iterator_uuid (&vulns), get_iterator_name (&vulns), - vuln_iterator_type (&vulns), - get_iterator_creation_time (&vulns), - get_iterator_modification_time (&vulns), + vuln_iterator_type (&vulns)); + + SENDF_TO_CLIENT_OR_FAIL ("%s", + iso_if_time (get_iterator_creation_time (&vulns))); + + SENDF_TO_CLIENT_OR_FAIL ("%s", + iso_if_time (get_iterator_modification_time (&vulns))); + + SENDF_TO_CLIENT_OR_FAIL ("%1.1f" + "%d", vuln_iterator_severity (&vulns), vuln_iterator_qod (&vulns)); diff --git a/src/gmp_get.c b/src/gmp_get.c index b13e73192..3793a49d6 100644 --- a/src/gmp_get.c +++ b/src/gmp_get.c @@ -323,12 +323,7 @@ send_get_common (const char *type, get_data_t *get, iterator_t *iterator, "<%s id=\"%s\">" "%s" "%s" - "%s" - "%s" - "%s" - "%i" - "%i" - "", + "%s", type, get_iterator_uuid (iterator) ? get_iterator_uuid (iterator) @@ -341,13 +336,18 @@ send_get_common (const char *type, get_data_t *get, iterator_t *iterator, : "", get_iterator_comment (iterator) ? get_iterator_comment (iterator) - : "", - get_iterator_creation_time (iterator) - ? get_iterator_creation_time (iterator) - : "", - get_iterator_modification_time (iterator) - ? get_iterator_modification_time (iterator) - : "", + : ""); + + buffer_xml_append_printf (buffer, + "%s", + iso_if_time (get_iterator_creation_time (iterator))); + + buffer_xml_append_printf (buffer, + "%s" + "%i" + "%i" + "", + iso_if_time (get_iterator_modification_time (iterator)), writable, in_use); diff --git a/src/manage.c b/src/manage.c index 249ab1522..e0ef3bb4b 100644 --- a/src/manage.c +++ b/src/manage.c @@ -5830,11 +5830,18 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count, nvt_iterator_detection (nvts)); } + g_string_append_printf (buffer, + "%s", + iso_if_time (get_iterator_creation_time (nvts))); + + g_string_append_printf (buffer, + "%s", + iso_if_time (get_iterator_modification_time (nvts))); + default_timeout = nvt_default_timeout (oid); + g_string_append_printf (buffer, "%s" - "%s" - "%s" "%d" "%s" "" @@ -5844,18 +5851,13 @@ get_nvt_xml (iterator_t *nvts, int details, int pref_count, "%s" "%s", default_timeout ? default_timeout : "", - get_iterator_creation_time (nvts) - ? get_iterator_creation_time (nvts) - : "", - get_iterator_modification_time (nvts) - ? get_iterator_modification_time (nvts) - : "", nvt_iterator_category (nvts), family_text, nvt_iterator_qod (nvts), nvt_iterator_qod_type (nvts), refs_str->str, nvt_tags->str); + free (default_timeout); g_string_free (nvt_tags, 1); diff --git a/src/manage.h b/src/manage.h index ed5d12519..9a73dfdcb 100644 --- a/src/manage.h +++ b/src/manage.h @@ -1564,10 +1564,10 @@ result_iterator_delta_uuid (iterator_t*); const char * result_iterator_delta_qod_type (iterator_t*); -const char * +time_t result_iterator_delta_creation_time (iterator_t*); -const char * +time_t result_iterator_delta_modification_time (iterator_t*); task_t diff --git a/src/manage_get.c b/src/manage_get.c index 2b81ac2f8..26b32a12c 100644 --- a/src/manage_get.c +++ b/src/manage_get.c @@ -154,18 +154,28 @@ get_iterator_comment (iterator_t* iterator) * * @param[in] iterator Iterator. * - * @return Creation time of the resource or NULL if iteration is complete. + * @return Creation time, or 0 if iteration is complete. */ -DEF_ACCESS (get_iterator_creation_time, 4); +time_t +get_iterator_creation_time (iterator_t* iterator) +{ + if (iterator->done) return 0; + return iterator_int64 (iterator, 4); +} /** * @brief Get the modification time of the resource from a GET iterator. * * @param[in] iterator Iterator. * - * @return Modification time of the resource or NULL if iteration is complete. + * @return Modification time, or 0 if iteration is complete. */ -DEF_ACCESS (get_iterator_modification_time, 5); +time_t +get_iterator_modification_time (iterator_t* iterator) +{ + if (iterator->done) return 0; + return iterator_int64 (iterator, 5); +} /** * @brief Get the owner name of the resource from a GET iterator. diff --git a/src/manage_get.h b/src/manage_get.h index 5c44e667c..2b7bfce24 100644 --- a/src/manage_get.h +++ b/src/manage_get.h @@ -66,10 +66,10 @@ get_iterator_name (iterator_t*); const char* get_iterator_comment (iterator_t*); -const char* +time_t get_iterator_creation_time (iterator_t*); -const char* +time_t get_iterator_modification_time (iterator_t*); const char* diff --git a/src/manage_sql.c b/src/manage_sql.c index c39503e5f..2f2f8b7cd 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21679,8 +21679,8 @@ report_add_results_array (report_t report, GArray *results) { "uuid", NULL, KEYWORD_TYPE_STRING }, \ { "iso_time (creation_time)", "name", KEYWORD_TYPE_STRING }, \ { "''", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = reports.owner)", \ @@ -22152,12 +22152,12 @@ where_qod (int min_qod) "name", \ KEYWORD_TYPE_STRING }, \ { "''", "comment", KEYWORD_TYPE_STRING }, \ - { " iso_time (date, opts.user_zone)", \ + { "date", \ "creation_time", \ - KEYWORD_TYPE_STRING }, \ - { " iso_time (date, opts.user_zone)", \ + KEYWORD_TYPE_INTEGER }, \ + { "date", \ "modification_time", \ - KEYWORD_TYPE_STRING }, \ + KEYWORD_TYPE_INTEGER }, \ { "date", "created", KEYWORD_TYPE_INTEGER }, \ { "date", "modified", KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = results.owner)", \ @@ -22305,12 +22305,12 @@ where_qod (int min_qod) "name", \ KEYWORD_TYPE_STRING }, \ { "''", "comment", KEYWORD_TYPE_STRING }, \ - { " iso_time (date, opts.user_zone)", \ + { "date", \ "creation_time", \ - KEYWORD_TYPE_STRING }, \ - { " iso_time (date, opts.user_zone)", \ + KEYWORD_TYPE_INTEGER }, \ + { "date", \ "modification_time", \ - KEYWORD_TYPE_STRING }, \ + KEYWORD_TYPE_INTEGER }, \ { "date", "created", KEYWORD_TYPE_INTEGER }, \ { "date", "modified", KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = results.owner)", \ @@ -22467,12 +22467,12 @@ where_qod (int min_qod) { "comparison.delta_qod", NULL, KEYWORD_TYPE_INTEGER }, \ { "comparison.delta_uuid", NULL, KEYWORD_TYPE_STRING }, \ { "delta_qod_type", NULL, KEYWORD_TYPE_STRING }, \ - { " iso_time (delta_date, opts.user_zone)", \ + { "delta_date", \ "delta_creation_time", \ - KEYWORD_TYPE_STRING }, \ - { " iso_time (delta_date, opts.user_zone)", \ + KEYWORD_TYPE_INTEGER }, \ + { "delta_date", \ "delta_modification_time", \ - KEYWORD_TYPE_STRING }, \ + KEYWORD_TYPE_INTEGER }, \ { "delta_task", NULL, KEYWORD_TYPE_INTEGER }, \ { "delta_report", NULL, KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = results.owner)", \ @@ -23906,13 +23906,13 @@ result_iterator_delta_qod_type (iterator_t* iterator) * * @param[in] iterator Iterator. * - * @return delta creation time if any, else NULL. + * @return Time, or 0 if iteration is complete. */ -const char * +time_t result_iterator_delta_creation_time (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_string (iterator, RESULT_ITERATOR_DELTA_COLUMN_OFFSET + 6); + return iterator_int64 (iterator, RESULT_ITERATOR_DELTA_COLUMN_OFFSET + 6); } /** @@ -23920,13 +23920,13 @@ result_iterator_delta_creation_time (iterator_t* iterator) * * @param[in] iterator Iterator. * - * @return delta modification time if any, else NULL. + * @return Time, or 0 if iteration is complete. */ -const char * +time_t result_iterator_delta_modification_time (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_string (iterator, RESULT_ITERATOR_DELTA_COLUMN_OFFSET + 7); + return iterator_int64 (iterator, RESULT_ITERATOR_DELTA_COLUMN_OFFSET + 7); } /** @@ -38530,8 +38530,8 @@ modify_note (const gchar *note_id, const char *active, const char *nvt, KEYWORD_TYPE_STRING \ }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (notes.creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (notes.modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "notes.creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "notes.modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "notes.creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "notes.modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = notes.owner)", \ @@ -38585,8 +38585,8 @@ modify_note (const gchar *note_id, const char *active, const char *nvt, { "notes_trash.uuid", "uuid", KEYWORD_TYPE_STRING }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (notes_trash.creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (notes_trash.modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "notes_trash.creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "notes_trash.modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "notes_trash.creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "notes_trash.modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { "(SELECT name FROM users WHERE users.id = notes_trash.owner)", \ @@ -39767,8 +39767,8 @@ modify_override (const gchar *override_id, const char *active, const char *nvt, KEYWORD_TYPE_STRING \ }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (overrides.creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (overrides.modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "overrides.creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "overrides.modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "overrides.creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "overrides.modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { \ @@ -39835,12 +39835,12 @@ modify_override (const gchar *override_id, const char *active, const char *nvt, { "overrides_trash.uuid", "uuid", KEYWORD_TYPE_STRING }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ { "CAST ('' AS TEXT)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (overrides_trash.creation_time)", \ + { "overrides_trash.creation_time", \ NULL, \ - KEYWORD_TYPE_STRING }, \ - { "iso_time (overrides_trash.modification_time)", \ + KEYWORD_TYPE_INTEGER }, \ + { "overrides_trash.modification_time", \ NULL, \ - KEYWORD_TYPE_STRING }, \ + KEYWORD_TYPE_INTEGER }, \ { "overrides_trash.creation_time", \ "created", \ KEYWORD_TYPE_INTEGER }, \ @@ -50155,9 +50155,9 @@ init_host_identifier_iterator (iterator_t* iterator, host_t host, if (host) init_iterator (iterator, - "SELECT id, uuid, name, comment, iso_time (creation_time)," - " iso_time (modification_time), creation_time," - " modification_time, owner, owner, value," + "SELECT id, uuid, name, comment, creation_time," + " modification_time, creation_time AS created," + " modification_time AS modified, owner, owner, value," " source_type, source_id, source_data," " (CASE WHEN source_type LIKE 'Report%%'" " THEN NOT EXISTS (SELECT * FROM reports" @@ -50168,9 +50168,9 @@ init_host_identifier_iterator (iterator_t* iterator, host_t host, " FROM host_identifiers" " WHERE host = %llu" " UNION" - " SELECT id, uuid, name, comment, iso_time (creation_time)," - " iso_time (modification_time), creation_time," - " modification_time, owner, owner," + " SELECT id, uuid, name, comment, creation_time," + " modification_time, creation_time AS created," + " modification_time AS modified, owner, owner," " (SELECT name FROM oss WHERE id = os)," " source_type, source_id, source_data," " (CASE WHEN source_type LIKE 'Report%%'" @@ -50189,9 +50189,9 @@ init_host_identifier_iterator (iterator_t* iterator, host_t host, ascending ? "ASC" : "DESC"); else init_iterator (iterator, - "SELECT id, uuid, name, comment, iso_time (creation_time)," - " iso_time (modification_time), creation_time," - " modification_time, owner, owner, value," + "SELECT id, uuid, name, comment, creation_time," + " modification_time, creation_time AS created," + " modification_time AS modified, owner, owner, value," " source_type, source_id, source_data, 0, '', ''" " FROM host_identifiers" " ORDER BY %s %s;", @@ -50921,8 +50921,8 @@ init_os_host_iterator (iterator_t* iterator, resource_t os) { assert (os); init_iterator (iterator, - "SELECT id, uuid, name, comment, iso_time (creation_time)," - " iso_time (modification_time), creation_time," + "SELECT id, uuid, name, comment, creation_time," + " modification_time, creation_time," " modification_time, owner, owner," " (SELECT round (CAST (severity AS numeric), 1)" " FROM host_max_severities" @@ -55289,8 +55289,8 @@ user_resources_in_use (user_t user, { "uuid", "uuid", KEYWORD_TYPE_STRING }, \ { "name", "name", KEYWORD_TYPE_STRING }, \ { "''", "comment", KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { "cast (null AS text)", "_owner", KEYWORD_TYPE_INTEGER }, \ diff --git a/src/manage_sql.h b/src/manage_sql.h index 7d98f1994..7d8a1e4df 100644 --- a/src/manage_sql.h +++ b/src/manage_sql.h @@ -248,9 +248,9 @@ typedef struct * * @param[in] prefix Column prefix. */ -#define GET_ITERATOR_COLUMNS_STRING \ - "id, uuid, name, comment, iso_time (creation_time)," \ - " iso_time (modification_time), creation_time AS created," \ +#define GET_ITERATOR_COLUMNS_STRING \ + "id, uuid, name, comment, creation_time," \ + " modification_time, creation_time AS created," \ " modification_time AS modified" /** @@ -263,8 +263,8 @@ typedef struct { prefix "uuid", NULL, KEYWORD_TYPE_STRING }, \ { prefix "name", NULL, KEYWORD_TYPE_STRING }, \ { prefix "comment", NULL, KEYWORD_TYPE_STRING }, \ - { " iso_time (" prefix "creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { " iso_time (" prefix "modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { prefix "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { prefix "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { prefix "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { prefix "modification_time", "modified", KEYWORD_TYPE_INTEGER } diff --git a/src/manage_sql_report_configs.c b/src/manage_sql_report_configs.c index ed158db2f..6d4b44c15 100644 --- a/src/manage_sql_report_configs.c +++ b/src/manage_sql_report_configs.c @@ -661,8 +661,8 @@ restore_report_config (const char *report_config_id) { "uuid", NULL, KEYWORD_TYPE_STRING }, \ { "name", NULL, KEYWORD_TYPE_STRING }, \ { "comment", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { \ @@ -696,8 +696,8 @@ restore_report_config (const char *report_config_id) { "uuid", NULL, KEYWORD_TYPE_STRING }, \ { "name", NULL, KEYWORD_TYPE_STRING }, \ { "comment", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { \ diff --git a/src/manage_sql_report_formats.c b/src/manage_sql_report_formats.c index dd0f3da50..3f6df153f 100644 --- a/src/manage_sql_report_formats.c +++ b/src/manage_sql_report_formats.c @@ -2653,8 +2653,8 @@ report_format_trust (report_format_t report_format) { "uuid", NULL, KEYWORD_TYPE_STRING }, \ { "name", NULL, KEYWORD_TYPE_STRING }, \ { "''", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { \ @@ -2690,8 +2690,8 @@ report_format_trust (report_format_t report_format) { "uuid", NULL, KEYWORD_TYPE_STRING }, \ { "name", NULL, KEYWORD_TYPE_STRING }, \ { "''", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \ - { "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \ + { "creation_time", NULL, KEYWORD_TYPE_INTEGER }, \ + { "modification_time", NULL, KEYWORD_TYPE_INTEGER }, \ { "creation_time", "created", KEYWORD_TYPE_INTEGER }, \ { "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \ { \ diff --git a/src/utils.c b/src/utils.c index 83c55f7fd..efe108b23 100644 --- a/src/utils.c +++ b/src/utils.c @@ -483,7 +483,7 @@ iso_time_internal (time_t *epoch_time, const char **abbrev) /** * @brief Create an ISO time from seconds since epoch. * - * @param[in] epoch_time Time in seconds from epoch. + * @param[in] epoch_time Pointer to time in seconds from epoch. * * @return Pointer to ISO time in static memory, or NULL on error. */ @@ -496,7 +496,7 @@ iso_time (time_t *epoch_time) /** * @brief Create an ISO time from seconds since epoch, given a timezone. * - * @param[in] epoch_time Time in seconds from epoch. + * @param[in] epoch_time Pointer to time in seconds from epoch. * @param[in] zone Timezone. * @param[out] abbrev Timezone abbreviation. * @@ -543,6 +543,28 @@ iso_time_tz (time_t *epoch_time, const char *zone, const char **abbrev) return ret; } +/** + * @brief Create an ISO time from seconds since epoch, with a 0 check. + * + * @param[in] epoch_time Time in seconds from epoch. + * + * @return ISO time string in static memory. If epoch_time is 0 then string is empty. + */ +char * +iso_if_time (time_t epoch_time) +{ + static char *empty = ""; + if (epoch_time) + { + char *ret; + + ret = iso_time (&epoch_time); + if (ret) + return ret; + } + return empty; +} + /* Locks. */ diff --git a/src/utils.h b/src/utils.h index 50333d71e..dfeed44b6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -55,6 +55,9 @@ iso_time (time_t *); char * iso_time_tz (time_t *, const char *, const char **); +char * +iso_if_time (time_t epoch_time); + /** * @brief Lockfile. */