7 #include "canned_responses.h"
11 int fprint_rss(FILE *f, const char *username) {
12 struct blerg *b = blerg_open(username);
13 uint64_t record_count = blerg_get_record_count(b);
14 uint64_t i = (record_count > 50 ? record_count - 50 : 0);
22 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
23 "<rss version=\"2.0\">\n"
25 "<title>%s's blërg</title>\n"
26 "<link>%s#%s</link>\n"
27 "<description>%s</description>\n",
34 while (i < record_count) {
35 blerg_fetch(b, i, &data, &len);
36 tmp = xml_escape_data(data, len);
37 post_time = blerg_get_timestamp(b, i);
38 strftime(date, 39, "%a, %d %b %Y %H:%M:%S %Z", gmtime(&post_time));
41 "<pubDate>%s</pubDate>\n"
42 "<guid>%sget/%s/%llu</guid>\n"
43 "<description>%s</description>\n"
61 int main (int argc, char *argv) {
67 request_method = getenv("REQUEST_METHOD");
68 if (request_method == NULL) {
69 fprintf(stderr, "Request method is null!?\n");
73 if (strncmp(request_method, "GET", 4) != 0) {
78 path = getenv("PATH_INFO");
89 ret = parse_url_info(path + 1, &info);
90 if ((ret & URL_INFO_AUTHOR) == 0) {
95 if (!blerg_exists(info.author)) {
100 printf("Content-type: application/rss+xml\r\n\r\n");
102 fprint_rss(stdout, "chip");