X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_curl_lib.h;h=0cbef9c73702de8a0a3cf495671282e7ef52803d;hb=200d05b44a96d6fec00e28736038c838c679f650;hp=8c595ee34b5073fc2b297876f2407c5958660311;hpb=4e29ecde9b3ad3e34af359f18b6679c06b17ce78;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index 8c595ee34..0cbef9c73 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h @@ -11,6 +11,11 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later */ /** * @file src/include/gnunet_curl_lib.h @@ -46,6 +51,52 @@ typedef void (*GNUNET_CURL_RescheduleCallback)(void *cls); +/** + * @brief Buffer data structure we use to buffer the HTTP download + * before giving it to the JSON parser. + */ +struct GNUNET_CURL_DownloadBuffer +{ + + /** + * Download buffer + */ + void *buf; + + /** + * The size of the download buffer + */ + size_t buf_size; + + /** + * Error code (based on libc errno) if we failed to download + * (i.e. response too large). + */ + int eno; + +}; + + +/** + * Parses the raw response we got from the Web server. + * + * @param db the raw data + * @param eh handle + * @param response_code HTTP response code + * @return the parsed object + */ +typedef void * +(*GNUNET_CURL_RawParser) (struct GNUNET_CURL_DownloadBuffer *db, + CURL *eh, + long *response_code); + +/** + * Deallocate the response. + * + * @param response object to clean + */ +typedef void +(*GNUNET_CURL_ResponseCleaner) (void *response); /** * Initialise this library. This function should be called before using any of @@ -95,6 +146,17 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx, long *timeout); +/** + * Add custom request header. + * + * @param ctx cURL context. + * @param header header string; will be given to the context AS IS. + * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. + */ +int +GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, + const char *header); + /** * Run the main event loop for the CURL interaction. * @@ -104,6 +166,19 @@ void GNUNET_CURL_perform (struct GNUNET_CURL_Context *ctx); +/** + * Run the main event loop for the Taler interaction. + * + * @param ctx the library context + * @param rp parses the raw response returned from + * the Web server. + * @param rc cleans/frees the response + */ +void +GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx, + GNUNET_CURL_RawParser rp, + GNUNET_CURL_ResponseCleaner rc); + /** * Cleanup library initialisation resources. This function should be called * after using this library to cleanup the resources occupied during library's @@ -130,7 +205,7 @@ struct GNUNET_CURL_Job; typedef void (*GNUNET_CURL_JobCompletionCallback)(void *cls, long response_code, - const json_t *json); + const void *response); /** @@ -185,6 +260,18 @@ struct GNUNET_CURL_RescheduleContext; struct GNUNET_CURL_RescheduleContext * GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx); +/** + * Initialize reschedule context; with custom response parser + * + * @param ctx context to manage + * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule(). + */ +struct GNUNET_CURL_RescheduleContext * +GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx, + GNUNET_CURL_RawParser rp, + GNUNET_CURL_ResponseCleaner rc); + + /** * Destroy reschedule context. *