exchange

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

commit 8dd16c9618adbd00bd95ead627a8336cd6e0ef81
parent 14d78468e99b3cc48cfc33d7f9b967a98dc85a9f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 16 Nov 2025 14:23:43 +0100

get mhd_typst to compile

Diffstat:
Msrc/include/taler/taler_mhd_lib.h | 8++++++++
Msrc/mhd/Makefile.am | 3++-
Msrc/mhd/mhd_typst.c | 52+++++++++++++++++++++++++++-------------------------
3 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/src/include/taler/taler_mhd_lib.h b/src/include/taler/taler_mhd_lib.h @@ -1184,4 +1184,12 @@ TALER_MHD_typst ( const struct TALER_MHD_TypstDocument docs[static num_documents]); +/** + * Abort all typst response generation processes. + * To be used when the system is shutting down. + */ +void +TALER_MHD_typst_stop_all (void); + + #endif diff --git a/src/mhd/Makefile.am b/src/mhd/Makefile.am @@ -16,7 +16,8 @@ libtalermhd_la_SOURCES = \ mhd_parsing.c \ mhd_responses.c \ mhd_run.c \ - mhd_spa.c + mhd_spa.c \ + mhd_typst.c libtalermhd_la_LDFLAGS = \ -version-info 8:0:1 \ -no-undefined diff --git a/src/mhd/mhd_typst.c b/src/mhd/mhd_typst.c @@ -23,7 +23,7 @@ #include "taler/platform.h" #include "taler/taler_util.h" #include "taler/taler_mhd_lib.h" - +#include <microhttpd.h> /** * Context for the entire typst build. @@ -135,7 +135,7 @@ cleanup_tc (struct TypstContext *tc) tc); for (unsigned int i = 0; i<tc->num_stages; i++) { - struct TypstStage *stage = tc->stages[i]; + struct TypstStage *stage = &tc->stages[i]; if (NULL != stage->cwh) { @@ -169,6 +169,11 @@ cleanup_tc (struct TypstContext *tc) GNUNET_DISK_directory_remove (tc->tmpdir); GNUNET_free (tc->tmpdir); } + if (NULL != tc->p) + { + GNUNET_DISK_pipe_close (tc->p); + tc->p = NULL; + } GNUNET_free (tc); } @@ -298,7 +303,7 @@ pdftk_done_cb (void *cls, static void complete_response (struct TypstContext *tc) { - char *argv[tc->num_stages + 5]; + const char *argv[tc->num_stages + 5]; argv[0] = "pdftk"; for (unsigned int i = 0; i<tc->num_stages; i++) @@ -310,18 +315,17 @@ complete_response (struct TypstContext *tc) tc->proc = GNUNET_OS_start_process_vap ( GNUNET_OS_INHERIT_STD_ERR, NULL, - GNUNET_DISK_pipe_handle (p, - GNUNET_DISK_PF_END_WRITE), + tc->p, NULL, "pdftk", - argv); + (char **) argv); if (NULL == tc->proc) { - GNUNET_log_stderror (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork"); - GNUNET_DISK_pipe_close (p); + GNUNET_DISK_pipe_close (tc->p); cleanup_tc (tc); - return NULL; + return; } tc->cwh = GNUNET_wait_child (tc->proc, &pdftk_done_cb, @@ -461,31 +465,29 @@ setup_stage (struct TypstStage *stage, /* now setup typst invocation */ { - char *argv[4]; + const char *argv[4]; argv[0] = "typst"; argv[1] = "compile"; argv[2] = input; argv[3] = NULL; - tc->proc = GNUNET_OS_start_process_vap ( + stage->proc = GNUNET_OS_start_process_vap ( GNUNET_OS_INHERIT_STD_ERR, NULL, - fh, + NULL, NULL, "typst", - argv); - if (NULL == tc->proc) + (char **) argv); + if (NULL == stage->proc) { - GNUNET_log_stderror (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork"); - GNUNET_DISK_pipe_close (p); - cleanup_tc (tc); GNUNET_free (input); - return NULL; + return false; } GNUNET_free (input); stage->tc->active_stages++; - stage->cwh = GNUNET_wait_child (tc->proc, + stage->cwh = GNUNET_wait_child (stage->proc, &typst_done_cb, stage); GNUNET_assert (NULL != stage->cwh); @@ -583,9 +585,9 @@ TALER_MHD_typst ( } GNUNET_free (template_path); } - if (0 == stage->tc->active_stages) + if (0 == tc->active_stages) { - complete_response (stage->tc); + complete_response (tc); } tc->p = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW); @@ -597,16 +599,16 @@ TALER_MHD_typst ( int fd; fh = GNUNET_DISK_pipe_detach_end (tc->p, - GNUNET_DISK_PF_END_READ); + GNUNET_DISK_PIPE_END_READ); fd = fh->fd; GNUNET_free (fh); - resp = MHD_response_from_fd (MHD_SIZE_UNKNOWN, - fd); + resp = MHD_create_response_from_fd (MHD_SIZE_UNKNOWN, + fd); TALER_MHD_add_global_headers (resp, false); GNUNET_break (MHD_YES == - MHD_add_response_header (response, + MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "application/pdf")); return resp;