sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 08f69b5e7eecbe6dc0cec9e16808fd8603dbcf11
parent 9bdc4443e2af29e9dc6efa24eeb5906bfe10fea0
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 22 Dec 2025 17:09:19 +0100

fix build against latest MHD2 API

Diffstat:
Msrc/sync/sync-httpd2_backup-post.c | 120+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/sync/sync-httpd2_backup.c | 19++++++++++---------
2 files changed, 72 insertions(+), 67 deletions(-)

diff --git a/src/sync/sync-httpd2_backup-post.c b/src/sync/sync-httpd2_backup-post.c @@ -603,13 +603,14 @@ handle_database_error (struct BackupContext *bc, MHD_HTTP_STATUS_CONFLICT); case SYNC_DB_PAYMENT_REQUIRED: { - const struct MHD_StringNullable *order_id; - - order_id = MHD_request_get_value (bc->request, - MHD_VK_GET_ARGUMENT, - "paying"); - if ( (NULL == order_id) || - (NULL == order_id->cstr) ) + struct MHD_StringNullable order_id; + + if ( (MHD_YES != + MHD_request_get_value (bc->request, + MHD_VK_URI_QUERY_PARAM, + "paying", + &order_id)) || + (NULL == order_id.cstr) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Payment required, starting payment process\n"); @@ -619,10 +620,10 @@ handle_database_error (struct BackupContext *bc, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Payment required, awaiting completion of `%s'\n", - order_id->cstr); + order_id.cstr); await_payment (bc, CHECK_PAYMENT_GENERIC_TIMEOUT, - order_id->cstr); + order_id.cstr); *suspend = true; return NULL; } @@ -813,50 +814,51 @@ SH_backup_post (struct MHD_Request *request, NULL); } { - const struct MHD_StringNullable *fresh; + struct MHD_StringNullable fresh; - fresh = MHD_request_get_value (request, - MHD_VK_GET_ARGUMENT, - "fresh"); - if (NULL != fresh) + if (MHD_YES == + MHD_request_get_value (request, + MHD_VK_URI_QUERY_PARAM, + "fresh", + &fresh)) bc->force_fresh_order = true; } { - const struct MHD_StringNullable *im; - - im = MHD_request_get_value (request, - MHD_VK_HEADER, - MHD_HTTP_HEADER_IF_MATCH); - if (NULL != im) - { - if ( (2 >= im->len) || - ('"' != im->cstr[0]) || - ('"' != im->cstr[im->len - 1]) || + struct MHD_StringNullable im; + + if ( (MHD_YES == + MHD_request_get_value (request, + MHD_VK_HEADER, + MHD_HTTP_HEADER_IF_MATCH, + &im)) && + ( (2 >= im.len) || + ('"' != im.cstr[0]) || + ('"' != im.cstr[im.len - 1]) || (GNUNET_OK != - GNUNET_STRINGS_string_to_data (im->cstr + 1, - im->len - 2, + GNUNET_STRINGS_string_to_data (im.cstr + 1, + im.len - 2, &bc->old_backup_hash, - sizeof (bc->old_backup_hash))) ) - { - GNUNET_break_op (0); - return TALER_MHD2_reply_with_error ( - request, - MHD_HTTP_STATUS_BAD_REQUEST, - TALER_EC_SYNC_BAD_IF_MATCH, - NULL); - } + sizeof (bc->old_backup_hash))) ) ) + { + GNUNET_break_op (0); + return TALER_MHD2_reply_with_error ( + request, + MHD_HTTP_STATUS_BAD_REQUEST, + TALER_EC_SYNC_BAD_IF_MATCH, + NULL); } } { - const struct MHD_StringNullable *sig_s; + struct MHD_StringNullable sig_s; - sig_s = MHD_request_get_value (request, - MHD_VK_HEADER, - "Sync-Signature"); - if ( (NULL == sig_s) || + if ( (MHD_YES != + MHD_request_get_value (request, + MHD_VK_HEADER, + "Sync-Signature", + &sig_s)) || (GNUNET_OK != - GNUNET_STRINGS_string_to_data (sig_s->cstr, - sig_s->len, + GNUNET_STRINGS_string_to_data (sig_s.cstr, + sig_s.len, &bc->account_sig, sizeof (bc->account_sig))) ) { @@ -869,18 +871,19 @@ SH_backup_post (struct MHD_Request *request, } } { - const struct MHD_StringNullable *etag; - - etag = MHD_request_get_value (request, - MHD_VK_HEADER, - MHD_HTTP_HEADER_IF_NONE_MATCH); - if ( (NULL == etag) || - (2 >= etag->len) || - ('"' != etag->cstr[0]) || - ('"' != etag->cstr[etag->len - 1]) || + struct MHD_StringNullable etag; + + if ( (MHD_YES != + MHD_request_get_value (request, + MHD_VK_HEADER, + MHD_HTTP_HEADER_IF_NONE_MATCH, + &etag)) || + (2 >= etag.len) || + ('"' != etag.cstr[0]) || + ('"' != etag.cstr[etag.len - 1]) || (GNUNET_OK != - GNUNET_STRINGS_string_to_data (etag->cstr + 1, - etag->len - 2, + GNUNET_STRINGS_string_to_data (etag.cstr + 1, + etag.len - 2, &bc->new_backup_hash, sizeof (bc->new_backup_hash))) ) { @@ -967,12 +970,13 @@ SH_backup_post (struct MHD_Request *request, } /* check if the client insists on paying */ { - const struct MHD_StringNullable *order_req; + struct MHD_StringNullable order_req; - order_req = MHD_request_get_value (request, - MHD_VK_GET_ARGUMENT, - "pay"); - if (NULL != order_req) + if (MHD_YES == + MHD_request_get_value (request, + MHD_VK_URI_QUERY_PARAM, + "pay", + &order_req)) { struct MHD_Response *resp; bool suspend; diff --git a/src/sync/sync-httpd2_backup.c b/src/sync/sync-httpd2_backup.c @@ -84,21 +84,22 @@ SH_backup_get (struct MHD_Request *request, } case SYNC_DB_ONE_RESULT: { - const struct MHD_StringNullable *inm; + struct MHD_StringNullable inm; - inm = MHD_request_get_value (request, + if ( (MHD_YES == + MHD_request_get_value (request, MHD_VK_HEADER, - MHD_HTTP_HEADER_IF_NONE_MATCH); - if ( (NULL != inm) && - (2 < inm->len) && - ('"' == inm->cstr[0]) && - ('=' == inm->cstr[inm->len - 1]) ) + MHD_HTTP_HEADER_IF_NONE_MATCH, + &inm)) && + (2 < inm.len) && + ('"' == inm.cstr[0]) && + ('=' == inm.cstr[inm.len - 1]) ) { struct GNUNET_HashCode inm_h; if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (inm->cstr + 1, - inm->len - 2, + GNUNET_STRINGS_string_to_data (inm.cstr + 1, + inm.len - 2, &inm_h, sizeof (inm_h))) {