* use strbuffer as wprintf backend
[citadel.git] / webcit / context_loop.c
index 032c82a603399aa453a5b8d07e04af46054c54bb..4e10f92b230f08f92779ffe1640daf15e617213b 100644 (file)
@@ -92,15 +92,20 @@ void do_housekeeping(void)
                pthread_mutex_lock(&sessions_to_kill->SessionMutex);
                close(sessions_to_kill->serv_sock);
                close(sessions_to_kill->chat_sock);
-               if (sessions_to_kill->preferences != NULL) {
-                       free(sessions_to_kill->preferences);
-               }
+//             if (sessions_to_kill->preferences != NULL) {
+//                     free(sessions_to_kill->preferences);
+//             }
                if (sessions_to_kill->cache_fold != NULL) {
                        free(sessions_to_kill->cache_fold);
                }
                free_attachments(sessions_to_kill);
                free_march_list(sessions_to_kill);
-               clear_substs(sessions_to_kill);
+               DeleteHash(&(sessions_to_kill->hash_prefs));
+               DeleteHash(&(sessions_to_kill->IconBarSetttings));
+               FreeStrBuf(&(sessions_to_kill->UrlFragment1));
+               FreeStrBuf(&(sessions_to_kill->UrlFragment2));
+               FreeStrBuf(&(sessions_to_kill->WBuf));
+
                pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
                sptr = sessions_to_kill->next;
                free(sessions_to_kill);
@@ -157,7 +162,7 @@ int GenerateSessionID(void)
 /*
  * Collapse multiple cookies on one line
  */
-int req_gets(int sock, char *buf, char *hold)
+int req_gets(int sock, char *buf, char *hold, size_t hlen)
 {
        int a, b;
 
@@ -177,7 +182,7 @@ int req_gets(int sock, char *buf, char *hold)
                        if (buf[a] == ';') {
                                // we don't refresh len, because of we 
                                // only exit from here.
-                               sprintf(hold, "Cookie: %s", &buf[a + 1]);
+                               snprintf(hold, hlen, "Cookie: %s", &buf[a + 1]);
                                buf[a] = 0;
                                b = 8;
                                while (isspace(hold[b]))
@@ -303,7 +308,7 @@ void context_loop(int sock)
         */
        memset(hold, 0, sizeof(hold));
        do {
-               if (req_gets(sock, buf, hold) < 0) return;
+               if (req_gets(sock, buf, hold, SIZ) < 0) return;
 
                /**
                 * Can we compress?
@@ -471,8 +476,11 @@ void context_loop(int sock)
 
                strcpy(TheSession->httpauth_user, httpauth_user);
                strcpy(TheSession->httpauth_pass, httpauth_pass);
+               TheSession->hash_prefs = NewHash(1,NULL);       /* Get a hash table for the user preferences */
                pthread_mutex_init(&TheSession->SessionMutex, NULL);
                pthread_mutex_lock(&SessionListMutex);
+               TheSession->urlstrings = NULL;
+               TheSession->vars = NULL;
                TheSession->nonce = rand();
                TheSession->next = SessionList;
                SessionList = TheSession;
@@ -490,6 +498,9 @@ void context_loop(int sock)
         */
        pthread_mutex_lock(&TheSession->SessionMutex);          /* bind */
        pthread_setspecific(MyConKey, (void *)TheSession);
+       
+       TheSession->urlstrings = NewHash(1,NULL);
+       TheSession->vars = NewHash(1,NULL);
        TheSession->http_sock = sock;
        TheSession->lastreq = time(NULL);                       /* log */
        TheSession->gzip_ok = gzip_ok;
@@ -503,6 +514,9 @@ void context_loop(int sock)
 #ifdef ENABLE_NLS
        stop_selected_language();                               /* unset locale */
 #endif
+       DeleteHash(&TheSession->urlstrings);
+       DeleteHash(&TheSession->vars);
+
        pthread_mutex_unlock(&TheSession->SessionMutex);        /* unbind */
 
        /* Free the request buffer */
@@ -516,5 +530,6 @@ void context_loop(int sock)
         * Free up any session-local substitution variables which
         * were set during this transaction
         */
-       clear_local_substs();
+       
+       
 }