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