27 lines
571 B
C
27 lines
571 B
C
/* NOT THREAD SAFE */
|
|
|
|
#ifndef _FETCH_H
|
|
#define _FETCH_H
|
|
|
|
#include <curl/curl.h>
|
|
#include <stdlib.h>
|
|
|
|
struct fetch {
|
|
CURL *handle;
|
|
};
|
|
|
|
struct response {
|
|
char *data;
|
|
size_t size;
|
|
char *content_type; /* Don't free. Managed by libcurl. */
|
|
};
|
|
|
|
typedef size_t (*CurlWriteCallback)(void *ptr, size_t size, size_t nmemb,
|
|
void *userdata);
|
|
|
|
struct fetch *fetch_init(void);
|
|
struct response *fetch(struct fetch *restrict f, CURLU *restrict url);
|
|
void fetch_cleanup(struct fetch *f);
|
|
void response_cleanup(struct response *resp);
|
|
|
|
#endif
|