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);
|
|
|
|
|
|
2026-01-09 07:42:40 +00:00
|
|
|
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);
|
2025-12-13 06:22:27 +00:00
|
|
|
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
|