char *link;
char *description;
time_t pubdate;
+ int channel_tag_nesting;
+ char channel_title[256];
+ int item_tag_nesting;
};
struct rssnetcfg *rnclist = NULL;
msg->cm_fields['U'] = strdup(ri->title);
msg->cm_fields['T'] = malloc(64);
snprintf(msg->cm_fields['T'], 64, "%ld", ri->pubdate);
+ if (!IsEmptyStr(ri->channel_title)) {
+ msg->cm_fields['O'] = strdup(ri->channel_title);
+ }
msglen = 1024 + strlen(ri->link) + strlen(ri->description) ;
msg->cm_fields['M'] = malloc(msglen);
void rss_xml_start(void *data, const char *el, const char **attr) {
struct rss_item *ri = (struct rss_item *) data;
+ if (!strcasecmp(el, "channel")) {
+ ++ri->channel_tag_nesting;
+ }
+
if (!strcasecmp(el, "item")) {
+ ++ri->item_tag_nesting;
/* Initialize the feed item data structure */
if (ri->guid != NULL) free(ri->guid);
/* Axe the namespace, we don't care about it */
-
safestrncpy(el, supplied_el, sizeof el);
while (sep = strchr(el, ':'), sep) {
strcpy(el, ++sep);
}
+ if (!strcasecmp(el, "channel")) {
+ --ri->channel_tag_nesting;
+ }
+
+ if ( (!strcasecmp(el, "title")) && (ri->channel_tag_nesting > 0) && (ri->item_tag_nesting == 0) ) {
+ safestrncpy(ri->channel_title, ri->chardata, sizeof ri->channel_title);
+ striplt(ri->channel_title);
+ }
+
if (!strcasecmp(el, "guid")) {
if (ri->guid != NULL) free(ri->guid);
striplt(ri->chardata);
}
if (!strcasecmp(el, "item")) {
+ --ri->item_tag_nesting;
rss_save_item(ri);
}