exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 2d0b9fe9bc34a6ac93f2d19fd68fd187889eda3e
parent 7aac031f34e8e098938e97b5fcbb7b4312f20a06
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 15 Nov 2025 19:54:13 +0100

updates for latest MHD2 API changes

Diffstat:
Msrc/include/taler/taler_mhd_lib.h | 36++++++++++++++++++++++++++++++++++++
Msrc/mhd/mhd2.c | 39++++++++++++++++++++++-----------------
Msrc/mhd/mhd2_legal.c | 47+++++++++++++++++++++++++----------------------
Msrc/mhd/mhd2_responses.c | 12+++++++-----
4 files changed, 90 insertions(+), 44 deletions(-)

diff --git a/src/include/taler/taler_mhd_lib.h b/src/include/taler/taler_mhd_lib.h @@ -1148,4 +1148,40 @@ TALER_MHD_spa_handler (const struct TALER_MHD_Spa *spa, const char *path); +/** + * Information about a document #TALER_MHD_typst() should output. + */ +struct TALER_MHD_TypstDocument +{ + /** + * Form name, used to determine the Typst template to use. + * NULL if @e data is a JSON string with a PDF to inline. + */ + const char *form_name; + + /** + * Form data. + */ + const json_t *data; +}; + + +/** + * Create an HTTP response by generating PDFs using Typst and + * combining them using pdftk. + * + * @param cfg configuration to use (where to find Typst templates) + * @param cfg_section_name name of the configuration section to use + * @param num_documents length of the @a docs array + * @param docs list of documents to combine into one large PDF + * @return NULL on error, otherwise HTTP response to return + */ +struct MHD_Response * +TALER_MHD_typst ( + const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *cfg_section_name, + unsigned int num_documents, + const struct TALER_MHD_TypstDocument docs[static num_documents]); + + #endif diff --git a/src/mhd/mhd2.c b/src/mhd/mhd2.c @@ -26,20 +26,21 @@ enum GNUNET_GenericReturnValue TALER_MHD2_is_https (struct MHD_Request *request) { - const struct MHD_StringNullable *forwarded_proto; + struct MHD_StringNullable forwarded_proto; union MHD_RequestInfoFixedData ci; union MHD_DaemonInfoFixedData di; - forwarded_proto = MHD_request_get_value (request, - MHD_VK_HEADER, - "X-Forwarded-Proto"); - if ( (NULL != forwarded_proto) && - (NULL != forwarded_proto->cstr) ) + if ( (MHD_NO != + MHD_request_get_value (request, + MHD_VK_HEADER, + "X-Forwarded-Proto", + &forwarded_proto)) && + (NULL != forwarded_proto.cstr) ) { - if (0 == strcasecmp (forwarded_proto->cstr, + if (0 == strcasecmp (forwarded_proto.cstr, "https")) return GNUNET_YES; - if (0 == strcasecmp (forwarded_proto->cstr, + if (0 == strcasecmp (forwarded_proto.cstr, "http")) return GNUNET_NO; GNUNET_break (0); @@ -75,28 +76,32 @@ TALER_MHD2_arg_to_yna (struct MHD_Request *request, enum TALER_EXCHANGE_YesNoAll default_val, enum TALER_EXCHANGE_YesNoAll *yna) { - const struct MHD_StringNullable *nstr; + struct MHD_StringNullable nstr; - nstr = MHD_request_get_value (request, - MHD_VK_GET_ARGUMENT, - arg); - if ( (NULL == nstr) || - (NULL == nstr->cstr) ) + if ( (MHD_NO == + MHD_request_get_value (request, + MHD_VK_URI_QUERY_PARAM, + arg, + &nstr)) || + (NULL == nstr.cstr) ) { *yna = default_val; return true; } - if (0 == strcasecmp (nstr->cstr, "yes")) + if (0 == strcasecmp (nstr.cstr, + "yes")) { *yna = TALER_EXCHANGE_YNA_YES; return true; } - if (0 == strcasecmp (nstr->cstr, "no")) + if (0 == strcasecmp (nstr.cstr, + "no")) { *yna = TALER_EXCHANGE_YNA_NO; return true; } - if (0 == strcasecmp (nstr->cstr, "all")) + if (0 == strcasecmp (nstr.cstr, + "all")) { *yna = TALER_EXCHANGE_YNA_ALL; return true; diff --git a/src/mhd/mhd2_legal.c b/src/mhd/mhd2_legal.c @@ -163,29 +163,31 @@ TALER_MHD2_reply_legal (struct MHD_Request *request, if (NULL != legal) { - const struct MHD_StringNullable *mimen; - const struct MHD_StringNullable *langn; + struct MHD_StringNullable mimen; + struct MHD_StringNullable langn; const char *mime; const char *lang; double best_mime_q = 0.0; double best_lang_q = 0.0; - mimen = MHD_request_get_value (request, - MHD_VK_HEADER, - MHD_HTTP_HEADER_ACCEPT); - if ( (NULL == mimen) || - (NULL == mimen->cstr) ) + if ( (MHD_NO == + MHD_request_get_value (request, + MHD_VK_HEADER, + MHD_HTTP_HEADER_ACCEPT, + &mimen)) || + (NULL == mimen.cstr) ) mime = "text/plain"; else - mime = mimen->cstr; - langn = MHD_request_get_value (request, - MHD_VK_HEADER, - MHD_HTTP_HEADER_ACCEPT_LANGUAGE); - if ( (NULL == langn) || - (NULL == langn->cstr) ) + mime = mimen.cstr; + if ( (MHD_NO == + MHD_request_get_value (request, + MHD_VK_HEADER, + MHD_HTTP_HEADER_ACCEPT_LANGUAGE, + &langn)) || + (NULL == langn.cstr) ) lang = "en"; else - lang = langn->cstr; + lang = langn.cstr; /* Find best match: must match mime type (if possible), and if mime type matches, ideally also language */ for (struct Terms *p = legal->terms_head; @@ -241,15 +243,16 @@ TALER_MHD2_reply_legal (struct MHD_Request *request, if (NULL != t) { - const struct MHD_StringNullable *etag; - - etag = MHD_request_get_value (request, - MHD_VK_HEADER, - MHD_HTTP_HEADER_IF_NONE_MATCH); - if ( (NULL != etag) && - (NULL != etag->cstr) && + struct MHD_StringNullable etag; + + if ( (MHD_NO != + MHD_request_get_value (request, + MHD_VK_HEADER, + MHD_HTTP_HEADER_IF_NONE_MATCH, + &etag)) && + (NULL != etag.cstr) && (NULL != t->terms_etag) && - (0 == strcasecmp (etag->cstr, + (0 == strcasecmp (etag.cstr, t->terms_etag)) ) { resp = MHD_response_from_empty (MHD_HTTP_STATUS_NOT_MODIFIED); diff --git a/src/mhd/mhd2_responses.c b/src/mhd/mhd2_responses.c @@ -70,18 +70,20 @@ TALER_MHD2_add_global_headers (struct MHD_Response *response, bool TALER_MHD2_can_compress (struct MHD_Request *request) { - const struct MHD_StringNullable *aeb; + struct MHD_StringNullable aeb; const char *ae; const char *de; if (0 != (TM_go & TALER_MHD2_GO_DISABLE_COMPRESSION)) return MHD_NO; - aeb = MHD_request_get_value (request, + if ( (MHD_NO == + MHD_request_get_value (request, MHD_VK_HEADER, - MHD_HTTP_HEADER_ACCEPT_ENCODING); - if (NULL == aeb) + MHD_HTTP_HEADER_ACCEPT_ENCODING, + &aeb)) || + (NULL == aeb.cstr) ) return false; - ae = aeb->cstr; + ae = aeb.cstr; if (NULL == ae) return false; if (0 == strcmp (ae,