donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 75ddc7b0435c5a991afe06382982ab5718d7a501
parent 45ed194289863d85b3f19cfb5cbb53664634b5e7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 24 Oct 2023 10:47:01 +0200

clean up

Diffstat:
Msrc/pq/Makefile.am | 1-
Dsrc/pq/pq_common.c | 68--------------------------------------------------------------------
Dsrc/pq/pq_common.h | 125-------------------------------------------------------------------------------
3 files changed, 0 insertions(+), 194 deletions(-)

diff --git a/src/pq/Makefile.am b/src/pq/Makefile.am @@ -10,7 +10,6 @@ lib_LTLIBRARIES = \ libtalerpq.la libtalerpq_la_SOURCES = \ - pq_common.h pq_common.c \ pq_query_helper.c \ pq_result_helper.c libtalerpq_la_LIBADD = \ diff --git a/src/pq/pq_common.c b/src/pq/pq_common.c @@ -1,68 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2023 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -*/ -/** - * @file pq/pq_common.c - * @brief common defines for the pq functions - * @author Özgür Kesim - */ -#include "platform.h" -#include "pq_common.h" - -struct TALER_PQ_AmountP -TALER_PQ_make_taler_pq_amount_ ( - const struct TALER_Amount *amount, - uint32_t oid_v, - uint32_t oid_f) -{ - struct TALER_PQ_AmountP rval = { - .cnt = htonl (2), - .oid_v = htonl (oid_v), - .oid_f = htonl (oid_f), - .sz_v = htonl (sizeof((amount)->value)), - .sz_f = htonl (sizeof((amount)->fraction)), - .v = GNUNET_htonll ((amount)->value), - .f = htonl ((amount)->fraction) - }; - - return rval; -} - - -size_t -TALER_PQ_make_taler_pq_amount_currency_ ( - const struct TALER_Amount *amount, - uint32_t oid_v, - uint32_t oid_f, - uint32_t oid_c, - struct TALER_PQ_AmountCurrencyP *rval) -{ - size_t clen = strlen (amount->currency); - - GNUNET_assert (clen < TALER_CURRENCY_LEN); - rval->cnt = htonl (3); - rval->oid_v = htonl (oid_v); - rval->oid_f = htonl (oid_f); - rval->oid_c = htonl (oid_c); - rval->sz_v = htonl (sizeof(amount->value)); - rval->sz_f = htonl (sizeof(amount->fraction)); - rval->sz_c = htonl (clen); - rval->v = GNUNET_htonll (amount->value); - rval->f = htonl (amount->fraction); - memcpy (rval->c, - amount->currency, - clen); - return sizeof (*rval) - TALER_CURRENCY_LEN + clen; -} diff --git a/src/pq/pq_common.h b/src/pq/pq_common.h @@ -1,125 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2023 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -*/ -/** - * @file pq/pq_common.h - * @brief common defines for the pq functions - * @author Özgür Kesim - */ -#ifndef TALER_PQ_COMMON_H_ -#define TALER_PQ_COMMON_H_ - -#include "taler_util.h" - -/** - * Internal types that are supported as TALER-exchange-specific array types. - * - * To support a new type, - * 1. add a new entry into this list, - * 2. for query-support, implement the size calculation and memory copying in - * qconv_array() accordingly, in pq_query_helper.c - * 3. provide a query-API for arrays of the type, by calling - * query_param_array_generic with the appropriate parameters, - * in pq_query_helper.c - * 4. for result-support, implement memory copying by adding another case - * to extract_array_generic, in pq_result_helper.c - * 5. provide a result-spec-API for arrays of the type, - * in pq_result_helper.c - * 6. expose the API's in taler_pq_lib.h - */ -enum TALER_PQ_ArrayType -{ - TALER_PQ_array_of_blinded_denom_sig, - TALER_PQ_array_of_blinded_coin_hash, - TALER_PQ_array_of_denom_hash, - /** - * Amounts *without* currency. - */ - TALER_PQ_array_of_amount, - TALER_PQ_array_of_MAX, /* must be last */ -}; - -/** - * Memory representation of an taler amount record for Postgres. - * - * All values need to be in network-byte-order. - */ -struct TALER_PQ_AmountP -{ - uint32_t cnt; /* # elements in the tuple (== 2) */ - uint32_t oid_v; /* oid of .v */ - uint32_t sz_v; /* size of .v */ - uint64_t v; /* value */ - uint32_t oid_f; /* oid of .f */ - uint32_t sz_f; /* size of .f */ - uint32_t f; /* fraction */ -} __attribute__((packed)); - - -/** - * Memory representation of an taler amount record with currency for Postgres. - * - * All values need to be in network-byte-order. - */ -struct TALER_PQ_AmountCurrencyP -{ - uint32_t cnt; /* # elements in the tuple (== 3) */ - uint32_t oid_v; /* oid of .v */ - uint32_t sz_v; /* size of .v */ - uint64_t v; /* value */ - uint32_t oid_f; /* oid of .f */ - uint32_t sz_f; /* size of .f */ - uint32_t f; /* fraction */ - uint32_t oid_c; /* oid of .c */ - uint32_t sz_c; /* size of .c */ - uint8_t c[TALER_CURRENCY_LEN]; /* currency */ -} __attribute__((packed)); - - -/** - * Create a `struct TALER_PQ_AmountP` for initialization - * - * @param amount amount of type `struct TALER_Amount *` - * @param oid_v OID of the INT8 type in postgres - * @param oid_f OID of the INT4 type in postgres - */ -struct TALER_PQ_AmountP -TALER_PQ_make_taler_pq_amount_ ( - const struct TALER_Amount *amount, - uint32_t oid_v, - uint32_t oid_f); - - -/** - * Create a `struct TALER_PQ_AmountCurrencyP` for initialization - * - * @param amount amount of type `struct TALER_Amount *` - * @param oid_v OID of the INT8 type in postgres - * @param oid_f OID of the INT4 type in postgres - * @param oid_c OID of the TEXT type in postgres - * @param[out] rval set to encoded @a amount - * @return actual (useful) size of @a rval for Postgres - */ -size_t -TALER_PQ_make_taler_pq_amount_currency_ ( - const struct TALER_Amount *amount, - uint32_t oid_v, - uint32_t oid_f, - uint32_t oid_c, - struct TALER_PQ_AmountCurrencyP *rval); - - -#endif /* TALER_PQ_COMMON_H_ */ -/* end of pg/pq_common.h */