summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-03-20 13:07:53 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-03-20 13:07:53 +0100
commitff283804e0dc61f2e6e7ad3de072f354df74effe (patch)
tree061747bfcae4912d02d628098e392fe1965ff06d
parentbc594605418654a6304ae86902e999f9dda35c57 (diff)
code cleanup: put table of parsed tagid at top (near reverse table)
-rw-r--r--sfeed.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/sfeed.c b/sfeed.c
index 7b5d08a..421bab5 100644
--- a/sfeed.c
+++ b/sfeed.c
@@ -110,7 +110,38 @@ static void xml_handler_start_el(XMLParser *, const char *, size_t);
static void xml_handler_start_el_parsed(XMLParser *, const char *,
size_t, int);
-/* map tag type to field */
+/* map tag name to tagid */
+/* RSS, alphabetical order */
+static FeedTag rsstags[] = {
+ { STRP("author"), RSSTagAuthor },
+ { STRP("content:encoded"), RSSTagContentEncoded },
+ { STRP("dc:creator"), RSSTagDccreator },
+ { STRP("dc:date"), RSSTagDcdate },
+ { STRP("description"), RSSTagDescription },
+ { STRP("guid"), RSSTagGuid },
+ { STRP("link"), RSSTagLink },
+ { STRP("media:description"), RSSTagMediaDescription },
+ { STRP("pubdate"), RSSTagPubdate },
+ { STRP("title"), RSSTagTitle },
+ { NULL, 0, -1 }
+};
+/* Atom, alphabetical order */
+static FeedTag atomtags[] = {
+ /* <author><name></name></author> */
+ { STRP("author"), AtomTagAuthor },
+ { STRP("content"), AtomTagContent },
+ { STRP("id"), AtomTagId },
+ /* <link href="" /> */
+ { STRP("link"), AtomTagLink },
+ { STRP("media:description"), AtomTagMediaDescription },
+ { STRP("published"), AtomTagPublished },
+ { STRP("summary"), AtomTagSummary },
+ { STRP("title"), AtomTagTitle },
+ { STRP("updated"), AtomTagUpdated },
+ { NULL, 0, -1 }
+};
+
+/* map tagid type to RSS/Atom field */
static int fieldmap[TagLast] = {
/* RSS */
[RSSTagDcdate] = FeedFieldTime,
@@ -141,39 +172,12 @@ static const char *baseurl = "";
static FeedContext ctx;
static XMLParser parser; /* XML parser state */
-/* Unique id for parsed tag. */
+/* Unique tagid for parsed tag name. */
static enum TagId
gettag(enum FeedType feedtype, const char *name, size_t namelen)
{
- /* RSS, alphabetical order */
- static FeedTag rsstags[] = {
- { STRP("author"), RSSTagAuthor },
- { STRP("content:encoded"), RSSTagContentEncoded },
- { STRP("dc:creator"), RSSTagDccreator },
- { STRP("dc:date"), RSSTagDcdate },
- { STRP("description"), RSSTagDescription },
- { STRP("guid"), RSSTagGuid },
- { STRP("link"), RSSTagLink },
- { STRP("media:description"), RSSTagMediaDescription },
- { STRP("pubdate"), RSSTagPubdate },
- { STRP("title"), RSSTagTitle },
- { NULL, 0, -1 }
- };
- /* Atom, alphabetical order */
- static FeedTag atomtags[] = {
- { STRP("author"), AtomTagAuthor },
- { STRP("content"), AtomTagContent },
- { STRP("id"), AtomTagId },
- { STRP("link"), AtomTagLink },
- { STRP("media:description"), AtomTagMediaDescription },
- { STRP("published"), AtomTagPublished },
- { STRP("summary"), AtomTagSummary },
- { STRP("title"), AtomTagTitle },
- { STRP("updated"), AtomTagUpdated },
- { NULL, 0, -1 }
- };
const FeedTag *tags;
- int i;
+ size_t i;
/* optimization: these are always non-matching */
if (namelen < 2 || namelen > 17)