2 * Bring external RSS feeds into rooms.
4 * Copyright (c) 2007-2015 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
33 #include <sys/types.h>
36 #include <curl/curl.h>
37 #include <libcitadel.h>
40 #include "citserver.h"
44 #include "ctdl_module.h"
45 #include "clientsocket.h"
47 #include "parsedate.h"
49 #include "citadel_dirs.h"
52 #include "event_client.h"
53 #include "rss_atom_parser.h"
55 void rss_remember_item(rss_item *ri, rss_aggregator *Cfg);
57 int RSSAtomParserDebugEnabled = 0;
59 #define N ((rss_aggregator*)IO->Data)->Cfg.QRnumber
62 * Convert an RDF/RSS datestamp into a time_t
64 time_t rdf_parsedate(const char *p)
70 if (strlen(p) < 10) return 0L;
72 memset(&tm, 0, sizeof tm);
75 * If the timestamp appears to be in W3C datetime format, try to
76 * parse it. See also: http://www.w3.org/TR/NOTE-datetime
78 * This code, along with parsedate.c, is a potential candidate for
79 * moving into libcitadel.
81 if ( (p[4] == '-') && (p[7] == '-') ) {
82 tm.tm_year = atoi(&p[0]) - 1900;
83 tm.tm_mon = atoi(&p[5]) - 1;
84 tm.tm_mday = atoi(&p[8]);
85 if ( (p[10] == 'T') && (p[13] == ':') ) {
86 tm.tm_hour = atoi(&p[11]);
87 tm.tm_min = atoi(&p[14]);
92 /* hmm... try RFC822 date stamp format */
97 /* yeesh. ok, just return the current date and time. */
101 void flush_rss_item(rss_item *ri)
103 /* Initialize the feed item data structure */
104 FreeStrBuf(&ri->guid);
105 FreeStrBuf(&ri->title);
106 FreeStrBuf(&ri->link);
107 FreeStrBuf(&ri->author_or_creator);
108 FreeStrBuf(&ri->author_email);
109 FreeStrBuf(&ri->author_url);
110 FreeStrBuf(&ri->description);
112 FreeStrBuf(&ri->linkTitle);
113 FreeStrBuf(&ri->reLink);
114 FreeStrBuf(&ri->reLinkTitle);
115 FreeStrBuf(&ri->channel_title);
119 /******************************************************************************
121 ******************************************************************************/
124 void RSS_item_rss_start (StrBuf *CData,
126 rss_aggregator *RSSAggr,
129 syslog(LOG_DEBUG, "RSS: This is an RSS feed.");
130 RSSAggr->ItemType = RSS_RSS;
133 void RSS_item_rdf_start(StrBuf *CData,
135 rss_aggregator *RSSAggr,
138 syslog(LOG_DEBUG, "RSS: This is an RDF feed.");
139 RSSAggr->ItemType = RSS_RSS;
142 void ATOM_item_feed_start(StrBuf *CData,
144 rss_aggregator *RSSAggr,
147 syslog(LOG_DEBUG, "RSS: This is an ATOM feed.");
148 RSSAggr->ItemType = RSS_ATOM;
152 void RSS_item_item_start(StrBuf *CData,
154 rss_aggregator *RSSAggr,
157 ri->item_tag_nesting ++;
161 void ATOM_item_entry_start(StrBuf *CData,
163 rss_aggregator *RSSAggr,
167 ri->item_tag_nesting ++;
171 void ATOM_item_link_start (StrBuf *CData,
173 rss_aggregator *RSSAggr,
177 const char *pHref = NULL;
178 const char *pType = NULL;
179 const char *pRel = NULL;
180 const char *pTitle = NULL;
182 for (i = 0; Attr[i] != NULL; i+=2)
184 if (!strcmp(Attr[i], "href"))
188 else if (!strcmp(Attr[i], "rel"))
192 else if (!strcmp(Attr[i], "type"))
196 else if (!strcmp(Attr[i], "title"))
202 return; /* WHUT? Pointing... where? */
203 if ((pType != NULL) && !strcasecmp(pType, "application/atom+xml"))
205 /* these just point to other rss resources,
206 we're not interested in them. */
209 if (!strcasecmp (pRel, "replies"))
211 NewStrBufDupAppendFlush(&ri->reLink, NULL, pHref, -1);
212 StrBufTrim(ri->link);
213 NewStrBufDupAppendFlush(&ri->reLinkTitle,
218 else if (!strcasecmp(pRel, "alternate"))
219 { /* Alternative representation of this Item... */
220 NewStrBufDupAppendFlush(&ri->link, NULL, pHref, -1);
221 StrBufTrim(ri->link);
222 NewStrBufDupAppendFlush(&ri->linkTitle,
228 #if 0 /* these are also defined, but dunno what to do with them.. */
229 else if (!strcasecmp(pRel, "related"))
232 else if (!strcasecmp(pRel, "self"))
235 else if (!strcasecmp(pRel, "enclosure"))
236 {/*...reference can get big, and is probably the full article*/
238 else if (!strcasecmp(pRel, "via"))
239 {/* this article was provided via... */
243 else if (StrLength(ri->link) == 0)
245 NewStrBufDupAppendFlush(&ri->link, NULL, pHref, -1);
246 StrBufTrim(ri->link);
247 NewStrBufDupAppendFlush(&ri->linkTitle, NULL, pTitle, -1);
254 void ATOMRSS_item_title_end(StrBuf *CData,
256 rss_aggregator *RSSAggr,
259 if ((ri->item_tag_nesting == 0) && (StrLength(CData) > 0)) {
260 NewStrBufDupAppendFlush(&ri->channel_title, CData, NULL, 0);
261 StrBufTrim(ri->channel_title);
265 void RSS_item_guid_end(StrBuf *CData,
267 rss_aggregator *RSSAggr,
270 if (StrLength(CData) > 0) {
271 NewStrBufDupAppendFlush(&ri->guid, CData, NULL, 0);
275 void ATOM_item_id_end(StrBuf *CData,
276 rss_item *ri, rss_aggregator *RSSAggr, const char** Attr)
278 if (StrLength(CData) > 0) {
279 NewStrBufDupAppendFlush(&ri->guid, CData, NULL, 0);
284 void RSS_item_link_end (StrBuf *CData,
286 rss_aggregator *RSSAggr,
289 if (StrLength(CData) > 0) {
290 NewStrBufDupAppendFlush(&ri->link, CData, NULL, 0);
291 StrBufTrim(ri->link);
294 void RSS_item_relink_end(StrBuf *CData,
296 rss_aggregator *RSSAggr,
299 if (StrLength(CData) > 0) {
300 NewStrBufDupAppendFlush(&ri->reLink, CData, NULL, 0);
301 StrBufTrim(ri->reLink);
305 void RSSATOM_item_title_end (StrBuf *CData,
307 rss_aggregator *RSSAggr,
310 if (StrLength(CData) > 0) {
311 NewStrBufDupAppendFlush(&ri->title, CData, NULL, 0);
312 StrBufTrim(ri->title);
316 void ATOM_item_content_end (StrBuf *CData,
318 rss_aggregator *RSSAggr,
321 long olen = StrLength (ri->description);
322 long clen = StrLength (CData);
326 NewStrBufDupAppendFlush(&ri->description,
330 StrBufTrim(ri->description);
332 else if (olen < clen) {
333 FlushStrBuf(ri->description);
334 NewStrBufDupAppendFlush(&ri->description,
339 StrBufTrim(ri->description);
343 void ATOM_item_summary_end (StrBuf *CData,
345 rss_aggregator *RSSAggr,
349 * this can contain an abstract of the article.
350 * but we don't want to verwrite a full document if we already have it.
352 if ((StrLength(CData) > 0) && (StrLength(ri->description) == 0))
354 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
355 StrBufTrim(ri->description);
359 void RSS_item_description_end (StrBuf *CData,
361 rss_aggregator *RSSAggr,
364 long olen = StrLength (ri->description);
365 long clen = StrLength (CData);
369 NewStrBufDupAppendFlush(&ri->description,
373 StrBufTrim(ri->description);
375 else if (olen < clen) {
376 FlushStrBuf(ri->description);
377 NewStrBufDupAppendFlush(&ri->description,
381 StrBufTrim(ri->description);
386 void ATOM_item_published_end (StrBuf *CData,
388 rss_aggregator *RSSAggr,
391 if (StrLength(CData) > 0) {
393 ri->pubdate = rdf_parsedate(ChrPtr(CData));
397 void ATOM_item_updated_end (StrBuf *CData,
399 rss_aggregator *RSSAggr,
402 if (StrLength(CData) > 0) {
404 ri->pubdate = rdf_parsedate(ChrPtr(CData));
408 void RSS_item_pubdate_end (StrBuf *CData,
410 rss_aggregator *RSSAggr,
413 if (StrLength(CData) > 0) {
415 ri->pubdate = rdf_parsedate(ChrPtr(CData));
420 void RSS_item_date_end (StrBuf *CData,
422 rss_aggregator *RSSAggr,
425 if (StrLength(CData) > 0) {
427 ri->pubdate = rdf_parsedate(ChrPtr(CData));
433 void RSS_item_author_end(StrBuf *CData,
435 rss_aggregator *RSSAggr,
438 if (StrLength(CData) > 0) {
439 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
440 StrBufTrim(ri->author_or_creator);
445 void ATOM_item_name_end(StrBuf *CData,
447 rss_aggregator *RSSAggr,
450 if (StrLength(CData) > 0) {
451 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
452 StrBufTrim(ri->author_or_creator);
456 void ATOM_item_email_end(StrBuf *CData,
458 rss_aggregator *RSSAggr,
461 if (StrLength(CData) > 0) {
462 NewStrBufDupAppendFlush(&ri->author_email, CData, NULL, 0);
463 StrBufTrim(ri->author_email);
467 void RSS_item_creator_end(StrBuf *CData,
469 rss_aggregator *RSSAggr,
472 if ((StrLength(CData) > 0) &&
473 (StrLength(ri->author_or_creator) == 0))
475 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
476 StrBufTrim(ri->author_or_creator);
481 void ATOM_item_uri_end(StrBuf *CData,
483 rss_aggregator *RSSAggr,
486 if (StrLength(CData) > 0) {
487 NewStrBufDupAppendFlush(&ri->author_url, CData, NULL, 0);
488 StrBufTrim(ri->author_url);
492 void RSS_item_item_end(StrBuf *CData,
494 rss_aggregator *RSSAggr,
497 --ri->item_tag_nesting;
498 rss_remember_item(ri, RSSAggr);
502 void ATOM_item_entry_end(StrBuf *CData,
504 rss_aggregator *RSSAggr,
507 --ri->item_tag_nesting;
508 rss_remember_item(ri, RSSAggr);
511 void RSS_item_rss_end(StrBuf *CData,
513 rss_aggregator *RSSAggr,
516 syslog(LOG_DEBUG, "End of feed detected. Closing parser.");
517 ri->done_parsing = 1;
520 void RSS_item_rdf_end(StrBuf *CData,
522 rss_aggregator *RSSAggr,
525 syslog(LOG_DEBUG, "End of feed detected. Closing parser.");
526 ri->done_parsing = 1;
530 void RSSATOM_item_ignore(StrBuf *CData,
532 rss_aggregator *RSSAggr,
540 * This callback stores up the data which appears in between tags.
542 void rss_xml_cdata_start(void *data)
544 rss_aggregator *RSSAggr = (rss_aggregator*) data;
546 FlushStrBuf(RSSAggr->CData);
549 void rss_xml_cdata_end(void *data)
552 void rss_xml_chardata(void *data, const XML_Char *s, int len)
554 rss_aggregator *RSSAggr = (rss_aggregator*) data;
556 StrBufAppendBufPlain (RSSAggr->CData, s, len, 0);
560 /******************************************************************************
562 ******************************************************************************/
564 extern pthread_mutex_t RSSQueueMutex;
566 HashList *StartHandlers = NULL;
567 HashList *EndHandlers = NULL;
568 HashList *KnownNameSpaces = NULL;
570 void FreeNetworkSaveMessage (void *vMsg)
572 networker_save_message *Msg = (networker_save_message *) vMsg;
574 CM_FreeContents(&Msg->Msg);
575 FreeStrBuf(&Msg->Message);
576 FreeStrBuf(&Msg->MsgGUID);
578 FreeStrBuf(&Msg->author_email);
579 FreeStrBuf(&Msg->author_or_creator);
580 FreeStrBuf(&Msg->title);
581 FreeStrBuf(&Msg->description);
583 FreeStrBuf(&Msg->link);
584 FreeStrBuf(&Msg->linkTitle);
586 FreeStrBuf(&Msg->reLink);
587 FreeStrBuf(&Msg->reLinkTitle);
594 * Commit a fetched and parsed RSS item to disk
596 void rss_remember_item(rss_item *ri, rss_aggregator *RSSAggr)
598 networker_save_message *SaveMsg;
599 struct MD5Context md5context;
600 u_char rawdigest[MD5_DIGEST_LEN];
604 SaveMsg = (networker_save_message *) malloc(sizeof(networker_save_message));
605 memset(SaveMsg, 0, sizeof(networker_save_message));
607 /* Construct a GUID to use in the S_USETABLE table.
608 * If one is not present in the item itself, make one up.
610 if (ri->guid != NULL) {
611 StrBufSpaceToBlank(ri->guid);
612 StrBufTrim(ri->guid);
613 guid = NewStrBufPlain(HKEY("rss/"));
614 StrBufAppendBuf(guid, ri->guid, 0);
617 MD5Init(&md5context);
618 if (ri->title != NULL) {
619 MD5Update(&md5context, (const unsigned char*)SKEY(ri->title));
621 if (ri->link != NULL) {
622 MD5Update(&md5context, (const unsigned char*)SKEY(ri->link));
624 MD5Final(rawdigest, &md5context);
625 guid = NewStrBufPlain(NULL, MD5_DIGEST_LEN * 2 + 12 /* _rss2ctdl*/);
626 StrBufHexEscAppend(guid, NULL, rawdigest, MD5_DIGEST_LEN);
627 StrBufAppendBufPlain(guid, HKEY("_rss2ctdl"), 0);
630 /* translate Item into message. */
631 syslog(LOG_DEBUG, "RSS: translating item...");
632 if (ri->description == NULL) ri->description = NewStrBufPlain(HKEY(""));
633 StrBufSpaceToBlank(ri->description);
634 SaveMsg->Msg.cm_magic = CTDLMESSAGE_MAGIC;
635 SaveMsg->Msg.cm_anon_type = MES_NORMAL;
636 SaveMsg->Msg.cm_format_type = FMT_RFC822;
638 /* gather the cheaply computed information now... */
640 if (ri->guid != NULL) {
641 CM_SetField(&SaveMsg->Msg, eExclusiveID, SKEY(ri->guid));
644 SaveMsg->MsgGUID = guid;
646 if (ri->pubdate <= 0) {
647 ri->pubdate = time(NULL);
649 CM_SetFieldLONG(&SaveMsg->Msg, eTimestamp, ri->pubdate);
650 if (ri->channel_title != NULL) {
651 if (StrLength(ri->channel_title) > 0) {
652 CM_SetField(&SaveMsg->Msg, eOriginalRoom, SKEY(ri->channel_title));
656 /* remember the ones for defferred processing to save computing power after we know if we realy need it. */
658 SaveMsg->author_or_creator = ri->author_or_creator;
659 ri->author_or_creator = NULL;
661 SaveMsg->author_email = ri->author_email;
662 ri->author_email = NULL;
664 SaveMsg->title = ri->title;
667 SaveMsg->link = ri->link;
670 SaveMsg->description = ri->description;
671 ri->description = NULL;
673 SaveMsg->linkTitle = ri->linkTitle;
674 ri->linkTitle = NULL;
676 SaveMsg->reLink = ri->reLink;
679 SaveMsg->reLinkTitle = ri->reLinkTitle;
680 ri->reLinkTitle = NULL;
682 n = GetCount(RSSAggr->Messages) + 1;
683 Put(RSSAggr->Messages, IKEY(n), SaveMsg, FreeNetworkSaveMessage);
688 void rss_xml_start(void *data, const char *supplied_el, const char **attr)
691 rss_aggregator *RSSAggr = (rss_aggregator*) data;
692 rss_item *ri = RSSAggr->Item;
697 /* Axe the namespace, we don't care about it */
700 "RSS: supplied el %d: %s\n", RSSAggr->RSSAggr->ItemType, supplied_el);
703 while (sep = strchr(pel, ':'), sep) {
707 if (pel != supplied_el)
711 if (!GetHash(KnownNameSpaces,
713 pel - supplied_el - 1,
717 "RSS: START ignoring "
718 "because of wrong namespace [%s]",
725 StrBufPlain(RSSAggr->Key, pel, -1);
726 StrBufLowerCase(RSSAggr->Key);
727 if (GetHash(StartHandlers, SKEY(RSSAggr->Key), &pv))
729 h = (rss_xml_handler*) pv;
731 if (((h->Flags & RSS_UNSET) != 0) &&
732 (RSSAggr->ItemType == RSS_UNSET))
734 h->Handler(RSSAggr->CData, ri, RSSAggr, attr);
736 else if (((h->Flags & RSS_RSS) != 0) &&
737 (RSSAggr->ItemType == RSS_RSS))
739 h->Handler(RSSAggr->CData, ri, RSSAggr, attr);
741 else if (((h->Flags & RSS_ATOM) != 0) &&
742 (RSSAggr->ItemType == RSS_ATOM))
744 h->Handler(RSSAggr->CData,
751 "RSS: START unhandled: [%s] [%s]...",
758 "RSS: START unhandled: [%s] [%s]...",
764 void rss_xml_end(void *data, const char *supplied_el)
767 rss_aggregator *RSSAggr = (rss_aggregator*) data;
768 rss_item *ri = RSSAggr->Item;
773 /* Axe the namespace, we don't care about it */
775 while (sep = strchr(pel, ':'), sep) {
778 syslog(LOG_DEBUG, "RSS: END %s...", supplied_el);
779 if (pel != supplied_el)
783 if (!GetHash(KnownNameSpaces,
785 pel - supplied_el - 1,
789 "RSS: END ignoring because of wrong namespace"
792 ChrPtr(RSSAggr->CData));
793 FlushStrBuf(RSSAggr->CData);
798 StrBufPlain(RSSAggr->Key, pel, -1);
799 StrBufLowerCase(RSSAggr->Key);
800 if (GetHash(EndHandlers, SKEY(RSSAggr->Key), &pv))
802 h = (rss_xml_handler*) pv;
804 if (((h->Flags & RSS_UNSET) != 0) &&
805 (RSSAggr->ItemType == RSS_UNSET))
807 h->Handler(RSSAggr->CData, ri, RSSAggr, NULL);
809 else if (((h->Flags & RSS_RSS) != 0) &&
810 (RSSAggr->ItemType == RSS_RSS))
812 h->Handler(RSSAggr->CData, ri, RSSAggr, NULL);
814 else if (((h->Flags & RSS_ATOM) != 0) &&
815 (RSSAggr->ItemType == RSS_ATOM))
817 h->Handler(RSSAggr->CData, ri, RSSAggr, NULL);
821 "RSS: END unhandled: [%s] [%s] = [%s]...",
824 ChrPtr(RSSAggr->CData));
828 "RSS: END unhandled: [%s] [%s] = [%s]...",
831 ChrPtr(RSSAggr->CData));
832 FlushStrBuf(RSSAggr->CData);
837 eNextState RSSAggregator_ParseReply(AsyncIO *IO)
840 rss_aggregator *RSSAggr;
849 RSSAggr->CData = NewStrBufPlain(NULL, SIZ);
850 RSSAggr->Key = NewStrBuf();
852 StrBufSipLine(RSSAggr->Key, IO->HttpReq.ReplyData, &at);
855 #define encoding "encoding=\""
856 ptr = strstr(ChrPtr(RSSAggr->Key), encoding);
861 ptr += sizeof (encoding) - 1;
862 pche = strchr(ptr, '"');
864 StrBufCutAt(RSSAggr->Key, -1, pche);
871 syslog(LOG_DEBUG, "RSS: Now parsing [%s]", ChrPtr(RSSAggr->Url));
873 RSSAggr->xp = XML_ParserCreateNS(ptr, ':');
875 syslog(LOG_ALERT, "Cannot create XML parser!");
878 FlushStrBuf(RSSAggr->Key);
880 RSSAggr->Messages = NewHash(1, Flathash);
881 XML_SetElementHandler(RSSAggr->xp, rss_xml_start, rss_xml_end);
882 XML_SetCharacterDataHandler(RSSAggr->xp, rss_xml_chardata);
883 XML_SetUserData(RSSAggr->xp, RSSAggr);
884 XML_SetCdataSectionHandler(RSSAggr->xp,
889 len = StrLength(IO->HttpReq.ReplyData);
890 ptr = SmashStrBuf(&IO->HttpReq.ReplyData);
891 XML_Parse(RSSAggr->xp, ptr, len, 0);
893 if (ri->done_parsing == 0) {
894 XML_Parse(RSSAggr->xp, "", 0, 1);
897 syslog(LOG_DEBUG, "RSS: XML Status [%s]", XML_ErrorString(XML_GetErrorCode(RSSAggr->xp)));
899 XML_ParserFree(RSSAggr->xp);
902 Buf = NewStrBufDup(RSSAggr->rooms);
903 RSSAggr->recp.recp_room = SmashStrBuf(&Buf);
904 RSSAggr->recp.num_room = RSSAggr->roomlist_parts;
905 RSSAggr->recp.recptypes_magic = RECPTYPES_MAGIC;
907 RSSAggr->Pos = GetNewHashPos(RSSAggr->Messages, 1);
911 if (GetNextHashPos(RSSAggr->Messages,
915 (void**) &RSSAggr->ThisMsg)) {
916 return NextDBOperation(IO, RSS_FetchNetworkUsetableEntry);
927 /******************************************************************************
928 * RSS handler registering logic *
929 ******************************************************************************/
931 void AddRSSStartHandler(rss_handler_func Handler,
937 h = (rss_xml_handler*) malloc(sizeof (rss_xml_handler));
939 h->Handler = Handler;
940 Put(StartHandlers, key, len, h, NULL);
943 void AddRSSEndHandler(rss_handler_func Handler,
949 h = (rss_xml_handler*) malloc(sizeof (rss_xml_handler));
951 h->Handler = Handler;
952 Put(EndHandlers, key, len, h, NULL);
955 void rss_parser_cleanup(void)
957 DeleteHash(&StartHandlers);
958 DeleteHash(&EndHandlers);
959 DeleteHash(&KnownNameSpaces);
962 void LogDebugEnableRSSATOMParser(const int n)
964 RSSAtomParserDebugEnabled = n;
967 CTDL_MODULE_INIT(rssparser)
971 StartHandlers = NewHash(1, NULL);
972 EndHandlers = NewHash(1, NULL);
974 AddRSSStartHandler(RSS_item_rss_start, RSS_UNSET, HKEY("rss"));
975 AddRSSStartHandler(RSS_item_rdf_start, RSS_UNSET, HKEY("rdf"));
976 AddRSSStartHandler(ATOM_item_feed_start, RSS_UNSET, HKEY("feed"));
977 AddRSSStartHandler(RSS_item_item_start, RSS_RSS, HKEY("item"));
978 AddRSSStartHandler(ATOM_item_entry_start, RSS_ATOM, HKEY("entry"));
979 AddRSSStartHandler(ATOM_item_link_start, RSS_ATOM, HKEY("link"));
981 AddRSSEndHandler(ATOMRSS_item_title_end, RSS_ATOM|RSS_RSS|RSS_REQUIRE_BUF, HKEY("title"));
982 AddRSSEndHandler(RSS_item_guid_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("guid"));
983 AddRSSEndHandler(ATOM_item_id_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("id"));
984 AddRSSEndHandler(RSS_item_link_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("link"));
986 // hm, rss to the comments of that blog, might be interesting in future, but...
987 AddRSSEndHandler(RSS_item_relink_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("commentrss"));
989 AddRSSEndHandler(RSS_item_relink_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("comments"));
991 AddRSSEndHandler(RSSATOM_item_title_end, RSS_ATOM|RSS_RSS|RSS_REQUIRE_BUF, HKEY("title"));
992 AddRSSEndHandler(ATOM_item_content_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("content"));
993 AddRSSEndHandler(RSS_item_description_end, RSS_RSS|RSS_ATOM|RSS_REQUIRE_BUF, HKEY("encoded"));
994 AddRSSEndHandler(ATOM_item_summary_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("summary"));
995 AddRSSEndHandler(RSS_item_description_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("description"));
996 AddRSSEndHandler(ATOM_item_published_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("published"));
997 AddRSSEndHandler(ATOM_item_updated_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("updated"));
998 AddRSSEndHandler(RSS_item_pubdate_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("pubdate"));
999 AddRSSEndHandler(RSS_item_date_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("date"));
1000 AddRSSEndHandler(RSS_item_author_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("author"));
1001 AddRSSEndHandler(RSS_item_creator_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("creator"));
1003 AddRSSEndHandler(ATOM_item_email_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("email"));
1004 AddRSSEndHandler(ATOM_item_name_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("name"));
1005 AddRSSEndHandler(ATOM_item_uri_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("uri"));
1007 AddRSSEndHandler(RSS_item_item_end, RSS_RSS, HKEY("item"));
1008 AddRSSEndHandler(RSS_item_rss_end, RSS_RSS, HKEY("rss"));
1009 AddRSSEndHandler(RSS_item_rdf_end, RSS_RSS, HKEY("rdf"));
1010 AddRSSEndHandler(ATOM_item_entry_end, RSS_ATOM, HKEY("entry"));
1013 /* at the start of atoms: <seq> <li>link to resource</li></seq> ignore them. */
1014 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("seq"));
1015 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("seq"));
1016 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("li"));
1017 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("li"));
1019 /* links to other feed generators... */
1020 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("feedflare"));
1021 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("feedflare"));
1022 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("browserfriendly"));
1023 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("browserfriendly"));
1025 KnownNameSpaces = NewHash(1, NULL);
1026 Put(KnownNameSpaces, HKEY("http://a9.com/-/spec/opensearch/1.1/"), NULL, reference_free_handler);
1027 Put(KnownNameSpaces, HKEY("http://a9.com/-/spec/opensearchrss/1.0/"), NULL, reference_free_handler);
1028 Put(KnownNameSpaces, HKEY("http://backend.userland.com/creativeCommonsRssModule"), NULL, reference_free_handler);
1029 Put(KnownNameSpaces, HKEY("http://purl.org/atom/ns#"), NULL, reference_free_handler);
1030 Put(KnownNameSpaces, HKEY("http://purl.org/dc/elements/1.1/"), NULL, reference_free_handler);
1031 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/"), NULL, reference_free_handler);
1032 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/content/"), NULL, reference_free_handler);
1033 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/slash/"), NULL, reference_free_handler);
1034 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/syndication/"), NULL, reference_free_handler);
1035 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/"), NULL, reference_free_handler);
1036 Put(KnownNameSpaces, HKEY("http://purl.org/syndication/thread/1.0"), NULL, reference_free_handler);
1037 Put(KnownNameSpaces, HKEY("http://rssnamespace.org/feedburner/ext/1.0"), NULL, reference_free_handler);
1038 Put(KnownNameSpaces, HKEY("http://schemas.google.com/g/2005"), NULL, reference_free_handler);
1039 Put(KnownNameSpaces, HKEY("http://webns.net/mvcb/"), NULL, reference_free_handler);
1040 Put(KnownNameSpaces, HKEY("http://web.resource.org/cc/"), NULL, reference_free_handler);
1041 Put(KnownNameSpaces, HKEY("http://wellformedweb.org/CommentAPI/"), NULL, reference_free_handler);
1042 Put(KnownNameSpaces, HKEY("http://www.georss.org/georss"), NULL, reference_free_handler);
1043 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/xhtml"), NULL, reference_free_handler);
1044 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), NULL, reference_free_handler);
1045 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), NULL, reference_free_handler);
1046 Put(KnownNameSpaces, HKEY("http://www.w3.org/2003/01/geo/wgs84_pos#"), NULL, reference_free_handler);
1047 Put(KnownNameSpaces, HKEY("http://www.w3.org/2005/Atom"), NULL, reference_free_handler);
1048 Put(KnownNameSpaces, HKEY("urn:flickr:"), NULL, reference_free_handler);
1050 /* we don't like these namespaces because of they shadow our usefull parameters. */
1051 Put(KnownNameSpaces, HKEY("http://search.yahoo.com/mrss/"), NULL, reference_free_handler);
1053 CtdlRegisterDebugFlagHook(HKEY("RSSAtomParser"), LogDebugEnableRSSATOMParser, &RSSAtomParserDebugEnabled);
1054 CtdlRegisterCleanupHook(rss_parser_cleanup);