chiark / gitweb /
logind: remove per-user runtime dir again if setup fails
[elogind.git] / src / import / curl-util.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2014 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <sys/types.h>
25 #include <curl/curl.h>
26
27 #include "hashmap.h"
28 #include "sd-event.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);