4 * This is the actual program called by the webserver. It maintains a
5 * persistent session to the Citadel server, handling HTTP WebCit requests as
6 * they arrive and presenting a user interface.
18 char wc_username[256];
19 char wc_password[256];
20 char wc_roomname[256];
22 void getz(char *buf) {
23 if (fgets(buf, 256, stdin) == NULL) strcpy(buf, "");
25 while ((strlen(buf)>0)&&(!isprint(buf[strlen(buf)-1])))
26 buf[strlen(buf)-1] = 0;
30 void output_reconnect_cookies() {
31 printf("Set-cookie: wc_session=%d\n", wc_session);
32 if (strlen(wc_host)>0) printf("Set-cookie: wc_host=%s\n", wc_host);
33 if (wc_port != 0) printf("Set-cookie: wc_port=%d\n", wc_port);
34 if (strlen(wc_username)>0) printf("Set-cookie: wc_username=%s\n",
36 if (strlen(wc_password)>0) printf("Set-cookie: wc_password=%s\n",
38 if (strlen(wc_roomname)>0) printf("Set-cookie: wc_roomname=%s\n",
45 static int TransactionCount = 0;
49 } while(strlen(buf)>0);
51 printf("HTTP/1.0 200 OK\n");
52 printf("Server: WebCit v2 (Velma)\n");
53 printf("Connection: close\n");
54 output_reconnect_cookies();
55 printf("Content-Type: text/html\n");
59 sprintf(&content[strlen(content)],
60 "<HTML><HEAD><TITLE>WebCit</TITLE></HEAD><BODY>\n");
61 sprintf(&content[strlen(content)],
62 "TransactionCount is %d<HR>\n", ++TransactionCount);
63 sprintf(&content[strlen(content)],
64 "You're in session %d<BR>\n", wc_session);
65 sprintf(&content[strlen(content)],
68 printf("Content-length: %d\n", strlen(content));
70 fwrite(content, strlen(content), 1, stdout);
76 int main(int argc, char *argv[]) {
79 printf("%s: usage: %s <session_id>\n", argv[0], argv[0]);
83 wc_session = atoi(argv[1]);
86 strcpy(wc_username, "");
87 strcpy(wc_password, "");
88 strcpy(wc_roomname, "");