* wildmat.c, braindamage.c: added
[citadel.git] / webcit / paging.c
1 /* $Id$ */
2
3 #include <stdlib.h>
4 #ifdef HAVE_UNISTD_H
5 #include <unistd.h>
6 #endif
7 #include <stdio.h>
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <ctype.h>
11 #include <string.h>
12 #include "webcit.h"
13 #include "child.h"
14
15 /*
16  * display the form for paging (x-messaging) another user
17  */
18 void display_page(void)
19 {
20         char buf[256];
21         char user[256];
22
23         printf("HTTP/1.0 200 OK\n");
24         output_headers(1, "bottom");
25
26         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
27         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
28         wprintf("<B>Page another user</B>\n");
29         wprintf("</FONT></TD></TR></TABLE>\n");
30
31         wprintf("This command sends a near-real-time message to any currently\n");
32         wprintf("logged in user.<BR><BR>\n");
33
34         wprintf("<FORM METHOD=\"POST\" ACTION=\"/page_user\">\n");
35
36         wprintf("Select a user to send a message to: <BR>");
37
38         wprintf("<SELECT NAME=\"recp\" SIZE=10>\n");
39         serv_puts("RWHO");
40         serv_gets(buf);
41         if (buf[0] == '1') {
42                 while (serv_gets(buf), strcmp(buf, "000")) {
43                         extract(user, buf, 1);
44                         wprintf("<OPTION>");
45                         escputs(user);
46                         wprintf("\n");
47                 }
48         }
49         wprintf("</SELECT>\n");
50         wprintf("<BR>\n");
51
52         wprintf("Enter message text:<BR>");
53         wprintf("<INPUT TYPE=\"text\" NAME=\"msgtext\" MAXLENGTH=80 SIZE=80>\n");
54         wprintf("<BR><BR>\n");
55
56         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send message\">");
57         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
58
59         wprintf("</FORM></CENTER>\n");
60         wDumpContent(1);
61 }
62
63 /*
64  * page another user
65  */
66 void page_user(void)
67 {
68         char recp[256];
69         char msgtext[256];
70         char sc[256];
71         char buf[256];
72
73         printf("HTTP/1.0 200 OK\n");
74         output_headers(1, "bottom");
75
76         strcpy(recp, bstr("recp"));
77         strcpy(msgtext, bstr("msgtext"));
78         strcpy(sc, bstr("sc"));
79
80         if (strcmp(sc, "Send message")) {
81                 wprintf("<EM>Message was not sent.</EM><BR>\n");
82                 return;
83         }
84         serv_printf("SEXP %s|%s", recp, msgtext);
85         serv_gets(buf);
86
87         if (buf[0] == '2') {
88                 wprintf("<EM>Message has been sent to ");
89                 escputs(recp);
90                 wprintf(".</EM><BR>\n");
91         } else {
92                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
93         }
94
95         wDumpContent(1);
96 }
97
98
99
100 /*
101  * multiuser chat
102  */
103 void do_chat(void)
104 {
105
106         printf("HTTP/1.0 200 OK\n");
107         output_headers(1, "bottom");
108
109         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
110         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
111         wprintf("<B>Real-time chat</B>\n");
112         wprintf("</FONT></TD></TR></TABLE>\n");
113
114         wprintf("A chat window should be appearing on your screen ");
115         wprintf("momentarily.  When you're ");
116         wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
117         wprintf("type <TT>/help</TT> for more commands.\n");
118
119         wprintf("<applet codebase=\"/static\" ");
120         wprintf("code=\"wcchat\" width=2 height=2>\n");
121         wprintf("<PARAM NAME=username VALUE=\"%s\">\n", wc_username);
122         wprintf("<PARAM NAME=password VALUE=\"%s\">\n", wc_password);
123         wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
124         wprintf("so you won't be able to access Chat.  Sorry.\n");
125         wprintf("</applet>\n");
126         wDumpContent(1);
127 }