summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-05-10 19:33:01 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-05-10 19:33:01 +0500
commite695a65df9d5a8ee7d5af705c4789e44fbcc0b60 (patch)
treeb86aaafa8c549f381bd9f76d23174b169b1ce792 /src/main.cpp
parenta14878b4a453f48f3b200481c343a7fc59181b0f (diff)
Config support
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f936e85..b7ff89a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,21 +1,41 @@
#include "RSS.hpp"
#include <curl/curl.h>
-#include <memory>
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#define CONFIG_LOCATION std::getenv("HOME") + "/.config/rsshit.xml"
+// #define CONFIG_LOCATION "rsshit.xml"
+
+std::string read_config() {
+ std::ifstream file(std::string(std::getenv("HOME")) + "/.config/rsshit.xml");
+ std::stringstream buffer;
+ buffer << file.rdbuf();
+
+ return buffer.str();
+}
int main() {
- // auto tmp = RSS_leaf::TokenizeXML("<test> abc </test>");
- auto rss = std::make_unique<RSS>("https://www.independent.co.uk/news/uk/rss");
- rss->channelInfo.print();
- int i = 0;
- for (auto entry : rss->Entries) {
- if (i > 3) break;
- entry.print();
- ++i;
+ std::string config;
+ try {
+ config = read_config();
+ if (config.length() == 0) {
+ std::cout << "failed to read config file: the file is empty" << std::endl;
+ return 1;
+ }
+ XML_leaf configParsed(config);
+ auto sources = configParsed.GetChildren("source");
+ for (auto src : sources) {
+ std::cout << "URL: " << src.GetValue() << std::endl;
+ RSS(src.GetValue()).print();
+ }
+ } catch (char *ex) {
+ std::cout << "failed to read config file: " << ex << std::endl;
+ return 1;
}
- // auto rss_1 = std::make_unique<RSS>("https://feeds.washingtonpost.com/rss/world");
- // auto rss_2 = std::make_unique<RSS>("https://news.yahoo.com/rss/mostviewed");
- // for (auto entry : rss_2->Entries)
- // entry.print();
+
+ // RSS("https://www.independent.co.uk/news/uk/rss").print();
+ // RSS("https://news.yahoo.com/rss/mostviewed").print();
return 0;
}