From 22c825f0fe99129c7d94792c4d450cd22ef5c414 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 May 2015 14:12:17 +0200 Subject: fix ftbfs of test --- src/pq/test_pq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 2d56e11e..260323ef 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -114,21 +114,21 @@ run_queries (PGconn *conn) TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (abs_time), TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (forever), TALER_PQ_QUERY_PARAM_PTR (&hc), - TALER_PQ_QUERY_PARAM_AMOUNT (hamount), - TALER_PQ_QUERY_PARAM_AMOUNT_NBO (namount), + TALER_PQ_QUERY_PARAM_AMOUNT (&hamount), + TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&namount), TALER_PQ_QUERY_PARAM_END }; struct TALER_PQ_QueryParam params_select[] = { TALER_PQ_QUERY_PARAM_END }; struct TALER_PQ_ResultSpec results_select[] = { - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("pub", pub2), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("sig", sig2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("abs_time", abs_time2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("forever", forever2), + TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("pub", &pub2), + TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("sig", &sig2), + TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("abs_time", &abs_time2), + TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("forever", &forever2), TALER_PQ_RESULT_SPEC ("hash", &hc2), - TALER_PQ_RESULT_SPEC_AMOUNT ("hamount", hamount2), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", namount2), + TALER_PQ_RESULT_SPEC_AMOUNT ("hamount", &hamount2), + TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", &namount2), TALER_PQ_RESULT_SPEC_END }; PGresult *result; -- cgit v1.2.3 From 3ac86568b0223ab3dfca83b497208dc0f2261fdd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 09:33:15 +0200 Subject: use talercheck DB --- src/mintdb/test-mint-db-postgres.conf | 2 +- src/pq/test_pq.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/mintdb/test-mint-db-postgres.conf b/src/mintdb/test-mint-db-postgres.conf index a5a738e4..07f8a0e5 100644 --- a/src/mintdb/test-mint-db-postgres.conf +++ b/src/mintdb/test-mint-db-postgres.conf @@ -3,4 +3,4 @@ DB = postgres #The connection string the plugin has to use for connecting to the database -DB_CONN_STR = postgres:///taler +DB_CONN_STR = postgres:///talercheck diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 260323ef..2133182d 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -165,7 +165,7 @@ main(int argc, int ret; // FIXME: pass valid connect string for tests... - conn = PQconnectdb (""); + conn = PQconnectdb ("postgres:///talercheck"); if (CONNECTION_OK != PQstatus (conn)) { fprintf (stderr, @@ -177,7 +177,7 @@ main(int argc, } result = PQexec (conn, - "CREATE TABLE test_pq (" + "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq (" " pub BYTEA NOT NULL" ",sig BYTEA NOT NULL" ",abs_time INT8 NOT NULL" -- cgit v1.2.3 From 6b9ccc4ca0a5cb35c6cc76a8d5247ac914561d64 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 09:53:31 +0200 Subject: fixing misc. minor bugs, towards getting testcases to work --- src/pq/db_pq.c | 5 ++- src/pq/pq_helper.c | 2 +- src/pq/test_pq.c | 101 ++++++++++++++++++++++++++++++----------------------- 3 files changed, 63 insertions(+), 45 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index 72a9370e..42ce3fa7 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -60,6 +60,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, break; case TALER_PQ_QF_RSA_PUBLIC_KEY: case TALER_PQ_QF_RSA_SIGNATURE: + case TALER_PQ_QF_TIME_ABSOLUTE: len++; break; default: @@ -67,6 +68,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, GNUNET_assert (0); break; } + i++; } /* new scope to allow stack allocation without alloca */ @@ -190,6 +192,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, GNUNET_assert (0); break; } + i++; } GNUNET_assert (off == len); res = PQexecPrepared (db_conn, @@ -200,7 +203,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, param_formats, 1); for (off = 0; off < soff; off++) - GNUNET_free (scratch[soff]); + GNUNET_free (scratch[off]); return res; } } diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c index b172a94b..183bd43f 100644 --- a/src/pq/pq_helper.c +++ b/src/pq/pq_helper.c @@ -155,7 +155,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, struct TALER_Amount *amount) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (amount), (name), NULL }; + {TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (*amount), (name), NULL }; return res; } diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 2133182d..1672cc54 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -77,9 +77,9 @@ postgres_prepare (PGconn *db_conn) ",namount_val" ",namount_frac" ",namount_curr" - "FROM test_pq" - "ORDER BY abs_time DESC " - "LIMIT 1;", + " FROM test_pq" + " ORDER BY abs_time DESC " + " LIMIT 1;", 0, NULL); return GNUNET_OK; #undef PREPARE @@ -108,47 +108,60 @@ run_queries (PGconn *conn) struct TALER_Amount hamount2; struct TALER_AmountNBO namount; struct TALER_AmountNBO namount2; - struct TALER_PQ_QueryParam params_insert[] = { - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), - TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (sig), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (abs_time), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (forever), - TALER_PQ_QUERY_PARAM_PTR (&hc), - TALER_PQ_QUERY_PARAM_AMOUNT (&hamount), - TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&namount), - TALER_PQ_QUERY_PARAM_END - }; - struct TALER_PQ_QueryParam params_select[] = { - TALER_PQ_QUERY_PARAM_END - }; - struct TALER_PQ_ResultSpec results_select[] = { - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("pub", &pub2), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("sig", &sig2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("abs_time", &abs_time2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("forever", &forever2), - TALER_PQ_RESULT_SPEC ("hash", &hc2), - TALER_PQ_RESULT_SPEC_AMOUNT ("hamount", &hamount2), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", &namount2), - TALER_PQ_RESULT_SPEC_END - }; PGresult *result; int ret; - - // FIXME: init pub, sig - result = TALER_PQ_exec_prepared (conn, - "test_insert", - params_insert); - PQclear (result); - result = TALER_PQ_exec_prepared (conn, - "test_select", - params_select); - ret = TALER_PQ_extract_result (result, - results_select, - 0); - // FIXME: cmp results! - TALER_PQ_cleanup_result (results_select); - PQclear (result); - + struct GNUNET_CRYPTO_rsa_PrivateKey *priv; + char msg[] = "Hello"; + + priv = GNUNET_CRYPTO_rsa_private_key_create (1024); + pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); + sig = GNUNET_CRYPTO_rsa_sign (priv, + msg, + sizeof (msg)); + { + struct TALER_PQ_QueryParam params_insert[] = { + TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), + TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (sig), + TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (abs_time), + TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (forever), + TALER_PQ_QUERY_PARAM_PTR (&hc), + TALER_PQ_QUERY_PARAM_AMOUNT (&hamount), + TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&namount), + TALER_PQ_QUERY_PARAM_END + }; + struct TALER_PQ_QueryParam params_select[] = { + TALER_PQ_QUERY_PARAM_END + }; + struct TALER_PQ_ResultSpec results_select[] = { + TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("pub", &pub2), + TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("sig", &sig2), + TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("abs_time", &abs_time2), + TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("forever", &forever2), + TALER_PQ_RESULT_SPEC ("hash", &hc2), + TALER_PQ_RESULT_SPEC_AMOUNT ("hamount", &hamount2), + TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", &namount2), + TALER_PQ_RESULT_SPEC_END + }; + + + result = TALER_PQ_exec_prepared (conn, + "test_insert", + params_insert); + PQclear (result); + result = TALER_PQ_exec_prepared (conn, + "test_select", + params_select); + ret = TALER_PQ_extract_result (result, + results_select, + 0); + // FIXME: cmp results! + + TALER_PQ_cleanup_result (results_select); + PQclear (result); + } + GNUNET_CRYPTO_rsa_signature_free (sig); + GNUNET_CRYPTO_rsa_private_key_free (priv); + GNUNET_CRYPTO_rsa_public_key_free (pub); if (GNUNET_OK != ret) return 1; @@ -165,6 +178,9 @@ main(int argc, int ret; // FIXME: pass valid connect string for tests... + GNUNET_log_setup ("test-pq", + "WARNING", + NULL); conn = PQconnectdb ("postgres:///talercheck"); if (CONNECTION_OK != PQstatus (conn)) { @@ -204,7 +220,6 @@ main(int argc, postgres_prepare (conn)) { GNUNET_break (0); - PQclear (result); PQfinish (conn); return 1; } -- cgit v1.2.3 From 6c774a1f032e2e09ab5e22a58a1979acc2c3430b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 14:16:10 +0200 Subject: completing test-case implementation: --- src/pq/db_pq.c | 4 ++-- src/pq/pq_helper.c | 2 +- src/pq/test_pq.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 61 insertions(+), 6 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index 42ce3fa7..220ce9f9 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -113,7 +113,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, param_formats[off] = 1; off++; param_values[off] = (void *) amount->currency; - param_lengths[off] = strlen (amount->currency) + 1; + param_lengths[off] = strlen (amount->currency); param_formats[off] = 1; off++; } @@ -136,7 +136,7 @@ TALER_PQ_exec_prepared (PGconn *db_conn, param_formats[off] = 1; off++; param_values[off] = (void *) amount->currency; - param_lengths[off] = strlen (amount->currency) + 1; + param_lengths[off] = strlen (amount->currency); param_formats[off] = 1; off++; } diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c index 183bd43f..5baab5a1 100644 --- a/src/pq/pq_helper.c +++ b/src/pq/pq_helper.c @@ -138,7 +138,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, struct TALER_AmountNBO *amount) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (amount), (name), NULL }; + {TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (*amount), (name), NULL }; return res; } diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 1672cc54..dfae8612 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -118,6 +118,12 @@ run_queries (PGconn *conn) sig = GNUNET_CRYPTO_rsa_sign (priv, msg, sizeof (msg)); + TALER_string_to_amount ("EUR:5.5", + &hamount); + TALER_amount_hton (&namount, + &hamount); + TALER_string_to_amount ("EUR:4.4", + &hamount); { struct TALER_PQ_QueryParam params_insert[] = { TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), @@ -143,19 +149,68 @@ run_queries (PGconn *conn) TALER_PQ_RESULT_SPEC_END }; - + fprintf (stderr, + "Inserting\n"); result = TALER_PQ_exec_prepared (conn, "test_insert", params_insert); + if (PGRES_COMMAND_OK != PQresultStatus (result)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database failure: %s\n", + PQresultErrorMessage (result)); + PQclear (result); + GNUNET_CRYPTO_rsa_signature_free (sig); + GNUNET_CRYPTO_rsa_private_key_free (priv); + GNUNET_CRYPTO_rsa_public_key_free (pub); + return 1; + } + PQclear (result); + fprintf (stderr, + "Selecting\n"); result = TALER_PQ_exec_prepared (conn, "test_select", params_select); + if (1 != + PQntuples (result)) + { + GNUNET_break (0); + PQclear (result); + GNUNET_CRYPTO_rsa_signature_free (sig); + GNUNET_CRYPTO_rsa_private_key_free (priv); + GNUNET_CRYPTO_rsa_public_key_free (pub); + return 1; + } ret = TALER_PQ_extract_result (result, results_select, 0); - // FIXME: cmp results! - + GNUNET_break (GNUNET_YES == ret); + fprintf (stderr, + "Verifying\n"); + GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); + GNUNET_break (forever.abs_value_us == forever2.abs_value_us); + GNUNET_break (0 == + memcmp (&hc, + &hc2, + sizeof (struct GNUNET_HashCode))); + GNUNET_break (0 == + TALER_amount_cmp (&hamount, + &hamount2)); + TALER_string_to_amount ("EUR:5.5", + &hamount); + TALER_amount_ntoh (&hamount2, + &namount2); + GNUNET_break (0 == + TALER_amount_cmp (&hamount, + &hamount2)); + GNUNET_break (0 == + GNUNET_CRYPTO_rsa_signature_cmp (sig, + sig2)); + GNUNET_break (0 == + GNUNET_CRYPTO_rsa_public_key_cmp (pub, + pub2)); + TALER_PQ_cleanup_result (results_select); PQclear (result); } -- cgit v1.2.3 From 955054bf25222be9c3942f695e74c8195627405c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 14:36:08 +0200 Subject: misc bugfixes --- src/include/taler_pq_lib.h | 2 +- src/pq/db_pq.c | 33 +++++++++++++++++++++------------ src/pq/pq_helper.c | 12 ++++++------ src/pq/test_pq.c | 1 + 4 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 148385c8..6570cb95 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -297,7 +297,7 @@ struct TALER_PQ_ResultSpec * @param dst point to where to store the result, type fits expected result size * @return array entry for the result specification to use */ -#define TALER_PQ_RESULT_SPEC(name, dst) { TALER_PQ_RF_VARSIZE_BLOB, (void *) dst, sizeof (*(dst)), name, NULL } +#define TALER_PQ_RESULT_SPEC(name, dst) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), sizeof (*(dst)), name, NULL } /** diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index 220ce9f9..3b39645a 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -225,25 +225,34 @@ TALER_PQ_cleanup_result (struct TALER_PQ_ResultSpec *rs) switch (rs[i].format) { case TALER_PQ_RF_VARSIZE_BLOB: - if (NULL != rs[i].dst) { - GNUNET_free (rs[i].dst); - rs[i].dst = NULL; - *rs[i].result_size = 0; + void **dst = rs[i].dst; + if (NULL != *dst) + { + GNUNET_free (*dst); + *dst = NULL; + *rs[i].result_size = 0; + } + break; } - break; case TALER_PQ_RF_RSA_PUBLIC_KEY: - if (NULL != rs[i].dst) { - GNUNET_CRYPTO_rsa_public_key_free (rs[i].dst); - rs[i].dst = NULL; + void **dst = rs[i].dst; + if (NULL != *dst) + { + GNUNET_CRYPTO_rsa_public_key_free (*dst); + *dst = NULL; + } + break; } - break; case TALER_PQ_RF_RSA_SIGNATURE: - if (NULL != rs[i].dst) { - GNUNET_CRYPTO_rsa_signature_free (rs[i].dst); - rs[i].dst = NULL; + void **dst = rs[i].dst; + if (NULL != *dst) + { + GNUNET_CRYPTO_rsa_signature_free (*dst); + *dst = NULL; + } } break; default: diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c index 5baab5a1..9cbdc54b 100644 --- a/src/pq/pq_helper.c +++ b/src/pq/pq_helper.c @@ -121,7 +121,7 @@ TALER_PQ_RESULT_SPEC_VAR (const char *name, size_t *sptr) { struct TALER_PQ_ResultSpec res = - { TALER_PQ_RF_VARSIZE_BLOB, (void *) (dst), 0, (name), sptr }; + { TALER_PQ_RF_VARSIZE_BLOB, (void *) (dst), 0, name, sptr }; return res; } @@ -138,7 +138,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, struct TALER_AmountNBO *amount) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_AMOUNT_NBO, (void *) (&amount), sizeof (*amount), (name), NULL }; + {TALER_PQ_RF_AMOUNT_NBO, (void *) amount, sizeof (*amount), name, NULL }; return res; } @@ -155,7 +155,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, struct TALER_Amount *amount) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_AMOUNT, (void *) (&amount), sizeof (*amount), (name), NULL }; + {TALER_PQ_RF_AMOUNT, (void *) amount, sizeof (*amount), name, NULL }; return res; } @@ -172,7 +172,7 @@ TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name, struct GNUNET_CRYPTO_rsa_PublicKey **rsa) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_RSA_PUBLIC_KEY, (void *) &(rsa), 0, (name), NULL }; + {TALER_PQ_RF_RSA_PUBLIC_KEY, (void *) rsa, 0, name, NULL }; return res; } @@ -189,7 +189,7 @@ TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name, struct GNUNET_CRYPTO_rsa_Signature **sig) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_RSA_SIGNATURE, (void *) &(sig), 0, (name), NULL }; + {TALER_PQ_RF_RSA_SIGNATURE, (void *) sig, 0, (name), NULL }; return res; } @@ -206,7 +206,7 @@ TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME (const char *name, struct GNUNET_TIME_Absolute *at) { struct TALER_PQ_ResultSpec res = - {TALER_PQ_RF_TIME_ABSOLUTE, (void *) (&at), sizeof (at), (name), NULL }; + {TALER_PQ_RF_TIME_ABSOLUTE, (void *) at, sizeof (*at), (name), NULL }; return res; } diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index dfae8612..7146281e 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -124,6 +124,7 @@ run_queries (PGconn *conn) &hamount); TALER_string_to_amount ("EUR:4.4", &hamount); + /* FIXME: test TALER_PQ_RESULT_SPEC_VAR */ { struct TALER_PQ_QueryParam params_insert[] = { TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), -- cgit v1.2.3 From 85f198ef32012b02d72a7e4af2924f69b6625f73 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 14:46:03 +0200 Subject: getting test to pass --- src/include/taler_pq_lib.h | 2 +- src/pq/db_pq.c | 4 ---- src/pq/pq_helper.c | 4 ++-- src/pq/test_pq.c | 11 ++--------- 4 files changed, 5 insertions(+), 16 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 6570cb95..980ca29b 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -179,7 +179,7 @@ TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(const struct GNUNET_CRYPTO_rsa_Signature *x); * @param x pointer to the query parameter to pass */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(struct GNUNET_TIME_Absolute x); +TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(const struct GNUNET_TIME_Absolute *x); /** diff --git a/src/pq/db_pq.c b/src/pq/db_pq.c index 3b39645a..bb18c56a 100644 --- a/src/pq/db_pq.c +++ b/src/pq/db_pq.c @@ -178,8 +178,6 @@ TALER_PQ_exec_prepared (PGconn *db_conn, at_nbo = GNUNET_new (struct GNUNET_TIME_AbsoluteNBO); scratch[soff++] = at_nbo; - /* FIXME: this does not work for 'forever' as PQ uses 63-bit integers; - should check and handle! (Need testcase!) */ *at_nbo = GNUNET_TIME_absolute_hton (*at_hbo); param_values[off] = (void *) at_nbo; param_lengths[off] = sizeof (struct GNUNET_TIME_AbsoluteNBO); @@ -537,8 +535,6 @@ TALER_PQ_extract_result (PGresult *result, PQgetvalue (result, row, fnum); - /* FIXME: this does not work for 'forever' as PQ uses 63-bit integers; - should check and handle! (Need testcase!) */ *dst = GNUNET_TIME_absolute_ntoh (*res); break; } diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c index 9cbdc54b..98c02de7 100644 --- a/src/pq/pq_helper.c +++ b/src/pq/pq_helper.c @@ -99,10 +99,10 @@ TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (const struct GNUNET_CRYPTO_rsa_Signature *x) * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (struct GNUNET_TIME_Absolute x) +TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (const struct GNUNET_TIME_Absolute *x) { struct TALER_PQ_QueryParam res = - { TALER_PQ_QF_TIME_ABSOLUTE, &(x), sizeof (x) }; + { TALER_PQ_QF_TIME_ABSOLUTE, x, sizeof (*x) }; return res; } diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 7146281e..d3417111 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -129,8 +129,8 @@ run_queries (PGconn *conn) struct TALER_PQ_QueryParam params_insert[] = { TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (sig), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (abs_time), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (forever), + TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&abs_time), + TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&forever), TALER_PQ_QUERY_PARAM_PTR (&hc), TALER_PQ_QUERY_PARAM_AMOUNT (&hamount), TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&namount), @@ -150,8 +150,6 @@ run_queries (PGconn *conn) TALER_PQ_RESULT_SPEC_END }; - fprintf (stderr, - "Inserting\n"); result = TALER_PQ_exec_prepared (conn, "test_insert", params_insert); @@ -168,8 +166,6 @@ run_queries (PGconn *conn) } PQclear (result); - fprintf (stderr, - "Selecting\n"); result = TALER_PQ_exec_prepared (conn, "test_select", params_select); @@ -187,8 +183,6 @@ run_queries (PGconn *conn) results_select, 0); GNUNET_break (GNUNET_YES == ret); - fprintf (stderr, - "Verifying\n"); GNUNET_break (abs_time.abs_value_us == abs_time2.abs_value_us); GNUNET_break (forever.abs_value_us == forever2.abs_value_us); GNUNET_break (0 == @@ -233,7 +227,6 @@ main(int argc, PGresult *result; int ret; - // FIXME: pass valid connect string for tests... GNUNET_log_setup ("test-pq", "WARNING", NULL); -- cgit v1.2.3 From aa89db4d0a92f341eb6239a06c7b69410934132b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 16 May 2015 20:33:01 +0200 Subject: organize #include, remove redundant includes --- src/include/taler_mint_service.h | 1 - src/include/taler_mintdb_lib.h | 1 - src/include/taler_mintdb_plugin.h | 2 - src/include/taler_pq_lib.h | 34 ++-- src/include/taler_util.h | 2 +- src/mint-tools/taler-mint-dbinit.c | 2 - src/mint-tools/taler-mint-keyup.c | 2 - src/mint-tools/taler-mint-reservemod.c | 4 - src/mint/taler-mint-httpd.c | 2 - src/mint/taler-mint-httpd_db.c | 4 - src/mint/taler-mint-httpd_db.h | 2 - src/mint/taler-mint-httpd_deposit.c | 4 - src/mint/taler-mint-httpd_refresh.c | 3 - src/mint/taler-mint-httpd_test.c | 1 - src/mintdb/mintdb_plugin.c | 3 +- src/mintdb/plugin_mintdb_postgres.c | 305 ++++++++++++++++----------------- src/pq/pq_helper.c | 22 +-- src/pq/test_pq.c | 36 ++-- src/util/json.c | 1 - src/util/os_installation.c | 2 +- src/util/wireformats.c | 1 - 21 files changed, 201 insertions(+), 233 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index 4c71c002..4fd9a281 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -22,7 +22,6 @@ #define _TALER_MINT_SERVICE_H #include "taler_util.h" -#include /** * @brief Handle to this library context diff --git a/src/include/taler_mintdb_lib.h b/src/include/taler_mintdb_lib.h index 646693de..739194a4 100644 --- a/src/include/taler_mintdb_lib.h +++ b/src/include/taler_mintdb_lib.h @@ -23,7 +23,6 @@ #ifndef TALER_MINTDB_LIB_H #define TALER_MINTDB_LIB_H -#include #include "taler_signatures.h" /** diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index 1a4a6c60..6cc8fd76 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -23,8 +23,6 @@ #define TALER_MINTDB_PLUGIN_H #include -#include "taler_util.h" -#include "taler_signatures.h" #include "taler_mintdb_lib.h" diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index d02dc55a..06ff580f 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -108,7 +108,7 @@ struct TALER_PQ_QueryParam /** * End of query parameter specification. */ -#define TALER_PQ_QUERY_PARAM_END { TALER_PQ_QF_END, NULL, 0 } +#define TALER_PQ_query_param_end { TALER_PQ_QF_END, NULL, 0 } /** * Generate fixed-size query parameter with size given explicitly. @@ -116,7 +116,7 @@ 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_fixed_size(x,s) { TALER_PQ_QF_FIXED_BLOB, (x), (s) } /** @@ -125,7 +125,7 @@ struct TALER_PQ_QueryParam * * @param x pointer to the query parameter to pass. */ -#define TALER_PQ_QUERY_PARAM_PTR(x) { TALER_PQ_QF_VARSIZE_BLOB, x, sizeof (*(x)) } +#define TALER_PQ_query_param_auto_from_type(x) { TALER_PQ_QF_VARSIZE_BLOB, x, sizeof (*(x)) } /** @@ -137,7 +137,7 @@ struct TALER_PQ_QueryParam * @param x pointer to the query parameter to pass */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_AMOUNT_NBO(const struct TALER_AmountNBO *x); +TALER_PQ_query_param_amount_nbo(const struct TALER_AmountNBO *x); /** @@ -149,7 +149,7 @@ TALER_PQ_QUERY_PARAM_AMOUNT_NBO(const struct TALER_AmountNBO *x); * @param x pointer to the query parameter to pass */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_AMOUNT(const struct TALER_Amount *x); +TALER_PQ_query_param_amount(const struct TALER_Amount *x); /** @@ -159,7 +159,7 @@ TALER_PQ_QUERY_PARAM_AMOUNT(const struct TALER_Amount *x); * @param x the query parameter to pass. */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(const struct GNUNET_CRYPTO_rsa_PublicKey *x); +TALER_PQ_query_param_rsa_public_key(const struct GNUNET_CRYPTO_rsa_PublicKey *x); /** @@ -169,7 +169,7 @@ TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(const struct GNUNET_CRYPTO_rsa_PublicKey *x) * @param x the query parameter to pass */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(const struct GNUNET_CRYPTO_rsa_Signature *x); +TALER_PQ_query_param_rsa_signature(const struct GNUNET_CRYPTO_rsa_Signature *x); /** @@ -179,7 +179,7 @@ TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(const struct GNUNET_CRYPTO_rsa_Signature *x); * @param x pointer to the query parameter to pass */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME(const struct GNUNET_TIME_Absolute *x); +TALER_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x); /** @@ -277,7 +277,7 @@ struct TALER_PQ_ResultSpec * * @return array last entry for the result specification to use */ -#define TALER_PQ_RESULT_SPEC_END { TALER_PQ_RF_END, NULL, 0, NULL, NULL } +#define TALER_PQ_result_spec_end { TALER_PQ_RF_END, NULL, 0, NULL, NULL } /** * We expect a fixed-size result, with size given explicitly @@ -287,7 +287,7 @@ struct TALER_PQ_ResultSpec * @param s number of bytes we should use in @a dst * @return array entry for the result specification to use */ -#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), (s), (name), NULL } +#define TALER_PQ_result_spec_fixed_size(name, dst, s) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), (s), (name), NULL } /** @@ -297,7 +297,7 @@ struct TALER_PQ_ResultSpec * @param dst point to where to store the result, type fits expected result size * @return array entry for the result specification to use */ -#define TALER_PQ_RESULT_SPEC(name, dst) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), sizeof (*(dst)), name, NULL } +#define TALER_PQ_result_spec_auto_from_type(name, dst) { TALER_PQ_RF_FIXED_BLOB, (void *) (dst), sizeof (*(dst)), name, NULL } /** @@ -309,7 +309,7 @@ struct TALER_PQ_ResultSpec * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_VAR (const char *name, +TALER_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr); @@ -322,7 +322,7 @@ TALER_PQ_RESULT_SPEC_VAR (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, +TALER_PQ_result_spec_amount_nbo (const char *name, struct TALER_AmountNBO *amount); @@ -334,7 +334,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, +TALER_PQ_result_spec_amount (const char *name, struct TALER_Amount *amount); @@ -346,7 +346,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name, +TALER_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_rsa_PublicKey **rsa); @@ -358,7 +358,7 @@ TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name, +TALER_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_rsa_Signature **sig); @@ -370,7 +370,7 @@ TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME (const char *name, +TALER_PQ_result_spec_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at); diff --git a/src/include/taler_util.h b/src/include/taler_util.h index cad89968..c9db9f78 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -108,7 +108,7 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, * @return a pointer to the dir path (to be freed by the caller) */ char * -TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); +TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); /** diff --git a/src/mint-tools/taler-mint-dbinit.c b/src/mint-tools/taler-mint-dbinit.c index 0eefc63b..3293a69a 100644 --- a/src/mint-tools/taler-mint-dbinit.c +++ b/src/mint-tools/taler-mint-dbinit.c @@ -21,9 +21,7 @@ #include "platform.h" #include #include -#include "taler_util.h" #include "taler_mintdb_plugin.h" -#include "taler_mintdb_lib.h" /** * Mint directory with the keys. diff --git a/src/mint-tools/taler-mint-keyup.c b/src/mint-tools/taler-mint-keyup.c index cc60756a..70c66443 100644 --- a/src/mint-tools/taler-mint-keyup.c +++ b/src/mint-tools/taler-mint-keyup.c @@ -22,8 +22,6 @@ * @author Christian Grothoff */ #include -#include -#include "taler_util.h" #include "taler_mintdb_lib.h" /** diff --git a/src/mint-tools/taler-mint-reservemod.c b/src/mint-tools/taler-mint-reservemod.c index 645a2f32..9dff5731 100644 --- a/src/mint-tools/taler-mint-reservemod.c +++ b/src/mint-tools/taler-mint-reservemod.c @@ -22,11 +22,7 @@ #include "platform.h" #include #include -#include "taler_util.h" -#include "taler_signatures.h" -#include "taler_pq_lib.h" #include "taler_mintdb_plugin.h" -#include "taler_mintdb_lib.h" /** * After what time to inactive reserves expire? diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c index deb30661..b9146c5d 100644 --- a/src/mint/taler-mint-httpd.c +++ b/src/mint/taler-mint-httpd.c @@ -26,8 +26,6 @@ #include #include #include -#include "taler_signatures.h" -#include "taler_util.h" #include "taler-mint-httpd_parsing.h" #include "taler-mint-httpd_mhd.h" #include "taler-mint-httpd_deposit.h" diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index b4256c03..22f225c2 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -21,12 +21,8 @@ #include "platform.h" #include #include -#include "taler-mint-httpd_db.h" -#include "taler_signatures.h" #include "taler-mint-httpd_responses.h" -#include "taler_util.h" #include "taler-mint-httpd_keystate.h" -#include "taler_mintdb_lib.h" /** diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index 4319a81e..56a4dd9c 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -22,8 +22,6 @@ #define TALER_MINT_HTTPD_DB_H #include -#include -#include "taler_util.h" #include "taler_mintdb_plugin.h" diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c index bf182d00..2e9facdf 100644 --- a/src/mint/taler-mint-httpd_deposit.c +++ b/src/mint/taler-mint-httpd_deposit.c @@ -30,11 +30,7 @@ #include #include #include -#include "taler_mintdb_plugin.h" -#include "taler_signatures.h" -#include "taler_util.h" #include "taler-mint-httpd_parsing.h" -#include "taler-mint-httpd_db.h" #include "taler-mint-httpd_deposit.h" #include "taler-mint-httpd_responses.h" #include "taler-mint-httpd_keystate.h" diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index cde7d22c..0ffba6e8 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -24,9 +24,6 @@ #include #include #include -#include "taler_mintdb_plugin.h" -#include "taler_signatures.h" -#include "taler_util.h" #include "taler-mint-httpd_parsing.h" #include "taler-mint-httpd_mhd.h" #include "taler-mint-httpd_refresh.h" diff --git a/src/mint/taler-mint-httpd_test.c b/src/mint/taler-mint-httpd_test.c index 61bd4d96..22c13908 100644 --- a/src/mint/taler-mint-httpd_test.c +++ b/src/mint/taler-mint-httpd_test.c @@ -24,7 +24,6 @@ #include #include #include "taler_signatures.h" -#include "taler_util.h" #include "taler-mint-httpd_test.h" #include "taler-mint-httpd_parsing.h" #include "taler-mint-httpd_responses.h" diff --git a/src/mintdb/mintdb_plugin.c b/src/mintdb/mintdb_plugin.c index 4480e27c..2e8d206f 100644 --- a/src/mintdb/mintdb_plugin.c +++ b/src/mintdb/mintdb_plugin.c @@ -20,7 +20,6 @@ * @author Sree Harsha Totakura */ #include "platform.h" -#include "taler_mintdb_lib.h" #include "taler_mintdb_plugin.h" #include @@ -112,7 +111,7 @@ plugin_init () opath = lt_dlgetsearchpath (); if (NULL != opath) old_dlsearchpath = GNUNET_strdup (opath); - path = TALER_os_installation_get_path (GNUNET_OS_IPK_LIBDIR); + path = TALER_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); if (NULL != path) { if (NULL != opath) diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index e5eb7cce..3800f03b 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -23,7 +23,6 @@ */ #include "platform.h" #include "taler_pq_lib.h" -#include "taler_signatures.h" #include "taler_mintdb_plugin.h" #include #include @@ -862,15 +861,15 @@ postgres_insert_denomination (void *cls, int ret; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (dki->denom_pub.rsa_public_key), - TALER_PQ_QUERY_PARAM_PTR (&issue->start.abs_value_us__), - 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_END + TALER_PQ_query_param_rsa_public_key (dki->denom_pub.rsa_public_key), + TALER_PQ_query_param_auto_from_type (&issue->start.abs_value_us__), + TALER_PQ_query_param_auto_from_type (&issue->expire_withdraw.abs_value_us__), + TALER_PQ_query_param_auto_from_type (&issue->expire_spend.abs_value_us__), + TALER_PQ_query_param_auto_from_type (&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_end }; result = TALER_PQ_exec_prepared (session->conn, "insert_denomination", @@ -906,13 +905,13 @@ postgres_reserve_get (void *cls, { PGresult *result; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(&reserve->pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(&reserve->pub), + TALER_PQ_query_param_end }; struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT("current_balance", &reserve->balance), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME("expiration_date", &reserve->expiry), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_amount("current_balance", &reserve->balance), + TALER_PQ_result_spec_absolute_time("expiration_date", &reserve->expiry), + TALER_PQ_result_spec_end }; result = TALER_PQ_exec_prepared (session->conn, @@ -962,10 +961,10 @@ postgres_reserves_update (void *cls, if (NULL == reserve) 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_PTR (&reserve->pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_absolute_time (&reserve->expiry), + TALER_PQ_query_param_amount (&reserve->balance), + TALER_PQ_query_param_auto_from_type (&reserve->pub), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "update_reserve", @@ -1034,10 +1033,10 @@ postgres_reserves_in_insert (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reserve does not exist; creating a new one\n"); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (reserve_pub), - TALER_PQ_QUERY_PARAM_AMOUNT (balance), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&expiry), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (reserve_pub), + TALER_PQ_query_param_amount (balance), + TALER_PQ_query_param_absolute_time (&expiry), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "create_reserve", @@ -1073,11 +1072,11 @@ postgres_reserves_in_insert (void *cls, /* create new incoming transaction, SQL "primary key" logic is used to guard against duplicates! */ struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (&reserve.pub), - TALER_PQ_QUERY_PARAM_AMOUNT (balance), - TALER_PQ_QUERY_PARAM_PTR_SIZED (details, strlen (details)), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&expiry), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (&reserve.pub), + TALER_PQ_query_param_amount (balance), + TALER_PQ_query_param_fixed_size (details, strlen (details)), + TALER_PQ_query_param_absolute_time (&expiry), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "create_reserves_in_transaction", @@ -1143,8 +1142,8 @@ postgres_get_collectable_blindcoin (void *cls, { PGresult *result; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (h_blind), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (h_blind), + TALER_PQ_query_param_end }; struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; struct GNUNET_CRYPTO_rsa_Signature *denom_sig; @@ -1166,11 +1165,11 @@ postgres_get_collectable_blindcoin (void *cls, goto cleanup; } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", &denom_pub), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("denom_sig", &denom_sig), - TALER_PQ_RESULT_SPEC("reserve_sig", &collectable->reserve_sig), - TALER_PQ_RESULT_SPEC("reserve_pub", &collectable->reserve_pub), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_rsa_public_key("denom_pub", &denom_pub), + TALER_PQ_result_spec_rsa_signature("denom_sig", &denom_sig), + TALER_PQ_result_spec_auto_from_type("reserve_sig", &collectable->reserve_sig), + TALER_PQ_result_spec_auto_from_type("reserve_pub", &collectable->reserve_pub), + TALER_PQ_result_spec_end }; if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) @@ -1216,12 +1215,12 @@ postgres_insert_collectable_blindcoin (void *cls, struct TALER_MINTDB_Reserve reserve; int ret = GNUNET_SYSERR; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (h_blind), - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (collectable->denom_pub.rsa_public_key), - TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (collectable->sig.rsa_signature), - TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_pub), - TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_sig), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (h_blind), + TALER_PQ_query_param_rsa_public_key (collectable->denom_pub.rsa_public_key), + TALER_PQ_query_param_rsa_signature (collectable->sig.rsa_signature), + TALER_PQ_query_param_auto_from_type (&collectable->reserve_pub), + TALER_PQ_query_param_auto_from_type (&collectable->reserve_sig), + TALER_PQ_query_param_end }; if (GNUNET_OK != postgres_start (cls, @@ -1294,8 +1293,8 @@ postgres_get_reserve_history (void *cls, { struct TALER_MINTDB_BankTransfer *bt; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (reserve_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (reserve_pub), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, @@ -1351,8 +1350,8 @@ postgres_get_reserve_history (void *cls, struct GNUNET_CRYPTO_rsa_Signature *denom_sig; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (reserve_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (reserve_pub), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "get_reserves_blindcoins", @@ -1368,11 +1367,11 @@ postgres_get_reserve_history (void *cls, goto cleanup; } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC ("blind_ev", &blind_ev), - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", &denom_pub), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("denom_sig", &denom_sig), - TALER_PQ_RESULT_SPEC ("reserve_sig", &reserve_sig), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_auto_from_type ("blind_ev", &blind_ev), + TALER_PQ_result_spec_rsa_public_key ("denom_pub", &denom_pub), + TALER_PQ_result_spec_rsa_signature ("denom_sig", &denom_sig), + TALER_PQ_result_spec_auto_from_type ("reserve_sig", &reserve_sig), + TALER_PQ_result_spec_end }; GNUNET_assert (NULL != rh); GNUNET_assert (NULL != rh_head); @@ -1427,10 +1426,10 @@ postgres_have_deposit (void *cls, const struct TALER_MINTDB_Deposit *deposit) { struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub), - TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id), - TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (&deposit->coin.coin_pub), + TALER_PQ_query_param_auto_from_type (&deposit->transaction_id), + TALER_PQ_query_param_auto_from_type (&deposit->merchant_pub), + TALER_PQ_query_param_end }; PGresult *result; int ret; @@ -1480,18 +1479,18 @@ postgres_insert_deposit (void *cls, ret = GNUNET_SYSERR; json_wire_enc = json_dumps (deposit->wire, JSON_COMPACT); struct TALER_PQ_QueryParam params[]= { - TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub), - 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_PTR (&deposit->merchant_pub), - TALER_PQ_QUERY_PARAM_PTR (&deposit->h_contract), - TALER_PQ_QUERY_PARAM_PTR (&deposit->h_wire), - TALER_PQ_QUERY_PARAM_PTR (&deposit->csig), - TALER_PQ_QUERY_PARAM_PTR_SIZED (json_wire_enc, + TALER_PQ_query_param_auto_from_type (&deposit->coin.coin_pub), + 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_auto_from_type (&deposit->transaction_id), + TALER_PQ_query_param_amount (&deposit->amount_with_fee), + TALER_PQ_query_param_auto_from_type (&deposit->merchant_pub), + TALER_PQ_query_param_auto_from_type (&deposit->h_contract), + TALER_PQ_query_param_auto_from_type (&deposit->h_wire), + TALER_PQ_query_param_auto_from_type (&deposit->csig), + TALER_PQ_query_param_fixed_size (json_wire_enc, strlen (json_wire_enc)), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "insert_deposit", params); if (PGRES_COMMAND_OK != PQresultStatus (result)) @@ -1527,8 +1526,8 @@ postgres_get_refresh_session (void *cls, { PGresult *result; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_end }; int ret; uint16_t num_oldcoins; @@ -1559,10 +1558,10 @@ postgres_get_refresh_session (void *cls, } memset (refresh_session, 0, sizeof (struct TALER_MINTDB_RefreshSession)); struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC("num_oldcoins", &num_oldcoins), - TALER_PQ_RESULT_SPEC("num_newcoins", &num_newcoins), - TALER_PQ_RESULT_SPEC("noreveal_index", &noreveal_index), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_auto_from_type("num_oldcoins", &num_oldcoins), + TALER_PQ_result_spec_auto_from_type("num_newcoins", &num_newcoins), + TALER_PQ_result_spec_auto_from_type("noreveal_index", &noreveal_index), + TALER_PQ_result_spec_end }; if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) { @@ -1602,11 +1601,11 @@ postgres_create_refresh_session (void *cls, uint16_t num_newcoins; uint16_t noreveal_index; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&num_oldcoins), - TALER_PQ_QUERY_PARAM_PTR(&num_newcoins), - TALER_PQ_QUERY_PARAM_PTR(&noreveal_index), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&num_oldcoins), + TALER_PQ_query_param_auto_from_type(&num_newcoins), + TALER_PQ_query_param_auto_from_type(&noreveal_index), + TALER_PQ_query_param_end }; num_oldcoins = htons (refresh_session->num_oldcoins); num_newcoins = htons (refresh_session->num_newcoins); @@ -1648,11 +1647,11 @@ postgres_insert_refresh_melt (void *cls, { struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(&melt->session_hash), - TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&melt->coin.coin_pub), - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY(melt->coin.denom_pub.rsa_public_key), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(&melt->session_hash), + TALER_PQ_query_param_auto_from_type(&oldcoin_index_nbo), + TALER_PQ_query_param_auto_from_type(&melt->coin.coin_pub), + TALER_PQ_query_param_rsa_public_key(melt->coin.denom_pub.rsa_public_key), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_melt", @@ -1691,18 +1690,18 @@ postgres_get_refresh_melt (void *cls, // FIXME: check logic! uint16_t oldcoin_index_nbo = htons (oldcoin_index); struct TALER_PQ_Query params[] = { - TALER_PQ_QUERY_PARAM_PTR (session_hash), - TALER_PQ_QUERY_PARAM_PTR (&oldcoin_index_nbo), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (session_hash), + TALER_PQ_query_param_auto_from_type (&oldcoin_index_nbo), + TALER_PQ_query_param_end }; struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC ("coin_pub", &melt->coin), - TALER_PQ_RESULT_SPEC ("coin_sig", &melt->coin_sig), - TALER_PQ_RESULT_SPEC ("denom_pub", &melt->coin), - TALER_PQ_RESULT_SPEC ("denom_sig", &melt->coin), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", melt->amount_with_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("fee", melt->melt_fee), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_auto_from_type ("coin_pub", &melt->coin), + TALER_PQ_result_spec_auto_from_type ("coin_sig", &melt->coin_sig), + TALER_PQ_result_spec_auto_from_type ("denom_pub", &melt->coin), + TALER_PQ_result_spec_auto_from_type ("denom_sig", &melt->coin), + TALER_PQ_result_spec_amount ("amount", melt->amount_with_fee), + TALER_PQ_result_spec_amount ("fee", melt->melt_fee), + TALER_PQ_result_spec_end }; result = TALER_PQ_exec_prepared (session->conn, @@ -1752,10 +1751,10 @@ postgres_insert_refresh_order (void *cls, { struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (&newcoin_index_nbo), - TALER_PQ_QUERY_PARAM_PTR (session_hash), - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (denom_pubs->rsa_public_key), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (&newcoin_index_nbo), + TALER_PQ_query_param_auto_from_type (session_hash), + TALER_PQ_query_param_rsa_public_key (denom_pubs->rsa_public_key), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_order", @@ -1800,9 +1799,9 @@ postgres_get_refresh_order (void *cls, uint16_t newcoin_index_nbo = htons (num_newcoins); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&newcoin_index_nbo), + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, @@ -1823,8 +1822,8 @@ postgres_get_refresh_order (void *cls, } GNUNET_assert (1 == PQntuples (result)); struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("denom_pub", &denom_pubs->rsa_public_key), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_rsa_public_key ("denom_pub", &denom_pubs->rsa_public_key), + TALER_PQ_result_spec_end }; if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) { @@ -1863,14 +1862,14 @@ postgres_insert_refresh_commit_coins (void *cls, uint16_t cnc_index_nbo = htons (i); uint16_t newcoin_index_nbo = htons (num_newcoins); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size), - TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_PQ_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc, + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_fixed_size(commit_coins->coin_ev, commit_coins->coin_ev_size), + TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type(&newcoin_index_nbo), + TALER_PQ_query_param_fixed_size (commit_coins->refresh_link->coin_priv_enc, commit_coins->refresh_link->blinding_key_enc_size + sizeof (struct TALER_CoinSpendPrivateKeyP)), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, @@ -1921,10 +1920,10 @@ postgres_get_refresh_commit_coins (void *cls, uint16_t cnc_index_nbo = htons (cnc_index); uint16_t newcoin_index_nbo = htons (newcoin_index); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type(&newcoin_index_nbo), + TALER_PQ_query_param_end }; void *c_buf; size_t c_buf_size; @@ -1950,9 +1949,9 @@ postgres_get_refresh_commit_coins (void *cls, } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size), - TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_variable_size("coin_ev", &c_buf, &c_buf_size), + TALER_PQ_result_spec_variable_size("link_vector_enc", &rl_buf, &rl_buf_size), + TALER_PQ_result_spec_end }; if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0)) { @@ -2000,12 +1999,12 @@ postgres_insert_refresh_commit_links (void *cls, uint16_t cnc_index_nbo = htons (i); uint16_t oldcoin_index_nbo = htons (j); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&commit_link->transfer_pub), - TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&commit_link->shared_secret_enc), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&commit_link->transfer_pub), + TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type(&oldcoin_index_nbo), + TALER_PQ_query_param_auto_from_type(&commit_link->shared_secret_enc), + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, @@ -2056,10 +2055,10 @@ postgres_get_refresh_commit_links (void *cls, uint16_t oldcoin_index_nbo = htons (num_links); struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo), - TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&cnc_index_nbo), + TALER_PQ_query_param_auto_from_type(&oldcoin_index_nbo), + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, @@ -2079,9 +2078,9 @@ postgres_get_refresh_commit_links (void *cls, } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC("transfer_pub", &links->transfer_pub), - TALER_PQ_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_auto_from_type("transfer_pub", &links->transfer_pub), + TALER_PQ_result_spec_auto_from_type("link_secret_enc", &links->shared_secret_enc), + TALER_PQ_result_spec_end }; if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0)) @@ -2167,10 +2166,10 @@ postgres_insert_refresh_collectable (void *cls, { struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(session_hash), - TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_PQ_QUERY_PARAM_RSA_SIGNATURE(ev_sig->rsa_signature), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(session_hash), + TALER_PQ_query_param_auto_from_type(&newcoin_index_nbo), + TALER_PQ_query_param_rsa_signature(ev_sig->rsa_signature), + TALER_PQ_query_param_end }; result = TALER_PQ_exec_prepared (session->conn, "insert_refresh_collectable", @@ -2205,8 +2204,8 @@ postgres_get_link_data_list (void *cls, struct TALER_MINTDB_LinkDataList *ldl; struct TALER_MINTDB_LinkDataList *pos; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(coin_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(coin_pub), + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_link", params); @@ -2233,10 +2232,10 @@ postgres_get_link_data_list (void *cls, void *ld_buf; size_t ld_buf_size; struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size), - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY("denom_pub", &denom_pub), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE("ev_sig", &sig), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_variable_size("link_vector_enc", &ld_buf, &ld_buf_size), + TALER_PQ_result_spec_rsa_public_key("denom_pub", &denom_pub), + TALER_PQ_result_spec_rsa_signature("ev_sig", &sig), + TALER_PQ_result_spec_end }; if (GNUNET_OK != TALER_PQ_extract_result (result, rs, i)) @@ -2299,8 +2298,8 @@ postgres_get_transfer (void *cls, { // FIXME: check logic! struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR(coin_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type(coin_pub), + TALER_PQ_query_param_end }; PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_transfer", params); @@ -2328,9 +2327,9 @@ postgres_get_transfer (void *cls, } struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC("transfer_pub", transfer_pub), - TALER_PQ_RESULT_SPEC("link_secret_enc", shared_secret_enc), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_auto_from_type("transfer_pub", transfer_pub), + TALER_PQ_result_spec_auto_from_type("link_secret_enc", shared_secret_enc), + TALER_PQ_result_spec_end }; if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0)) @@ -2375,8 +2374,8 @@ postgres_get_coin_transactions (void *cls, { struct TALER_MINTDB_Deposit *deposit; struct TALER_PQ_QueryParam params[] = { - TALER_PQ_QUERY_PARAM_PTR (&coin_pub->eddsa_pub), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_auto_from_type (&coin_pub->eddsa_pub), + TALER_PQ_query_param_end }; json_error_t json_error; void *json_wire_enc; @@ -2395,19 +2394,19 @@ postgres_get_coin_transactions (void *cls, { deposit = GNUNET_new (struct TALER_MINTDB_Deposit); struct TALER_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC ("coin_pub", &deposit->coin), - TALER_PQ_RESULT_SPEC ("coin_sig", &deposit->csig), - TALER_PQ_RESULT_SPEC ("merchant_pub", &deposit->merchant_pub), - TALER_PQ_RESULT_SPEC ("h_contract", &deposit->h_contract), - TALER_PQ_RESULT_SPEC ("h_wire", &deposit->h_wire), - TALER_PQ_RESULT_SPEC_VAR ("wire", &json_wire_enc, &json_wire_enc_size), - TALER_PQ_RESULT_SPEC ("transaction_id", &deposit->transaction_id), + TALER_PQ_result_spec_auto_from_type ("coin_pub", &deposit->coin), + TALER_PQ_result_spec_auto_from_type ("coin_sig", &deposit->csig), + TALER_PQ_result_spec_auto_from_type ("merchant_pub", &deposit->merchant_pub), + TALER_PQ_result_spec_auto_from_type ("h_contract", &deposit->h_contract), + TALER_PQ_result_spec_auto_from_type ("h_wire", &deposit->h_wire), + TALER_PQ_result_spec_variable_size ("wire", &json_wire_enc, &json_wire_enc_size), + TALER_PQ_result_spec_auto_from_type ("transaction_id", &deposit->transaction_id), /** FIXME: - * TALER_PQ_RESULT_SPEC ("timestamp", &deposit->timestamp), - * TALER_PQ_RESULT_SPEC ("refund_deadline", &deposit->refund_deadline), + * TALER_PQ_result_spec_auto_from_type ("timestamp", &deposit->timestamp), + * TALER_PQ_result_spec_auto_from_type ("refund_deadline", &deposit->refund_deadline), * TALER_PQ_RESULT_AMOUNT_NBO ("deposit_fee", &deposit->deposit_fee) */ - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_end }; if ((GNUNET_OK != TALER_PQ_extract_result (result, rs, i)) || (GNUNET_OK != TALER_PQ_extract_amount (result, diff --git a/src/pq/pq_helper.c b/src/pq/pq_helper.c index 98c02de7..5da1ced4 100644 --- a/src/pq/pq_helper.c +++ b/src/pq/pq_helper.c @@ -33,7 +33,7 @@ * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_AMOUNT_NBO (const struct TALER_AmountNBO *x) +TALER_PQ_query_param_amount_nbo (const struct TALER_AmountNBO *x) { struct TALER_PQ_QueryParam res = { TALER_PQ_QF_AMOUNT_NBO, x, sizeof (*x) }; @@ -51,7 +51,7 @@ TALER_PQ_QUERY_PARAM_AMOUNT_NBO (const struct TALER_AmountNBO *x) * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_AMOUNT (const struct TALER_Amount *x) +TALER_PQ_query_param_amount (const struct TALER_Amount *x) { struct TALER_PQ_QueryParam res = { TALER_PQ_QF_AMOUNT, x, sizeof (*x) }; @@ -67,7 +67,7 @@ TALER_PQ_QUERY_PARAM_AMOUNT (const struct TALER_Amount *x) * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (const struct GNUNET_CRYPTO_rsa_PublicKey *x) +TALER_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_rsa_PublicKey *x) { struct TALER_PQ_QueryParam res = { TALER_PQ_QF_RSA_PUBLIC_KEY, (x), 0 }; @@ -83,7 +83,7 @@ TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (const struct GNUNET_CRYPTO_rsa_PublicKey *x * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (const struct GNUNET_CRYPTO_rsa_Signature *x) +TALER_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_rsa_Signature *x) { struct TALER_PQ_QueryParam res = { TALER_PQ_QF_RSA_SIGNATURE, (x), 0 }; @@ -99,7 +99,7 @@ TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (const struct GNUNET_CRYPTO_rsa_Signature *x) * @return array entry for the query parameters to use */ struct TALER_PQ_QueryParam -TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (const struct GNUNET_TIME_Absolute *x) +TALER_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x) { struct TALER_PQ_QueryParam res = { TALER_PQ_QF_TIME_ABSOLUTE, x, sizeof (*x) }; @@ -116,7 +116,7 @@ TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (const struct GNUNET_TIME_Absolute *x) * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_VAR (const char *name, +TALER_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr) { @@ -134,7 +134,7 @@ TALER_PQ_RESULT_SPEC_VAR (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, +TALER_PQ_result_spec_amount_nbo (const char *name, struct TALER_AmountNBO *amount) { struct TALER_PQ_ResultSpec res = @@ -151,7 +151,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT_NBO (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, +TALER_PQ_result_spec_amount (const char *name, struct TALER_Amount *amount) { struct TALER_PQ_ResultSpec res = @@ -168,7 +168,7 @@ TALER_PQ_RESULT_SPEC_AMOUNT (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name, +TALER_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_rsa_PublicKey **rsa) { struct TALER_PQ_ResultSpec res = @@ -185,7 +185,7 @@ TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name, +TALER_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_rsa_Signature **sig) { struct TALER_PQ_ResultSpec res = @@ -202,7 +202,7 @@ TALER_PQ_RESULT_SPEC_RSA_SIGNATURE (const char *name, * @return array entry for the result specification to use */ struct TALER_PQ_ResultSpec -TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME (const char *name, +TALER_PQ_result_spec_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at) { struct TALER_PQ_ResultSpec res = diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index d3417111..185b95ca 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -124,30 +124,30 @@ run_queries (PGconn *conn) &hamount); TALER_string_to_amount ("EUR:4.4", &hamount); - /* FIXME: test TALER_PQ_RESULT_SPEC_VAR */ + /* FIXME: test TALER_PQ_result_spec_variable_size */ { struct TALER_PQ_QueryParam params_insert[] = { - TALER_PQ_QUERY_PARAM_RSA_PUBLIC_KEY (pub), - TALER_PQ_QUERY_PARAM_RSA_SIGNATURE (sig), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&abs_time), - TALER_PQ_QUERY_PARAM_ABSOLUTE_TIME (&forever), - TALER_PQ_QUERY_PARAM_PTR (&hc), - TALER_PQ_QUERY_PARAM_AMOUNT (&hamount), - TALER_PQ_QUERY_PARAM_AMOUNT_NBO (&namount), - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_rsa_public_key (pub), + TALER_PQ_query_param_rsa_signature (sig), + TALER_PQ_query_param_absolute_time (&abs_time), + TALER_PQ_query_param_absolute_time (&forever), + TALER_PQ_query_param_auto_from_type (&hc), + TALER_PQ_query_param_amount (&hamount), + TALER_PQ_query_param_amount_nbo (&namount), + TALER_PQ_query_param_end }; struct TALER_PQ_QueryParam params_select[] = { - TALER_PQ_QUERY_PARAM_END + TALER_PQ_query_param_end }; struct TALER_PQ_ResultSpec results_select[] = { - TALER_PQ_RESULT_SPEC_RSA_PUBLIC_KEY ("pub", &pub2), - TALER_PQ_RESULT_SPEC_RSA_SIGNATURE ("sig", &sig2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("abs_time", &abs_time2), - TALER_PQ_RESULT_SPEC_ABSOLUTE_TIME ("forever", &forever2), - TALER_PQ_RESULT_SPEC ("hash", &hc2), - TALER_PQ_RESULT_SPEC_AMOUNT ("hamount", &hamount2), - TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("namount", &namount2), - TALER_PQ_RESULT_SPEC_END + TALER_PQ_result_spec_rsa_public_key ("pub", &pub2), + TALER_PQ_result_spec_rsa_signature ("sig", &sig2), + TALER_PQ_result_spec_absolute_time ("abs_time", &abs_time2), + TALER_PQ_result_spec_absolute_time ("forever", &forever2), + TALER_PQ_result_spec_auto_from_type ("hash", &hc2), + TALER_PQ_result_spec_amount ("hamount", &hamount2), + TALER_PQ_result_spec_amount_nbo ("namount", &namount2), + TALER_PQ_result_spec_end }; result = TALER_PQ_exec_prepared (conn, diff --git a/src/util/json.c b/src/util/json.c index f6f2e49a..1747cd92 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -21,7 +21,6 @@ #include "platform.h" #include #include "taler_util.h" -#include "taler_json_lib.h" /** * Shorthand for exit jumps. diff --git a/src/util/os_installation.c b/src/util/os_installation.c index ad89f4e5..1308fa3f 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -454,7 +454,7 @@ os_get_exec_path () * @return a pointer to the dir path (to be freed by the caller) */ char * -TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) +TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) { size_t n; const char *dirname; diff --git a/src/util/wireformats.c b/src/util/wireformats.c index df32f2d3..e86044d7 100644 --- a/src/util/wireformats.c +++ b/src/util/wireformats.c @@ -22,7 +22,6 @@ #include "platform.h" #include #include "taler_util.h" -#include "taler_json_lib.h" /** * Shorthand for exit jumps. -- cgit v1.2.3 From 25e530f37a09dd154d09e468cc724252524da6c6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 17 May 2015 16:46:16 +0200 Subject: add test for varsize pq operation --- src/include/taler_pq_lib.h | 4 ++-- src/pq/test_pq.c | 14 +++++++++++++- src/util/crypto.c | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/pq/test_pq.c') diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 06ff580f..d030d9b7 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -310,8 +310,8 @@ struct TALER_PQ_ResultSpec */ struct TALER_PQ_ResultSpec TALER_PQ_result_spec_variable_size (const char *name, - void **dst, - size_t *sptr); + void **dst, + size_t *sptr); /** diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index 185b95ca..ff89e29f 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c @@ -60,9 +60,10 @@ postgres_prepare (PGconn *db_conn) ",namount_val" ",namount_frac" ",namount_curr" + ",vsize" ") VALUES " "($1, $2, $3, $4, $5, $6," - "$7, $8, $9, $10, $11);", + "$7, $8, $9, $10, $11, $12);", 11, NULL); PREPARE ("test_select", "SELECT" @@ -77,6 +78,7 @@ postgres_prepare (PGconn *db_conn) ",namount_val" ",namount_frac" ",namount_curr" + ",vsize" " FROM test_pq" " ORDER BY abs_time DESC " " LIMIT 1;", @@ -112,6 +114,8 @@ run_queries (PGconn *conn) int ret; struct GNUNET_CRYPTO_rsa_PrivateKey *priv; char msg[] = "Hello"; + void *msg2; + size_t msg2_len; priv = GNUNET_CRYPTO_rsa_private_key_create (1024); pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); @@ -134,6 +138,7 @@ run_queries (PGconn *conn) TALER_PQ_query_param_auto_from_type (&hc), TALER_PQ_query_param_amount (&hamount), TALER_PQ_query_param_amount_nbo (&namount), + TALER_PQ_query_param_fixed_size (msg, strlen (msg)), TALER_PQ_query_param_end }; struct TALER_PQ_QueryParam params_select[] = { @@ -147,6 +152,7 @@ run_queries (PGconn *conn) TALER_PQ_result_spec_auto_from_type ("hash", &hc2), TALER_PQ_result_spec_amount ("hamount", &hamount2), TALER_PQ_result_spec_amount_nbo ("namount", &namount2), + TALER_PQ_result_spec_variable_size ("vsize", &msg2, &msg2_len), TALER_PQ_result_spec_end }; @@ -205,6 +211,11 @@ run_queries (PGconn *conn) GNUNET_break (0 == GNUNET_CRYPTO_rsa_public_key_cmp (pub, pub2)); + GNUNET_break (strlen (msg) == msg2_len); + GNUNET_break (0 == + strncmp (msg, + msg2, + msg2_len)); TALER_PQ_cleanup_result (results_select); PQclear (result); @@ -254,6 +265,7 @@ main(int argc, ",namount_val INT8 NOT NULL" ",namount_frac INT4 NOT NULL" ",namount_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" + ",vsize VARCHAR NOT NULL" ")"); if (PGRES_COMMAND_OK != PQresultStatus (result)) { diff --git a/src/util/crypto.c b/src/util/crypto.c index 8cd08af6..abc9fc5f 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -49,7 +49,7 @@ fatal_error_handler (void *cls, /** * Initialize libgcrypt. */ -void +void __attribute__ ((constructor)) TALER_gcrypt_init () { gcry_set_fatalerror_handler (&fatal_error_handler, -- cgit v1.2.3