omdb/fetch.h

28 lines
571 B
C
Raw Normal View History

2025-12-13 06:22:27 +00:00
/* 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