diff --git a/src/manage_get.c b/src/manage_get.c index 2b81ac2f8..3c9e151b9 100644 --- a/src/manage_get.c +++ b/src/manage_get.c @@ -154,18 +154,46 @@ 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 NULL if iteration is complete. Caller must free. */ -DEF_ACCESS (get_iterator_creation_time, 4); +gchar * +get_iterator_creation_time (iterator_t* iterator) +{ + time_t epoch; + char *iso; + + if (iterator->done) return NULL; + + epoch = iterator_int64 (iterator, 4); + iso = iso_time (&epoch); + if (iso) + // iso points to static memory. + return g_strdup (iso); + return g_strdup("ERR"); +} /** * @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 NULL if iteration is complete. Caller must free. */ -DEF_ACCESS (get_iterator_modification_time, 5); +gchar * +get_iterator_modification_time (iterator_t* iterator) +{ + time_t epoch; + char *iso; + + if (iterator->done) return NULL; + + epoch = iterator_int64 (iterator, 5); + iso = iso_time (&epoch); + if (iso) + // iso points to static memory. + return g_strdup (iso); + return g_strdup("ERR"); +} /** * @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..a990825f1 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* +gchar* get_iterator_creation_time (iterator_t*); -const char* +gchar* get_iterator_modification_time (iterator_t*); const char* diff --git a/src/manage_sql.h b/src/manage_sql.h index 6ea3ac24c..e897075c1 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 }