From: Eric Bollengier Date: Mon, 16 May 2011 16:53:25 +0000 (+0200) Subject: Add db_strtime_handler to get DATE fields from database X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ec279a681b9bdb9e6bf8b1d99a5bcc9df339c643;p=bacula%2Fbacula Add db_strtime_handler to get DATE fields from database --- diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 0be1f4f81d..a6777a4570 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -44,6 +44,7 @@ bool db_open_batch_connexion(JCR *jcr, B_DB *mdb); char *db_strerror(B_DB *mdb); int db_int64_handler(void *ctx, int num_fields, char **row); +int db_strtime_handler(void *ctx, int num_fields, char **row); int db_list_handler(void *ctx, int num_fields, char **row); void db_debug_print(JCR *jcr, FILE *fp); int db_int_handler(void *ctx, int num_fields, char **row); diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 3bb8a9c170..e4f88f61a9 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -99,6 +99,21 @@ int db_int64_handler(void *ctx, int num_fields, char **row) return 0; } +/* + * Called here to retrieve a btime from the database. + * The returned integer will be extended to 64 bit. + */ +int db_strtime_handler(void *ctx, int num_fields, char **row) +{ + db_int64_ctx *lctx = (db_int64_ctx *)ctx; + + if (row[0]) { + lctx->value = str_to_utime(row[0]); + lctx->count++; + } + return 0; +} + /* * Use to build a comma separated list of values from a query. "10,20,30" */