]> code.citadel.org Git - citadel.git/blobdiff - webcit/context_loop.c
* temporary solution to our ser_readln migration: have a buffer on the session, read...
[citadel.git] / webcit / context_loop.c
index c8461d2c8f56741209994d08d953c68db1c9ff25..39a85d5c94bd2392533d88849664257b2f91d12e 100644 (file)
@@ -38,9 +38,11 @@ void DestroySession(wcsession **sessions_to_kill)
        DeleteHash(&((*sessions_to_kill)->hash_prefs));
        DeleteHash(&((*sessions_to_kill)->IconBarSettings));
        DeleteHash(&((*sessions_to_kill)->ServCfg));
+       FreeStrBuf(&((*sessions_to_kill)->ReadBuf));
        FreeStrBuf(&((*sessions_to_kill)->UrlFragment1));
        FreeStrBuf(&((*sessions_to_kill)->UrlFragment2));
        FreeStrBuf(&((*sessions_to_kill)->UrlFragment3));
+       FreeStrBuf(&((*sessions_to_kill)->UrlFragment4));
        FreeStrBuf(&((*sessions_to_kill)->WBuf));
        FreeStrBuf(&((*sessions_to_kill)->HBuf));
        FreeStrBuf(&((*sessions_to_kill)->CLineBuf));
@@ -50,6 +52,9 @@ void DestroySession(wcsession **sessions_to_kill)
        FreeStrBuf(&((*sessions_to_kill)->wc_roomname));
        FreeStrBuf(&((*sessions_to_kill)->httpauth_user));
        FreeStrBuf(&((*sessions_to_kill)->httpauth_pass));
+       FreeStrBuf(&((*sessions_to_kill)->ImportantMsg));
+       FreeStrBuf(&((*sessions_to_kill)->cs_inet_email));
+       FreeStrBuf(&((*sessions_to_kill)->MigrateReadLineBuf));
        free((*sessions_to_kill));
        (*sessions_to_kill) = NULL;
 }
@@ -160,16 +165,6 @@ int GenerateSessionID(void)
        return ++seq;
 }
 
-/*
- * Collapse multiple cookies on one line
- */
-int ReqGetStrBuf(int *sock, StrBuf *Target, StrBuf *buf)
-{
-       
-       return ClientGetLine(sock, Target, buf);
-}
-
-
 
 /*
  * lingering_close() a`la Apache. see
@@ -258,6 +253,7 @@ const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}
  */
 void context_loop(int *sock)
 {
+       const char *Pos = NULL;
        const char *buf;
        int desired_session = 0;
        int got_cookie = 0;
@@ -293,7 +289,9 @@ void context_loop(int *sock)
        do {
                nLine ++;
                Line = NewStrBuf();
-               if (ReqGetStrBuf(sock, Line, Buf) < 0) return;
+
+
+               if (ClientGetLine(sock, Line, Buf, &Pos) < 0) return;
 
                LineLen = StrLength(Line);
 
@@ -319,8 +317,8 @@ void context_loop(int *sock)
                        continue;
                }
 
+               StrBufSanitizeAscii(Line, 'ยง');
                StrBufExtract_token(HeaderName, Line, 0, ':');
-               /*/// TODO: filter bad chars! */
 
                pchs = ChrPtr(Line);
                pch = pchs + StrLength(HeaderName) + 1;
@@ -335,7 +333,7 @@ void context_loop(int *sock)
        } while (LineLen > 0);
        FreeStrBuf(&HeaderName);
 
-/*///  dbg_PrintHash(HTTPHeaders, nix, NULL); */
+/*     dbg_PrintHash(HTTPHeaders, nix, NULL);  */
 
 
        /*
@@ -519,6 +517,9 @@ void context_loop(int *sock)
                }
                else TheSession->httpauth_pass = NewStrBufPlain(httpauth_user, -1);
 
+               if (TheSession->MigrateReadLineBuf != NULL)
+                       FlushStrBuf(TheSession->MigrateReadLineBuf);
+               else TheSession->MigrateReadLineBuf = NewStrBuf();
                TheSession->CLineBuf = NewStrBuf();
                TheSession->hash_prefs = NewHash(1,NULL);       /* Get a hash table for the user preferences */
                pthread_mutex_init(&TheSession->SessionMutex, NULL);
@@ -542,6 +543,8 @@ void context_loop(int *sock)
        pthread_mutex_lock(&TheSession->SessionMutex);          /* bind */
        pthread_setspecific(MyConKey, (void *)TheSession);
        
+       if (TheSession->ImportantMsg == NULL)
+               TheSession->ImportantMsg = NewStrBuf();
        TheSession->urlstrings = NewHash(1,NULL);
        TheSession->vars = NewHash(1,NULL);
        TheSession->http_sock = *sock;
@@ -553,7 +556,7 @@ void context_loop(int *sock)
        }
        go_selected_language();                                 /* set locale */
 #endif
-       session_loop(HTTPHeaders, ReqLine, ReqType, Buf);                               /* do transaction */
+       session_loop(HTTPHeaders, ReqLine, ReqType, Buf, &Pos);                         /* do transaction */
 #ifdef ENABLE_NLS
        stop_selected_language();                               /* unset locale */
 #endif