#include "webcit.h"
#include "webserver.h"
+#include "modules_init.h"
/* Only one thread may manipulate SessionList at a time... */
pthread_mutex_t SessionListMutex;
if ((*sessions_to_kill)->cache_fold != NULL) {
free((*sessions_to_kill)->cache_fold);
}
- DeleteHash(&((*sessions_to_kill)->attachments));
+ DeleteServInfo(&((*sessions_to_kill)->serv_info));
free_march_list((*sessions_to_kill));
- DeleteHash(&((*sessions_to_kill)->hash_prefs));
- DeleteHash(&((*sessions_to_kill)->IconBarSettings));
- DeleteHash(&((*sessions_to_kill)->ServCfg));
- FreeStrBuf(&((*sessions_to_kill)->UrlFragment1));
- FreeStrBuf(&((*sessions_to_kill)->UrlFragment2));
- FreeStrBuf(&((*sessions_to_kill)->UrlFragment3));
- FreeStrBuf(&((*sessions_to_kill)->WBuf));
- FreeStrBuf(&((*sessions_to_kill)->HBuf));
- FreeStrBuf(&((*sessions_to_kill)->CLineBuf));
- FreeStrBuf(&((*sessions_to_kill)->wc_username));
- FreeStrBuf(&((*sessions_to_kill)->wc_fullname));
- FreeStrBuf(&((*sessions_to_kill)->wc_password));
- FreeStrBuf(&((*sessions_to_kill)->wc_roomname));
- FreeStrBuf(&((*sessions_to_kill)->httpauth_user));
- FreeStrBuf(&((*sessions_to_kill)->httpauth_pass));
+
+ session_destroy_modules(*sessions_to_kill);
+
free((*sessions_to_kill));
(*sessions_to_kill) = NULL;
}
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
}
-const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}
+/*const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}*/
/*
* handle one request
*/
void context_loop(int *sock)
{
+ const char *Pos = NULL;
const char *buf;
int desired_session = 0;
int got_cookie = 0;
int LineLen;
void *vLine;
StrBuf *Buf, *Line, *LastLine, *HeaderName, *ReqLine, *ReqType, *HTTPVersion;
- StrBuf *accept_language = NULL;
const char *pch, *pchs, *pche;
HashList *HTTPHeaders;
do {
nLine ++;
Line = NewStrBuf();
- if (ReqGetStrBuf(sock, Line, Buf) < 0) return;
+
+
+ if (ClientGetLine(sock, Line, Buf, &Pos) < 0) return;
LineLen = StrLength(Line);
continue;
}
+ StrBufSanitizeAscii(Line, 'ยง');
StrBufExtract_token(HeaderName, Line, 0, ':');
- /*/// TODO: filter bad chars! */
pchs = ChrPtr(Line);
pch = pchs + StrLength(HeaderName) + 1;
} while (LineLen > 0);
FreeStrBuf(&HeaderName);
-/*/// dbg_PrintHash(HTTPHeaders, nix, NULL); */
+/* dbg_PrintHash(HTTPHeaders, nix, NULL); */
/*
if_modified_since = httpdate_to_timestamp((StrBuf*)vLine);
}
- if (GetHash(HTTPHeaders, HKEY("ACCEPT-LANGUAGE"), &vLine) &&
- (vLine != NULL)) {
- accept_language = (StrBuf*) vLine;
- }
ReqType = NewStrBuf();
if (TheSession == NULL) {
pthread_mutex_lock(&SessionListMutex);
- for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
+ for (sptr = SessionList;
+ ((sptr != NULL) && (TheSession == NULL));
+ sptr = sptr->next) {
/** If HTTP-AUTH, look for a session with matching credentials */
if ( (!IsEmptyStr(httpauth_user))
TheSession = (wcsession *)
malloc(sizeof(wcsession));
memset(TheSession, 0, sizeof(wcsession));
+ TheSession->headers = HTTPHeaders;
TheSession->serv_sock = (-1);
TheSession->chat_sock = (-1);
TheSession->wc_session = desired_session;
}
- if (TheSession->httpauth_user != NULL){
- FlushStrBuf(TheSession->httpauth_user);
- StrBufAppendBufPlain(TheSession->httpauth_user, httpauth_user, -1, 0);
- }
- else TheSession->httpauth_user = NewStrBufPlain(httpauth_user, -1);
- if (TheSession->httpauth_user != NULL){
- FlushStrBuf(TheSession->httpauth_pass);
- StrBufAppendBufPlain(TheSession->httpauth_pass, httpauth_user, -1, 0);
- }
- else TheSession->httpauth_pass = NewStrBufPlain(httpauth_user, -1);
+ TheSession->httpauth_user = NewStrBufPlain(httpauth_user, -1);
+ TheSession->httpauth_pass = NewStrBufPlain(httpauth_user, -1);
+
+ pthread_setspecific(MyConKey, (void *)TheSession);
+ session_new_modules(TheSession);
- TheSession->CLineBuf = NewStrBuf();
- 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->nonce = rand();
pthread_mutex_unlock(&SessionListMutex);
session_is_new = 1;
}
+ TheSession->headers = HTTPHeaders;
/*
* A future improvement might be to check the session integrity
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->http_sock = *sock;
TheSession->gzip_ok = gzip_ok;
-#ifdef ENABLE_NLS
- if (session_is_new) {
- httplang_to_locale(accept_language);
- }
- go_selected_language(); /* set locale */
-#endif
- session_loop(HTTPHeaders, ReqLine, ReqType, Buf); /* do transaction */
-#ifdef ENABLE_NLS
- stop_selected_language(); /* unset locale */
-#endif
- DeleteHash(&TheSession->summ);
- DeleteHash(&TheSession->urlstrings);
- DeleteHash(&TheSession->vars);
- FreeStrBuf(&TheSession->WBuf);
- FreeStrBuf(&TheSession->HBuf);
-
-
+
+ session_attach_modules(TheSession);
+
+ session_loop(ReqLine, ReqType, Buf, &Pos); /* do transaction */
+ session_detach_modules(TheSession);
+
+ TheSession->headers = NULL;
pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
/* Free the request buffer */
FreeStrBuf(&ReqLine);
FreeStrBuf(&ReqType);
FreeStrBuf(&Buf);
- /*
- * Free up any session-local substitution variables which
- * were set during this transaction
- */
-
-
}
void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)