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