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));
free((*sessions_to_kill));
(*sessions_to_kill) = NULL;
}
if (GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
(vLine != NULL)) {
cookie_to_stuff(vLine, &desired_session,
- NULL, 0, NULL, 0, NULL, 0);
+ NULL, NULL, NULL);
got_cookie = 1;
}
/** If HTTP-AUTH, look for a session with matching credentials */
if ( (!IsEmptyStr(httpauth_user))
- &&(!strcasecmp(sptr->httpauth_user, httpauth_user))
- &&(!strcasecmp(sptr->httpauth_pass, httpauth_pass)) ) {
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_user), httpauth_user))
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_pass), httpauth_pass)) ) {
TheSession = sptr;
}
TheSession->wc_session = desired_session;
}
- strcpy(TheSession->httpauth_user, httpauth_user);
- strcpy(TheSession->httpauth_pass, httpauth_pass);
+ 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->hash_prefs = NewHash(1,NULL); /* Get a hash table for the user preferences */
pthread_mutex_init(&TheSession->SessionMutex, NULL);
pthread_mutex_lock(&SessionListMutex);
}
-void tmpl_nonce(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%ld",
(WCC != NULL)? WCC->nonce:0);
}
+void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
+}
+
+void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
+}
+
+
+
void
InitModule_CONTEXT
(void)
{
- RegisterNamespace("NONCE", 0, 0, tmpl_nonce, 0);
+ RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, CTX_NONE);
+ RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, CTX_NONE);
+ RegisterNamespace("NONCE", 0, 0, tmplput_nonce, 0);
}