aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-07-24 17:43:07 +0200
committerChristian Grothoff <christian@grothoff.org>2024-07-29 12:18:47 +0200
commit84d82e110511cc74061e4e210caa3389d0345b39 (patch)
treea32f2dc21bd0cf2831d6988e8b39bc3d5f562589 /src
parentab74f09dfc9f97d288351a5aa28b37be04f7ed6c (diff)
move TALER_JSON_ symbols into libtalerjson where they belong
Diffstat (limited to 'src')
-rw-r--r--src/include/taler_json_lib.h170
-rw-r--r--src/include/taler_util.h50
-rw-r--r--src/json/.gitignore1
-rw-r--r--src/json/Makefile.am17
-rw-r--r--src/json/conversion.c (renamed from src/util/conversion.c)1
-rw-r--r--src/json/test_conversion.c (renamed from src/util/test_conversion.c)1
-rwxr-xr-xsrc/json/test_conversion.sh (renamed from src/util/test_conversion.sh)0
-rw-r--r--src/util/Makefile.am13
8 files changed, 144 insertions, 109 deletions
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 7dd728719..dd47feb12 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -54,8 +54,9 @@
* @return json pack specification
*/
struct GNUNET_JSON_PackSpec
-TALER_JSON_pack_time_abs_human (const char *name,
- struct GNUNET_TIME_Absolute at);
+TALER_JSON_pack_time_abs_human (
+ const char *name,
+ struct GNUNET_TIME_Absolute at);
/**
@@ -176,8 +177,9 @@ TALER_JSON_pack_exchange_withdraw_values (
* @return json pack specification
*/
struct GNUNET_JSON_PackSpec
-TALER_JSON_pack_amount (const char *name,
- const struct TALER_Amount *amount);
+TALER_JSON_pack_amount (
+ const char *name,
+ const struct TALER_Amount *amount);
/**
@@ -478,8 +480,9 @@ struct TALER_JSON_ProtocolVersion
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_version (const char *field,
- struct TALER_JSON_ProtocolVersion *ver);
+TALER_JSON_spec_version (
+ const char *field,
+ struct TALER_JSON_ProtocolVersion *ver);
/**
@@ -506,8 +509,9 @@ TALER_JSON_spec_denom_pub_cipher (
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_denom_sig (const char *field,
- struct TALER_DenominationSignature *sig);
+TALER_JSON_spec_denom_sig (
+ const char *field,
+ struct TALER_DenominationSignature *sig);
/**
@@ -547,9 +551,9 @@ TALER_JSON_spec_exchange_withdraw_values (
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_blinded_planchet (const char *field,
- struct TALER_BlindedPlanchet *blinded_planchet
- );
+TALER_JSON_spec_blinded_planchet (
+ const char *field,
+ struct TALER_BlindedPlanchet *blinded_planchet);
/**
@@ -570,9 +574,10 @@ TALER_JSON_spec_blinded_planchet (const char *field,
* @param[out] strptr where to store a pointer to the field with the best variant
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_i18n_string (const char *name,
- const char *language_pattern,
- const char **strptr);
+TALER_JSON_spec_i18n_string (
+ const char *name,
+ const char *language_pattern,
+ const char **strptr);
/**
@@ -587,8 +592,9 @@ TALER_JSON_spec_i18n_string (const char *name,
* @param[out] strptr where to store a pointer to the field with the best variant
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_i18n_str (const char *name,
- const char **strptr);
+TALER_JSON_spec_i18n_str (
+ const char *name,
+ const char **strptr);
/**
@@ -600,8 +606,9 @@ TALER_JSON_spec_i18n_str (const char *name,
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_token_issue_sig (const char *field,
- struct TALER_TokenIssueSignatureP *sig);
+TALER_JSON_spec_token_issue_sig (
+ const char *field,
+ struct TALER_TokenIssueSignatureP *sig);
/**
@@ -626,8 +633,9 @@ TALER_JSON_spec_blinded_token_issue_sig (
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
-TALER_JSON_spec_token_envelope (const char *field,
- struct TALER_TokenEnvelopeP *env);
+TALER_JSON_spec_token_envelope (
+ const char *field,
+ struct TALER_TokenEnvelopeP *env);
/**
@@ -646,8 +654,9 @@ TALER_JSON_spec_token_envelope (const char *field,
* #GNUNET_SYSERR on internal error
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_contract_hash (const json_t *json,
- struct TALER_PrivateContractHashP *hc);
+TALER_JSON_contract_hash (
+ const json_t *json,
+ struct TALER_PrivateContractHashP *hc);
/**
@@ -661,8 +670,9 @@ TALER_JSON_contract_hash (const json_t *json,
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_contract_seed_forgettable (const json_t *spec,
- json_t *contract);
+TALER_JSON_contract_seed_forgettable (
+ const json_t *spec,
+ json_t *contract);
/**
@@ -673,8 +683,9 @@ TALER_JSON_contract_seed_forgettable (const json_t *spec,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_contract_mark_forgettable (json_t *json,
- const char *field);
+TALER_JSON_contract_mark_forgettable (
+ json_t *json,
+ const char *field);
/**
@@ -687,8 +698,9 @@ TALER_JSON_contract_mark_forgettable (json_t *json,
* #GNUNET_SYSERR on error
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_contract_part_forget (json_t *json,
- const char *field);
+TALER_JSON_contract_part_forget (
+ json_t *json,
+ const char *field);
/**
@@ -717,10 +729,11 @@ typedef void
* @return #GNUNET_OK on success, #GNUNET_SYSERR if @e path is invalid.
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_expand_path (json_t *json,
- const char *path,
- TALER_JSON_ExpandPathCallback cb,
- void *cb_cls);
+TALER_JSON_expand_path (
+ json_t *json,
+ const char *path,
+ TALER_JSON_ExpandPathCallback cb,
+ void *cb_cls);
/**
@@ -770,8 +783,9 @@ TALER_JSON_get_error_code2 (const void *data,
* @return #GNUNET_OK on success, #GNUNET_SYSERR if @a wire_s is malformed
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s,
- struct TALER_MerchantWireHashP *hc);
+TALER_JSON_merchant_wire_signature_hash (
+ const json_t *wire_s,
+ struct TALER_MerchantWireHashP *hc);
/**
@@ -800,9 +814,10 @@ TALER_JSON_merchant_wire_signature_hash (const json_t *wire_s,
* NOT incremented.
*/
const json_t *
-TALER_JSON_extract_i18n (const json_t *object,
- const char *language_pattern,
- const char *field);
+TALER_JSON_extract_i18n (
+ const json_t *object,
+ const char *language_pattern,
+ const char *field);
/**
@@ -812,7 +827,8 @@ TALER_JSON_extract_i18n (const json_t *object,
* @return true if @a i18n is well-formed
*/
bool
-TALER_JSON_check_i18n (const json_t *i18n);
+TALER_JSON_check_i18n (
+ const json_t *i18n);
/**
@@ -823,7 +839,8 @@ TALER_JSON_check_i18n (const json_t *i18n);
* @return NULL on error
*/
char *
-TALER_JSON_wire_to_method (const json_t *wire_s);
+TALER_JSON_wire_to_method (
+ const json_t *wire_s);
/**
@@ -834,7 +851,8 @@ TALER_JSON_wire_to_method (const json_t *wire_s);
* @return NULL on error
*/
char *
-TALER_JSON_wire_to_payto (const json_t *wire_s);
+TALER_JSON_wire_to_payto (
+ const json_t *wire_s);
/**
@@ -844,25 +862,85 @@ TALER_JSON_wire_to_payto (const json_t *wire_s);
* @param[out] ech where to write the policy hash
*/
void
-TALER_deposit_policy_hash (const json_t *policy,
- struct TALER_ExtensionPolicyHashP *ech);
+TALER_deposit_policy_hash (
+ const json_t *policy,
+ struct TALER_ExtensionPolicyHashP *ech);
+
/**
* Hash the @a manifests of extensions, given as JSON
*
* @param manifests Manifests of the extensions
* @param[out] eh where to write the hash
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
enum GNUNET_GenericReturnValue
-TALER_JSON_extensions_manifests_hash (const json_t *manifests,
- struct TALER_ExtensionManifestsHashP *eh);
+TALER_JSON_extensions_manifests_hash (
+ const json_t *manifests,
+ struct TALER_ExtensionManifestsHashP *eh);
+
/**
* Canonicalize a JSON input to a string according to RFC 8785.
*/
char *
-TALER_JSON_canonicalize (const json_t *input);
+TALER_JSON_canonicalize (
+ const json_t *input);
+
+
+/**
+ * Handle to an external process that will assist
+ * with some JSON-to-JSON conversion.
+ */
+struct TALER_JSON_ExternalConversion;
+
+/**
+ * Type of a callback that receives a JSON @a result.
+ *
+ * @param cls closure
+ * @param status_type how did the process die
+ * @param code termination status code from the process
+ * @param result some JSON result, NULL if we failed to get an JSON output
+ */
+typedef void
+(*TALER_JSON_JsonCallback) (
+ void *cls,
+ enum GNUNET_OS_ProcessStatusType status_type,
+ unsigned long code,
+ const json_t *result);
+
+
+/**
+ * Launch some external helper @a binary to convert some @a input
+ * and eventually call @a cb with the result.
+ *
+ * @param input JSON to serialize and pass to the helper process
+ * @param cb function to call on the result
+ * @param cb_cls closure for @a cb
+ * @param binary name of the binary to execute
+ * @param ... NULL-terminated list of arguments for the @a binary,
+ * usually starting with again the name of the binary
+ * @return handle to cancel the operation (and kill the helper)
+ */
+struct TALER_JSON_ExternalConversion *
+TALER_JSON_external_conversion_start (
+ const json_t *input,
+ TALER_JSON_JsonCallback cb,
+ void *cb_cls,
+ const char *binary,
+ ...);
+
+/**
+ * Abort external conversion, killing the process and preventing
+ * the callback from being called. Must not be called after the
+ * callback was invoked.
+ *
+ * @param[in] ec external conversion handle to cancel
+ */
+void
+TALER_JSON_external_conversion_stop (
+ struct TALER_JSON_ExternalConversion *ec);
+
#endif /* TALER_JSON_LIB_H_ */
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index 000d0dee5..10671ea4b 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -776,56 +776,6 @@ TALER_get_lowest_age (
#define TALER_adult_age(mask) \
sizeof((mask)->bits) * 8 - __builtin_clz ((mask)->bits) - 1
-/**
- * Handle to an external process that will assist
- * with some JSON-to-JSON conversion.
- */
-struct TALER_JSON_ExternalConversion;
-
-/**
- * Type of a callback that receives a JSON @a result.
- *
- * @param cls closure
- * @param status_type how did the process die
- * @param code termination status code from the process
- * @param result some JSON result, NULL if we failed to get an JSON output
- */
-typedef void
-(*TALER_JSON_JsonCallback) (void *cls,
- enum GNUNET_OS_ProcessStatusType status_type,
- unsigned long code,
- const json_t *result);
-
-
-/**
- * Launch some external helper @a binary to convert some @a input
- * and eventually call @a cb with the result.
- *
- * @param input JSON to serialize and pass to the helper process
- * @param cb function to call on the result
- * @param cb_cls closure for @a cb
- * @param binary name of the binary to execute
- * @param ... NULL-terminated list of arguments for the @a binary,
- * usually starting with again the name of the binary
- * @return handle to cancel the operation (and kill the helper)
- */
-struct TALER_JSON_ExternalConversion *
-TALER_JSON_external_conversion_start (const json_t *input,
- TALER_JSON_JsonCallback cb,
- void *cb_cls,
- const char *binary,
- ...);
-
-/**
- * Abort external conversion, killing the process and preventing
- * the callback from being called. Must not be called after the
- * callback was invoked.
- *
- * @param[in] ec external conversion handle to cancel
- */
-void
-TALER_JSON_external_conversion_stop (
- struct TALER_JSON_ExternalConversion *ec);
#undef __TALER_UTIL_LIB_H_INSIDE__
diff --git a/src/json/.gitignore b/src/json/.gitignore
index d28843406..5da208e58 100644
--- a/src/json/.gitignore
+++ b/src/json/.gitignore
@@ -1 +1,2 @@
test_json_wire
+test_conversion
diff --git a/src/json/Makefile.am b/src/json/Makefile.am
index 200afa714..492a4ed39 100644
--- a/src/json/Makefile.am
+++ b/src/json/Makefile.am
@@ -10,6 +10,7 @@ lib_LTLIBRARIES = \
libtalerjson.la
libtalerjson_la_SOURCES = \
+ conversion.c \
i18n.c \
json.c \
json_helper.c \
@@ -28,16 +29,30 @@ libtalerjson_la_LIBADD = \
$(XLIB)
TESTS = \
+ test_conversion \
test_json
check_PROGRAMS= \
+ test_conversion \
test_json
test_json_SOURCES = \
test_json.c
test_json_LDADD = \
- $(top_builddir)/src/json/libtalerjson.la \
+ libtalerjson.la \
-lgnunetjson \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
-ljansson
+
+test_conversion_SOURCES = \
+ test_conversion.c
+test_conversion_LDADD = \
+ libtalerjson.la \
+ $(top_builddir)/src/util/libtalerutil.la \
+ -lgnunetjson \
+ -lgnunetutil \
+ -ljansson
+
+EXTRA_DIST = \
+ test_conversion.sh
diff --git a/src/util/conversion.c b/src/json/conversion.c
index a7bc63789..42b6f8ed2 100644
--- a/src/util/conversion.c
+++ b/src/json/conversion.c
@@ -20,6 +20,7 @@
*/
#include "platform.h"
#include "taler_util.h"
+#include "taler_json_lib.h"
#include <gnunet/gnunet_util_lib.h>
diff --git a/src/util/test_conversion.c b/src/json/test_conversion.c
index 00cb35e72..449b02d59 100644
--- a/src/util/test_conversion.c
+++ b/src/json/test_conversion.c
@@ -21,6 +21,7 @@
#include "platform.h"
#include "taler_util.h"
#include <gnunet/gnunet_json_lib.h>
+#include "taler_json_lib.h"
/**
* Return value from main().
diff --git a/src/util/test_conversion.sh b/src/json/test_conversion.sh
index 26e1a36d8..26e1a36d8 100755
--- a/src/util/test_conversion.sh
+++ b/src/json/test_conversion.sh
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 1a730cdb6..9c9a76b22 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -21,8 +21,7 @@ EXTRA_DIST = \
taler-config.in \
test_helper_eddsa.conf \
test_helper_rsa.conf \
- test_helper_cs.conf \
- test_conversion.sh
+ test_helper_cs.conf
bin_PROGRAMS = \
taler-exchange-secmod-eddsa \
@@ -82,7 +81,6 @@ libtalerutil_la_SOURCES = \
aml_signatures.c \
auditor_signatures.c \
config.c \
- conversion.c \
crypto.c \
crypto_confirmation.c \
crypto_contract.c \
@@ -131,7 +129,6 @@ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=
check_PROGRAMS = \
test_age_restriction \
test_amount \
- test_conversion \
test_crypto \
test_helper_eddsa \
test_helper_rsa \
@@ -148,14 +145,6 @@ test_age_restriction_LDADD = \
-lgnunetutil \
libtalerutil.la
-test_conversion_SOURCES = \
- test_conversion.c
-test_conversion_LDADD = \
- -lgnunetjson \
- -lgnunetutil \
- -ljansson \
- libtalerutil.la
-
test_amount_SOURCES = \
test_amount.c
test_amount_LDADD = \