2 * RSS/Atom feed generator
4 * Copyright (c) 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
22 #include "webserver.h"
26 * RSS feed generator -- do one message
28 void feed_rss_one_message(long msgnum) {
30 wc_printf("<title>title %ld title</title>", msgnum);
31 wc_printf("<pubDate>Wed, 08 Sep 2010 20:03:21 GMT</pubDate>");
32 wc_printf("<link>http://xxxxx.xxxx.xxxxxx.xxxx.xxx</link>");
33 wc_printf("<description><b>foo bar baz:</b> message %ld</description>", msgnum);
34 wc_printf("<guid>xxxx-xxxx-xxxx-xxxx-xxxx-xxxx</guid>");
39 * RSS feed generator -- go through the message list
41 void feed_rss_do_messages(void) {
45 int num_msgs_alloc = 0;
48 serv_puts("MSGS ALL");
49 serv_getln(buf, sizeof buf);
50 if (buf[0] != '1') return;
52 while (serv_getln(buf, sizeof buf), strcmp(buf, "000"))
54 if (num_msgs >= num_msgs_alloc) {
55 num_msgs_alloc += 1024;
56 msgs = realloc(msgs, num_msgs_alloc*sizeof(long) );
58 msgs[num_msgs++] = atol(buf);
63 feed_rss_one_message(msgs[i-1]);
72 * Entry point for RSS feed generator
76 output_headers(0, 0, 0, 1, 1, 0);
77 hprintf("Content-type: text/xml\r\n");
80 "Connection: close\r\n"
82 PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
86 wc_printf("<?xml version=\"1.0\"?>"
87 "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
92 escputs(ChrPtr(WC->CurRoom.name));
93 wc_printf("</title>");
96 urlescputs(ChrPtr(site_prefix));
99 // <language>en-us</language>
100 // <description>Linux Today News Service</description>
101 // <atom:link href="http://linuxtoday.com/biglt.rss" rel="self" type="application/rss+xml" />
104 // <title>Linux Today</title>
105 // <url>http://linuxtoday.com/pics/ltnet.png</url>
106 // <link>http://linuxtoday.com</link>
109 feed_rss_do_messages();
111 wc_printf("</channel>"
117 end_webcit_session();
125 WebcitAddUrlHandler(HKEY("feed_rss"), "", 0, feed_rss, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);