]> code.citadel.org Git - citadel.git/blobdiff - webcit/rss.c
* move serv_info into the session, here we can control its de/allocation the right...
[citadel.git] / webcit / rss.c
index 1369098903d67b07af80962942edee80593dc2f7..ab01a2aef1d598d1062a8966a3047c0bf2848969 100644 (file)
@@ -43,7 +43,7 @@ void display_rss_control(char *reply_to, char *subject)
  * roomname the room we sould print out as rss 
  * request_method the way the rss is requested????
  */
-void display_rss(char *roomname, StrBuf *request_method)
+void display_rss(const StrBuf *roomname, StrBuf *request_method)
 {
        message_summary *Msg;
        wcsession *WCC = WC;
@@ -60,6 +60,7 @@ void display_rss(char *roomname, StrBuf *request_method)
        size_t obuflen;               /**< Length of output buffer              */
        char *osav;                   /**< Saved pointer to output buffer       */
 #endif
+       char description[SIZ] = "";
        char buf[SIZ];
        char date[30];
        char from[256];
@@ -75,19 +76,28 @@ void display_rss(char *roomname, StrBuf *request_method)
        
        if (!WCC->logged_in) {
                #ifdef ALLOW_ANON_RSS
+               StrBuf *User;
+               StrBuf *Pass;
+               StrBuf *Buf;
                serv_printf("USER %s", ANON_RSS_USER);
                serv_getln(buf, sizeof buf);
                serv_printf("PASS %s", ANON_RSS_PASS);
-               serv_getln(buf, sizeof buf);
-               become_logged_in(ANON_RSS_USER, ANON_RSS_PASS, buf);
+
+               StrBuf_ServGetln(Buf);
+               User = NewStrBufPlain(HKEY(ANON_RSS_USER));
+               Pass = NewStrBufPlain(HKEY(ANON_RSS_PASS));
+               become_logged_in(User, Pass, Buf);
                WCC->killthis = 1;
+               FreeStrBuf(&User);
+               FreeStrBuf(&Pass);
+               FreeStrBuf(&Buf);
                #else
                authorization_required(_("Not logged in"));
                return;
                #endif
        }
 
-       if (gotoroom((char *)roomname)) {
+       if (gotoroom(roomname)) {
                lprintf(3, "RSS: Can't goto requested room\n");
                hprintf("HTTP/1.1 404 Not Found\r\n");
                hprintf("Content-Type: text/html\r\n");
@@ -124,7 +134,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                        }
                }
        }
-       // Commented out. Play dumb for now, also doesn't work with anonrss hack
+       /*/ Commented out. Play dumb for now, also doesn't work with anonrss hack */
        /* if (if_modified_since > 0 && if_modified_since > now) {
                lprintf(3, "RSS: Feed not updated since the last time you looked\n");
                hprintf("HTTP/1.1 304 Not Modified\r\n");
@@ -133,10 +143,10 @@ void display_rss(char *roomname, StrBuf *request_method)
                gmtime_r(&now, &now_tm);
                strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S GMT", &now_tm);
                hprintf("Date: %s\r\n", date);
-               if (*msgn) hprintf("ETag: %s\r\n", msgn); */
+               if (*msgn) hprintf("ETag: %s\r\n", msgn); * /
                // wDumpContent(0);
                // return;
-       //} 
+               //} */
 
        /* Do RSS header */
        lprintf(3, "RSS: Yum yum! This feed is tasty!\n");
@@ -152,15 +162,14 @@ void display_rss(char *roomname, StrBuf *request_method)
        /* <?xml.. etc confuses our subst parser, so do it here */
        svput("XML_HEAD", WCS_STRING, "<?xml version=\"1.0\" ?>");
        svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
-       svput("ROOM", WCS_STRING, WCC->wc_roomname);
-       svput("NODE", WCS_STRING, serv_info.serv_humannode);
-       // Fix me
-       svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WCC->http_host);
+       SVPutBuf("ROOM", WCC->wc_roomname, 1);
+       SVPutBuf("NODE", WCC->serv_info->serv_humannode, 1);
+       /* TODO:  Fix me */
+       svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), ChrPtr(WCC->http_host));
        
        /** Get room info for description */
        serv_puts("RINF");
        serv_getln(buf, sizeof buf);
-       char description[SIZ] = "";
        if (buf[0] == '1') {
                while (1) {
                        serv_getln(buf, sizeof buf);
@@ -224,7 +233,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                        svput("SUBJ", WCS_STRING, _("From"));
                }
                svprintf(HKEY("IN_ROOM"), WCS_STRING, _("%s in %s"), from, room);
-               if (strcmp(hnod, serv_info.serv_humannode) && !IsEmptyStr(hnod)) {
+               if (strcmp(hnod, ChrPtr(WCC->serv_info->serv_humannode)) && !IsEmptyStr(hnod)) {
                        svprintf(HKEY("NODE"), WCS_STRING, _(" on %s"), hnod);
                }
                if (now) {
@@ -345,7 +354,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                } 
 
 ENDBODY:
-               //wprintf("   </item>\n");
+               /* wprintf("   </item>\n"); */
                do_template("rss_item_end", NULL);
 ENDITEM:
                now = 0L;