From d81e32a49f8d2d533f61889018bd6188616f5ff8 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 16 May 2011 18:53:25 +0200 Subject: [PATCH] Add db_strtime_handler to get DATE fields from database --- bacula/src/cats/protos.h | 1 + bacula/src/cats/sql.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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" */ -- 2.39.5