if StrBuf_ServGetln() is called in a loop, its return value has to be checked for...
[citadel.git] / webcit / messages.c
index a6cfc33d779090ba261b7e7c573c21eb5f4a9cb0..231d98eef54d9c3a4d8479fab8f310618d2994a1 100644 (file)
@@ -100,9 +100,6 @@ int load_message(message_summary *Msg,
                        StrBufExtract_token(HdrToken, Buf, 0, '=');
                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
                        
-#ifdef TECH_PREVIEW
-                       if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
-#endif
                        /* look up one of the examine_* functions to parse the content */
                        if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
                            (vHdr != NULL)) {
@@ -131,9 +128,6 @@ int load_message(message_summary *Msg,
                                StrBufExtract_token(HdrToken, Buf, 0, ':');
                                if (StrLength(HdrToken) > 0) {
                                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
-#ifdef TECH_PREVIEW
-                                       if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
-#endif
                                        /* the examine*'s know how to do with mime headers too... */
                                        if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
                                            (vHdr != NULL)) {
@@ -491,22 +485,6 @@ void print_message(void) {
        wDumpContent(0);
 }
 
-/* 
- * Mobile browser view of message
- */
-void mobile_message_view(void) 
-{
-       long msgnum = 0L;
-       const StrBuf *Mime;
-  
-       msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
-       output_headers(1, 0, 0, 0, 0, 1);
-       begin_burst();
-       do_template("msgcontrols", NULL);
-       read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
-       wDumpContent(0);
-}
-
 /*
  * Display a message's headers
  */
@@ -559,8 +537,10 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
        Msg = (message_summary*)malloc(sizeof(message_summary));
        memset(Msg, 0, sizeof(message_summary));
        while (len = StrBuf_ServGetln(Buf),
+              (len >= 0) && 
               ((len != 3)  ||
-               strcmp(ChrPtr(Buf), "000")== 0)){
+               strcmp(ChrPtr(Buf), "000")))
+       {
                buf = ChrPtr(Buf);
                ebuf = strchr(ChrPtr(Buf), '=');
                nBuf = ebuf - buf;
@@ -569,7 +549,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
                        StrBufCutLeft(Buf, nBuf + 1);
                        Eval->f(Msg, Buf);
                }
-               else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
+               else syslog(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
        }
        return Msg;
 }
@@ -611,7 +591,10 @@ int load_msg_ptrs(const char *servcmd,
                return (Stat->nummsgs);
        }
        Buf2 = NewStrBuf();
-       while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
+       while (len = StrBuf_ServGetln(Buf), 
+              ((len >= 0) &&
+               ((len != 3) || 
+                strcmp(ChrPtr(Buf), "000")!= 0)))
        {
                if (Stat->nummsgs < Stat->maxload) {
                        skipit = 0;
@@ -1072,7 +1055,7 @@ void post_message(void)
                        if (GetServerStatus(Buf, NULL) != 2) {
                                /* You probably don't even have a dumb Drafts folder */
                                StrBufCutLeft(Buf, 4);
-                               lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
+                               syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
                                StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
                                StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
                                display_enter();
@@ -1145,7 +1128,7 @@ void post_message(void)
                }
                else 
                {
-                       lprintf(9, "%s\n", ChrPtr(CmdBuf));
+                       syslog(9, "%s\n", ChrPtr(CmdBuf));
                        serv_puts(ChrPtr(CmdBuf));
                        FreeStrBuf(&CmdBuf);
 
@@ -1183,7 +1166,7 @@ void post_message(void)
                        } else {
                                StrBufCutLeft(Buf, 4);
 
-                               lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
+                               syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
                                StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
                                if (save_to_drafts) gotoroom(WCC->CurRoom.name);
                                display_enter();
@@ -1236,16 +1219,16 @@ void upload_attachment(void) {
        void *v;
        wc_mime_attachment *att;
 
-       lprintf(9, "upload_attachment()\n");
+       syslog(9, "upload_attachment()\n");
        wc_printf("upload_attachment()<br>\n");
 
        if (WCC->upload_length <= 0) {
-               lprintf(9, "ERROR no attachment was uploaded\n");
+               syslog(9, "ERROR no attachment was uploaded\n");
                wc_printf("ERROR no attachment was uploaded<br>\n");
                return;
        }
 
-       lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
+       syslog(9, "Client is uploading %d bytes\n", WCC->upload_length);
        wc_printf("Client is uploading %d bytes<br>\n", WCC->upload_length);
        att = malloc(sizeof(wc_mime_attachment));
        memset(att, 0, sizeof(wc_mime_attachment ));
@@ -1853,7 +1836,6 @@ InitModule_MSG
        WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
        WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
        WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
-       WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
        WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
 
        WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);