GNUnet  0.17.6
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  */
30 #ifndef GNUNET_CURL_LIB_H
31 #define GNUNET_CURL_LIB_H
32 #include <curl/curl.h>
33 #include "gnunet_util_lib.h"
34 
35 
44 typedef void
45 (*GNUNET_CURL_RescheduleCallback)(void *cls);
46 
52 {
56  void *buf;
57 
61  size_t buf_size;
62 
67  int eno;
68 };
69 
70 
79 typedef void *
80 (*GNUNET_CURL_RawParser) (struct GNUNET_CURL_DownloadBuffer *db,
81  CURL *eh,
82  long *response_code);
83 
89 typedef void
91 
100 struct GNUNET_CURL_Context *
102  void *cb_cls);
103 
104 
131 void
133  fd_set *read_fd_set,
134  fd_set *write_fd_set,
135  fd_set *except_fd_set,
136  int *max_fd,
137  long *timeout);
138 
139 
149  const char *header);
150 
156 void
158 
159 
168 void
172 
180 void
182 
183 
187 struct GNUNET_CURL_Job;
188 
196 typedef void
198  long response_code,
199  const void *response);
200 
201 
210 typedef void
212  long response_code,
213  const void *body,
214  size_t body_size);
215 
216 
229 struct GNUNET_CURL_Job *
231  CURL *eh,
233  void *jcc_cls);
234 
235 
251 struct GNUNET_CURL_Job *
253  CURL *eh,
255  void *jcc_cls);
256 
257 
266 void
268  const char *userpass);
269 
270 
285 void
287  const char *certtype,
288  const char *certfile,
289  const char *keyfile,
290  const char *keypass);
291 
292 
309 struct GNUNET_CURL_Job *
311  CURL *eh,
312  const struct curl_slist *job_headers,
314  void *jcc_cls);
315 
316 
332 struct GNUNET_CURL_Job *
334  CURL *eh,
335  const struct curl_slist *job_headers,
337  void *jcc_cls);
338 
339 
346 void
348  const struct curl_slist *extra_headers);
349 
350 
357 void
359 
360 
361 /* ******* GNUnet SCHEDULER integration ************ */
362 
363 
368 
369 
378 
389 
390 
396 void
398 
399 
409 void
411 
412 
419 void
421  const char *header_name);
422 
423 
433 int
434 GNUNET_CURL_is_valid_scope_id (const char *scope_id);
435 
436 
437 #endif /* end of group */
439 
440 /* end of gnunet_curl_lib.h */
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
Definition: gnunet-cadet.c:137
static struct MHD_Response * response
Our canonical response.
static char * rp
Relying party.
static struct GNUNET_FS_DirectoryBuilder * db
Definition: gnunet-search.c:94
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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:215
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.
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:789
void GNUNET_CURL_fini(struct GNUNET_CURL_Context *ctx)
Cleanup library initialisation resources.
Definition: curl.c:822
void(* GNUNET_CURL_ResponseCleaner)(void *response)
Deallocate the response.
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:499
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:457
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:572
struct GNUNET_CURL_Context * GNUNET_CURL_init(GNUNET_CURL_RescheduleCallback cb, void *cb_cls)
Initialise this library.
Definition: curl.c:237
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:726
void GNUNET_CURL_job_cancel(struct GNUNET_CURL_Job *job)
Cancel a job.
Definition: curl.c:586
void GNUNET_CURL_perform(struct GNUNET_CURL_Context *ctx)
Run the main event loop for the CURL interaction.
Definition: curl.c:780
struct GNUNET_CURL_RescheduleContext * GNUNET_CURL_gnunet_rc_create(struct GNUNET_CURL_Context *ctx)
Initialize reschedule context.
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:550
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:205
int 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:280
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_RawParser)(struct GNUNET_CURL_DownloadBuffer *db, CURL *eh, long *response_code)
Parses the raw response we got from the Web server.
enum GNUNET_GenericReturnValue GNUNET_CURL_append_header(struct GNUNET_CURL_Context *ctx, const char *header)
Add custom request header.
Definition: curl.c:713
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.
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:475
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:272
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
Context.
Definition: curl.c:131
void * cb_cls
Closure for cb.
Definition: curl.c:172
GNUNET_CURL_RescheduleCallback cb
Function we need to call whenever the event loop's socket set changed.
Definition: curl.c:167
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:73
struct curl_slist * job_headers
Headers used for this job, the list needs to be freed after the job has finished.
Definition: curl.c:123
GNUNET_CURL_JobCompletionCallback jcc
Function to call upon completion.
Definition: curl.c:97
void * jcc_cls
Closure for jcc.
Definition: curl.c:102
Closure for GNUNET_CURL_gnunet_scheduler_reschedule().