Files
iptv-downloader/config/config.h
T

64 lines
1.9 KiB
C

#pragma once
#include <stddef.h>
/* ── Compile-time limits (not user-configurable) ───────────────── */
#define MAX_DL 256
#define MAX_NOTIF 50
#define BACKLOG 32
#define CURL_DL_TIMEOUT 7200L
#define CURL_API_TIMEOUT 20L
/* ── Runtime configuration struct ─────────────────────────────── */
typedef struct {
/* Network */
int port;
char bind_iface[64]; /* "" = no binding, "wg0-mullvad" = VPN only */
/* IPTV provider (Xtream Codes) */
char iptv_api[512];
char iptv_user[128];
char iptv_pass[128];
char stream_base[512];
/* Download directories */
char dl_dir_tv[512];
char dl_dir_mov[512];
/* Integrations */
char discord_webhook[512];
char jellyfin_url[512];
char jellyfin_token[256];
/* Paths */
char template_dir[512]; /* dir containing header.html, footer.html, iptv.css, *.js */
char data_dir[512]; /* dir for history.json, notifications.json */
/* Limits */
long max_recv_speed; /* bytes/sec, 0 = unlimited */
} Config;
extern Config g_cfg;
/*
* Config load order (first found wins):
* 1. Path passed to config_load(path) if non-NULL
* 2. $IPTV_DL_CONFIG env var
* 3. ~/.iptv-downloader/config.json
* 4. /etc/iptv-downloader/config.json
* 5. Built-in defaults (works with no config file)
*
* Returns path used (static buffer), or NULL if using defaults only.
*/
const char *config_load(const char *explicit_path);
/* Write current g_cfg back to the path that was loaded */
void config_save(void);
/* Print current config as JSON to stderr */
void config_dump(void);
/* Return history file path: data_dir/history.json */
void config_history_path(char *buf, size_t n);
/* Return notifications file path: data_dir/notifications.json */
void config_notif_path(char *buf, size_t n);