-
- if (!strcmp((char*)n->name, "title")) {
- res->title = (char*)child->content;
- } else if (!strcmp((char*)n->name, "link")) {
- res->link = (char*)child->content;
- } else if (!strcmp((char*)n->name, "description")) {
- res->description = (char*)child->content;
- } else if (!strcmp((char*)n->name, "language")) {
- res->language = (char*)child->content;
- } else if (!strcmp((char*)n->name, "pubDate")) {
- res->pubdate = (char*)child->content;
- } else if (!strcmp((char*)n->name, "lastBuildDate")) {
- res->lastbuilddate = (char*)child->content;
- } else if (!strcmp((char*)n->name, "generator")) {
- res->generator = (char*)child->content;
- } else if (!strcmp((char*)n->name, "docs")) {
- res->docs = (char*)child->content;
- } else if (!strcmp((char*)n->name, "managingEditor")) {
- res->managingeditor = (char*)child->content;
- } else if (!strcmp((char*)n->name, "webMaster")) {
- res->webmaster = (char*)child->content;
- } else if (!strcmp((char*)n->name, "item")) {
+ }
+
+#define ASSIGN(a) if (strcasecmp((const char*)n->name, #a) == EQUAL) { \
+ if (res->a) free(res->a); \
+ res->a = strdup((const char*)child->content); \
+ return; \
+ }
+ ASSIGN(title);
+ ASSIGN(link);
+ ASSIGN(description);
+ ASSIGN(language);
+ ASSIGN(pubDate);
+ ASSIGN(lastBuildDate);
+ ASSIGN(generator);
+ ASSIGN(docs);
+ ASSIGN(managingEditor);
+ ASSIGN(webMaster);
+ ASSIGN(copyright);
+ ASSIGN(ttl);
+#undef ASSIGN
+ if (!strcasecmp((const char*)n->name, "item")) {