replace macros with functions for better type-checking
This commit is contained in:
parent
f7780b52f1
commit
5004fce6ca
@ -116,7 +116,8 @@ struct TALER_PQ_QueryParam
|
||||
* @param x pointer to the query parameter to pass
|
||||
* @param s number of bytes of @a x to use for the query
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x, s) { TALER_PQ_QF_FIXED_BLOB, (x), (s) }
|
||||
#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x,s) { TALER_PQ_QF_FIXED_BLOB, (x), (s) }
|
||||
|
||||
|
||||
/**
|
||||
* Generate fixed-size query parameter with size determined
|
||||
@ -126,16 +127,17 @@ struct TALER_PQ_QueryParam
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_PTR(x) { TALER_PQ_QF_VARSIZE_BLOB, x, sizeof (*(x)) }
|
||||
|
||||
|
||||
/**
|
||||
* 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, must be
|
||||
* a variable of type `struct TALER_AmountNBO`.
|
||||
* @param x pointer to the query parameter to pass
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_AMOUNT_NBO(x) { TALER_PQ_QF_AMOUNT_NBO, &(x), sizeof (x) }
|
||||
struct TALER_PQ_QueryParam
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO(const struct TALER_AmountNBO *x);
|
||||
|
||||
|
||||
/**
|
||||
@ -144,39 +146,40 @@ struct TALER_PQ_QueryParam
|
||||
* 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, must be
|
||||
* a variable of type `struct TALER_Amount`.
|
||||
* @param x pointer to the query parameter to pass
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_AMOUNT(x) { TALER_PQ_QF_AMOUNT, &(x), sizeof (x) }
|
||||
struct TALER_PQ_QueryParam
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT(const struct TALER_Amount *x);
|
||||
|
||||
|
||||
/**
|
||||
* Generate query parameter for an RSA public key. The
|
||||
* database must contain a BLOB type in the respective position.
|
||||
*
|
||||
* @param x the query parameter to pass, must be
|
||||
* a variable of type `struct GNUNET_CRYPTO_rsa_PublicKey *`.
|
||||
* @param x the query parameter to pass.
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(x) { TALER_PQ_QF_RSA_PUBLIC_KEY, (x), 0 }
|
||||
struct TALER_PQ_QueryParam
|
||||
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(const struct GNUNET_CRYPTO_rsa_PublicKey *x);
|
||||
|
||||
|
||||
/**
|
||||
* Generate query parameter for an RSA signature. The
|
||||
* database must contain a BLOB type in the respective position.
|
||||
*
|
||||
* @param x the query parameter to pass, must be
|
||||
* a variable of type `struct GNUNET_CRYPTO_rsa_Signature *`.
|
||||
* @param x the query parameter to pass
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(x) { TALER_PQ_QF_RSA_SIGNATURE, (x), 0 }
|
||||
struct TALER_PQ_QueryParam
|
||||
TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(const struct GNUNET_CRYPTO_rsa_Signature *x);
|
||||
|
||||
|
||||
/**
|
||||
* Generate query parameter for an absolute time value.
|
||||
* The database must store a 64-bit integer.
|
||||
*
|
||||
* @param x pointer to the query parameter to pass, must be
|
||||
* a variable of type `struct GNUNET_TIME_Absolute`.
|
||||
* @param x pointer to the query parameter to pass
|
||||
*/
|
||||
#define TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(x) { TALER_PQ_QF_TIME_ABSOLUTE, &(x), sizeof (x) }
|
||||
struct TALER_PQ_QueryParam
|
||||
TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(struct GNUNET_TIME_Absolute x);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -851,9 +851,9 @@ postgres_insert_denomination (void *cls,
|
||||
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_withdraw.abs_value_us__),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_spend.abs_value_us__),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&issue->expire_legal.abs_value_us__),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->value),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->fee_withdraw),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (issue->fee_refresh),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->value),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->fee_withdraw),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&issue->fee_refresh),
|
||||
TALER_PQ_QUERY_PARAM_END
|
||||
};
|
||||
result = TALER_PQ_exec_prepared (session->conn,
|
||||
@ -947,7 +947,7 @@ postgres_reserves_update (void *cls,
|
||||
return GNUNET_SYSERR;
|
||||
struct TALER_PQ_QueryParam params[] = {
|
||||
TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (reserve->expiry),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT (reserve->balance),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT (&reserve->balance),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&reserve->pub),
|
||||
TALER_PQ_QUERY_PARAM_END
|
||||
};
|
||||
@ -1460,7 +1460,7 @@ postgres_insert_deposit (void *cls,
|
||||
TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (deposit->coin.denom_pub.rsa_public_key),
|
||||
TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (deposit->coin.denom_sig.rsa_signature),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT (deposit->amount_with_fee),
|
||||
TALER_PQ_QUERY_PARAM_AMOUNT (&deposit->amount_with_fee),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_contract),
|
||||
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_wire),
|
||||
|
@ -12,7 +12,8 @@ lib_LTLIBRARIES = \
|
||||
libtalerpq.la
|
||||
|
||||
libtalerpq_la_SOURCES = \
|
||||
db_pq.c
|
||||
db_pq.c \
|
||||
pq_helper.c
|
||||
|
||||
libtalerpq_la_LIBADD = \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
|
Loading…
Reference in New Issue
Block a user