1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2 * BSD-style license. Please see the COPYING file for details.
10 #include "canned_responses.h"
14 int fprint_rss(FILE *f, const char *username) {
15 struct blerg *b = blerg_open(username);
16 uint64_t record_count = blerg_get_record_count(b);
17 uint64_t i = (record_count > 50 ? record_count - 50 : 0);
25 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
26 "<rss version=\"2.0\">\n"
28 "<title>%s's blërg</title>\n"
29 "<link>%s#%s</link>\n"
30 "<description>%s</description>\n",
37 while (i < record_count) {
38 blerg_fetch(b, i, &data, &len);
39 tmp = xml_escape_data(data, len);
40 post_time = blerg_get_timestamp(b, i);
41 strftime(date, 39, "%a, %d %b %Y %H:%M:%S %Z", gmtime(&post_time));
44 "<pubDate>%s</pubDate>\n"
45 "<guid>%sget/%s/%llu</guid>\n"
46 "<description>%s</description>\n"
64 int main (int argc, char *argv) {
70 request_method = getenv("REQUEST_METHOD");
71 if (request_method == NULL) {
72 fprintf(stderr, "Request method is null!?\n");
76 if (strncmp(request_method, "GET", 4) != 0) {
81 path = getenv("PATH_INFO");
92 ret = parse_url_info(path + 1, &info);
93 if ((ret & URL_INFO_NAME) == 0) {
98 if (!blerg_exists(info.name)) {
103 printf("Content-type: application/rss+xml\r\n\r\n");
105 fprint_rss(stdout, info.name);