]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
+ add non-TP-Related Wildfire enabled error logging function
[citadel.git] / webcit / messages.c
index df72ad1ce604a2a988a048a525e2967d0a21f8ca..d60b2eefb9ecf4647418774814a6a4f1daeb394a 100644 (file)
@@ -122,7 +122,10 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
                                        state++;
                                }
                        }
-                       else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(HdrToken));
+                       else LogError(Target, 
+                                     __FUNCTION__,  
+                                     "don't know how to handle message header[%s]\n", 
+                                     ChrPtr(HdrToken));
                        break;
                case 1:/* Message Mime Header */
                        if (StrLength(Buf) == 0) {
@@ -1109,11 +1112,11 @@ void post_message(void)
                 */
                pch = strrchr(ChrPtr(att->FileName), '/');
                if (pch != NULL) {
-                       StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName));
+                       StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
                }
                pch = strrchr(ChrPtr(att->FileName), '\\');
                if (pch != NULL) {
-                       StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName));
+                       StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
                }
 
                /**
@@ -1529,13 +1532,16 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
  * partnum             The MIME part to be output
  * force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
  */
-void mimepart(const char *msgnum, const char *partnum, int force_download)
+void mimepart(int force_download)
 {
+       wcsession *WCC = WC;
+
        char buf[256];
        off_t bytes;
        char content_type[256];
-       
-       serv_printf("OPNA %s|%s", msgnum, partnum);
+       const char *ContentType = &content_type[0];
+
+       serv_printf("OPNA %s|%s", ChrPtr(WCC->UrlFragment2), ChrPtr(WCC->UrlFragment3));
        serv_getln(buf, sizeof buf);
        if (buf[0] == '2') {
                bytes = extract_long(&buf[4], 0);
@@ -1545,12 +1551,21 @@ void mimepart(const char *msgnum, const char *partnum, int force_download)
                else {
                        extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
                }
-               output_headers(0, 0, 0, 0, 0, 0);
 
-               read_server_binary(WC->WBuf, bytes);
+               read_server_binary(WCC->WBuf, bytes);
                serv_puts("CLOS");
                serv_getln(buf, sizeof buf);
-               http_transmit_thing(content_type, 0);
+
+               if (!force_download) {
+                       if (!strcasecmp(ContentType, "application/octet-stream")) {
+                               ContentType = GuessMimeByFilename(SKEY(WCC->UrlFragment4));
+                       }
+                       if (!strcasecmp(ContentType, "application/octet-stream")) {
+                               ContentType = GuessMimeType(SKEY(WCC->WBuf));
+                       }
+               }
+               output_headers(0, 0, 0, 0, 0, 0);
+               http_transmit_thing(ContentType, 0);
        } else {
                hprintf("HTTP/1.1 404 %s\n", &buf[4]);
                output_headers(0, 0, 0, 0, 0, 0);
@@ -1616,15 +1631,11 @@ void MimeLoadData(wc_mime_attachment *Mime)
 
 
 void view_mimepart(void) {
-       mimepart(ChrPtr(WC->UrlFragment2),
-                ChrPtr(WC->UrlFragment3),
-                0);
+       mimepart(0);
 }
 
 void download_mimepart(void) {
-       mimepart(ChrPtr(WC->UrlFragment2),
-                ChrPtr(WC->UrlFragment3),
-                1);
+       mimepart(1);
 }
 
 void view_postpart(void) {