GNUnet 0.28.1-dev.4-24-g0cf3356dd
 
Loading...
Searching...
No Matches
gnunet_curl_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2014, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
33#ifndef GNUNET_CURL_LIB_H
34#define GNUNET_CURL_LIB_H
35
36#include <curl/curl.h>
37#include "gnunet_util_lib.h"
38
39
48typedef void
50
56{
60 void *buf;
61
65 size_t buf_size;
66
71 int eno;
72};
73
74
83typedef void *
84(*GNUNET_CURL_RawParser) (struct GNUNET_CURL_DownloadBuffer *db,
85 CURL *eh,
86 long *response_code);
87
93typedef void
95
104struct GNUNET_CURL_Context *
106 void *cb_cls);
107
108
135void
137 fd_set *read_fd_set,
138 fd_set *write_fd_set,
139 fd_set *except_fd_set,
140 int *max_fd,
141 long *timeout);
142
143
153 const char *header);
154
160void
162
163
172void
176
184void
186
187
191struct GNUNET_CURL_Job;
192
200typedef void
202 long response_code,
203 const void *response);
204
205
214typedef void
216 long response_code,
217 const void *body,
218 size_t body_size);
219
220
246typedef enum GNUNET_GenericReturnValue
248 const char *line,
249 size_t line_size);
250
251
257#define GNUNET_CURL_STREAM_PAUSE CURL_WRITEFUNC_PAUSE
258
259
272typedef size_t
273(*GNUNET_CURL_StreamCallback)(void *cls,
274 const void *data,
275 size_t data_size);
276
277
325
326
352struct GNUNET_CURL_Job *
354 CURL *eh,
355 const struct curl_slist *job_headers,
356 const struct GNUNET_CURL_StreamHandlers *sh);
357
358
394void
396 bool recv_paused,
397 bool send_paused);
398
399
412struct GNUNET_CURL_Job *
414 CURL *eh,
416 void *jcc_cls);
417
418
434struct GNUNET_CURL_Job *
436 CURL *eh,
438 void *jcc_cls);
439
440
449void
451 const char *userpass);
452
453
468void
470 const char *certtype,
471 const char *certfile,
472 const char *keyfile,
473 const char *keypass);
474
475
489struct GNUNET_CURL_Job *
491 CURL *eh,
492 const struct curl_slist *job_headers,
494 void *jcc_cls);
495
496
511struct GNUNET_CURL_Job *
513 CURL *eh,
514 const struct curl_slist *job_headers,
516 void *jcc_cls);
517
518
525void
527 const struct curl_slist *extra_headers);
528
529
536void
538
539
540/* ******* GNUnet SCHEDULER integration ************ */
541
542
547
548
557
568
569
575void
577
578
588void
590
591
598void
600 const char *header_name);
601
602
613GNUNET_CURL_is_valid_scope_id (const char *scope_id);
614
615
616#endif
/* end of group */
618
/* end of group addition to lib_extra */
620
621/* end of gnunet_curl_lib.h */
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition gnunet-arm.c:118
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
static char * line
Desired phone line (string to be converted to a hash).
static struct MHD_Response * response
Our canonical response.
static char * data
The data to insert into the dht.
static struct GNUNET_FS_Handle * ctx
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
static size_t data_size
Number of bytes in data.
static char * rp
Relying party.
static struct GNUNET_FS_DirectoryBuilder * db
void GNUNET_CURL_set_tlscert(struct GNUNET_CURL_Context *ctx, const char *certtype, const char *certfile, const char *keyfile, const char *keypass)
Force use of the provided TLS client certificate for client authentication for all operations perform...
Definition curl.c:237
void GNUNET_CURL_gnunet_scheduler_reschedule(void *cls)
Implementation of the GNUNET_CURL_RescheduleCallback for GNUnet's scheduler.
void(* GNUNET_CURL_RawJobCompletionCallback)(void *cls, long response_code, const void *body, size_t body_size)
Function to call upon completion of a raw job.
void(* GNUNET_CURL_JobCompletionCallback)(void *cls, long response_code, const void *response)
Function to call upon completion of a job.
struct GNUNET_CURL_Job * GNUNET_CURL_job_add_raw(struct GNUNET_CURL_Context *ctx, CURL *eh, const struct curl_slist *job_headers, GNUNET_CURL_RawJobCompletionCallback jcc, void *jcc_cls)
Schedule a CURL request to be executed and call the given jcc upon its completion.
Definition curl.c:608
struct GNUNET_CURL_RescheduleContext * GNUNET_CURL_gnunet_rc_create_with_parser(struct GNUNET_CURL_Context *ctx, GNUNET_CURL_RawParser rp, GNUNET_CURL_ResponseCleaner rc)
Initialize reschedule context; with custom response parser.
void GNUNET_CURL_job_set_paused(struct GNUNET_CURL_Job *job, bool recv_paused, bool send_paused)
Say which directions of job are to be paused from now on.
Definition curl.c:657
struct GNUNET_CURL_Job * GNUNET_CURL_job_add(struct GNUNET_CURL_Context *ctx, CURL *eh, GNUNET_CURL_JobCompletionCallback jcc, void *jcc_cls)
Schedule a CURL request to be executed and call the given jcc upon its completion.
Definition curl.c:753
void GNUNET_CURL_get_select_info(struct GNUNET_CURL_Context *ctx, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *max_fd, long *timeout)
Obtain the information for a select() call to wait until GNUNET_CURL_perform() is ready again.
Definition curl.c:1040
struct GNUNET_CURL_Context * GNUNET_CURL_init(GNUNET_CURL_RescheduleCallback cb, void *cb_cls)
Initialise this library.
Definition curl.c:259
void GNUNET_CURL_fini(struct GNUNET_CURL_Context *ctx)
Cleanup library initialisation resources.
Definition curl.c:1073
void(* GNUNET_CURL_ResponseCleaner)(void *response)
Deallocate the response.
void GNUNET_CURL_extend_headers(struct GNUNET_CURL_Job *job, const struct curl_slist *extra_headers)
Add extra_headers to the HTTP headers for job.
Definition curl.c:586
struct GNUNET_CURL_RescheduleContext * GNUNET_CURL_gnunet_rc_create(struct GNUNET_CURL_Context *ctx)
Initialize reschedule context.
void GNUNET_CURL_perform2(struct GNUNET_CURL_Context *ctx, GNUNET_CURL_RawParser rp, GNUNET_CURL_ResponseCleaner rc)
Run the main event loop for the HTTP interaction.
Definition curl.c:927
void GNUNET_CURL_job_cancel(struct GNUNET_CURL_Job *job)
Cancel a job.
Definition curl.c:767
size_t(* GNUNET_CURL_StreamCallback)(void *cls, const void *data, size_t data_size)
Function called with a chunk of the response body as it arrives.
enum GNUNET_GenericReturnValue GNUNET_CURL_is_valid_scope_id(const char *scope_id)
Return GNUNET_YES if given a valid scope ID and GNUNET_NO otherwise.
Definition curl.c:302
void GNUNET_CURL_perform(struct GNUNET_CURL_Context *ctx)
Run the main event loop for the CURL interaction.
Definition curl.c:1031
void GNUNET_CURL_set_userpass(struct GNUNET_CURL_Context *ctx, const char *userpass)
Force use of the provided username and password for client authentication for all operations performe...
Definition curl.c:227
void *(* GNUNET_CURL_RawParser)(struct GNUNET_CURL_DownloadBuffer *db, CURL *eh, long *response_code)
Parses the raw response we got from the Web server.
struct GNUNET_CURL_Job * GNUNET_CURL_job_add_with_ct_json(struct GNUNET_CURL_Context *ctx, CURL *eh, GNUNET_CURL_JobCompletionCallback jcc, void *jcc_cls)
Schedule a CURL request to be executed and call the given jcc upon its completion.
Definition curl.c:730
struct GNUNET_CURL_Job * GNUNET_CURL_job_add_stream(struct GNUNET_CURL_Context *ctx, CURL *eh, const struct curl_slist *job_headers, const struct GNUNET_CURL_StreamHandlers *sh)
Schedule a CURL request whose response is delivered incrementally, rather than buffered in full and h...
Definition curl.c:633
enum GNUNET_GenericReturnValue GNUNET_CURL_append_header(struct GNUNET_CURL_Context *ctx, const char *header)
Add custom request header.
Definition curl.c:909
void(* GNUNET_CURL_RescheduleCallback)(void *cls)
Function called by the context to ask for the event loop to be rescheduled, that is the application s...
void GNUNET_CURL_gnunet_rc_destroy(struct GNUNET_CURL_RescheduleContext *rc)
Destroy reschedule context.
enum GNUNET_GenericReturnValue(* GNUNET_CURL_StreamHeaderCallback)(void *cls, const char *line, size_t line_size)
Function called with one raw header line of the response, as it arrives.
void GNUNET_CURL_enable_async_scope_header(struct GNUNET_CURL_Context *ctx, const char *header_name)
Enable sending the async scope ID as a header.
Definition curl.c:294
struct GNUNET_CURL_Job * GNUNET_CURL_job_add2(struct GNUNET_CURL_Context *ctx, CURL *eh, const struct curl_slist *job_headers, GNUNET_CURL_JobCompletionCallback jcc, void *jcc_cls)
Schedule a CURL request to be executed and call the given jcc upon its completion.
Definition curl.c:678
GNUNET_GenericReturnValue
Named constants for return values.
void * cb_cls
Closure for cb.
Definition curl.c:194
GNUNET_CURL_RescheduleCallback cb
Function we need to call whenever the event loop's socket set changed.
Definition curl.c:189
Buffer data structure we use to buffer the HTTP download before giving it to the JSON parser.
void * buf
Download buffer.
size_t buf_size
The size of the download buffer.
int eno
Error code (based on libc errno) if we failed to download (e.g.
Jobs are CURL requests running within a struct GNUNET_CURL_Context.
Definition curl.c:78
struct curl_slist * job_headers
Headers used for this job, the list needs to be freed after the job has finished.
Definition curl.c:140
GNUNET_CURL_JobCompletionCallback jcc
Function to call upon completion.
Definition curl.c:102
void * jcc_cls
Closure for jcc.
Definition curl.c:107
Closure for GNUNET_CURL_gnunet_scheduler_reschedule().
What to call for a job added with GNUNET_CURL_job_add_stream().
void * jcc_cls
Closure for jcc.
GNUNET_CURL_RawJobCompletionCallback jcc
Called once the transfer has ended, successfully or not.
void * hcb_cls
Closure for hcb.
void * scb_cls
Closure for scb.
GNUNET_CURL_StreamHeaderCallback hcb
Called per response header line, or NULL if the caller does not want them.
GNUNET_CURL_StreamCallback scb
Called per chunk of response body.