* Finished the share/unshare room screen in Edit Room
[citadel.git] / webcit / roomops.c
1 /* $Id$ */
2
3
4 #include <ctype.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <fcntl.h>
9 #include <signal.h>
10 #include <sys/types.h>
11 #include <sys/wait.h>
12 #include <sys/socket.h>
13 #include <sys/time.h>
14 #include <limits.h>
15 #include <netinet/in.h>
16 #include <netdb.h>
17 #include <string.h>
18 #include <pwd.h>
19 #include <errno.h>
20 #include <stdarg.h>
21 #include <pthread.h>
22 #include <signal.h>
23 #include "webcit.h"
24
25
26
27
28
29
30
31 char floorlist[128][SIZ];
32
33
34 /*
35  * load the list of floors
36  */
37 void load_floorlist(void)
38 {
39         int a;
40         char buf[SIZ];
41
42         for (a = 0; a < 128; ++a)
43                 floorlist[a][0] = 0;
44
45         serv_puts("LFLR");
46         serv_gets(buf);
47         if (buf[0] != '1') {
48                 strcpy(floorlist[0], "Main Floor");
49                 return;
50         }
51         while (serv_gets(buf), strcmp(buf, "000")) {
52                 extract(floorlist[extract_int(buf, 0)], buf, 1);
53         }
54 }
55
56
57 /*
58  * remove a room from the march list
59  */
60 void remove_march(char *aaa)
61 {
62         struct march *mptr, *mptr2;
63
64         if (WC->march == NULL)
65                 return;
66
67         if (!strcasecmp(WC->march->march_name, aaa)) {
68                 mptr = WC->march->next;
69                 free(WC->march);
70                 WC->march = mptr;
71                 return;
72         }
73         mptr2 = WC->march;
74         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
75                 if (!strcasecmp(mptr->march_name, aaa)) {
76                         mptr2->next = mptr->next;
77                         free(mptr);
78                         mptr = mptr2;
79                 } else {
80                         mptr2 = mptr;
81                 }
82         }
83 }
84
85
86
87
88
89 void room_tree_list(struct roomlisting *rp)
90 {
91         char rmname[64];
92         int f;
93
94         if (rp == NULL)
95                 return;
96
97         if (rp->lnext != NULL) {
98                 room_tree_list(rp->lnext);
99         }
100         strcpy(rmname, rp->rlname);
101         f = rp->rlflags;
102
103         wprintf("<A HREF=\"/dotgoto&room=");
104         urlescputs(rmname);
105         wprintf("\"");
106         wprintf(">");
107         escputs1(rmname, 1);
108         if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109                 wprintf("}");
110         else if (f & QR_DIRECTORY)
111                 wprintf("]");
112         else if (f & QR_NETWORK)
113                 wprintf(")");
114         else
115                 wprintf("&gt;");
116         wprintf("</A><TT> </TT>\n");
117
118         if (rp->rnext != NULL) {
119                 room_tree_list(rp->rnext);
120         }
121         free(rp);
122 }
123
124
125 /* 
126  * Room ordering stuff (compare first by floor, then by order)
127  */
128 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
129 {
130         if ((r1 == NULL) && (r2 == NULL))
131                 return (0);
132         if (r1 == NULL)
133                 return (-1);
134         if (r2 == NULL)
135                 return (1);
136         if (r1->rlfloor < r2->rlfloor)
137                 return (-1);
138         if (r1->rlfloor > r2->rlfloor)
139                 return (1);
140         if (r1->rlorder < r2->rlorder)
141                 return (-1);
142         if (r1->rlorder > r2->rlorder)
143                 return (1);
144         return (0);
145 }
146
147
148 /*
149  * Common code for all room listings
150  */
151 void listrms(char *variety)
152 {
153         char buf[SIZ];
154         int num_rooms = 0;
155
156         struct roomlisting *rl = NULL;
157         struct roomlisting *rp;
158         struct roomlisting *rs;
159
160
161         /* Ask the server for a room list */
162         serv_puts(variety);
163         serv_gets(buf);
164         if (buf[0] != '1') {
165                 wprintf("&nbsp;");
166                 return;
167         }
168         while (serv_gets(buf), strcmp(buf, "000")) {
169                 ++num_rooms;
170                 rp = malloc(sizeof(struct roomlisting));
171                 extract(rp->rlname, buf, 0);
172                 rp->rlflags = extract_int(buf, 1);
173                 rp->rlfloor = extract_int(buf, 2);
174                 rp->rlorder = extract_int(buf, 3);
175                 rp->lnext = NULL;
176                 rp->rnext = NULL;
177
178                 rs = rl;
179                 if (rl == NULL) {
180                         rl = rp;
181                 } else
182                         while (rp != NULL) {
183                                 if (rordercmp(rp, rs) < 0) {
184                                         if (rs->lnext == NULL) {
185                                                 rs->lnext = rp;
186                                                 rp = NULL;
187                                         } else {
188                                                 rs = rs->lnext;
189                                         }
190                                 } else {
191                                         if (rs->rnext == NULL) {
192                                                 rs->rnext = rp;
193                                                 rp = NULL;
194                                         } else {
195                                                 rs = rs->rnext;
196                                         }
197                                 }
198                         }
199         }
200
201         room_tree_list(rl);
202
203         /* If no rooms were listed, print an nbsp to make the cell
204          * borders show up anyway.
205          */
206         if (num_rooms == 0) wprintf("&nbsp;");
207 }
208
209
210
211
212
213
214
215
216
217 /*
218  * list all rooms by floor
219  */
220 void list_all_rooms_by_floor(void)
221 {
222         int a;
223         char buf[SIZ];
224
225         load_floorlist();
226
227         output_headers(1);
228
229         wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
230         wprintf("<TH>Rooms with new messages</TH>");
231         wprintf("<TH>Rooms with no new messages</TH></TR>\n");
232
233         for (a = 0; a < 128; ++a)
234                 if (floorlist[a][0] != 0) {
235
236                         /* Floor name column */
237                         wprintf("<TR><TD>");
238
239                         serv_printf("OIMG _floorpic_|%d", a);
240                         serv_gets(buf);
241                         if (buf[0] == '2') {
242                                 serv_puts("CLOS");
243                                 serv_gets(buf);
244                                 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
245                                         a, &floorlist[a][0]);
246                         } else {
247                                 escputs(&floorlist[a][0]);
248                         }
249
250                         wprintf("</TD>");
251
252                         /* Rooms with new messages column */
253                         wprintf("<TD>");
254                         sprintf(buf, "LKRN %d", a);
255                         listrms(buf);
256                         wprintf("</TD>\n<TD>");
257
258                         /* Rooms with old messages column */
259                         sprintf(buf, "LKRO %d", a);
260                         listrms(buf);
261                         wprintf("</TD></TR>\n");
262                 }
263         wprintf("</TABLE>\n");
264         wDumpContent(1);
265 }
266
267
268 /*
269  * list all forgotten rooms
270  */
271 void zapped_list(void)
272 {
273         output_headers(1);
274         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
275         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
276         wprintf("<B>Zapped (forgotten) rooms</B>\n");
277         wprintf("</TD></TR></TABLE><BR>\n");
278         listrms("LZRM -1");
279         wprintf("<BR><BR>\n");
280         wprintf("Click on any room to un-zap it and goto that room.\n");
281         wDumpContent(1);
282 }
283
284
285 /*
286  * read this room's info file (set v to 1 for verbose mode)
287  */
288 void readinfo(void)
289 {
290         char buf[SIZ];
291
292         serv_puts("RINF");
293         serv_gets(buf);
294         if (buf[0] == '1') {
295                 wprintf("<FONT SIZE=-1>");
296                 fmout(NULL);
297                 wprintf("</FONT>");
298         }
299 }
300
301
302
303
304 /* Display room graphic.  The server doesn't actually
305  * need the room name, but we supply it in order to
306  * keep the browser from using a cached graphic from 
307  * another room.
308  */
309 void embed_room_graphic(void) {
310         char buf[SIZ];
311
312         serv_puts("OIMG _roompic_");
313         serv_gets(buf);
314         if (buf[0] == '2') {
315                 wprintf("<TD>");
316                 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
317                 urlescputs(WC->wc_roomname);
318                 wprintf("\"></TD>");
319                 serv_puts("CLOS");
320                 serv_gets(buf);
321         }
322
323 }
324
325
326 /* Let the user know if new mail has arrived 
327  */
328 void embed_newmail_button(void) {
329         if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
330                 wprintf("<TD VALIGN=TOP>"
331                         "<IMG SRC=\"/static/mail.gif\" border=0 "
332                         "ALT=\"You have new mail\">"
333                         "<BR><BLINK>%d</BLINK>", WC->new_mail);
334                 wprintf("<FONT SIZE=-2> new mail messages</FONT></TD>");
335                 WC->remember_new_mail = WC->new_mail;
336         }
337 }
338
339
340
341 void embed_room_banner(char *got) {
342         char fakegot[SIZ];
343
344         /* We need to have the information returned by a GOTO server command.
345          * If it isn't supplied, we fake it by issuing our own GOTO.
346          */
347         if (got == NULL) {
348                 serv_printf("GOTO %s", WC->wc_roomname);
349                 serv_gets(fakegot);
350                 got = fakegot;
351         }
352
353         /* Check for new mail. */
354         WC->new_mail = extract_int(&got[4], 9);
355
356         svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
357         svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
358         svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
359         svcallback("ROOMPIC", embed_room_graphic);
360         svcallback("ROOMINFO", readinfo);
361         svcallback("YOUHAVEMAIL", embed_newmail_button);
362
363         do_template("roombanner.html");
364         clear_local_substs();
365 }
366
367
368
369
370
371 /*
372  * generic routine to take the session to a new room
373  *
374  * display_name values:  0 = goto only
375  *                       1 = goto and display
376  *                       2 = display only
377  */
378 void gotoroom(char *gname, int display_name)
379 {
380         char buf[SIZ];
381         static long ls = (-1L);
382
383
384         if (display_name) {
385                 output_headers(0);
386                 wprintf("Pragma: no-cache\n");
387                 wprintf("Cache-Control: no-store\n");
388
389                 wprintf("<HTML><HEAD>\n"
390                         "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
391                         "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
392                         "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
393                         "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
394                         "</HEAD>\n");
395                 do_template("background.html");
396         }
397         if (display_name != 2) {
398                 /* store ungoto information */
399                 strcpy(WC->ugname, WC->wc_roomname);
400                 WC->uglsn = ls;
401         }
402         /* move to the new room */
403         serv_printf("GOTO %s", gname);
404         serv_gets(buf);
405         if (buf[0] != '2') {
406                 serv_puts("GOTO _BASEROOM_");
407                 serv_gets(buf);
408         }
409         if (buf[0] != '2') {
410                 if (display_name) {
411                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
412                         wDumpContent(1);
413                 }
414                 return;
415         }
416         extract(WC->wc_roomname, &buf[4], 0);
417         WC->room_flags = extract_int(&buf[4], 4);
418         /* highest_msg_read = extract_int(&buf[4],6);
419            maxmsgnum = extract_int(&buf[4],5);
420            is_mail = (char) extract_int(&buf[4],7); */
421         ls = extract_long(&buf[4], 6);
422
423         if (WC->is_aide)
424                 WC->is_room_aide = WC->is_aide;
425         else
426                 WC->is_room_aide = (char) extract_int(&buf[4], 8);
427
428         remove_march(WC->wc_roomname);
429         if (!strcasecmp(gname, "_BASEROOM_"))
430                 remove_march(gname);
431
432         /* Display the room banner */
433         if (display_name) {
434                 embed_room_banner(buf);
435                 wDumpContent(1);
436         }
437         strcpy(WC->wc_roomname, WC->wc_roomname);
438 }
439
440
441 /*
442  * Locate the room on the march list which we most want to go to.  Each room
443  * is measured given a "weight" of preference based on various factors.
444  */
445 char *pop_march(int desired_floor)
446 {
447         static char TheRoom[64];
448         int TheFloor = 0;
449         int TheOrder = 32767;
450         int TheWeight = 0;
451         int weight;
452         struct march *mptr = NULL;
453
454         strcpy(TheRoom, "_BASEROOM_");
455         if (WC->march == NULL)
456                 return (TheRoom);
457
458         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
459                 weight = 0;
460                 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
461                         weight = weight + 10000;
462                 if (mptr->march_floor == desired_floor)
463                         weight = weight + 5000;
464
465                 weight = weight + ((128 - (mptr->march_floor)) * 128);
466                 weight = weight + (128 - (mptr->march_order));
467
468                 if (weight > TheWeight) {
469                         TheWeight = weight;
470                         strcpy(TheRoom, mptr->march_name);
471                         TheFloor = mptr->march_floor;
472                         TheOrder = mptr->march_order;
473                 }
474         }
475         return (TheRoom);
476 }
477
478
479
480 /* Goto next room having unread messages.
481  * We want to skip over rooms that the user has already been to, and take the
482  * user back to the lobby when done.  The room we end up in is placed in
483  * newroom - which is set to 0 (the lobby) initially.
484  * We start the search in the current room rather than the beginning to prevent
485  * two or more concurrent users from dragging each other back to the same room.
486  */
487 void gotonext(void)
488 {
489         char buf[SIZ];
490         struct march *mptr, *mptr2;
491         char next_room[32];
492
493         /* First check to see if the march-mode list is already allocated.
494          * If it is, pop the first room off the list and go there.
495          */
496
497         if (WC->march == NULL) {
498                 serv_puts("LKRN");
499                 serv_gets(buf);
500                 if (buf[0] == '1')
501                         while (serv_gets(buf), strcmp(buf, "000")) {
502                                 mptr = (struct march *) malloc(sizeof(struct march));
503                                 mptr->next = NULL;
504                                 extract(mptr->march_name, buf, 0);
505                                 mptr->march_floor = extract_int(buf, 2);
506                                 mptr->march_order = extract_int(buf, 3);
507                                 if (WC->march == NULL) {
508                                         WC->march = mptr;
509                                 } else {
510                                         mptr2 = WC->march;
511                                         while (mptr2->next != NULL)
512                                                 mptr2 = mptr2->next;
513                                         mptr2->next = mptr;
514                                 }
515                         }
516 /* add _BASEROOM_ to the end of the march list, so the user will end up
517  * in the system base room (usually the Lobby>) at the end of the loop
518  */
519                 mptr = (struct march *) malloc(sizeof(struct march));
520                 mptr->next = NULL;
521                 strcpy(mptr->march_name, "_BASEROOM_");
522                 if (WC->march == NULL) {
523                         WC->march = mptr;
524                 } else {
525                         mptr2 = WC->march;
526                         while (mptr2->next != NULL)
527                                 mptr2 = mptr2->next;
528                         mptr2->next = mptr;
529                 }
530 /*
531  * ...and remove the room we're currently in, so a <G>oto doesn't make us
532  * walk around in circles
533  */
534                 remove_march(WC->wc_roomname);
535         }
536         if (WC->march != NULL) {
537                 strcpy(next_room, pop_march(-1));
538         } else {
539                 strcpy(next_room, "_BASEROOM_");
540         }
541
542
543         smart_goto(next_room);
544 }
545
546
547 void smart_goto(char *next_room) {
548         gotoroom(next_room, 0);
549         readloop("readnew");
550 }
551
552
553
554 /*
555  * mark all messages in current room as having been read
556  */
557 void slrp_highest(void)
558 {
559         char buf[SIZ];
560
561         /* set pointer */
562         serv_puts("SLRP HIGHEST");
563         serv_gets(buf);
564         if (buf[0] != '2') {
565                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
566                 return;
567         }
568 }
569
570
571 /*
572  * un-goto the previous room
573  */
574 void ungoto(void)
575 {
576         char buf[SIZ];
577
578         if (!strcmp(WC->ugname, "")) {
579                 smart_goto(WC->wc_roomname);
580                 return;
581         }
582         serv_printf("GOTO %s", WC->ugname);
583         serv_gets(buf);
584         if (buf[0] != '2') {
585                 smart_goto(WC->wc_roomname);
586                 return;
587         }
588         if (WC->uglsn >= 0L) {
589                 serv_printf("SLRP %ld", WC->uglsn);
590                 serv_gets(buf);
591         }
592         strcpy(buf, WC->ugname);
593         strcpy(WC->ugname, "");
594         smart_goto(buf);
595 }
596
597 /*
598  * display the form for editing a room
599  */
600 void display_editroom(void)
601 {
602         char buf[SIZ];
603         char cmd[SIZ];
604         char node[SIZ];
605         char er_name[20];
606         char er_password[10];
607         char er_dirname[15];
608         char er_roomaide[26];
609         unsigned er_flags;
610         int er_floor;
611         int i, j;
612         char *tab;
613         char *shared_with;
614         char *not_shared_with;
615
616         tab = bstr("tab");
617         if (strlen(tab) == 0) tab = "admin";
618
619         serv_puts("GETR");
620         serv_gets(buf);
621
622         if (buf[0] != '2') {
623                 display_error(&buf[4]);
624                 return;
625         }
626         extract(er_name, &buf[4], 0);
627         extract(er_password, &buf[4], 1);
628         extract(er_dirname, &buf[4], 2);
629         er_flags = extract_int(&buf[4], 3);
630         er_floor = extract_int(&buf[4], 4);
631
632         output_headers(1);
633
634         /* print the tabbed dialog */
635         wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
636
637         if (!strcmp(tab, "admin")) {
638                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
639         }
640         else {
641                 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
642         }
643         wprintf("Room administration");
644         if (!strcmp(tab, "admin")) {
645                 wprintf("</B></FONT></TD>\n");
646         }
647         else {
648                 wprintf("</A></TD>\n");
649         }
650
651         wprintf("<TD> </TD>\n");
652
653         if (!strcmp(tab, "config")) {
654                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
655         }
656         else {
657                 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
658         }
659         wprintf("Room configuration");
660         if (!strcmp(tab, "config")) {
661                 wprintf("</B></FONT></TD>\n");
662         }
663         else {
664                 wprintf("</A></TD>\n");
665         }
666
667         wprintf("<TD> </TD>\n");
668
669         if (!strcmp(tab, "sharing")) {
670                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
671         }
672         else {
673                 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
674         }
675         wprintf("Sharing");
676         if (!strcmp(tab, "sharing")) {
677                 wprintf("</B></FONT></TD>\n");
678         }
679         else {
680                 wprintf("</A></TD>\n");
681         }
682
683         wprintf("<TD> </TD>\n");
684
685         if (!strcmp(tab, "listserv")) {
686                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
687         }
688         else {
689                 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
690         }
691         wprintf("Mailing list service");
692         if (!strcmp(tab, "listserv")) {
693                 wprintf("</B></FONT></TD>\n");
694         }
695         else {
696                 wprintf("</A></TD>\n");
697         }
698
699         wprintf("<TD> </TD></TR></TABLE>\n");
700
701         /* end tabbed dialog */ 
702
703
704         if (!strcmp(tab, "admin")) {
705                 wprintf("<UL>"
706                         "<LI><A HREF=\"/confirm_delete_room\">\n"
707                         "Delete this room</A>\n"
708                         "<LI><A HREF=\"/display_editroompic\">\n"
709                         "Set or change the graphic for this room's banner</A>\n"
710                         "<LI><A HREF=\"/display_editinfo\">\n"
711                         "Edit this room's Info file</A>\n"
712                         "</UL>");
713         }
714
715         if (!strcmp(tab, "config")) {
716                 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
717         
718                 wprintf("<UL><LI>Name of room: ");
719                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
720         
721                 wprintf("<LI>Resides on floor: ");
722                 load_floorlist();
723                 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
724                 for (i = 0; i < 128; ++i)
725                         if (strlen(floorlist[i]) > 0) {
726                                 wprintf("<OPTION ");
727                                 if (i == er_floor)
728                                         wprintf("SELECTED ");
729                                 wprintf("VALUE=\"%d\">", i);
730                                 escputs(floorlist[i]);
731                                 wprintf("</OPTION>\n");
732                         }
733                 wprintf("</SELECT>\n");
734         
735                 wprintf("<LI>Type of room:<UL>\n");
736
737                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
738                 if ((er_flags & QR_PRIVATE) == 0)
739                 wprintf("CHECKED ");
740                 wprintf("> Public room\n");
741
742                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
743                 if ((er_flags & QR_PRIVATE) &&
744                     (er_flags & QR_GUESSNAME))
745                         wprintf("CHECKED ");
746                 wprintf("> Private - guess name\n");
747         
748                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
749                 if ((er_flags & QR_PRIVATE) &&
750                     (er_flags & QR_PASSWORDED))
751                         wprintf("CHECKED ");
752                 wprintf("> Private - require password:\n");
753                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
754         
755                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
756                 if ((er_flags & QR_PRIVATE)
757                     && ((er_flags & QR_GUESSNAME) == 0)
758                     && ((er_flags & QR_PASSWORDED) == 0))
759                         wprintf("CHECKED ");
760                 wprintf("> Private - invitation only\n");
761         
762                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
763                 wprintf("> If private, cause current users to forget room\n");
764         
765                 wprintf("</UL>\n");
766         
767                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
768                 if (er_flags & QR_PREFONLY)
769                         wprintf("CHECKED ");
770                 wprintf("> Preferred users only\n");
771         
772                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
773                 if (er_flags & QR_READONLY)
774                         wprintf("CHECKED ");
775                 wprintf("> Read-only room\n");
776         
777         /* directory stuff */
778                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
779                 if (er_flags & QR_DIRECTORY)
780                         wprintf("CHECKED ");
781                 wprintf("> File directory room\n");
782
783                 wprintf("<UL><LI>Directory name: ");
784                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
785
786                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
787                 if (er_flags & QR_UPLOAD)
788                         wprintf("CHECKED ");
789                 wprintf("> Uploading allowed\n");
790         
791                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
792                 if (er_flags & QR_DOWNLOAD)
793                         wprintf("CHECKED ");
794                 wprintf("> Downloading allowed\n");
795         
796                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
797                 if (er_flags & QR_VISDIR)
798                         wprintf("CHECKED ");
799                 wprintf("> Visible directory</UL>\n");
800         
801         /* end of directory stuff */
802         
803                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
804                 if (er_flags & QR_NETWORK)
805                         wprintf("CHECKED ");
806                 wprintf("> Network shared room\n");
807
808         /* start of anon options */
809         
810                 wprintf("<LI>Anonymous messages<UL>\n");
811         
812                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
813                 if (((er_flags & QR_ANONONLY) == 0)
814                     && ((er_flags & QR_ANONOPT) == 0))
815                         wprintf("CHECKED ");
816                 wprintf("> No anonymous messages\n");
817         
818                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
819                 if (er_flags & QR_ANONONLY)
820                         wprintf("CHECKED ");
821                 wprintf("> All messages are anonymous\n");
822         
823                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
824                 if (er_flags & QR_ANONOPT)
825                         wprintf("CHECKED ");
826                 wprintf("> Prompt user when entering messages</UL>\n");
827         
828         /* end of anon options */
829         
830                 wprintf("<LI>Room aide: \n");
831                 serv_puts("GETA");
832                 serv_gets(buf);
833                 if (buf[0] != '2') {
834                         wprintf("<EM>%s</EM>\n", &buf[4]);
835                 } else {
836                         extract(er_roomaide, &buf[4], 0);
837                         wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
838                 }
839         
840                 wprintf("</UL><CENTER>\n");
841                 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
842                 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
843                 wprintf("</CENTER>\n");
844         }
845
846
847         /* Sharing the room with other Citadel nodes... */
848         if (!strcmp(tab, "sharing")) {
849
850                 shared_with = strdup("");
851                 not_shared_with = strdup("");
852
853                 /* Learn the current configuration */
854                 serv_puts("CONF getsys|application/x-citadel-ignet-config");
855                 serv_gets(buf);
856                 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
857                         extract(node, buf, 0);
858                         not_shared_with = realloc(not_shared_with,
859                                         strlen(not_shared_with) + 32);
860                         strcat(not_shared_with, node);
861                         strcat(not_shared_with, "|");
862                 }
863
864                 serv_puts("GNET");
865                 serv_gets(buf);
866                 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
867                         extract(cmd, buf, 0);
868                         extract(node, buf, 1);
869                         if (!strcasecmp(cmd, "ignet_push_share")) {
870                                 shared_with = realloc(shared_with,
871                                                 strlen(shared_with) + 32);
872                                 strcat(shared_with, node);
873                                 strcat(shared_with, "|");
874                         }
875                 }
876
877                 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
878                         extract(node, shared_with, i);
879                         for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
880                                 extract(cmd, not_shared_with, j);
881                                 if (!strcasecmp(node, cmd)) {
882                                         remove_token(not_shared_with, j, '|');
883                                 }
884                         }
885                 }
886
887                 /* Display the stuff */
888                 wprintf("<CENTER><BR>"
889                         "<TABLE border=1 cellpadding=5><TR>"
890                         "<TD><B><I>Shared with</I></B></TD>"
891                         "<TD><B><I>Not shared with</I></B></TD></TR>\n"
892                         "<TR><TD>\n");
893
894                 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
895                         extract(node, shared_with, i);
896                         if (strlen(node) > 0) {
897                                 wprintf("%s ", node);
898                                 wprintf("<A HREF=\"/netedit&cmd=remove&line="
899                                         "ignet_push_share|");
900                                 urlescputs(node);
901                                 wprintf("&tab=sharing\">(unshare)</A><BR>");
902                         }
903                 }
904
905                 wprintf("</TD><TD>\n");
906
907                 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
908                         extract(node, not_shared_with, i);
909                         if (strlen(node) > 0) {
910                                 wprintf("%s ", node);
911                                 wprintf("<A HREF=\"/netedit&cmd=add&line="
912                                         "ignet_push_share|");
913                                 urlescputs(node);
914                                 wprintf("&tab=sharing\">(share)</A><BR>");
915                         }
916                 }
917
918                 wprintf("</TD></TR></TABLE><BR>\n"
919                         "<I><B>Reminder:</B> When sharing a room, "
920                         "it must be shared from both ends.  Adding a node to "
921                         "the 'shared' list sends messages out, but in order to"
922                         " receive messages, the other nodes must be configured"
923                         " to send messages out to your system as well.</I><BR>"
924                         "</CENTER>\n");
925
926         }
927
928         /* Mailing list management */
929         if (!strcmp(tab, "listserv")) {
930                 wprintf("<CENTER><I>Under construction</I></CENTER>\n");
931         }
932
933         wDumpContent(1);
934 }
935
936
937 /*
938  * save new parameters for a room
939  */
940 void editroom(void)
941 {
942         char buf[SIZ];
943         char er_name[20];
944         char er_password[10];
945         char er_dirname[15];
946         char er_roomaide[26];
947         int er_floor;
948         unsigned er_flags;
949         int bump;
950
951
952         if (strcmp(bstr("sc"), "OK")) {
953                 display_error("Cancelled.  Changes were not saved.");
954                 return;
955         }
956         serv_puts("GETR");
957         serv_gets(buf);
958
959         if (buf[0] != '2') {
960                 display_error(&buf[4]);
961                 return;
962         }
963         extract(er_name, &buf[4], 0);
964         extract(er_password, &buf[4], 1);
965         extract(er_dirname, &buf[4], 2);
966         er_flags = extract_int(&buf[4], 3);
967
968         strcpy(er_roomaide, bstr("er_roomaide"));
969         if (strlen(er_roomaide) == 0) {
970                 serv_puts("GETA");
971                 serv_gets(buf);
972                 if (buf[0] != '2') {
973                         strcpy(er_roomaide, "");
974                 } else {
975                         extract(er_roomaide, &buf[4], 0);
976                 }
977         }
978         strcpy(buf, bstr("er_name"));
979         buf[20] = 0;
980         if (strlen(buf) > 0)
981                 strcpy(er_name, buf);
982
983         strcpy(buf, bstr("er_password"));
984         buf[10] = 0;
985         if (strlen(buf) > 0)
986                 strcpy(er_password, buf);
987
988         strcpy(buf, bstr("er_dirname"));
989         buf[15] = 0;
990         if (strlen(buf) > 0)
991                 strcpy(er_dirname, buf);
992
993         strcpy(buf, bstr("type"));
994         er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
995
996         if (!strcmp(buf, "invonly")) {
997                 er_flags |= (QR_PRIVATE);
998         }
999         if (!strcmp(buf, "guessname")) {
1000                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1001         }
1002         if (!strcmp(buf, "passworded")) {
1003                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1004         }
1005         if (!strcmp(bstr("prefonly"), "yes")) {
1006                 er_flags |= QR_PREFONLY;
1007         } else {
1008                 er_flags &= ~QR_PREFONLY;
1009         }
1010
1011         if (!strcmp(bstr("readonly"), "yes")) {
1012                 er_flags |= QR_READONLY;
1013         } else {
1014                 er_flags &= ~QR_READONLY;
1015         }
1016
1017         if (!strcmp(bstr("network"), "yes")) {
1018                 er_flags |= QR_NETWORK;
1019         } else {
1020                 er_flags &= ~QR_NETWORK;
1021         }
1022
1023         if (!strcmp(bstr("directory"), "yes")) {
1024                 er_flags |= QR_DIRECTORY;
1025         } else {
1026                 er_flags &= ~QR_DIRECTORY;
1027         }
1028
1029         if (!strcmp(bstr("ulallowed"), "yes")) {
1030                 er_flags |= QR_UPLOAD;
1031         } else {
1032                 er_flags &= ~QR_UPLOAD;
1033         }
1034
1035         if (!strcmp(bstr("dlallowed"), "yes")) {
1036                 er_flags |= QR_DOWNLOAD;
1037         } else {
1038                 er_flags &= ~QR_DOWNLOAD;
1039         }
1040
1041         if (!strcmp(bstr("visdir"), "yes")) {
1042                 er_flags |= QR_VISDIR;
1043         } else {
1044                 er_flags &= ~QR_VISDIR;
1045         }
1046
1047         strcpy(buf, bstr("anon"));
1048
1049         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1050         if (!strcmp(buf, "anononly"))
1051                 er_flags |= QR_ANONONLY;
1052         if (!strcmp(buf, "anon2"))
1053                 er_flags |= QR_ANONOPT;
1054
1055         bump = 0;
1056         if (!strcmp(bstr("bump"), "yes"))
1057                 bump = 1;
1058
1059         er_floor = atoi(bstr("er_floor"));
1060
1061         sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1062              er_name, er_password, er_dirname, er_flags, bump, er_floor);
1063         serv_puts(buf);
1064         serv_gets(buf);
1065         if (buf[0] != '2') {
1066                 display_error(&buf[4]);
1067                 return;
1068         }
1069         gotoroom(er_name, 0);
1070
1071         if (strlen(er_roomaide) > 0) {
1072                 sprintf(buf, "SETA %s", er_roomaide);
1073                 serv_puts(buf);
1074                 serv_gets(buf);
1075                 if (buf[0] != '2') {
1076                         display_error(&buf[4]);
1077                         return;
1078                 }
1079         }
1080         smart_goto(er_name);
1081 }
1082
1083 /*
1084  * Invite, Kick, and show Who Knows a room
1085  */
1086 void display_whok(void)
1087 {
1088         char buf[SIZ], room[SIZ], username[SIZ];
1089
1090         serv_puts("GETR");
1091         serv_gets(buf);
1092
1093         if (buf[0] != '2') {
1094                 display_error(&buf[4]);
1095                 return;
1096         }
1097         extract(room, &buf[4], 0);
1098
1099         strcpy(username, bstr("username"));
1100
1101         output_headers(1);
1102
1103         if(!strcmp(bstr("sc"), "Kick")) {
1104                 sprintf(buf, "KICK %s", username);
1105                 serv_puts(buf);
1106                 serv_gets(buf);
1107
1108                 if (buf[0] != '2') {
1109                         display_error(&buf[4]);
1110                         return;
1111                 } else {
1112                         wprintf("User %s kicked out of room %s.\n", 
1113                                 username, room);
1114                 }
1115         } else if(!strcmp(bstr("sc"), "Invite")) {
1116                 sprintf(buf, "INVT %s", username);
1117                 serv_puts(buf);
1118                 serv_gets(buf);
1119
1120                 if (buf[0] != '2') {
1121                         display_error(&buf[4]);
1122                         return;
1123                 } else {
1124                         wprintf("User %s invited to room %s.\n", 
1125                                 username, room);
1126                 }
1127         }
1128         
1129
1130         wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1131         wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1132         serv_puts("WHOK");
1133         serv_gets(buf);
1134         if (buf[0] == '1') {
1135                 while (serv_gets(buf), strcmp(buf, "000")) {
1136                         extract(username, buf, 0);
1137                         wprintf("<OPTION>");
1138                         escputs(username);
1139                         wprintf("\n");
1140                 }
1141         }
1142         wprintf("</SELECT>\n");
1143
1144         wprintf("<CENTER>\n");
1145         wprintf("<input type=submit name=sc value=\"Kick\">");
1146         wprintf("</CENTER>\n");
1147         wprintf("</FORM>\n");
1148         wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1149         wprintf("Invite: ");
1150         wprintf("<input type=text name=username>\n");
1151         wprintf("<input type=hidden name=sc value=\"Invite\">");
1152         wprintf("<input type=submit value=\"Invite\">");
1153         wDumpContent(1);
1154 }
1155
1156
1157
1158 /*
1159  * display the form for entering a new room
1160  */
1161 void display_entroom(void)
1162 {
1163         int i;
1164         char buf[SIZ];
1165
1166         serv_puts("CRE8 0");
1167         serv_gets(buf);
1168
1169         if (buf[0] != '2') {
1170                 display_error(&buf[4]);
1171                 return;
1172         }
1173         output_headers(1);
1174
1175         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1176         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1177         wprintf("<B>Enter (create) a new room</B>\n");
1178         wprintf("</FONT></TD></TR></TABLE>\n");
1179
1180         wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1181
1182         wprintf("<UL><LI>Name of room: ");
1183         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1184
1185         wprintf("<LI>Type of room:<UL>\n");
1186
1187         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1188         wprintf("CHECKED > Public room\n");
1189
1190         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1191         wprintf("> Private - guess name\n");
1192
1193         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1194         wprintf("> Private - require password:\n");
1195         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1196
1197         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1198         wprintf("> Private - invitation only\n");
1199         wprintf("</UL>\n");
1200
1201         wprintf("<LI>Resides on floor: ");
1202         load_floorlist(); 
1203         wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1204         for (i = 0; i < 128; ++i)
1205                 if (strlen(floorlist[i]) > 0) {
1206                         wprintf("<OPTION ");
1207                         wprintf("VALUE=\"%d\">", i);
1208                         escputs(floorlist[i]);
1209                         wprintf("</OPTION>\n");
1210                 }
1211         wprintf("</SELECT>\n");                
1212         wprintf("</UL>\n");
1213
1214
1215         wprintf("<CENTER>\n");
1216         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1217         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1218         wprintf("</CENTER>\n");
1219         wprintf("</FORM>\n<HR>");
1220         serv_printf("MESG roomaccess");
1221         serv_gets(buf);
1222         if (buf[0] == '1') {
1223                 fmout(NULL);
1224         }
1225         wDumpContent(1);
1226 }
1227
1228
1229
1230 /*
1231  * enter a new room
1232  */
1233 void entroom(void)
1234 {
1235         char buf[SIZ];
1236         char er_name[20];
1237         char er_type[20];
1238         char er_password[10];
1239         int er_floor;
1240         int er_num_type;
1241
1242         if (strcmp(bstr("sc"), "OK")) {
1243                 display_error("Cancelled.  No new room was created.");
1244                 return;
1245         }
1246         strcpy(er_name, bstr("er_name"));
1247         strcpy(er_type, bstr("type"));
1248         strcpy(er_password, bstr("er_password"));
1249         er_floor = atoi(bstr("er_floor"));
1250
1251         er_num_type = 0;
1252         if (!strcmp(er_type, "guessname"))
1253                 er_num_type = 1;
1254         if (!strcmp(er_type, "passworded"))
1255                 er_num_type = 2;
1256         if (!strcmp(er_type, "invonly"))
1257                 er_num_type = 3;
1258
1259         sprintf(buf, "CRE8 1|%s|%d|%s|%d", 
1260                 er_name, er_num_type, er_password, er_floor);
1261         serv_puts(buf);
1262         serv_gets(buf);
1263         if (buf[0] != '2') {
1264                 display_error(&buf[4]);
1265                 return;
1266         }
1267         smart_goto(er_name);
1268 }
1269
1270
1271 /*
1272  * display the screen to enter a private room
1273  */
1274 void display_private(char *rname, int req_pass)
1275 {
1276
1277         output_headers(1);
1278
1279         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1280         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1281         wprintf("<B>Goto a private room</B>\n");
1282         wprintf("</FONT></TD></TR></TABLE>\n");
1283
1284         wprintf("<CENTER>\n");
1285         wprintf("If you know the name of a hidden (guess-name) or\n");
1286         wprintf("passworded room, you can enter that room by typing\n");
1287         wprintf("its name below.  Once you gain access to a private\n");
1288         wprintf("room, it will appear in your regular room listings\n");
1289         wprintf("so you don't have to keep returning here.\n");
1290         wprintf("<BR><BR>");
1291
1292         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1293
1294         wprintf("<TABLE border><TR><TD>");
1295         wprintf("Enter room name:</TD><TD>");
1296         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1297
1298         if (req_pass) {
1299                 wprintf("</TD></TR><TR><TD>");
1300                 wprintf("Enter room password:</TD><TD>");
1301                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1302         }
1303         wprintf("</TD></TR></TABLE>\n");
1304
1305         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1306         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1307         wprintf("</FORM>\n");
1308         wDumpContent(1);
1309 }
1310
1311 /* 
1312  * goto a private room
1313  */
1314 void goto_private(void)
1315 {
1316         char hold_rm[32];
1317         char buf[SIZ];
1318
1319         if (strcasecmp(bstr("sc"), "OK")) {
1320                 display_main_menu();
1321                 return;
1322         }
1323         strcpy(hold_rm, WC->wc_roomname);
1324         strcpy(buf, "GOTO ");
1325         strcat(buf, bstr("gr_name"));
1326         strcat(buf, "|");
1327         strcat(buf, bstr("gr_pass"));
1328         serv_puts(buf);
1329         serv_gets(buf);
1330
1331         if (buf[0] == '2') {
1332                 smart_goto(bstr("gr_name"));
1333                 return;
1334         }
1335         if (!strncmp(buf, "540", 3)) {
1336                 display_private(bstr("gr_name"), 1);
1337                 return;
1338         }
1339         output_headers(1);
1340         wprintf("%s\n", &buf[4]);
1341         wDumpContent(1);
1342         return;
1343 }
1344
1345
1346 /*
1347  * display the screen to zap a room
1348  */
1349 void display_zap(void)
1350 {
1351         output_headers(1);
1352
1353         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1354         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1355         wprintf("<B>Zap (forget) the current room</B>\n");
1356         wprintf("</FONT></TD></TR></TABLE>\n");
1357
1358         wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1359         wprintf("disappear from your room list.  Is this what you wish ");
1360         wprintf("to do?<BR>\n");
1361
1362         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1363         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1364         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1365         wprintf("</FORM>\n");
1366         wDumpContent(1);
1367 }
1368
1369
1370 /* 
1371  * zap a room
1372  */
1373 void zap(void)
1374 {
1375         char buf[SIZ];
1376         char final_destination[SIZ];
1377
1378         /* If the forget-room routine fails for any reason, we fall back
1379          * to the current room; otherwise, we go to the Lobby
1380          */
1381         strcpy(final_destination, WC->wc_roomname);
1382
1383         if (!strcasecmp(bstr("sc"), "OK")) {
1384                 serv_printf("GOTO %s", WC->wc_roomname);
1385                 serv_gets(buf);
1386                 if (buf[0] != '2') {
1387                         /* ExpressMessageCat(&buf[4]);   FIXME    */
1388                 } else {
1389                         serv_puts("FORG");
1390                         serv_gets(buf);
1391                         if (buf[0] != '2') {
1392                                 /* ExpressMessageCat(&buf[4]);  FIXME   */
1393                         } else {
1394                                 strcpy(final_destination, "_BASEROOM_");
1395                         }
1396                 }
1397         }
1398         smart_goto(final_destination);
1399 }
1400
1401
1402
1403
1404 /*
1405  * Confirm deletion of the current room
1406  */
1407 void confirm_delete_room(void)
1408 {
1409         char buf[SIZ];
1410
1411         serv_puts("KILL 0");
1412         serv_gets(buf);
1413         if (buf[0] != '2') {
1414                 display_error(&buf[4]);
1415                 return;
1416         }
1417         output_headers(1);
1418         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1419         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1420         wprintf("<B>Confirm deletion of room</B>\n");
1421         wprintf("</FONT></TD></TR></TABLE>\n");
1422
1423         wprintf("<CENTER>");
1424         wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1425
1426         wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1427         escputs(WC->wc_roomname);
1428         wprintf("</FONT>?<BR>\n");
1429
1430         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1431         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1432
1433         wprintf("</FORM></CENTER>\n");
1434         wDumpContent(1);
1435 }
1436
1437
1438 /*
1439  * Delete the current room
1440  */
1441 void delete_room(void)
1442 {
1443         char buf[SIZ];
1444         char sc[SIZ];
1445
1446         strcpy(sc, bstr("sc"));
1447
1448         if (strcasecmp(sc, "Delete")) {
1449                 display_error("Cancelled.  This room was not deleted.");
1450                 return;
1451         }
1452         serv_puts("KILL 1");
1453         serv_gets(buf);
1454         if (buf[0] != '2') {
1455                 display_error(&buf[4]);
1456         } else {
1457                 smart_goto("_BASEROOM_");
1458         }
1459 }
1460
1461
1462
1463 /*
1464  * Perform changes to a room's network configuration
1465  */
1466 void netedit(void) {
1467         FILE *fp;
1468         char buf[SIZ];
1469
1470         fp = tmpfile();
1471         if (fp == NULL) {
1472                 display_editroom();
1473                 return;
1474         }
1475
1476         serv_puts("GNET");
1477         serv_gets(buf);
1478         if (buf[0] != '1') {
1479                 fclose(fp);
1480                 display_editroom();
1481                 return;
1482         }
1483
1484         /* This loop works for add *or* remove.  Spiffy, eh? */
1485         while (serv_gets(buf), strcmp(buf, "000")) {
1486                 if (strcasecmp(buf, bstr("line"))) {
1487                         fprintf(fp, "%s\n", buf);
1488                 }
1489         }
1490
1491         rewind(fp);
1492         serv_puts("SNET");
1493         serv_gets(buf);
1494         if (buf[0] != '4') {
1495                 fclose(fp);
1496                 display_editroom();
1497                 return;
1498         }
1499
1500         while (fgets(buf, sizeof buf, fp) != NULL) {
1501                 buf[strlen(buf)-1] = 0;
1502                 serv_puts(buf);
1503         }
1504
1505         if (!strcasecmp(bstr("cmd"), "add")) {
1506                 serv_puts(bstr("line"));
1507         }
1508
1509         serv_puts("000");
1510         fclose(fp);
1511         display_editroom();
1512 }