From 74a21a5259f9dbcb3a9df887cefe70de0567fd63 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 6 May 2015 11:47:12 +0200 Subject: fixing #3768, using new pq API more --- src/include/taler_amount_lib.h | 5 +++++ src/include/taler_pq_lib.h | 27 ++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h index 54eeda844..783b32547 100644 --- a/src/include/taler_amount_lib.h +++ b/src/include/taler_amount_lib.h @@ -32,6 +32,11 @@ */ #define TALER_CURRENCY_LEN 12 +/** + * Taler currency length as a string. + */ +#define TALER_CURRENCY_LEN_STR "12" + /** * @brief The "fraction" value in a `struct TALER_Amount` represents which * fraction of the "main" value? diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index d31ecf84c..6bf5c0c82 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -102,12 +102,15 @@ struct TALER_PQ_QueryParam #define TALER_PQ_QUERY_PARAM_PTR(x) { TALER_PQ_QF_VARSIZE_BLOB, x, sizeof (*(x)) } /** - * Generate fixed-size query parameter with size determined - * by variable type. + * Generate query parameter for a currency, consisting of the three + * components "value", "fraction" and "currency" in this order. The + * types must be a 64-bit integer, 32-bit integer and a + * TALER_CURRENCY_LEN-sized BLOB/VARCHAR respectively. * - * @param x pointer to the query parameter to pass. + * @param x pointer to the query parameter to pass, must be + * a variable of type `struct TALER_AmountNBO`. */ -#define TALER_PQ_QUERY_PARAM_AMOUNT_NBO(x) { TALER_PQ_QF_AMOUNT_NBO, x, sizeof (*(x)) } +#define TALER_PQ_QUERY_PARAM_AMOUNT_NBO(x) { TALER_PQ_QF_AMOUNT_NBO, &(x), sizeof (x) } /** @@ -135,7 +138,13 @@ enum TALER_PQ_ResultFormat * We have a currency amount. * Data points to a `struct TALER_AmountNBO`, size only used for checking. */ - TALER_PQ_RF_AMOUNT_NBO + TALER_PQ_RF_AMOUNT_NBO, + + /** + * We have a currency amount. + * Data points to a `struct TALER_Amount`, size only used for checking. + */ + TALER_PQ_RF_AMOUNT }; @@ -209,6 +218,14 @@ struct TALER_PQ_ResultSpec #define TALER_PQ_RESULT_SPEC_VAR(name, dst, sptr) {TALER_PQ_RF_VARSIZE_BLOB, (void *) (dst), 0, (name), sptr } +/** + * Currency amount expected. + * + * @param name name of the field in the table + * @param amount a `struct TALER_AmountNBO` where to store the result + */ +#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(name, amount) {TALER_PQ_RF_AMOUNT_NBO, (void *) (&dst), sizeof (amount), (name), NULL } + /** * Currency amount expected. * -- cgit v1.2.3