+
+#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
-#include <ctype.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
#include "webcit.h"
-#include "child.h"
+
+#define TRUE 1
+#define FALSE 0
+
+typedef unsigned char byte; /* Byte type */
/*
* Pack all session info into one easy-to-digest cookie. Healthy and delicious!
*/
-void stuff_to_cookie(char *cookie, int session, char *user, char *pass, char *room, int nofr) {
- char buf[256];
- int i;
-
- sprintf(buf, "%d|%s|%s|%s|%d", session, user, pass, room, nofr);
- strcpy(cookie, "");
-
- for (i=0; i<strlen(buf); ++i)
- sprintf(&cookie[strlen(cookie)], "%02X", buf[i]);
+void stuff_to_cookie(char *cookie, int session, char *user, char *pass, char *room)
+{
+ char buf[SIZ];
+ sprintf(buf, "%d|%s|%s|%s|END", session, user, pass, room);
+ CtdlEncodeBase64(cookie, buf, strlen(buf));
}
/*
* Extract all that fun stuff out of the cookie.
*/
-void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *room, int *nofr) {
- char buf[256];
- int i;
-
- for (i=0; i<strlen(cookie); i=i+2) {
- sscanf(&cookie[i], "%02x", (unsigned int *)&buf[i/2]);
- buf[(i/2)+1] = 0;
- }
-
- if (session != NULL) *session = extract_int(buf, 0);
- if (user != NULL) extract(user, buf, 1);
- if (pass != NULL) extract(pass, buf, 2);
- if (room != NULL) extract(room, buf, 3);
- if (nofr != NULL) *nofr = extract_int(buf, 4);
+void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *room)
+{
+ char buf[SIZ];
+
+ CtdlDecodeBase64(buf, cookie, strlen(cookie));
+
+ if (session != NULL)
+ *session = extract_int(buf, 0);
+ if (user != NULL)
+ extract(user, buf, 1);
+ if (pass != NULL)
+ extract(pass, buf, 2);
+ if (room != NULL)
+ extract(room, buf, 3);
}