]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/import/curl-util.h
c7c24c9f7eab320e46d119066b47a384ee8aced7
[thirdparty/systemd.git] / src / import / curl-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2014 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <curl/curl.h>
24 #include <sys/types.h>
25
26 #include "sd-event.h"
27
28 #include "hashmap.h"
29
30 typedef struct CurlGlue CurlGlue;
31
32 struct CurlGlue {
33 sd_event *event;
34 CURLM *curl;
35 sd_event_source *timer;
36 Hashmap *ios;
37 Hashmap *translate_fds;
38
39 void (*on_finished)(CurlGlue *g, CURL *curl, CURLcode code);
40 void *userdata;
41 };
42
43 int curl_glue_new(CurlGlue **glue, sd_event *event);
44 CurlGlue* curl_glue_unref(CurlGlue *glue);
45
46 DEFINE_TRIVIAL_CLEANUP_FUNC(CurlGlue*, curl_glue_unref);
47
48 int curl_glue_make(CURL **ret, const char *url, void *userdata);
49 int curl_glue_add(CurlGlue *g, CURL *c);
50 void curl_glue_remove_and_free(CurlGlue *g, CURL *c);
51
52 struct curl_slist *curl_slist_new(const char *first, ...) _sentinel_;
53 int curl_header_strdup(const void *contents, size_t sz, const char *field, char **value);
54 int curl_parse_http_time(const char *t, usec_t *ret);
55
56 DEFINE_TRIVIAL_CLEANUP_FUNC(CURL*, curl_easy_cleanup);
57 DEFINE_TRIVIAL_CLEANUP_FUNC(struct curl_slist*, curl_slist_free_all);