aboutsummaryrefslogtreecommitdiff
path: root/src/pq/pq_helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-10 16:31:29 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-10 16:31:29 +0200
commitaef3b7c350e34f71425ef403d3e5991aced2eb57 (patch)
tree89df52847c5e52750193bfa87bbf0e62d6b8a0d7 /src/pq/pq_helper.c
parentd45534c574cad8a001a113358885adf989132f8d (diff)
implementing pq APIs for #3827, not yet tested or used through
Diffstat (limited to 'src/pq/pq_helper.c')
-rw-r--r--src/pq/pq_helper.c146
1 files changed, 135 insertions, 11 deletions
diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c
index 5da1ced41..01441dec3 100644
--- a/src/pq/pq_helper.c
+++ b/src/pq/pq_helper.c
@@ -15,7 +15,7 @@
*/
/**
* @file pq/pq_helper.c
- * @brief functions to initialize parameter arrays
+ * @brief functions to initialize parameter arrays
* @author Christian Grothoff
*/
#include "platform.h"
@@ -39,7 +39,7 @@ TALER_PQ_query_param_amount_nbo (const struct TALER_AmountNBO *x)
{ TALER_PQ_QF_AMOUNT_NBO, x, sizeof (*x) };
return res;
}
-
+
/**
* Generate query parameter for a currency, consisting of the three
@@ -108,6 +108,63 @@ TALER_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
/**
+ * Generate query parameter for an uint16_t in host byte order.
+ *
+ * @param x pointer to the query parameter to pass
+ */
+struct TALER_PQ_QueryParam
+TALER_PQ_query_param_uint16 (const uint16_t *x)
+{
+ struct TALER_PQ_QueryParam res =
+ { TALER_PQ_QF_UINT16, x, sizeof (*x) };
+ return res;
+}
+
+
+/**
+ * Generate query parameter for an uint32_t in host byte order.
+ *
+ * @param x pointer to the query parameter to pass
+ */
+struct TALER_PQ_QueryParam
+TALER_PQ_query_param_uint32 (const uint32_t *x)
+{
+ struct TALER_PQ_QueryParam res =
+ { TALER_PQ_QF_UINT32, x, sizeof (*x) };
+ return res;
+}
+
+
+/**
+ * Generate query parameter for an uint16_t in host byte order.
+ *
+ * @param x pointer to the query parameter to pass
+ */
+struct TALER_PQ_QueryParam
+TALER_PQ_query_param_uint64 (const uint64_t *x)
+{
+ struct TALER_PQ_QueryParam res =
+ { TALER_PQ_QF_UINT64, x, sizeof (*x) };
+ return res;
+}
+
+
+/**
+ * Generate query parameter for a JSON object (stored as a string
+ * in the DB).
+ *
+ * @param x pointer to the json object to pass
+ */
+struct TALER_PQ_QueryParam
+TALER_PQ_query_param_json (const json_t *x)
+{
+ struct TALER_PQ_QueryParam res =
+ { TALER_PQ_QF_JSON, x, 0 };
+ return res;
+}
+
+
+/**
* Variable-size result expected.
*
* @param name name of the field in the table
@@ -120,7 +177,7 @@ TALER_PQ_result_spec_variable_size (const char *name,
void **dst,
size_t *sptr)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{ TALER_PQ_RF_VARSIZE_BLOB, (void *) (dst), 0, name, sptr };
return res;
}
@@ -137,7 +194,7 @@ struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_amount_nbo (const char *name,
struct TALER_AmountNBO *amount)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{TALER_PQ_RF_AMOUNT_NBO, (void *) amount, sizeof (*amount), name, NULL };
return res;
}
@@ -154,7 +211,7 @@ struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_amount (const char *name,
struct TALER_Amount *amount)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{TALER_PQ_RF_AMOUNT, (void *) amount, sizeof (*amount), name, NULL };
return res;
}
@@ -171,11 +228,11 @@ struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_rsa_public_key (const char *name,
struct GNUNET_CRYPTO_rsa_PublicKey **rsa)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{TALER_PQ_RF_RSA_PUBLIC_KEY, (void *) rsa, 0, name, NULL };
return res;
}
-
+
/**
* RSA signature expected.
@@ -188,12 +245,12 @@ struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_rsa_signature (const char *name,
struct GNUNET_CRYPTO_rsa_Signature **sig)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{TALER_PQ_RF_RSA_SIGNATURE, (void *) sig, 0, (name), NULL };
return res;
}
-
+
/**
* Absolute time expected.
*
@@ -205,10 +262,77 @@ struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_absolute_time (const char *name,
struct GNUNET_TIME_Absolute *at)
{
- struct TALER_PQ_ResultSpec res =
+ struct TALER_PQ_ResultSpec res =
{TALER_PQ_RF_TIME_ABSOLUTE, (void *) at, sizeof (*at), (name), NULL };
return res;
}
-
+
+
+/**
+ * uint16_t expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] u16 where to store the result
+ * @return array entry for the result specification to use
+ */
+struct TALER_PQ_ResultSpec
+TALER_PQ_result_spec_uint16 (const char *name,
+ uint16_t *u16)
+{
+ struct TALER_PQ_ResultSpec res =
+ {TALER_PQ_RF_UINT16, (void *) u16, sizeof (*u16), (name), NULL };
+ return res;
+}
+
+
+/**
+ * uint32_t expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] u32 where to store the result
+ * @return array entry for the result specification to use
+ */
+struct TALER_PQ_ResultSpec
+TALER_PQ_result_spec_uint32 (const char *name,
+ uint16_t *u32)
+{
+ struct TALER_PQ_ResultSpec res =
+ {TALER_PQ_RF_UINT32, (void *) u32, sizeof (*u32), (name), NULL };
+ return res;
+}
+
+
+/**
+ * uint64_t expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] u64 where to store the result
+ * @return array entry for the result specification to use
+ */
+struct TALER_PQ_ResultSpec
+TALER_PQ_result_spec_uint64 (const char *name,
+ uint64_t *u64)
+{
+ struct TALER_PQ_ResultSpec res =
+ {TALER_PQ_RF_UINT64, (void *) u64, sizeof (*u64), (name), NULL };
+ return res;
+}
+
+
+/**
+ * json_t expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] jp where to store the result
+ * @return array entry for the result specification to use
+ */
+struct TALER_PQ_ResultSpec
+TALER_PQ_result_spec_json (const char *name,
+ json_t **jp)
+{
+ struct TALER_PQ_ResultSpec res =
+ {TALER_PQ_RF_JSON, (void *) jp, 0, (name), NULL };
+ return res;
+}
/* end of pq_helper.c */