2 * Bring external RSS feeds into rooms.
4 * Copyright (c) 2007-2010 by the citadel.org team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #if TIME_WITH_SYS_TIME
26 # include <sys/time.h>
30 # include <sys/time.h>
39 #include <sys/types.h>
42 #include <curl/curl.h>
43 #include <libcitadel.h>
46 #include "citserver.h"
50 #include "ctdl_module.h"
51 #include "clientsocket.h"
53 #include "parsedate.h"
55 #include "citadel_dirs.h"
61 const char *LinkShortenerServices[] = {
68 "http://tinyurl.com/",
72 typedef struct rssnetcfg rssnetcfg;
77 time_t last_error_when;
81 #define RSS_UNSET (1<<0)
82 #define RSS_RSS (1<<1)
83 #define RSS_ATOM (1<<2)
84 #define RSS_REQUIRE_BUF (1<<3)
86 typedef struct _rss_item {
97 StrBuf *channel_title;
99 StrBuf *author_or_creator;
101 StrBuf *author_email;
105 typedef void (*rss_handler_func)(StrBuf *CData,
110 typedef struct __rss_xml_handler {
112 rss_handler_func Handler;
116 typedef struct _rsscollection {
123 rss_xml_handler *Current;
126 struct rssnetcfg *rnclist = NULL;
127 HashList *StartHandlers;
128 HashList *EndHandlers;
129 HashList *KnownNameSpaces;
130 void AddRSSStartHandler(rss_handler_func Handler, int Flags, const char *key, long len)
133 h = (rss_xml_handler*) malloc(sizeof (rss_xml_handler));
135 h->Handler = Handler;
136 Put(StartHandlers, key, len, h, NULL);
138 void AddRSSEndHandler(rss_handler_func Handler, int Flags, const char *key, long len)
141 h = (rss_xml_handler*) malloc(sizeof (rss_xml_handler));
143 h->Handler = Handler;
144 Put(EndHandlers, key, len, h, NULL);
153 * dug this out of the trashcan of the midgard project, lets see if it works for us.
154 * original code by Alexander Bokovoy <bokovoy@avilink.ne> distributed under GPL V2 or later
158 >= 0 - successfull, 0 means conversion doesn't use multibyte sequences
159 -1 - error during iconv_open call
160 -2 - error during iconv_close call
161 ----------------------------------
162 This function expects that multibyte encoding in 'charset' wouldn't have
163 characters with more than 3 bytes. It is not intended to convert UTF-8 because
164 we'll never receive UTF-8 in our handler (it is handled by Exat itself).
167 fill_encoding_info (const char *charset, XML_Encoding * info)
169 iconv_t cd = (iconv_t)(-1);
171 CtdlLogPrintf(0, "RSS: fill encoding info ...\n");
173 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
174 cd = iconv_open ("UCS-2LE", charset);
176 cd = iconv_open ("UCS-2BE", charset);
179 if (cd == (iconv_t) (-1))
185 unsigned short out = 0;
186 unsigned char buf[4];
187 unsigned int i0, i1, i2;
190 for (i0 = 0; i0 < 0x100; i0++)
194 //result = try (cd, buf, 1, &out);
204 for (i1 = 0; i1 < 0x100; i1++)
207 ///result = try (cd, buf, 2, &out);
218 for (i2 = 0; i2 < 0x100; i2++)
221 ////result = try (cd, buf, 3, &out);
237 if (iconv_close (cd) < 0)
245 iconv_convertor (void *data, const char *s)
247 XML_Encoding *info = data;
249 CtdlLogPrintf(0, "RSS: Converting ...\n");
255 result = g_byte_array_new ();
256 if (process_block (info->data, (char *) s, strlen (s), result) == 0)
258 res = *(result->data);
259 g_byte_array_free (result, TRUE);
262 g_byte_array_free (result, TRUE);
268 my_release (void *data)
270 iconv_t cd = (iconv_t) data;
271 if (iconv_close (cd) != 0)
273 /// TODO: uh no. exit (1);
277 handle_unknown_xml_encoding (void *encodingHandleData,
278 const XML_Char * name,
282 CtdlLogPrintf(0, "RSS: unknown encoding ...\n");
283 result = fill_encoding_info (name, info);
287 Special case: client asked for reverse conversion, we'll provide him with
288 iconv descriptor which handles it. Client should release it by himself.
290 if(encodingHandleData != NULL)
291 *((iconv_t *)encodingHandleData) = iconv_open(name, "UTF-8");
293 Optimization: we do not need conversion function if encoding is one-to-one,
294 info->map table will be enough
299 info->convert = NULL;
300 info->release = NULL;
304 We do need conversion function because this encoding uses multibyte sequences
306 info->data = (void *) iconv_open ("UTF-8", name);
307 if ((int)info->data == -1)
309 info->convert = iconv_convertor;
310 info->release = my_release;
313 if(encodingHandleData != NULL)
314 *(iconv_t *)encodingHandleData = NULL;
320 size_t GetLocationString( void *ptr, size_t size, size_t nmemb, void *userdata)
322 #define LOCATION "location"
323 if (strncasecmp((char*)ptr, LOCATION, sizeof(LOCATION) - 1) == 0)
325 StrBuf *pURL = (StrBuf*) userdata;
326 char *pch = (char*) ptr;
329 pche = pch + (size * nmemb);
330 pch += sizeof(LOCATION);
332 while (isspace(*pch) || (*pch == ':'))
335 while (isspace(*pche) || (*pche == '\0'))
339 StrBufPlain(pURL, pch, pche - pch + 1);
344 int LookupUrl(StrBuf *ShorterUrlStr)
347 char errmsg[1024] = "";
351 curl = curl_easy_init();
353 CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
356 Answer = NewStrBufPlain(NULL, SIZ);
358 curl_easy_setopt(curl, CURLOPT_URL, ChrPtr(ShorterUrlStr));
359 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
360 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
361 curl_easy_setopt(curl, CURLOPT_WRITEDATA, Answer);
362 // curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, rss_libcurl_callback);
363 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlFillStrBuf_callback);
364 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
365 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
366 #ifdef CURLOPT_HTTP_CONTENT_DECODING
367 curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
368 curl_easy_setopt(curl, CURLOPT_ENCODING, "");
370 curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
371 curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180); /* die after 180 seconds */
372 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
374 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION , GetLocationString);
375 curl_easy_setopt(curl, CURLOPT_WRITEHEADER, ShorterUrlStr);
379 (!IsEmptyStr(config.c_ip_addr))
380 && (strcmp(config.c_ip_addr, "*"))
381 && (strcmp(config.c_ip_addr, "::"))
382 && (strcmp(config.c_ip_addr, "0.0.0.0"))
384 curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
387 if (CtdlThreadCheckStop())
390 rc = curl_easy_perform(curl);
392 CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", rc, errmsg);
399 curl_easy_cleanup(curl);
407 void CrawlMessageForShorterUrls(HashList *pUrls, StrBuf *Message)
410 const char *pShortenerService;
416 pShortenerService = LinkShortenerServices[nShorter++];
417 while (pShortenerService != NULL)
419 pch = ChrPtr(Message);
420 pUrl = strstr(pch, pShortenerService);
421 while ((pUrl != NULL) && (nHits < 99))
423 pCUrl = malloc(sizeof(ConstStr));
426 pch = pUrl + strlen(pShortenerService);
427 while (isalnum(*pch)||(*pch == '-')||(*pch == '/'))
429 pCUrl->len = pch - pCUrl->Key;
431 Put(pUrls, IKEY(nHits), pCUrl, NULL);
433 pUrl = strstr(pch, pShortenerService);
435 pShortenerService = LinkShortenerServices[nShorter++];
439 int SortConstStrByPosition(const void *Item1, const void *Item2)
441 const ConstStr *p1, *p2;
442 p1 = (const ConstStr*) Item1;
443 p2 = (const ConstStr*) Item2;
444 if (p1->Key == p2->Key)
446 if (p1->Key > p2->Key)
451 void ExpandShortUrls(StrBuf *Message)
459 /* we just suspect URL shorteners to be inside of feeds from twitter
460 * or other short content messages, so don't crawl through real blogs.
462 if (StrLength(Message) > 500)
465 pUrls = NewHash(1, Flathash);
466 CrawlMessageForShorterUrls(pUrls, Message);
468 if (GetCount(pUrls) > 0)
470 StrBuf *ShorterUrlStr;
476 Shadow = NewStrBufPlain(NULL, StrLength(Message));
477 SortByPayload (pUrls, SortConstStrByPosition);
479 ShorterUrlStr = NewStrBufPlain(NULL, StrLength(Message));
481 pch = ChrPtr(Message);
482 pche = pch + StrLength(Message);
483 Pos = GetNewHashPos(pUrls, 1);
484 while (GetNextHashPos(pUrls, Pos, &len, &Key, &pv))
486 pCUrl = (ConstStr*) pv;
488 if (pch != pCUrl->Key)
489 StrBufAppendBufPlain(Shadow, pch, pCUrl->Key - pch, 0);
491 StrBufPlain(ShorterUrlStr, CKEY(*pCUrl));
492 if (LookupUrl(ShorterUrlStr))
494 StrBufAppendBufPlain(Shadow, HKEY("<a href=\""), 0);
495 StrBufAppendBuf(Shadow, ShorterUrlStr, 0);
496 StrBufAppendBufPlain(Shadow, HKEY("\">"), 0);
497 StrBufAppendBuf(Shadow, ShorterUrlStr, 0);
498 StrBufAppendBufPlain(Shadow, HKEY("["), 0);
499 StrBufAppendBufPlain(Shadow, pCUrl->Key, pCUrl->len, 0);
500 StrBufAppendBufPlain(Shadow, HKEY("]</a>"), 0);
504 StrBufAppendBufPlain(Shadow, HKEY("<a href=\""), 0);
505 StrBufAppendBufPlain(Shadow, pCUrl->Key, pCUrl->len, 0);
506 StrBufAppendBufPlain(Shadow, HKEY("\">"), 0);
507 StrBufAppendBufPlain(Shadow, pCUrl->Key, pCUrl->len, 0);
508 StrBufAppendBufPlain(Shadow, HKEY("</a>"), 0);
510 pch = pCUrl->Key + pCUrl->len + 1;
514 StrBufAppendBufPlain(Shadow, pch, pche - pch, 0);
515 FlushStrBuf(Message);
516 StrBufAppendBuf(Message, Shadow, 0);
518 FreeStrBuf(&ShorterUrlStr);
527 void AppendLink(StrBuf *Message, StrBuf *link, StrBuf *LinkTitle, const char *Title)
529 if (StrLength(link) > 0)
531 StrBufAppendBufPlain(Message, HKEY("<a href=\""), 0);
532 StrBufAppendBuf(Message, link, 0);
533 StrBufAppendBufPlain(Message, HKEY("\">"), 0);
534 if (StrLength(LinkTitle) > 0)
535 StrBufAppendBuf(Message, LinkTitle, 0);
536 else if ((Title != NULL) && !IsEmptyStr(Title))
537 StrBufAppendBufPlain(Message, Title, -1, 0);
539 StrBufAppendBuf(Message, link, 0);
540 StrBufAppendBufPlain(Message, HKEY("</a><br>\n"), 0);
544 * Commit a fetched and parsed RSS item to disk
546 void rss_save_item(rss_item *ri)
549 struct MD5Context md5context;
550 u_char rawdigest[MD5_DIGEST_LEN];
553 struct cdbdata *cdbut;
555 struct CtdlMessage *msg;
556 struct recptypes *recp = NULL;
560 recp = (struct recptypes *) malloc(sizeof(struct recptypes));
561 if (recp == NULL) return;
562 memset(recp, 0, sizeof(struct recptypes));
563 memset(&ut, 0, sizeof(struct UseTable));
564 recp->recp_room = strdup(ri->roomlist);
565 recp->num_room = num_tokens(ri->roomlist, '|');
566 recp->recptypes_magic = RECPTYPES_MAGIC;
568 /* Construct a GUID to use in the S_USETABLE table.
569 * If one is not present in the item itself, make one up.
571 if (ri->guid != NULL) {
572 StrBufSpaceToBlank(ri->guid);
573 StrBufTrim(ri->guid);
574 snprintf(utmsgid, sizeof utmsgid, "rss/%s", ChrPtr(ri->guid));
577 MD5Init(&md5context);
578 if (ri->title != NULL) {
579 MD5Update(&md5context, (const unsigned char*)ChrPtr(ri->title), StrLength(ri->title));
581 if (ri->link != NULL) {
582 MD5Update(&md5context, (const unsigned char*)ChrPtr(ri->link), StrLength(ri->link));
584 MD5Final(rawdigest, &md5context);
585 for (i=0; i<MD5_DIGEST_LEN; i++) {
586 sprintf(&utmsgid[i*2], "%02X", (unsigned char) (rawdigest[i] & 0xff));
587 utmsgid[i*2] = tolower(utmsgid[i*2]);
588 utmsgid[(i*2)+1] = tolower(utmsgid[(i*2)+1]);
590 strcat(utmsgid, "_rss2ctdl");
593 /* Find out if we've already seen this item */
595 cdbut = cdb_fetch(CDB_USETABLE, utmsgid, strlen(utmsgid));
598 /* Item has already been seen */
599 CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", utmsgid);
602 /* rewrite the record anyway, to update the timestamp */
603 strcpy(ut.ut_msgid, utmsgid);
604 ut.ut_timestamp = time(NULL);
605 cdb_store(CDB_USETABLE, utmsgid, strlen(utmsgid), &ut, sizeof(struct UseTable) );
610 /* Item has not been seen, so save it. */
611 CtdlLogPrintf(CTDL_DEBUG, "RSS: saving item...\n");
612 if (ri->description == NULL) ri->description = NewStrBufPlain(HKEY(""));
613 StrBufSpaceToBlank(ri->description);
614 msg = malloc(sizeof(struct CtdlMessage));
615 memset(msg, 0, sizeof(struct CtdlMessage));
616 msg->cm_magic = CTDLMESSAGE_MAGIC;
617 msg->cm_anon_type = MES_NORMAL;
618 msg->cm_format_type = FMT_RFC822;
620 if (ri->guid != NULL) {
621 msg->cm_fields['E'] = strdup(ChrPtr(ri->guid));
624 if (ri->author_or_creator != NULL) {
626 StrBuf *Encoded, *QPEncoded;
628 StrBuf *EmailAddress;
633 UserName = NewStrBuf();
634 EmailAddress = NewStrBuf();
635 EncBuf = NewStrBuf();
637 StrBufTrim(ri->author_or_creator);
638 From = html_to_ascii(ChrPtr(ri->author_or_creator),
639 StrLength(ri->author_or_creator),
641 FromLen = strlen(From);
642 if (From[FromLen - 1] == '\n')
644 From[FromLen - 1] = '\0';
646 FromAt = strchr(From, '@') != NULL;
647 if (!FromAt && StrLength (ri->author_email) > 0)
649 Encoded = NewStrBuf();
650 if (!IsEmptyStr(From))
652 StrBufPrintf(Encoded,
655 ChrPtr(ri->author_email));
659 StrBufPrintf(Encoded,
661 ChrPtr(ri->author_email));
667 Encoded = NewStrBufPlain(From, -1);
670 Encoded = NewStrBuf();
671 StrBufPrintf(Encoded,
674 "rss@localhost"); /// TODO: get hostname?
679 QPEncoded = StrBufSanitizeEmailRecipientVector(Encoded, UserName, EmailAddress, EncBuf);
680 msg->cm_fields['A'] = SmashStrBuf(&QPEncoded);
682 FreeStrBuf(&Encoded);
683 FreeStrBuf(&UserName);
684 FreeStrBuf(&EmailAddress);
689 msg->cm_fields['A'] = strdup("rss");
692 msg->cm_fields['N'] = strdup(NODENAME);
693 if (ri->title != NULL) {
696 StrBuf *Encoded, *QPEncoded;
699 StrBufSpaceToBlank(ri->title);
700 len = StrLength(ri->title);
701 Sbj = html_to_ascii(ChrPtr(ri->title), len, 512, 0);
703 if (Sbj[len - 1] == '\n')
708 Encoded = NewStrBufPlain(Sbj, len);
712 StrBufRFC2047encode(&QPEncoded, Encoded);
714 msg->cm_fields['U'] = SmashStrBuf(&QPEncoded);
715 FreeStrBuf(&Encoded);
717 msg->cm_fields['T'] = malloc(64);
718 snprintf(msg->cm_fields['T'], 64, "%ld", ri->pubdate);
719 if (ri->channel_title != NULL) {
720 if (StrLength(ri->channel_title) > 0) {
721 msg->cm_fields['O'] = strdup(ChrPtr(ri->channel_title));
724 if (ri->link == NULL)
725 ri->link = NewStrBufPlain(HKEY(""));
726 ExpandShortUrls(ri->description);
727 msglen += 1024 + StrLength(ri->link) + StrLength(ri->description) ;
729 Message = NewStrBufPlain(NULL, StrLength(ri->description));
731 StrBufPlain(Message, HKEY(
732 "Content-type: text/html; charset=\"UTF-8\"\r\n\r\n"
735 StrBufAppendBuf(Message, ri->description, 0);
736 StrBufAppendBufPlain(Message, HKEY("<br><br>\n"), 0);
738 AppendLink(Message, ri->link, ri->linkTitle, NULL);
739 AppendLink(Message, ri->reLink, ri->reLinkTitle, "Reply to this");
740 StrBufAppendBufPlain(Message, HKEY("</body></html>\n"), 0);
742 msg->cm_fields['M'] = SmashStrBuf(&Message);
744 CtdlSubmitMsg(msg, recp, NULL, 0);
745 CtdlFreeMessage(msg);
747 /* write the uidl to the use table so we don't store this item again */
748 strcpy(ut.ut_msgid, utmsgid);
749 ut.ut_timestamp = time(NULL);
750 cdb_store(CDB_USETABLE, utmsgid, strlen(utmsgid), &ut, sizeof(struct UseTable) );
752 free_recipients(recp);
758 * Convert an RDF/RSS datestamp into a time_t
760 time_t rdf_parsedate(const char *p)
766 if (strlen(p) < 10) return 0L;
768 memset(&tm, 0, sizeof tm);
771 * If the timestamp appears to be in W3C datetime format, try to
772 * parse it. See also: http://www.w3.org/TR/NOTE-datetime
774 * This code, along with parsedate.c, is a potential candidate for
775 * moving into libcitadel.
777 if ( (p[4] == '-') && (p[7] == '-') ) {
778 tm.tm_year = atoi(&p[0]) - 1900;
779 tm.tm_mon = atoi(&p[5]) - 1;
780 tm.tm_mday = atoi(&p[8]);
781 if ( (p[10] == 'T') && (p[13] == ':') ) {
782 tm.tm_hour = atoi(&p[11]);
783 tm.tm_min = atoi(&p[14]);
788 /* hmm... try RFC822 date stamp format */
791 if (t > 0) return(t);
793 /* yeesh. ok, just return the current date and time. */
797 void flush_rss_item(rss_item *ri)
799 /* Initialize the feed item data structure */
800 FreeStrBuf(&ri->guid);
801 FreeStrBuf(&ri->title);
802 FreeStrBuf(&ri->link);
803 FreeStrBuf(&ri->author_or_creator);
804 FreeStrBuf(&ri->author_email);
805 FreeStrBuf(&ri->author_url);
806 FreeStrBuf(&ri->description);
809 void rss_xml_start(void *data, const char *supplied_el, const char **attr)
812 rsscollection *rssc = (rsscollection*) data;
813 rssnetcfg *Cfg = rssc->Cfg;
814 rss_item *ri = rssc->Item;
819 /* Axe the namespace, we don't care about it */
820 /// CtdlLogPrintf(0, "RSS: supplied el %d: %s...\n", rssc->Cfg->ItemType, supplied_el);
822 while (sep = strchr(pel, ':'), sep) {
826 if (pel != supplied_el)
830 if (!GetHash(KnownNameSpaces,
832 pel - supplied_el - 1,
836 CtdlLogPrintf(0, "RSS: START ignoring because of wrong namespace [%s] = [%s]\n",
843 StrBufPlain(rssc->Key, pel, -1);
844 StrBufLowerCase(rssc->Key);
845 if (GetHash(StartHandlers, SKEY(rssc->Key), &pv))
847 rssc->Current = h = (rss_xml_handler*) pv;
849 if (((h->Flags & RSS_UNSET) != 0) &&
850 (Cfg->ItemType == RSS_UNSET))
852 h->Handler(rssc->CData, ri, Cfg, attr);
854 else if (((h->Flags & RSS_RSS) != 0) &&
855 (Cfg->ItemType == RSS_RSS))
857 h->Handler(rssc->CData, ri, Cfg, attr);
859 else if (((h->Flags & RSS_ATOM) != 0) &&
860 (Cfg->ItemType == RSS_ATOM))
862 h->Handler(rssc->CData, ri, Cfg, attr);
866 CtdlLogPrintf(0, "RSS: START unhandled: [%s] [%s]...\n", pel, supplied_el);
871 CtdlLogPrintf(0, "RSS: START unhandled: [%s] [%s]...\n", pel, supplied_el);
875 void rss_xml_end(void *data, const char *supplied_el)
878 rsscollection *rssc = (rsscollection*) data;
879 rssnetcfg *Cfg = rssc->Cfg;
880 rss_item *ri = rssc->Item;
885 /* Axe the namespace, we don't care about it */
887 while (sep = strchr(pel, ':'), sep) {
890 // CtdlLogPrintf(0, "RSS: END %s...\n", el);
891 if (pel != supplied_el)
895 if (!GetHash(KnownNameSpaces,
897 pel - supplied_el - 1,
901 CtdlLogPrintf(0, "RSS: END ignoring because of wrong namespace [%s] = [%s]\n",
902 supplied_el, ChrPtr(rssc->CData));
904 FlushStrBuf(rssc->CData);
909 StrBufPlain(rssc->Key, pel, -1);
910 StrBufLowerCase(rssc->Key);
911 if (GetHash(EndHandlers, SKEY(rssc->Key), &pv))
913 h = (rss_xml_handler*) pv;
915 if (((h->Flags & RSS_UNSET) != 0) &&
916 (Cfg->ItemType == RSS_UNSET))
918 h->Handler(rssc->CData, ri, Cfg, NULL);
920 else if (((h->Flags & RSS_RSS) != 0) &&
921 (Cfg->ItemType == RSS_RSS))
923 h->Handler(rssc->CData, ri, Cfg, NULL);
925 else if (((h->Flags & RSS_ATOM) != 0) &&
926 (Cfg->ItemType == RSS_ATOM))
928 h->Handler(rssc->CData, ri, Cfg, NULL);
932 CtdlLogPrintf(0, "RSS: END unhandled: [%s] [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
937 CtdlLogPrintf(0, "RSS: END unhandled: [%s] [%s] = [%s]...\n", pel, supplied_el, ChrPtr(rssc->CData));
939 FlushStrBuf(rssc->CData);
940 rssc->Current = NULL;
947 void RSS_item_rss_start (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
949 CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RSS feed.\n");
950 Cfg->ItemType = RSS_RSS;
953 void RSS_item_rdf_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
955 CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RDF feed.\n");
956 Cfg->ItemType = RSS_RSS;
959 void ATOM_item_feed_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
961 CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an ATOM feed.\n");
962 Cfg->ItemType = RSS_ATOM;
966 void RSS_item_item_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
968 ri->item_tag_nesting ++;
972 void ATOM_item_entry_start(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
975 ri->item_tag_nesting ++;
979 void ATOM_item_link_start (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
982 const char *pHref = NULL;
983 const char *pType = NULL;
984 const char *pRel = NULL;
985 const char *pTitle = NULL;
987 for (i = 0; Attr[i] != NULL; i+=2)
989 if (!strcmp(Attr[i], "href"))
993 else if (!strcmp(Attr[i], "rel"))
997 else if (!strcmp(Attr[i], "type"))
1001 else if (!strcmp(Attr[i], "title"))
1007 return; /* WHUT? Pointing... where? */
1008 if ((pType != NULL) && !strcasecmp(pType, "application/atom+xml"))
1009 return; /* these just point to other rss resources, we're not interested in them. */
1012 if (!strcasecmp (pRel, "replies"))
1014 NewStrBufDupAppendFlush(&ri->reLink, NULL, pHref, -1);
1015 StrBufTrim(ri->link);
1016 NewStrBufDupAppendFlush(&ri->reLinkTitle, NULL, pTitle, -1);
1018 else if (!strcasecmp(pRel, "alternate")) /* Alternative representation of this Item... */
1020 NewStrBufDupAppendFlush(&ri->link, NULL, pHref, -1);
1021 StrBufTrim(ri->link);
1022 NewStrBufDupAppendFlush(&ri->linkTitle, NULL, pTitle, -1);
1025 #if 0 /* these are also defined, but dunno what to do with them.. */
1026 else if (!strcasecmp(pRel, "related"))
1029 else if (!strcasecmp(pRel, "self"))
1032 else if (!strcasecmp(pRel, "enclosure"))
1033 {/* this reference can get big, and is probably the full article... */
1035 else if (!strcasecmp(pRel, "via"))
1036 {/* this article was provided via... */
1040 else if (StrLength(ri->link) == 0)
1042 NewStrBufDupAppendFlush(&ri->link, NULL, pHref, -1);
1043 StrBufTrim(ri->link);
1044 NewStrBufDupAppendFlush(&ri->linkTitle, NULL, pTitle, -1);
1051 void ATOMRSS_item_title_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1053 if ((ri->item_tag_nesting == 0) && (StrLength(CData) > 0)) {
1054 NewStrBufDupAppendFlush(&ri->channel_title, CData, NULL, 0);
1055 StrBufTrim(ri->channel_title);
1059 void RSS_item_guid_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1061 if (StrLength(CData) > 0) {
1062 NewStrBufDupAppendFlush(&ri->guid, CData, NULL, 0);
1066 void ATOM_item_id_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1068 if (StrLength(CData) > 0) {
1069 NewStrBufDupAppendFlush(&ri->guid, CData, NULL, 0);
1074 void RSS_item_link_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1076 if (StrLength(CData) > 0) {
1077 NewStrBufDupAppendFlush(&ri->link, CData, NULL, 0);
1078 StrBufTrim(ri->link);
1081 void RSS_item_relink_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1083 if (StrLength(CData) > 0) {
1084 NewStrBufDupAppendFlush(&ri->reLink, CData, NULL, 0);
1085 StrBufTrim(ri->reLink);
1089 void RSSATOM_item_title_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1091 if (StrLength(CData) > 0) {
1092 NewStrBufDupAppendFlush(&ri->title, CData, NULL, 0);
1093 StrBufTrim(ri->title);
1097 void ATOM_item_content_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1099 long olen = StrLength (ri->description);
1100 long clen = StrLength (CData);
1104 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
1105 StrBufTrim(ri->description);
1107 else if (olen < clen) {
1108 FlushStrBuf(ri->description);
1109 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
1110 StrBufTrim(ri->description);
1114 void ATOM_item_summary_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1116 /* this can contain an abstract of the article. but we don't want to verwrite a full document if we already have it. */
1117 if ((StrLength(CData) > 0) && (StrLength(ri->description) == 0))
1119 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
1120 StrBufTrim(ri->description);
1124 void RSS_item_description_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1126 long olen = StrLength (ri->description);
1127 long clen = StrLength (CData);
1131 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
1132 StrBufTrim(ri->description);
1134 else if (olen < clen) {
1135 FlushStrBuf(ri->description);
1136 NewStrBufDupAppendFlush(&ri->description, CData, NULL, 0);
1137 StrBufTrim(ri->description);
1142 void ATOM_item_published_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1144 if (StrLength(CData) > 0) {
1146 ri->pubdate = rdf_parsedate(ChrPtr(CData));
1150 void ATOM_item_updated_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1152 if (StrLength(CData) > 0) {
1154 ri->pubdate = rdf_parsedate(ChrPtr(CData));
1158 void RSS_item_pubdate_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1160 if (StrLength(CData) > 0) {
1162 ri->pubdate = rdf_parsedate(ChrPtr(CData));
1167 void RSS_item_date_end (StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1169 if (StrLength(CData) > 0) {
1171 ri->pubdate = rdf_parsedate(ChrPtr(CData));
1177 void RSS_item_author_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1179 if (StrLength(CData) > 0) {
1180 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
1181 StrBufTrim(ri->author_or_creator);
1186 void ATOM_item_name_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1188 if (StrLength(CData) > 0) {
1189 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
1190 StrBufTrim(ri->author_or_creator);
1194 void ATOM_item_email_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1196 if (StrLength(CData) > 0) {
1197 NewStrBufDupAppendFlush(&ri->author_email, CData, NULL, 0);
1198 StrBufTrim(ri->author_email);
1202 void RSS_item_creator_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1204 if ((StrLength(CData) > 0) &&
1205 (StrLength(ri->author_or_creator) == 0))
1207 NewStrBufDupAppendFlush(&ri->author_or_creator, CData, NULL, 0);
1208 StrBufTrim(ri->author_or_creator);
1213 void ATOM_item_uri_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1215 if (StrLength(CData) > 0) {
1216 NewStrBufDupAppendFlush(&ri->author_url, CData, NULL, 0);
1217 StrBufTrim(ri->author_url);
1221 void RSS_item_item_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1223 --ri->item_tag_nesting;
1228 void ATOM_item_entry_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1230 --ri->item_tag_nesting;
1234 void RSS_item_rss_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1236 // CtdlLogPrintf(CTDL_DEBUG, "End of feed detected. Closing parser.\n");
1237 ri->done_parsing = 1;
1240 void RSS_item_rdf_end(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1242 // CtdlLogPrintf(CTDL_DEBUG, "End of feed detected. Closing parser.\n");
1243 ri->done_parsing = 1;
1247 void RSSATOM_item_ignore(StrBuf *CData, rss_item *ri, rssnetcfg *Cfg, const char** Attr)
1254 * This callback stores up the data which appears in between tags.
1256 void rss_xml_cdata_start(void *data)
1258 rsscollection *rssc = (rsscollection*) data;
1260 FlushStrBuf(rssc->CData);
1263 void rss_xml_cdata_end(void *data)
1266 void rss_xml_chardata(void *data, const XML_Char *s, int len)
1268 rsscollection *rssc = (rsscollection*) data;
1270 StrBufAppendBufPlain (rssc->CData, s, len, 0);
1274 * Callback function for passing libcurl's output to expat for parsing
1276 size_t rss_libcurl_callback(void *ptr, size_t size, size_t nmemb, void *stream)
1278 XML_Parse((XML_Parser)stream, ptr, (size * nmemb), 0);
1279 return (size*nmemb);
1285 * Begin a feed parse
1287 void rss_do_fetching(rssnetcfg *Cfg) {
1290 XML_Parser xp = NULL;
1295 char errmsg[1024] = "";
1300 memset(&ri, 0, sizeof(rss_item));
1304 CtdlLogPrintf(CTDL_DEBUG, "Fetching RSS feed <%s>\n", Cfg->url);
1306 curl = curl_easy_init();
1308 CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
1311 Answer = NewStrBufPlain(NULL, SIZ);
1313 curl_easy_setopt(curl, CURLOPT_URL, Cfg->url);
1314 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
1315 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
1316 curl_easy_setopt(curl, CURLOPT_WRITEDATA, Answer);
1317 // curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, rss_libcurl_callback);
1318 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlFillStrBuf_callback);
1319 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
1320 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
1321 #ifdef CURLOPT_HTTP_CONTENT_DECODING
1322 curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
1323 curl_easy_setopt(curl, CURLOPT_ENCODING, "");
1325 curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
1326 curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180); /* die after 180 seconds */
1328 (!IsEmptyStr(config.c_ip_addr))
1329 && (strcmp(config.c_ip_addr, "*"))
1330 && (strcmp(config.c_ip_addr, "::"))
1331 && (strcmp(config.c_ip_addr, "0.0.0.0"))
1333 curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
1336 if (CtdlThreadCheckStop())
1338 curl_easy_cleanup(curl);
1342 if (CtdlThreadCheckStop())
1345 res = curl_easy_perform(curl);
1347 CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", res, errmsg);
1350 if (CtdlThreadCheckStop())
1356 memset(&ri, 0, sizeof(rss_item));
1357 ri.roomlist = Cfg->rooms;
1358 rssc.CData = NewStrBufPlain(NULL, SIZ);
1359 rssc.Key = NewStrBuf();
1361 StrBufSipLine(rssc.Key, Answer, &at);
1364 #define encoding "encoding=\""
1365 ptr = strstr(ChrPtr(rssc.Key), encoding);
1370 ptr += sizeof (encoding) - 1;
1371 pche = strchr(ptr, '"');
1373 StrBufCutAt(rssc.Key, -1, pche);
1381 xp = XML_ParserCreateNS(ptr, ':');
1383 CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
1386 FlushStrBuf(rssc.Key);
1389 XML_SetUnknownEncodingHandler(xp,
1390 handle_unknown_xml_encoding,
1394 XML_SetElementHandler(xp, rss_xml_start, rss_xml_end);
1395 XML_SetCharacterDataHandler(xp, rss_xml_chardata);
1396 XML_SetUserData(xp, &rssc);
1397 XML_SetCdataSectionHandler(xp,
1398 rss_xml_cdata_start,
1402 len = StrLength(Answer);
1403 ptr = SmashStrBuf(&Answer);
1404 XML_Parse(xp, ptr, len, 0);
1406 if (ri.done_parsing == 0)
1407 XML_Parse(xp, "", 0, 1);
1410 CtdlLogPrintf(CTDL_ALERT, "RSS: XML Status [%s] \n",
1412 XML_GetErrorCode(xp)));
1415 curl_easy_cleanup(curl);
1418 flush_rss_item(&ri);
1419 FreeStrBuf(&rssc.CData);
1420 FreeStrBuf(&rssc.Key);
1425 * Scan a room's netconfig to determine whether it is requesting any RSS feeds
1427 void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
1429 char filename[PATH_MAX];
1434 rssnetcfg *rncptr = NULL;
1435 rssnetcfg *use_this_rncptr = NULL;
1439 assoc_file_name(filename, sizeof filename, qrbuf, ctdl_netcfg_dir);
1441 if (CtdlThreadCheckStop())
1444 /* Only do net processing for rooms that have netconfigs */
1445 fp = fopen(filename, "r");
1450 while (fgets(buf, sizeof buf, fp) != NULL && !CtdlThreadCheckStop()) {
1451 buf[strlen(buf)-1] = 0;
1453 extract_token(instr, buf, 0, '|', sizeof instr);
1454 if (!strcasecmp(instr, "rssclient")) {
1456 use_this_rncptr = NULL;
1458 extract_token(feedurl, buf, 1, '|', sizeof feedurl);
1460 /* If any other rooms have requested the same feed, then we will just add this
1461 * room to the target list for that client request.
1463 for (rncptr=rnclist; rncptr!=NULL; rncptr=rncptr->next) {
1464 if (!strcmp(rncptr->url, feedurl)) {
1465 use_this_rncptr = rncptr;
1469 /* Otherwise create a new client request */
1470 if (use_this_rncptr == NULL) {
1471 rncptr = (rssnetcfg *) malloc(sizeof(rssnetcfg));
1472 rncptr->ItemType = RSS_UNSET;
1473 if (rncptr != NULL) {
1474 rncptr->next = rnclist;
1475 safestrncpy(rncptr->url, feedurl, sizeof rncptr->url);
1476 rncptr->rooms = NULL;
1478 use_this_rncptr = rncptr;
1482 /* Add the room name to the request */
1483 if (use_this_rncptr != NULL) {
1484 if (use_this_rncptr->rooms == NULL) {
1485 rncptr->rooms = strdup(qrbuf->QRname);
1488 len = strlen(use_this_rncptr->rooms) + strlen(qrbuf->QRname) + 5;
1489 ptr = realloc(use_this_rncptr->rooms, len);
1492 strcat(ptr, qrbuf->QRname);
1493 use_this_rncptr->rooms = ptr;
1506 * Scan for rooms that have RSS client requests configured
1508 void rssclient_scan(void) {
1509 static time_t last_run = 0L;
1510 static int doing_rssclient = 0;
1511 rssnetcfg *rptr = NULL;
1514 * This is a simple concurrency check to make sure only one rssclient run
1515 * is done at a time. We could do this with a mutex, but since we
1516 * don't really require extremely fine granularity here, we'll do it
1517 * with a static variable instead.
1519 if (doing_rssclient) return;
1520 doing_rssclient = 1;
1522 CtdlLogPrintf(CTDL_DEBUG, "rssclient started\n");
1523 CtdlForEachRoom(rssclient_scan_room, NULL);
1525 while (rnclist != NULL && !CtdlThreadCheckStop()) {
1526 rss_do_fetching(rnclist);
1528 rnclist = rnclist->next;
1529 if (rptr->rooms != NULL) free(rptr->rooms);
1533 CtdlLogPrintf(CTDL_DEBUG, "rssclient ended\n");
1534 last_run = time(NULL);
1535 doing_rssclient = 0;
1540 CTDL_MODULE_INIT(rssclient)
1544 CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
1545 CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
1548 StartHandlers = NewHash(1, NULL);
1549 EndHandlers = NewHash(1, NULL);
1551 AddRSSStartHandler(RSS_item_rss_start, RSS_UNSET, HKEY("rss"));
1552 AddRSSStartHandler(RSS_item_rdf_start, RSS_UNSET, HKEY("rdf"));
1553 AddRSSStartHandler(ATOM_item_feed_start, RSS_UNSET, HKEY("feed"));
1554 AddRSSStartHandler(RSS_item_item_start, RSS_RSS, HKEY("item"));
1555 AddRSSStartHandler(ATOM_item_entry_start, RSS_ATOM, HKEY("entry"));
1556 AddRSSStartHandler(ATOM_item_link_start, RSS_ATOM, HKEY("link"));
1558 AddRSSEndHandler(ATOMRSS_item_title_end, RSS_ATOM|RSS_RSS|RSS_REQUIRE_BUF, HKEY("title"));
1559 AddRSSEndHandler(RSS_item_guid_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("guid"));
1560 AddRSSEndHandler(ATOM_item_id_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("id"));
1561 AddRSSEndHandler(RSS_item_link_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("link"));
1563 // hm, rss to the comments of that blog, might be interesting in future, but...
1564 AddRSSEndHandler(RSS_item_relink_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("commentrss"));
1566 AddRSSEndHandler(RSS_item_relink_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("comments"));
1568 AddRSSEndHandler(RSSATOM_item_title_end, RSS_ATOM|RSS_RSS|RSS_REQUIRE_BUF, HKEY("title"));
1569 AddRSSEndHandler(ATOM_item_content_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("content"));
1570 AddRSSEndHandler(RSS_item_description_end, RSS_RSS|RSS_ATOM|RSS_REQUIRE_BUF, HKEY("encoded"));
1571 AddRSSEndHandler(ATOM_item_summary_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("summary"));
1572 AddRSSEndHandler(RSS_item_description_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("description"));
1573 AddRSSEndHandler(ATOM_item_published_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("published"));
1574 AddRSSEndHandler(ATOM_item_updated_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("updated"));
1575 AddRSSEndHandler(RSS_item_pubdate_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("pubdate"));
1576 AddRSSEndHandler(RSS_item_date_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("date"));
1577 AddRSSEndHandler(RSS_item_author_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("author"));
1578 AddRSSEndHandler(RSS_item_creator_end, RSS_RSS|RSS_REQUIRE_BUF, HKEY("creator"));
1580 AddRSSEndHandler(ATOM_item_email_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("email"));
1581 AddRSSEndHandler(ATOM_item_name_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("name"));
1582 AddRSSEndHandler(ATOM_item_uri_end, RSS_ATOM|RSS_REQUIRE_BUF, HKEY("uri"));
1584 AddRSSEndHandler(RSS_item_item_end, RSS_RSS, HKEY("item"));
1585 AddRSSEndHandler(RSS_item_rss_end, RSS_RSS, HKEY("rss"));
1586 AddRSSEndHandler(RSS_item_rdf_end, RSS_RSS, HKEY("rdf"));
1587 AddRSSEndHandler(ATOM_item_entry_end, RSS_ATOM, HKEY("entry"));
1590 /* at the start of atoms: <seq> <li>link to resource</li></seq> ignore them. */
1591 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("seq"));
1592 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("seq"));
1593 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("li"));
1594 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("li"));
1596 /* links to other feed generators... */
1597 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("feedflare"));
1598 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("feedflare"));
1599 AddRSSStartHandler(RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("browserfriendly"));
1600 AddRSSEndHandler (RSSATOM_item_ignore, RSS_RSS|RSS_ATOM, HKEY("browserfriendly"));
1602 KnownNameSpaces = NewHash(1, NULL);
1603 Put(KnownNameSpaces, HKEY("http://a9.com/-/spec/opensearch/1.1/"), NULL, reference_free_handler);
1604 Put(KnownNameSpaces, HKEY("http://a9.com/-/spec/opensearchrss/1.0/"), NULL, reference_free_handler);
1605 Put(KnownNameSpaces, HKEY("http://backend.userland.com/creativeCommonsRssModule"), NULL, reference_free_handler);
1606 Put(KnownNameSpaces, HKEY("http://purl.org/atom/ns#"), NULL, reference_free_handler);
1607 Put(KnownNameSpaces, HKEY("http://purl.org/dc/elements/1.1/"), NULL, reference_free_handler);
1608 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/"), NULL, reference_free_handler);
1609 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/content/"), NULL, reference_free_handler);
1610 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/slash/"), NULL, reference_free_handler);
1611 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/modules/syndication/"), NULL, reference_free_handler);
1612 Put(KnownNameSpaces, HKEY("http://purl.org/rss/1.0/"), NULL, reference_free_handler);
1613 Put(KnownNameSpaces, HKEY("http://purl.org/syndication/thread/1.0"), NULL, reference_free_handler);
1614 Put(KnownNameSpaces, HKEY("http://rssnamespace.org/feedburner/ext/1.0"), NULL, reference_free_handler);
1615 Put(KnownNameSpaces, HKEY("http://schemas.google.com/g/2005"), NULL, reference_free_handler);
1616 Put(KnownNameSpaces, HKEY("http://webns.net/mvcb/"), NULL, reference_free_handler);
1617 Put(KnownNameSpaces, HKEY("http://web.resource.org/cc/"), NULL, reference_free_handler);
1618 Put(KnownNameSpaces, HKEY("http://wellformedweb.org/CommentAPI/"), NULL, reference_free_handler);
1619 Put(KnownNameSpaces, HKEY("http://www.georss.org/georss"), NULL, reference_free_handler);
1620 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/xhtml"), NULL, reference_free_handler);
1621 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), NULL, reference_free_handler);
1622 Put(KnownNameSpaces, HKEY("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), NULL, reference_free_handler);
1623 Put(KnownNameSpaces, HKEY("http://www.w3.org/2003/01/geo/wgs84_pos#"), NULL, reference_free_handler);
1624 Put(KnownNameSpaces, HKEY("http://www.w3.org/2005/Atom"), NULL, reference_free_handler);
1625 Put(KnownNameSpaces, HKEY("urn:flickr:"), NULL, reference_free_handler);
1627 /* we don't like these namespaces because of they shadow our usefull parameters. */
1628 Put(KnownNameSpaces, HKEY("http://search.yahoo.com/mrss/"), NULL, reference_free_handler);