refactor: reorganize into subdirs (config/ util/ http/ notifs/ queue/ integrations/ static/)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#include "iptv_api.h"
|
||||
#include "config.h"
|
||||
#include "buf.h"
|
||||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static size_t curl_write_buf(char *ptr, size_t sz, size_t n, void *ud) {
|
||||
buf_append((Buf*)ud, ptr, sz*n); return sz*n;
|
||||
}
|
||||
|
||||
char *api_get(const char *action, const char *extra) {
|
||||
CURL *c = curl_easy_init();
|
||||
Buf b; buf_init(&b);
|
||||
char url[1024];
|
||||
snprintf(url, sizeof(url), "%s?username=%s&password=%s&action=%s%s",
|
||||
g_cfg.iptv_api, g_cfg.iptv_user, g_cfg.iptv_pass,
|
||||
action, extra ? extra : "");
|
||||
curl_easy_setopt(c, CURLOPT_URL, url);
|
||||
curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, curl_write_buf);
|
||||
curl_easy_setopt(c, CURLOPT_WRITEDATA, &b);
|
||||
curl_easy_setopt(c, CURLOPT_TIMEOUT, CURL_API_TIMEOUT);
|
||||
curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_perform(c);
|
||||
curl_easy_cleanup(c);
|
||||
return b.data; /* caller frees */
|
||||
}
|
||||
Reference in New Issue
Block a user