12 * Pack all session info into one easy-to-digest cookie. Healthy and delicious!
14 void stuff_to_cookie(char *cookie, int session, char *user, char *pass, char *room) {
18 sprintf(buf, "%d|%s|%s|%s", session, user, pass, room);
21 for (i=0; i<strlen(buf); ++i)
22 sprintf(&cookie[strlen(cookie)], "%02X", buf[i]);
28 * Extract all that fun stuff out of the cookie.
30 void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *room) {
34 for (i=0; i<strlen(cookie); i=i+2) {
35 sscanf(&cookie[i], "%02x", (unsigned int *)&buf[i/2]);
39 if (session != NULL) *session = extract_int(buf, 0);
40 if (user != NULL) extract(user, buf, 1);
41 if (pass != NULL) extract(pass, buf, 2);
42 if (room != NULL) extract(room, buf, 3);