/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "alloc-util.h"
#include "curl-util.h"
#include "fd-util.h"
#include "string-util.h"
int k = 0;
assert(g);
if (!msg)
return;
return;
if (g->on_finished)
}
assert(s);
assert(g);
else
action = 0;
log_debug("Failed to propagate IO event.");
return -EINVAL;
}
return 0;
}
static int curl_glue_socket_callback(CURLM *curl, curl_socket_t s, int action, void *userdata, void *socketp) {
int r;
assert(g);
if (action == CURL_POLL_REMOVE) {
if (io) {
int fd;
safe_close(fd);
}
return 0;
}
if (r < 0) {
log_oom();
return -1;
}
if (r < 0) {
log_oom();
return -1;
}
if (action == CURL_POLL_IN)
else if (action == CURL_POLL_OUT)
else if (action == CURL_POLL_INOUT)
if (io) {
return -1;
return -1;
} else {
/* When curl needs to remove an fd from us it closes
* the fd first, and only then calls into us. This is
* nasty, since we cannot pass the fd on to epoll()
* anymore. Hence, duplicate the fds here, and keep a
* copy for epoll which we control after use. */
if (fd < 0)
return -1;
return -1;
if (r < 0) {
log_oom();
return -1;
}
if (r < 0) {
log_oom();
return -1;
}
fd = -1;
}
return 0;
}
int k = 0;
assert(s);
assert(g);
log_debug("Failed to propagate timeout.");
return -EINVAL;
}
return 0;
}
assert(g);
if (timeout_ms < 0) {
if (g->timer) {
return -1;
}
return 0;
}
usec = now(clock_boottime_or_monotonic()) + (usec_t) timeout_ms * USEC_PER_MSEC + USEC_PER_MSEC - 1;
if (g->timer) {
return -1;
return -1;
} else {
if (sd_event_add_time(g->event, &g->timer, clock_boottime_or_monotonic(), usec, 0, curl_glue_on_timer, g) < 0)
return -1;
}
return 0;
}
if (!g)
return NULL;
if (g->curl)
curl_multi_cleanup(g->curl);
int fd;
safe_close(fd);
}
hashmap_free(g->ios);
sd_event_unref(g->event);
free(g);
return NULL;
}
int r;
if (!g)
return -ENOMEM;
if (event)
else {
r = sd_event_default(&g->event);
if (r < 0)
return r;
}
g->curl = curl_multi_init();
if (!g->curl)
return -ENOMEM;
return -EINVAL;
return -EINVAL;
return -EINVAL;
return -EINVAL;
*glue = g;
g = NULL;
return 0;
}
const char *useragent;
CURL *c;
int r;
c = curl_easy_init();
if (!c)
return -ENOMEM;
/* curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); */
r = -EIO;
goto fail;
}
r = -EIO;
goto fail;
}
r = -EIO;
goto fail;
}
r = -EIO;
goto fail;
}
*ret = c;
return 0;
fail:
return r;
}
assert(g);
assert(c);
return -EIO;
return 0;
}
assert(g);
if (!c)
return;
if (g->curl)
curl_multi_remove_handle(g->curl, c);
}
struct curl_slist *l;
if (!first)
return NULL;
if (!l)
return NULL;
for (;;) {
struct curl_slist *n;
const char *i;
if (!i)
break;
n = curl_slist_append(l, i);
if (!n) {
return NULL;
}
l = n;
}
return l;
}
const char *p = contents;
size_t l;
char *s;
if (sz < l)
return 0;
return 0;
p += l;
sz -= l;
return 0;
/* Skip over preceeding whitespace */
p++;
sz--;
}
/* Truncate trailing whitespace*/
sz--;
if (!s)
return -ENOMEM;
*value = s;
return 1;
}
const char *e;
time_t v;
assert(t);
return -errno;
/* RFC822 */
if (!e || *e != 0)
/* RFC 850 */
if (!e || *e != 0)
/* ANSI C */
if (!e || *e != 0)
return -EINVAL;
if (v == (time_t) -1)
return -EINVAL;
return 0;
}