]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/import/curl-util.h
f4ec3dae9e442aea4d52817698e1ed31f020f8ac
[thirdparty/systemd.git] / src / import / curl-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2014 Lennart Poettering
6 ***/
7
8 #include <curl/curl.h>
9 #include <sys/types.h>
10
11 #include "sd-event.h"
12
13 #include "hashmap.h"
14
15 typedef struct CurlGlue CurlGlue;
16
17 struct CurlGlue {
18 sd_event *event;
19 CURLM *curl;
20 sd_event_source *timer;
21 Hashmap *ios;
22 Hashmap *translate_fds;
23
24 void (*on_finished)(CurlGlue *g, CURL *curl, CURLcode code);
25 void *userdata;
26 };
27
28 int curl_glue_new(CurlGlue **glue, sd_event *event);
29 CurlGlue* curl_glue_unref(CurlGlue *glue);
30
31 DEFINE_TRIVIAL_CLEANUP_FUNC(CurlGlue*, curl_glue_unref);
32
33 int curl_glue_make(CURL **ret, const char *url, void *userdata);
34 int curl_glue_add(CurlGlue *g, CURL *c);
35 void curl_glue_remove_and_free(CurlGlue *g, CURL *c);
36
37 struct curl_slist *curl_slist_new(const char *first, ...) _sentinel_;
38 int curl_header_strdup(const void *contents, size_t sz, const char *field, char **value);
39 int curl_parse_http_time(const char *t, usec_t *ret);
40
41 DEFINE_TRIVIAL_CLEANUP_FUNC(CURL*, curl_easy_cleanup);
42 DEFINE_TRIVIAL_CLEANUP_FUNC(struct curl_slist*, curl_slist_free_all);