commit 34a68bd55add3a0aacb3850c150074f07c34350a
parent fd5188e7dd1d5a2263919347d37fb82bcd4c9778
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 26 May 2026 00:33:23 +0200
make parse choice functions static
Diffstat:
7 files changed, 68 insertions(+), 90 deletions(-)
diff --git a/src/include/taler/taler_merchant_util.h b/src/include/taler/taler_merchant_util.h
@@ -1836,38 +1836,6 @@ TALER_MERCHANT_spec_token_families (
/**
- * Parse JSON contract terms choice input.
- *
- * @param[in] root JSON object containing choice input
- * @param[out] input parsed choice input, NULL if @a input is malformed
- * @param index index of choice input in inputs array
- * @return #GNUNET_SYSERR if @a input is malformed; #GNUNET_OK otherwise
- */
-// FIXME: make static?
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_contract_choice_input (
- json_t *root,
- struct TALER_MERCHANT_ContractInput *input,
- size_t index);
-
-
-/**
- * Parse JSON order choice input.
- *
- * @param[in] root JSON object containing choice input
- * @param[out] input parsed choice input, NULL if @a input is malformed
- * @param index index of choice input in inputs array
- * @return #GNUNET_SYSERR if @a input is malformed; #GNUNET_OK otherwise
- */
-// FIXME: make static?
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_order_choice_input (
- json_t *root,
- struct TALER_MERCHANT_OrderInput *input,
- size_t index);
-
-
-/**
* Check if @a taxes is an array of valid Taxes in the sense of
* Taler's API definition.
*
@@ -1895,38 +1863,6 @@ TALER_MERCHANT_json_spec_cot (
/**
- * Parse JSON contract terms choice output.
- *
- * @param[in] root JSON object containing choice output
- * @param[out] output parsed choice output, NULL if @a output is malformed
- * @param index index of choice output in outputs array
- * @return #GNUNET_SYSERR if @a output is malformed; #GNUNET_OK otherwise
- */
-// FIXME: make static?
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_contract_choice_output (
- json_t *root,
- struct TALER_MERCHANT_ContractOutput *output,
- size_t index);
-
-
-/**
- * Parse JSON order choice output.
- *
- * @param[in] root JSON object containing choice output
- * @param[out] output parsed choice output, NULL if @a output is malformed
- * @param index index of choice output in outputs array
- * @return #GNUNET_SYSERR if @a output is malformed; #GNUNET_OK otherwise
- */
-// FIXME: make static?
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_order_choice_output (
- json_t *root,
- struct TALER_MERCHANT_OrderOutput *output,
- size_t index);
-
-
-/**
* Get JSON representation of contract choice.
*
* @param[in] choice contract choice to serialize
diff --git a/src/util/contract_choice_parse.c b/src/util/contract_choice_parse.c
@@ -65,8 +65,16 @@ contract_choice_output_free (
}
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_contract_choice_input (
+/**
+ * Parse JSON contract terms choice input.
+ *
+ * @param[in] root JSON object containing choice input
+ * @param[out] input parsed choice input, NULL if @a input is malformed
+ * @param index index of choice input in inputs array
+ * @return #GNUNET_SYSERR if @a input is malformed; #GNUNET_OK otherwise
+ */
+static enum GNUNET_GenericReturnValue
+parse_contract_choice_input (
json_t *root,
struct TALER_MERCHANT_ContractInput *input,
size_t index)
@@ -138,8 +146,16 @@ TALER_MERCHANT_parse_contract_choice_input (
}
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_contract_choice_output (
+/**
+ * Parse JSON contract terms choice output.
+ *
+ * @param[in] root JSON object containing choice output
+ * @param[out] output parsed choice output, NULL if @a output is malformed
+ * @param index index of choice output in outputs array
+ * @return #GNUNET_SYSERR if @a output is malformed; #GNUNET_OK otherwise
+ */
+static enum GNUNET_GenericReturnValue
+parse_contract_choice_output (
json_t *root,
struct TALER_MERCHANT_ContractOutput *output,
size_t index)
@@ -374,9 +390,9 @@ parse_contract_choices (
};
if (GNUNET_OK !=
- TALER_MERCHANT_parse_contract_choice_input ((json_t *) jinput,
- &input,
- idx))
+ parse_contract_choice_input ((json_t *) jinput,
+ &input,
+ idx))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -409,9 +425,9 @@ parse_contract_choices (
};
if (GNUNET_OK !=
- TALER_MERCHANT_parse_contract_choice_output ((json_t *) joutput,
- &output,
- idx))
+ parse_contract_choice_output ((json_t *) joutput,
+ &output,
+ idx))
{
GNUNET_break (0);
contract_choice_output_free (&output);
diff --git a/src/util/contract_choice_serialize.c b/src/util/contract_choice_serialize.c
@@ -50,8 +50,8 @@ json_from_contract_input (
"token"),
GNUNET_JSON_pack_string ("token_family_slug",
input->details.token.token_family_slug),
- GNUNET_JSON_pack_int64 ("count",
- input->details.token.count));
+ GNUNET_JSON_pack_uint64 ("count",
+ input->details.token.count));
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/util/order_choice_parse.c b/src/util/order_choice_parse.c
@@ -30,8 +30,16 @@
#include "taler/taler_merchant_util.h"
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_order_choice_input (
+/**
+ * Parse JSON order choice input.
+ *
+ * @param[in] root JSON object containing choice input
+ * @param[out] input parsed choice input, NULL if @a input is malformed
+ * @param index index of choice input in inputs array
+ * @return #GNUNET_SYSERR if @a input is malformed; #GNUNET_OK otherwise
+ */
+static enum GNUNET_GenericReturnValue
+parse_order_choice_input (
json_t *root,
struct TALER_MERCHANT_OrderInput *input,
size_t index)
@@ -70,8 +78,8 @@ TALER_MERCHANT_parse_order_choice_input (
GNUNET_JSON_spec_string ("token_family_slug",
&input->details.token.token_family_slug),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint32 ("count",
- &input->details.token.count),
+ GNUNET_JSON_spec_uint ("count",
+ &input->details.token.count),
NULL),
GNUNET_JSON_spec_end ()
};
@@ -103,8 +111,16 @@ TALER_MERCHANT_parse_order_choice_input (
}
-enum GNUNET_GenericReturnValue
-TALER_MERCHANT_parse_order_choice_output (
+/**
+ * Parse JSON order choice output.
+ *
+ * @param[in] root JSON object containing choice output
+ * @param[out] output parsed choice output, NULL if @a output is malformed
+ * @param index index of choice output in outputs array
+ * @return #GNUNET_SYSERR if @a output is malformed; #GNUNET_OK otherwise
+ */
+static enum GNUNET_GenericReturnValue
+parse_order_choice_output (
json_t *root,
struct TALER_MERCHANT_OrderOutput *output,
size_t index)
@@ -326,9 +342,9 @@ parse_order_choices (
};
if (GNUNET_OK !=
- TALER_MERCHANT_parse_order_choice_input ((json_t *) jinput,
- &input,
- idx))
+ parse_order_choice_input ((json_t *) jinput,
+ &input,
+ idx))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -361,9 +377,9 @@ parse_order_choices (
};
if (GNUNET_OK !=
- TALER_MERCHANT_parse_order_choice_output ((json_t *) joutput,
- &output,
- idx))
+ parse_order_choice_output ((json_t *) joutput,
+ &output,
+ idx))
{
GNUNET_break (0);
return GNUNET_SYSERR;
diff --git a/src/util/order_choice_serialize.c b/src/util/order_choice_serialize.c
@@ -50,8 +50,8 @@ json_from_order_input (
"token"),
GNUNET_JSON_pack_string ("token_family_slug",
input->details.token.token_family_slug),
- GNUNET_JSON_pack_int64 ("count",
- input->details.token.count));
+ GNUNET_JSON_pack_uint64 ("count",
+ input->details.token.count));
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/util/template_parse.c b/src/util/template_parse.c
@@ -40,6 +40,11 @@ TALER_MERCHANT_template_type_from_contract (const json_t *template_contract)
type_val = json_object_get (template_contract,
"template_type");
+ if (NULL == type_val)
+ {
+ /* missing => fixed order */
+ return TALER_MERCHANT_TEMPLATE_TYPE_FIXED_ORDER;
+ }
if (! json_is_string (type_val))
{
GNUNET_break_op (0);
diff --git a/src/util/util.c b/src/util/util.c
@@ -65,6 +65,11 @@ TALER_MERCHANT_taxes_array_valid (const json_t *taxes)
enum TALER_MERCHANT_ContractTokenKind
TALER_MERCHANT_contract_token_kind_from_string (const char *str)
{
+ if (NULL == str)
+ {
+ GNUNET_break (0);
+ return TALER_MERCHANT_CONTRACT_TOKEN_KIND_INVALID;
+ }
if (0 == strcmp ("subscription",
str))
return TALER_MERCHANT_CONTRACT_TOKEN_KIND_SUBSCRIPTION;