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