30 lines
541 B
C

#ifndef HTTP_GET_H
#define HTTP_GET_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#ifdef __cplusplus
extern "C" {
#endif
// Struct to hold response data
struct Memory {
char *response;
size_t size;
};
// Callback for libcurl to write response into our struct
static size_t write_callback(void *data, size_t size, size_t nmemb, void *userp);
// Function: GET request, returns heap string (caller must free)
char *http_get(const char *url);
#ifdef __cplusplus
}
#endif
#endif // HTTP_GET_H