8 * String to unset the cookie.
9 * Any date "in the past" will work, so I chose my birthday, right down to
10 * the exact minute. :)
12 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
13 typedef unsigned char byte; /* Byte type used by cookie_to_stuff() */
16 * Pack all session info into one easy-to-digest cookie. Healthy and delicious!
18 void stuff_to_cookie(int unset_cookies)
24 hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
28 StrBufAppendPrintf(WCC->HBuf, "Set-cookie: webcit=");
29 snprintf(buf, sizeof(buf), "%d", WCC->wc_session);
30 StrBufHexescAppend(WCC->HBuf, NULL, buf);
31 StrBufHexescAppend(WCC->HBuf, NULL, "|");
32 StrBufHexescAppend(WCC->HBuf, WCC->wc_username, NULL);
33 StrBufHexescAppend(WCC->HBuf, NULL, "|");
34 StrBufHexescAppend(WCC->HBuf, WCC->wc_password, NULL);
35 StrBufHexescAppend(WCC->HBuf, NULL, "|");
36 StrBufHexescAppend(WCC->HBuf, WCC->wc_roomname, NULL);
37 StrBufHexescAppend(WCC->HBuf, NULL, "|");
38 StrBufHexescAppend(WCC->HBuf, NULL, get_selected_language());
39 StrBufHexescAppend(WCC->HBuf, NULL, "|");
41 if (server_cookie != NULL) {
42 StrBufAppendPrintf(WCC->HBuf,
47 StrBufAppendBufPlain(WCC->HBuf,
48 HKEY("; path=/\r\n"), 0);
54 * Convert unpacked hex string to an integer
56 int xtoi(const char *in, size_t len)
60 while (!IsEmptyStr(in) && isxdigit((byte) *in) && (len-- > 0))
64 if (!isdigit((unsigned char)c)) {
65 c = tolower((unsigned char) c);
66 if ((c < 'a') || (c > 'f'))
77 * Extract all that fun stuff out of the cookie.
79 void cookie_to_stuff(StrBuf *cookie,
86 if (session != NULL) {
87 *session = StrBufExtract_int(cookie, 0, '|');
90 StrBufExtract_token(user, cookie, 1, '|');
93 StrBufExtract_token(pass, cookie, 2, '|');
96 StrBufExtract_token(room, cookie, 3, '|');
98 if (language != NULL) {
99 StrBufExtract_token(language, cookie, 4, '|');