From 7de26292b744122b20e9cd6ecea95a2273311587 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 15 Mar 2020 22:06:28 +0100 Subject: add function that logically belongs to libgnunetcurl instead of in multiple Taler binaries --- src/curl/curl.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/curl') diff --git a/src/curl/curl.c b/src/curl/curl.c index 01c7c5fca..da486ecc1 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c @@ -189,7 +189,8 @@ GNUNET_CURL_init (GNUNET_CURL_RescheduleCallback cb, void *cb_cls) if (curl_fail) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Curl was not initialised properly\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Curl was not initialised properly\n"); return NULL; } if (NULL == (multi = curl_multi_init ())) @@ -227,6 +228,27 @@ GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx, } +/** + * Return #GNUNET_YES if given a valid scope ID and + * #GNUNET_NO otherwise. See #setup_job_headers, + * logic related to + * #GNUNET_CURL_enable_async_scope_header() for the + * code that generates such a @a scope_id. + * + * @returns #GNUNET_YES iff given a valid scope ID + */ +int +GNUNET_CURL_is_valid_scope_id (const char *scope_id) +{ + if (strlen (scope_id) >= 64) + return GNUNET_NO; + for (size_t i = 0; i < strlen (scope_id); i++) + if (! (isalnum (scope_id[i]) || (scope_id[i] == '-'))) + return GNUNET_NO; + return GNUNET_YES; +} + + /** * Callback used when downloading the reply to an HTTP request. * Just appends all of the data to the `buf` in the -- cgit v1.2.3