7 #include "canned_responses.h"
10 int fprint_rss(FILE *f, const char *username) {
11 struct blerg *b = blerg_open(username);
12 uint64_t record_count = blerg_get_record_count(b);
13 uint64_t i = (record_count > 50 ? record_count - 50 : 0);
21 "<?xml version=\"1.0\" encoding=\"utf8\" ?>\n"
22 "<rss version=\"2.0\">\n"
24 "<title>%s's blërg</title>\n"
25 "<link>%s#%s</link>\n"
26 "<description>%s</description>\n",
28 "http://blerg.dominionfawesome.com/",
33 while (i < record_count) {
34 blerg_fetch(b, i, &data, &len);
35 tmp = xml_escape_data(data, len);
36 post_time = blerg_get_timestamp(b, i);
37 strftime(date, 39, "%a, %d %b %Y %H:%M:%S %Z", gmtime(&post_time));
40 "<pubDate>%s</pubDate>\n"
41 "<description>%s</description>\n"
58 int main (int argc, char *argv) {
64 request_method = getenv("REQUEST_METHOD");
65 if (request_method == NULL) {
66 fprintf(stderr, "Request method is null!?\n");
70 if (strncmp(request_method, "GET", 4) != 0) {
75 path = getenv("PATH_INFO");
86 ret = parse_url_info(path + 1, &info);
87 if ((ret & URL_INFO_AUTHOR) == 0) {
92 if (!blerg_exists(info.author)) {
97 printf("Content-type: application/rss+xml\r\n\r\n");
99 fprint_rss(stdout, "chip");