]> code.citadel.org Git - citadel.git/blob - webcit/roomops.c
portability enhancements
[citadel.git] / webcit / roomops.c
1 /* $Id$ */
2
3 #include <stdlib.h>
4 #include <string.h>
5 #ifdef HAVE_UNISTD_H
6 #include <unistd.h>
7 #endif
8 #include <stdio.h>
9 #include <signal.h>
10 #include <sys/types.h>
11 #include "webcit.h"
12 #include "child.h"
13
14 struct march {
15         struct march *next;
16         char march_name[32];
17         };
18
19 char floorlist[128][256];
20 char ugname[128];
21 long uglsn;
22 unsigned room_flags;
23 int is_aide = 0;
24 int is_room_aide = 0;
25
26 struct march *march = NULL;
27
28 /*
29  * load the list of floors
30  */
31 void load_floorlist(void) {
32         int a;
33         char buf[256];
34
35         for (a=0; a<128; ++a) floorlist[a][0] = 0;
36
37         serv_puts("LFLR");
38         serv_gets(buf);
39         if (buf[0]!='1') {
40                 strcpy(floorlist[0],"Main Floor");
41                 return;
42                 }
43         while (serv_gets(buf), strcmp(buf,"000")) {
44                 extract(floorlist[extract_int(buf,0)],buf,1);
45                 }
46         }
47
48
49
50 /*
51  * remove a room from the march list
52  */
53 void remove_march(char *aaa)
54 {
55         struct march *mptr,*mptr2;
56
57         if (march==NULL) return;
58
59         if (!strcasecmp(march->march_name,aaa)) {
60                 mptr = march->next;
61                 free(march);
62                 march = mptr;
63                 return;
64                 }
65
66         mptr2 = march;
67         for (mptr=march; mptr!=NULL; mptr=mptr->next) {
68                 if (!strcasecmp(mptr->march_name,aaa)) {
69                         mptr2->next = mptr->next;
70                         free(mptr);
71                         mptr=mptr2;
72                         }
73                 else {
74                         mptr2=mptr;
75                         }
76                 }
77         }
78
79
80 void listrms(char *variety)
81 {
82         char buf[256];
83         char rmname[32];
84         int f;
85
86         fprintf(stderr, "doing listrms(%s)\n", variety);
87         serv_puts(variety);
88         serv_gets(buf);
89         if (buf[0]!='1') return;
90         while (serv_gets(buf), strcmp(buf,"000")) {
91                 extract(rmname,buf,0);
92                 wprintf("<A HREF=\"/dotgoto&room=");
93                 urlescputs(rmname);
94                 wprintf("\" TARGET=\"top\">");
95                 escputs1(rmname,1);
96                 f = extract_int(buf,1);
97                 if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
98                 else if (f & QR_DIRECTORY) wprintf("]");
99                 else if (f & QR_NETWORK) wprintf(")");
100                 else wprintf("&gt;");
101
102                 wprintf("</A><TT> </TT>\n");
103                 };
104         wprintf("<BR>\n");
105         }
106
107
108
109 /*
110  * list all rooms by floor
111  */
112 void list_all_rooms_by_floor(void) {
113         int a;
114         char buf[256];
115
116         load_floorlist();
117
118         printf("HTTP/1.0 200 OK\n");
119         output_headers();
120         wprintf("<HTML><HEAD><TITLE>List known rooms</TITLE></HEAD><BODY>\n");
121
122         wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
123         wprintf("<TH>Rooms with new messages</TH>");
124         wprintf("<TH>Rooms with no new messages</TH></TR>\n");
125
126         for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
127
128                 /* Floor name column */
129                 wprintf("<TR><TD>");
130         
131 /*      
132                 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
133                         &floorlist[a][0]);
134  */
135                 escputs(&floorlist[a][0]);
136
137                 wprintf("</TD>");
138
139                 /* Rooms with new messages column */
140                 wprintf("<TD>");
141                 sprintf(buf,"LKRN %d",a);
142                 listrms(buf);
143                 wprintf("</TD><TD>\n");
144
145                 /* Rooms with old messages column */
146                 sprintf(buf,"LKRO %d",a);
147                 listrms(buf);
148                 wprintf("</TD></TR>\n");
149                 }
150         wprintf("</TABLE>\n");
151         wprintf("</BODY></HTML>\n");
152         wDumpContent();
153         }
154
155
156 /*
157  * list all forgotten rooms
158  */
159 void zapped_list(void) {
160         wprintf("<CENTER><H1>Forgotten rooms</H1>\n");
161         listrms("LZRM -1");
162         wprintf("</CENTER><HR>\n");
163         }
164         
165
166 /*
167  * read this room's info file (set v to 1 for verbose mode)
168  */
169 void readinfo(int v)
170 {
171         char buf[256];
172
173         serv_puts("RINF");
174         serv_gets(buf);
175         if (buf[0]=='1') fmout(NULL);
176         else {
177                 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
178                 }
179         }
180
181
182 /*
183  * generic routine to take the session to a new room
184  *
185  * display_name values:  0 = goto only
186  *                       1 = goto and display
187  *                       2 = display only
188  */
189 void gotoroom(char *gname, int display_name)
190 {
191         char buf[256];
192         static long ls = 0L;
193
194
195         printf("HTTP/1.0 200 OK\n");
196         output_headers();
197         wprintf("<HTML><BODY>\n");
198
199         if (display_name != 2) {
200                 /* store ungoto information */
201                 strcpy(ugname,wc_roomname);
202                 uglsn = ls;
203                 }
204
205         /* move to the new room */
206         sprintf(buf,"GOTO %s",gname);
207         serv_puts(buf);
208         serv_gets(buf);
209         if (buf[0]!='2') {
210                 serv_puts("GOTO _BASEROOM_");
211                 serv_gets(buf);
212                 }
213         if (buf[0]!='2') {
214                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
215                 wDumpContent();
216                 return;
217                 }
218
219         extract(wc_roomname,&buf[4],0);
220         room_flags = extract_int(&buf[4],4);
221
222         remove_march(wc_roomname);
223         if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
224
225         /* Display the room banner */
226
227         if (display_name) {
228                 wprintf("<CENTER><TABLE border=0><TR>");
229
230                 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
231                         wprintf("<TD><A HREF=\"/ungoto\">");
232                         wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
233                         }
234
235                 wprintf("<TD><H1>%s</H1>",wc_roomname);
236                 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
237                         extract_int(&buf[4],1),
238                         extract_int(&buf[4],2));
239
240                 /* FIX add room image here */
241
242                 wprintf("<TD>");
243                 readinfo(0);
244                 wprintf("</TD>");
245
246                 wprintf("<TD><A HREF=\"/gotonext\">");
247                 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
248
249                 wprintf("</TR></TABLE></CENTER>\n");
250
251                 }
252         /* highest_msg_read = extract_int(&buf[4],6);
253         maxmsgnum = extract_int(&buf[4],5);
254         is_mail = (char) extract_int(&buf[4],7); */
255         is_room_aide = (char) extract_int(&buf[4],8);
256         ls = extract_long(&buf[4],6);
257
258         strcpy(wc_roomname, wc_roomname);
259         wDumpContent();
260         }
261
262
263 /*
264  * operation to goto a room
265  */
266 void dotgoto(void) {
267         gotoroom(bstr("room"),1);
268         }
269
270
271 /* Goto next room having unread messages.
272  * We want to skip over rooms that the user has already been to, and take the
273  * user back to the lobby when done.  The room we end up in is placed in
274  * newroom - which is set to 0 (the lobby) initially.
275  * We start the search in the current room rather than the beginning to prevent
276  * two or more concurrent users from dragging each other back to the same room.
277  */
278 void gotonext(void) {
279         char buf[256];
280         struct march *mptr,*mptr2;
281         char next_room[32];
282
283         /* First check to see if the march-mode list is already allocated.
284          * If it is, pop the first room off the list and go there.
285          */
286
287         if (march==NULL) {
288                 serv_puts("LKRN");
289                 serv_gets(buf);
290                 if (buf[0]=='1')
291                     while (serv_gets(buf), strcmp(buf,"000")) {
292                         mptr = (struct march *) malloc(sizeof(struct march));
293                         mptr->next = NULL;
294                         extract(mptr->march_name,buf,0);
295                         if (march==NULL) {
296                                 march = mptr;
297                                 }
298                         else {
299                                 mptr2 = march;
300                                 while (mptr2->next != NULL)
301                                         mptr2 = mptr2->next;
302                                 mptr2->next = mptr;
303                                 }
304                         }
305
306 /* add _BASEROOM_ to the end of the march list, so the user will end up
307  * in the system base room (usually the Lobby>) at the end of the loop
308  */
309                 mptr = (struct march *) malloc(sizeof(struct march));
310                 mptr->next = NULL;
311                 strcpy(mptr->march_name,"_BASEROOM_");
312                 if (march==NULL) {
313                         march = mptr;
314                         }
315                 else {
316                         mptr2 = march;
317                         while (mptr2->next != NULL)
318                                 mptr2 = mptr2->next;
319                         mptr2->next = mptr;
320                         }
321 /*
322  * ...and remove the room we're currently in, so a <G>oto doesn't make us
323  * walk around in circles
324  */
325                 remove_march(wc_roomname);
326                 }
327
328
329         if (march!=NULL) {
330                 strcpy(next_room,march->march_name);
331                 }
332         else {
333                 strcpy(next_room,"_BASEROOM_");
334                 }
335         gotoroom(next_room,1);
336    }
337
338
339
340 /*
341  * mark all messages in current room as having been read
342  */
343 void slrp_highest(void) {
344         char buf[256];
345
346         /* set pointer */
347         serv_puts("SLRP HIGHEST");
348         serv_gets(buf);
349         if (buf[0]!='2') {
350                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
351                 return;
352                 }
353         }
354
355
356 /*
357  * un-goto the previous room
358  */
359 void ungoto(void) { 
360         char buf[256];
361         
362         if (!strcmp(ugname,"")) return;
363         sprintf(buf,"GOTO %s",ugname);
364         serv_puts(buf);
365         serv_gets(buf);
366         if (buf[0]!='2') {
367                 wprintf("%s\n",&buf[4]);
368                 return;
369                 }
370         sprintf(buf,"SLRP %ld",uglsn);
371         serv_puts(buf);
372         serv_gets(buf);
373         if (buf[0]!='2') wprintf("%s\n",&buf[4]);
374         strcpy(buf,ugname);
375         strcpy(ugname,"");
376         gotoroom(buf,1);
377         }
378
379 /*
380  * display the form for editing a room
381  */
382 int display_editroom(void) {
383         char buf[256];
384         char er_name[20];
385         char er_password[10];
386         char er_dirname[15];
387         char er_roomaide[26];
388         unsigned er_flags;
389
390         serv_puts("GETR");
391         serv_gets(buf);
392
393         if (buf[0]!='2') {
394                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
395                 return(0);
396                 }
397
398         extract(er_name,&buf[4],0);
399         extract(er_password,&buf[4],1);
400         extract(er_dirname,&buf[4],2);
401         er_flags=extract_int(&buf[4],3);
402
403
404         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
405         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
406         wprintf("<B>Edit this room</B>\n");
407         wprintf("</FONT></TD></TR></TABLE>\n");
408
409         wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
410
411         wprintf("<UL><LI>Name of room: ");      
412         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
413
414         wprintf("<LI>Type of room:<UL>\n");
415
416         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
417         if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
418         wprintf("> Public room\n");
419
420         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
421         if ((er_flags & QR_PRIVATE)&&
422            (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
423         wprintf("> Private - guess name\n");
424
425         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
426         if ((er_flags & QR_PRIVATE)&&
427            (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
428         wprintf("> Private - require password:\n");
429         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
430
431         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
432         if ( (er_flags & QR_PRIVATE)
433            && ((er_flags & QR_GUESSNAME) == 0)
434            && ((er_flags & QR_PASSWORDED) == 0) )
435                 wprintf("CHECKED ");
436         wprintf("> Private - invitation only\n");
437
438         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
439         wprintf("> If private, cause current users to forget room\n");
440
441         wprintf("</UL>\n");
442
443         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
444         if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
445         wprintf("> Preferred users only\n");
446
447         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
448         if (er_flags & QR_READONLY) wprintf("CHECKED ");
449         wprintf("> Read-only room\n");
450
451 /* directory stuff */
452         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
453         if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
454         wprintf("> File directory room\n");
455
456         wprintf("<UL><LI>Directory name: ");
457         wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
458
459         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
460         if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
461         wprintf("> Uploading allowed\n");
462
463         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
464         if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
465         wprintf("> Downloading allowed\n");
466
467         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
468         if (er_flags & QR_VISDIR) wprintf("CHECKED ");
469         wprintf("> Visible directory</UL>\n");
470
471 /* end of directory stuff */
472         
473         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
474         if (er_flags & QR_NETWORK) wprintf("CHECKED ");
475         wprintf("> Network shared room\n");
476
477 /* start of anon options */
478
479         wprintf("<LI>Anonymous messages<UL>\n");
480         
481         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
482         if ( ((er_flags & QR_ANONONLY)==0)
483            && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
484         wprintf("> No anonymous messages\n");
485
486         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
487         if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
488         wprintf("> All messages are anonymous\n");
489
490         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
491         if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
492         wprintf("> Prompt user when entering messages</UL>\n");
493
494 /* end of anon options */
495
496         wprintf("<LI>Room aide: \n");
497         serv_puts("GETA");
498         serv_gets(buf);
499         if (buf[0]!='2') {
500                 wprintf("<EM>%s</EM>\n",&buf[4]);
501                 }
502         else {
503                 extract(er_roomaide,&buf[4],0);
504                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
505                 }
506                 
507         wprintf("</UL><CENTER>\n");
508         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
509         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
510         wprintf("</CENTER>\n");
511
512         wprintf("</FORM>\n");
513         return(1);
514         }
515
516
517 /*
518  * save new parameters for a room
519  */
520 int editroom(void) {
521         char buf[256];
522         char er_name[20];
523         char er_password[10];
524         char er_dirname[15];
525         char er_roomaide[26];
526         unsigned er_flags;
527         int bump;
528
529
530         if (strcmp(bstr("sc"),"OK")) {
531                 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
532                 return(0);
533                 }
534         
535         serv_puts("GETR");
536         serv_gets(buf);
537
538         if (buf[0]!='2') {
539                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
540                 return(0);
541                 }
542
543         extract(er_name,&buf[4],0);
544         extract(er_password,&buf[4],1);
545         extract(er_dirname,&buf[4],2);
546         er_flags=extract_int(&buf[4],3);
547
548         strcpy(er_roomaide,bstr("er_roomaide"));
549         if (strlen(er_roomaide)==0) {
550                 serv_puts("GETA");
551                 serv_gets(buf);
552                 if (buf[0]!='2') {
553                         strcpy(er_roomaide,"");
554                         }
555                 else {
556                         extract(er_roomaide,&buf[4],0);
557                         }
558                 }
559
560         strcpy(buf,bstr("er_name"));            buf[20] = 0;
561         if (strlen(buf)>0) strcpy(er_name,buf);
562
563         strcpy(buf,bstr("er_password"));        buf[10] = 0;
564         if (strlen(buf)>0) strcpy(er_password,buf);
565
566         strcpy(buf,bstr("er_dirname"));         buf[15] = 0;
567         if (strlen(buf)>0) strcpy(er_dirname,buf);
568
569         strcpy(buf,bstr("type"));
570         er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
571
572         if (!strcmp(buf,"invonly")) {
573                 er_flags |= (QR_PRIVATE);
574                 }
575         if (!strcmp(buf,"guessname")) {
576                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
577                 }
578         if (!strcmp(buf,"passworded")) {
579                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
580                 }
581
582         if (!strcmp(bstr("prefonly"),"yes")) {
583                 er_flags |= QR_PREFONLY;
584                 }
585         else {
586                 er_flags &= ~QR_PREFONLY;
587                 }
588
589         if (!strcmp(bstr("readonly"),"yes")) {
590                 er_flags |= QR_READONLY;
591                 }
592         else {
593                 er_flags &= ~QR_READONLY;
594                 }
595
596         if (!strcmp(bstr("network"),"yes")) {
597                 er_flags |= QR_NETWORK;
598                 }
599         else {
600                 er_flags &= ~QR_NETWORK;
601                 }
602
603         if (!strcmp(bstr("directory"),"yes")) {
604                 er_flags |= QR_DIRECTORY;
605                 }
606         else {
607                 er_flags &= ~QR_DIRECTORY;
608                 }
609
610         if (!strcmp(bstr("ulallowed"),"yes")) {
611                 er_flags |= QR_UPLOAD;
612                 }
613         else {
614                 er_flags &= ~QR_UPLOAD;
615                 }
616
617         if (!strcmp(bstr("dlallowed"),"yes")) {
618                 er_flags |= QR_DOWNLOAD;
619                 }
620         else {
621                 er_flags &= ~QR_DOWNLOAD;
622                 }
623
624         if (!strcmp(bstr("visdir"),"yes")) {
625                 er_flags |= QR_VISDIR;
626                 }
627         else {
628                 er_flags &= ~QR_VISDIR;
629                 }
630
631         strcpy(buf,bstr("anon"));
632
633         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
634         if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
635         if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
636
637         bump = 0;
638         if (!strcmp(bstr("bump"),"yes")) bump = 1;
639
640         sprintf(buf,"SETR %s|%s|%s|%u|%d",
641                 er_name,er_password,er_dirname,er_flags,bump);
642         serv_puts(buf);
643         serv_gets(buf);
644         if (buf[0]!='2') {
645                 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
646                 return(display_editroom());
647                 }
648         gotoroom(er_name,0);
649
650         if (strlen(er_roomaide)>0) {
651                 sprintf(buf,"SETA %s",er_roomaide);
652                 serv_puts(buf);
653                 serv_gets(buf);
654                 if (buf[0]!='2') {
655                         wprintf("<EM>%s</EM><HR>\n",&buf[4]);
656                         return(display_editroom());
657                         }
658                 }
659
660         wprintf("<EM>Changes have been saved.</EM><BR>");
661         return(0);
662         }
663
664
665
666 /*
667  * display the form for entering a new room
668  */
669 int display_entroom(void) {
670         char buf[256];
671
672         serv_puts("CRE8 0");
673         serv_gets(buf);
674         
675         if (buf[0]!='2') {
676                 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
677                 return(0);
678                 }
679
680         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
681         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
682         wprintf("<B>Enter (create) a new room</B>\n");
683         wprintf("</FONT></TD></TR></TABLE>\n");
684
685         wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
686
687         wprintf("<UL><LI>Name of room: ");      
688         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
689
690         wprintf("<LI>Type of room:<UL>\n");
691
692         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
693         wprintf("CHECKED > Public room\n");
694
695         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
696         wprintf("> Private - guess name\n");
697
698         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
699         wprintf("> Private - require password:\n");
700         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
701
702         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
703         wprintf("> Private - invitation only\n");
704
705         wprintf("<CENTER>\n");
706         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
707         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
708         wprintf("</CENTER>\n");
709         wprintf("</FORM>\n");
710         return(1);
711         }
712
713
714
715 /*
716  * enter a new room
717  */
718 int entroom(void) {
719         char buf[256];
720         char er_name[20];
721         char er_type[20];
722         char er_password[10];
723         int er_num_type;
724
725         if (strcmp(bstr("sc"),"OK")) {
726                 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
727                 return(0);
728                 }
729         
730         strcpy(er_name,bstr("er_name"));
731         strcpy(er_type,bstr("type"));
732         strcpy(er_password,bstr("er_password"));
733
734         er_num_type = 0;
735         if (!strcmp(er_type,"guessname")) er_num_type = 1;
736         if (!strcmp(er_type,"passworded")) er_num_type = 2;
737         if (!strcmp(er_type,"invonly")) er_num_type = 3;
738
739         sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
740         serv_puts(buf);
741         serv_gets(buf);
742         if (buf[0]!='2') {
743                 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
744                 return(display_editroom());
745                 }
746         gotoroom(er_name,0);
747         return(0);
748         }
749
750
751 /*
752  * display the screen to enter a private room
753  */
754 void display_private(char *rname, int req_pass)
755 {
756
757
758         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
759         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
760         wprintf("<B>Enter a private room</B>\n");
761         wprintf("</FONT></TD></TR></TABLE>\n");
762
763         wprintf("<CENTER>\n");
764         wprintf("If you know the name of a hidden (guess-name) or\n");
765         wprintf("passworded room, you can enter that room by typing\n");
766         wprintf("its name below.  Once you gain access to a private\n");
767         wprintf("room, it will appear in your regular room listings\n");
768         wprintf("so you don't have to keep returning here.\n");
769         wprintf("<BR><BR>");
770         
771         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
772
773         wprintf("<TABLE border><TR><TD>");
774         wprintf("Enter room name:</TD><TD>");
775         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
776
777         if (req_pass) {
778                 wprintf("</TD></TR><TR><TD>");
779                 wprintf("Enter room password:</TD><TD>");
780                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
781                 }
782
783         wprintf("</TD></TR></TABLE>\n");
784         
785         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
786         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
787         wprintf("</FORM>");
788         }
789
790 /* 
791  * goto a private room
792  */
793 int goto_private(void) {
794         char hold_rm[32];
795         char buf[256];
796         
797         if (strcmp(bstr("sc"),"OK")) {
798                 return(2);
799                 }
800
801         strcpy(hold_rm,wc_roomname);
802         strcpy(buf,"GOTO ");
803         strcat(buf,bstr("gr_name"));
804         strcat(buf,"|");
805         strcat(buf,bstr("gr_pass"));
806         serv_puts(buf);
807         serv_gets(buf);
808
809         if (buf[0]=='2') {
810                 gotoroom(bstr("gr_name"),1);
811                 return(0);
812                 }
813
814         if (!strncmp(buf,"540",3)) {
815                 display_private(bstr("gr_name"),1);
816                 return(1);
817                 }
818
819         wprintf("<EM>%s</EM>\n",&buf[4]);
820         return(2);
821         }
822
823
824 /*
825  * display the screen to zap a room
826  */
827 void display_zap(void) {
828         char zaproom[32];
829         
830         strcpy(zaproom, bstr("room"));
831         
832         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
833         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
834         wprintf("<B>Zap (forget) the current room</B>\n");
835         wprintf("</FONT></TD></TR></TABLE>\n");
836
837         wprintf("If you select this option, <em>%s</em> will ", zaproom);
838         wprintf("disappear from your room list.  Is this what you wish ");
839         wprintf("to do?<BR>\n");
840
841         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
842         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
843         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
844         wprintf("</FORM>");
845         }
846
847
848 /* 
849  * zap a room
850  */
851 int zap(void) {
852         char zaproom[32];
853         char buf[256];
854
855         if (strcmp(bstr("sc"),"OK")) {
856                 return(2);
857                 }
858
859         strcpy(zaproom, bstr("room"));
860         sprintf(buf, "GOTO %s", zaproom);
861         serv_puts(buf);
862         serv_gets(buf);
863         if (buf[0] != '2') {
864                 wprintf("<EM>%s</EM>\n",&buf[4]);
865                 return(2);
866                 }
867
868         serv_puts("FORG");
869         serv_gets(buf);
870         if (buf[0] != '2') {
871                 wprintf("<EM>%s</EM>\n",&buf[4]);
872                 return(2);
873                 }
874
875         gotoroom(bstr("_BASEROOM_"),1);
876         return(0);
877         }