From d8f2ad2361b8ef1b1509cbcd584bea89139df370 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Fri, 16 Jun 2023 15:24:51 -0400 Subject: [PATCH] handlers.c: add feed name to output --- Makefile | 2 +- handlers.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c13744e..f24d5e8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PREFIX = ~/.local -VERSION = 0.3.1 +VERSION = 0.4.0 PKG_CONFIG = pkg-config diff --git a/handlers.c b/handlers.c index 9f7dae4..5ddb85a 100644 --- a/handlers.c +++ b/handlers.c @@ -155,10 +155,13 @@ openFile(const char *folder, char *fileName, char *fileExt) } static void -outputHtml(itemStruct *item, FILE *f) +outputHtml(itemStruct *item, FILE *f, const char *folder) { if (item->fields[FIELD_TITLE]) fprintf(f, "

%s


\n", item->fields[FIELD_TITLE]); + + fprintf(f, "From feed %s
\n", folder); + if (item->fields[FIELD_LINK]) fprintf(f, "Link
\n", item->fields[FIELD_LINK]); if (item->fields[FIELD_ENCLOSURE_URL]) @@ -171,10 +174,13 @@ outputHtml(itemStruct *item, FILE *f) #ifdef JSON static void -outputJson(itemStruct *item, FILE *f) +outputJson(itemStruct *item, FILE *f, const char *folder) { json_object *root = json_object_new_object(); + json_object_object_add(root, "feedname", + json_object_new_string(folder)); + if (item->fields[FIELD_TITLE]) json_object_object_add(root, "title", json_object_new_string(item->fields[FIELD_TITLE])); @@ -211,7 +217,7 @@ processItem(itemStruct *item, const char *folder) int ret = 0; char fileExt[10]; - void (*outputFunction)(itemStruct *, FILE *); + void (*outputFunction)(itemStruct *, FILE *, const char *); switch (outputFormat) { case OUTPUT_HTML: @@ -247,7 +253,7 @@ processItem(itemStruct *item, const char *folder) // Do not overwrite files if (!ftell(itemFile)) { - outputFunction(item, itemFile); + outputFunction(item, itemFile, folder); ret = 1; if (summaryFormat == SUMMARY_FILES) logMsg(LOG_OUTPUT, "%s%c%s%s\n", folder, fsep(), basename, fileExt);