From 09db8e9120d948edc2596cae82019de1e3b0c566 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Sun, 9 Feb 2020 23:00:13 +1030 Subject: add flag for images in RSS feed --- config.h | 9 +++++---- makefile | 2 +- pages.c | 13 +++++++------ pages.h | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/config.h b/config.h index bcd15c1..fd3e6dd 100644 --- a/config.h +++ b/config.h @@ -20,9 +20,10 @@ enum flag { - NONE = 0, - RSS = 1, - PINNED = 2, + NONE = 1<<0, + RSS = 1<<1, + RSSIMAGES = 1<<2, + PINNED = 1<<3, }; struct page @@ -116,7 +117,7 @@ static const struct page pages[] = { {opinions_animepage, NONE}, {opinions_everythingpage, NONE}, {portfoliopage, NONE}, - {postspage, RSS|PINNED}, /* flags: RSS feed, pinned posts */ + {postspage, RSS|RSSIMAGES|PINNED}, /* flags: RSS feed, RSS images, pinned posts */ }; #endif diff --git a/makefile b/makefile index 1530317..898378e 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ TARGET = generate LIBS = CC = gcc -CFLAGS = -std=c99 -g -Wall -Werror -Wno-unused-variable +CFLAGS = -std=c99 -g -Wall -Werror -Wno-unused-variable .PHONY: default all clean diff --git a/pages.c b/pages.c index 3498e20..1e5d152 100644 --- a/pages.c +++ b/pages.c @@ -659,6 +659,7 @@ generatepinned(char *buff, size_t size) strncat(buff, "

\n
\nPinned posts:\n", 60); + //TODO: check we fit into the buffer // pray we fit for (int i = 0; i < sizeof(pinned)/sizeof(pinned[0]); i++) { @@ -775,7 +776,7 @@ postspage(int flags) /* generate rss feed if required */ if (flags & RSS) { - generaterss(posts, totalposts); + generaterss(posts, totalposts, flags); } return 1; } @@ -868,7 +869,7 @@ char } int -writerss(FILE *out, int post) +writerss(FILE *out, int post, int flags) { /* * create rss item using 'post_content'/'posts'.txt into FILE 'out' @@ -918,9 +919,9 @@ writerss(FILE *out, int post) strncpy(description, line, 100); } - /* try to find images */ + /* try to find images if flag set */ char *img; - if ((img = strstr(line, "