* move stuff from Hdr into substruct that may be easily wiped by memset 0'ing them
[citadel.git] / webcit / messages.c
index 0a9f2c746b332965191e670047f4f336ddb74e81..a3bca061a13ec2d54410d6b39015cfcdb7a03425 100644 (file)
@@ -364,10 +364,19 @@ void handle_one_message(void)
        wcsession *WCC = WC;
        const StrBuf *Tmpl;
        StrBuf *CmdBuf = NULL;
+       const char *pMsg;
 
-       //msgnum = StrTol(WCC->UrlFragment3);
-       //gotoroom(WCC->UrlFragment2);
-       switch (WCC->Hdr->eReqType)
+
+       pMsg = strchr(ChrPtr(WCC->Hdr->HR.ReqLine), '/');
+       if (pMsg == NULL) {
+               HttpStatus(CitStatus);
+               return;
+       }
+
+       msgnum = atol(pMsg + 1);
+       StrBufCutAt(WCC->Hdr->HR.ReqLine, 0, pMsg);
+       gotoroom(WCC->Hdr->HR.ReqLine);
+       switch (WCC->Hdr->HR.eReqType)
        {
        case eGET:
        case ePOST:
@@ -426,8 +435,8 @@ void embed_message(void) {
        const StrBuf *Tmpl;
        StrBuf *CmdBuf = NULL;
 
-       msgnum = StrBufExtract_long(WCC->Hdr->ReqLine, 2, '/');
-       switch (WCC->Hdr->eReqType)
+       msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
+       switch (WCC->Hdr->HR.eReqType)
        {
        case eGET:
        case ePOST:
@@ -466,7 +475,7 @@ void print_message(void) {
        long msgnum = 0L;
        const StrBuf *Mime;
 
-       msgnum = StrBufExtract_long(WC->Hdr->ReqLine, 2, '/');
+       msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
        output_headers(0, 0, 0, 0, 0, 0);
 
        hprintf("Content-type: text/html\r\n"
@@ -490,7 +499,7 @@ void mobile_message_view(void)
        long msgnum = 0L;
        const StrBuf *Mime;
   
-       msgnum = StrBufExtract_long(WC->Hdr->ReqLine, 2, '/');
+       msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
        output_headers(1, 0, 0, 0, 0, 1);
        begin_burst();
        do_template("msgcontrols", NULL);
@@ -507,7 +516,7 @@ void display_headers(void) {
        long msgnum = 0L;
        char buf[1024];
 
-       msgnum = StrBufExtract_long(WC->Hdr->ReqLine, 2, '/');
+       msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
        output_headers(0, 0, 0, 0, 0, 0);
 
        hprintf("Content-type: text/plain\r\n"
@@ -1738,8 +1747,8 @@ void mimepart(int force_download)
        StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
        const char *CT;
 
-       msgnum = StrBufExtract_long(WCC->Hdr->ReqLine, 2, '/');
-       att = StrBufExtract_long(WCC->Hdr->ReqLine, 3, '/');
+       msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
+       att = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 1, '/');
 
        Buf = NewStrBuf();
        serv_printf("OPNA %ld|%ld", msgnum, att);
@@ -1758,7 +1767,7 @@ void mimepart(int force_download)
 
                if (!force_download) {
                        if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
-                               StrBufExtract_token(Buf, WCC->Hdr->ReqLine, 4, '/');
+                               StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
                                CT = GuessMimeByFilename(SKEY(Buf));
                        }
                        if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
@@ -1845,8 +1854,8 @@ void view_postpart(void) {
        StrBuf *filename = NewStrBuf();
        StrBuf *partnum = NewStrBuf();
 
-       StrBufExtract_token(partnum, WC->Hdr->ReqLine, 2, '/');
-       StrBufExtract_token(filename, WC->Hdr->ReqLine, 3, '/');
+       StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
+       StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
 
        postpart(partnum, filename, 0);
 
@@ -1858,8 +1867,8 @@ void download_postpart(void) {
        StrBuf *filename = NewStrBuf();
        StrBuf *partnum = NewStrBuf();
 
-       StrBufExtract_token(partnum, WC->Hdr->ReqLine, 2, '/');
-       StrBufExtract_token(filename, WC->Hdr->ReqLine, 3, '/');
+       StrBufExtract_token(partnum, WC->Hdr->HR.ReqLine, 0, '/');
+       StrBufExtract_token(filename, WC->Hdr->HR.ReqLine, 1, '/');
 
        postpart(partnum, filename, 1);