omdb/fetch.h
2026-01-09 01:42:40 -06:00

31 lines
757 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);
CURLU *init_curl_url(const char *restrict ustr);
void set_param(CURLU *restrict url, const char *restrict key,
char *restrict value);
void print_url(CURLU *restrict url);
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