10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
42 char floorlist[128][SIZ];
45 * load the list of floors
47 void load_floorlist(void)
52 for (a = 0; a < 128; ++a)
58 strcpy(floorlist[0], "Main Floor");
61 while (serv_gets(buf), strcmp(buf, "000")) {
62 extract(floorlist[extract_int(buf, 0)], buf, 1);
68 * remove a room from the march list
70 void remove_march(char *aaa)
72 struct march *mptr, *mptr2;
74 if (WC->march == NULL)
77 if (!strcasecmp(WC->march->march_name, aaa)) {
78 mptr = WC->march->next;
84 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
85 if (!strcasecmp(mptr->march_name, aaa)) {
86 mptr2->next = mptr->next;
99 void room_tree_list(struct roomlisting *rp)
108 room_tree_list(rp->lnext);
110 strcpy(rmname, rp->rlname);
113 wprintf("<A HREF=\"/dotgoto&room=");
118 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
120 else if (f & QR_DIRECTORY)
122 else if (f & QR_NETWORK)
126 wprintf("</A><TT> </TT>\n");
128 room_tree_list(rp->rnext);
134 * Room ordering stuff (compare first by floor, then by order)
136 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
138 if ((r1 == NULL) && (r2 == NULL))
144 if (r1->rlfloor < r2->rlfloor)
146 if (r1->rlfloor > r2->rlfloor)
148 if (r1->rlorder < r2->rlorder)
150 if (r1->rlorder > r2->rlorder)
157 * Common code for all room listings
159 void listrms(char *variety)
164 struct roomlisting *rl = NULL;
165 struct roomlisting *rp;
166 struct roomlisting *rs;
169 /* Ask the server for a room list */
176 while (serv_gets(buf), strcmp(buf, "000")) {
178 rp = malloc(sizeof(struct roomlisting));
179 extract(rp->rlname, buf, 0);
180 rp->rlflags = extract_int(buf, 1);
181 rp->rlfloor = extract_int(buf, 2);
182 rp->rlorder = extract_int(buf, 3);
191 if (rordercmp(rp, rs) < 0) {
192 if (rs->lnext == NULL) {
199 if (rs->rnext == NULL) {
211 /* If no rooms were listed, print an nbsp to make the cell
212 * borders show up anyway.
214 if (num_rooms == 0) wprintf(" ");
219 * list all rooms by floor (only should get called from knrooms() because
220 * that's where output_headers() is called from)
222 void tabular_room_list(void)
227 wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
228 wprintf("<TH>Rooms with new messages</TH>");
229 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
231 for (a = 0; a < 128; ++a)
232 if (floorlist[a][0] != 0) {
234 /* Floor name column */
237 serv_printf("OIMG _floorpic_|%d", a);
242 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
243 a, &floorlist[a][0]);
245 escputs(&floorlist[a][0]);
250 /* Rooms with new messages column */
252 sprintf(buf, "LKRN %d", a);
254 wprintf("</TD>\n<TD>");
256 /* Rooms with old messages column */
257 sprintf(buf, "LKRO %d", a);
259 wprintf("</TD></TR>\n");
261 wprintf("</TABLE>\n");
274 * list all forgotten rooms
276 void zapped_list(void)
279 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
280 wprintf("<SPAN CLASS=\"titlebar\">Zapped (forgotten) rooms</SPAN>\n");
281 wprintf("</TD></TR></TABLE><BR>\n");
283 wprintf("<BR><BR>\n");
284 wprintf("Click on any room to un-zap it and goto that room.\n");
290 * read this room's info file (set v to 1 for verbose mode)
306 /* Display room graphic. The server doesn't actually
307 * need the room name, but we supply it in order to
308 * keep the browser from using a cached graphic from
311 void embed_room_graphic(void) {
314 serv_puts("OIMG _roompic_");
317 wprintf("<TD BGCOLOR=\"#444455\">");
318 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
319 urlescputs(WC->wc_roomname);
328 /* Let the user know if new mail has arrived
330 void embed_newmail_button(void) {
331 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
333 "<A HREF=\"/dotgoto?room=_MAIL_\">"
334 "<IMG SRC=\"/static/mail.gif\" border=0 "
335 "ALT=\"You have new mail\">"
336 "<BR><SPAN CLASS=\"youhavemail\">"
337 "%d new mail</SPAN></A>", WC->new_mail);
338 WC->remember_new_mail = WC->new_mail;
345 * Display the current view and offer an option to change it
347 void embed_view_o_matic(void) {
350 wprintf("<FORM NAME=\"viewomatic\">\n"
351 "<SELECT NAME=\"newview\" SIZE=\"1\" "
352 "OnChange=\"location.href=viewomatic.newview.options"
353 "[selectedIndex].value\">\n");
355 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
357 * Only offer the views that make sense, given the default
358 * view for the room. For example, don't offer a Calendar
359 * view in a non-Calendar room.
363 || (i == WC->wc_default_view)
364 || ( (i == 0) && (WC->wc_default_view == 1) )
365 || ( (i == 1) && (WC->wc_default_view == 0) )
368 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
369 ((i == WC->wc_view) ? "SELECTED" : ""),
371 escputs(viewdefs[i]);
372 wprintf("</OPTION>\n");
375 wprintf("</SELECT></FORM>\n");
380 void embed_room_banner(char *got) {
383 /* We need to have the information returned by a GOTO server command.
384 * If it isn't supplied, we fake it by issuing our own GOTO.
387 serv_printf("GOTO %s", WC->wc_roomname);
392 /* If the user happens to select the "make this my start page" link,
393 * we want it to remember the URL as a "/dotskip" one instead of
394 * a "skip" or "gotonext" or something like that.
396 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
399 /* Check for new mail. */
400 WC->new_mail = extract_int(&got[4], 9);
401 WC->wc_view = extract_int(&got[4], 11);
403 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
404 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
405 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
406 svcallback("ROOMPIC", embed_room_graphic);
407 svcallback("ROOMINFO", readinfo);
408 svcallback("YOUHAVEMAIL", embed_newmail_button);
409 svcallback("VIEWOMATIC", embed_view_o_matic);
410 svcallback("START", offer_start_page);
412 do_template("roombanner");
413 clear_local_substs();
421 * generic routine to take the session to a new room
423 * display_name values: 0 = goto only
424 * 1 = goto and display
427 void gotoroom(char *gname, int display_name)
430 static long ls = (-1L);
435 wprintf("Pragma: no-cache\n");
436 wprintf("Cache-Control: no-store\n");
438 wprintf("<HTML><HEAD>\n"
439 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
440 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
441 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
442 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
444 do_template("background");
446 if (display_name != 2) {
447 /* store ungoto information */
448 strcpy(WC->ugname, WC->wc_roomname);
451 /* move to the new room */
452 serv_printf("GOTO %s", gname);
455 serv_puts("GOTO _BASEROOM_");
460 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
465 extract(WC->wc_roomname, &buf[4], 0);
466 WC->room_flags = extract_int(&buf[4], 4);
467 /* highest_msg_read = extract_int(&buf[4],6);
468 maxmsgnum = extract_int(&buf[4],5);
469 is_mail = (char) extract_int(&buf[4],7); */
470 ls = extract_long(&buf[4], 6);
473 WC->is_room_aide = WC->is_aide;
475 WC->is_room_aide = (char) extract_int(&buf[4], 8);
477 remove_march(WC->wc_roomname);
478 if (!strcasecmp(gname, "_BASEROOM_"))
481 /* Display the room banner */
483 embed_room_banner(buf);
486 strcpy(WC->wc_roomname, WC->wc_roomname);
487 WC->wc_view = extract_int(&buf[4], 11);
488 WC->wc_default_view = extract_int(&buf[4], 12);
493 * Locate the room on the march list which we most want to go to. Each room
494 * is measured given a "weight" of preference based on various factors.
496 char *pop_march(int desired_floor)
498 static char TheRoom[128];
500 int TheOrder = 32767;
503 struct march *mptr = NULL;
505 strcpy(TheRoom, "_BASEROOM_");
506 if (WC->march == NULL)
509 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
511 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
512 weight = weight + 10000;
513 if (mptr->march_floor == desired_floor)
514 weight = weight + 5000;
516 weight = weight + ((128 - (mptr->march_floor)) * 128);
517 weight = weight + (128 - (mptr->march_order));
519 if (weight > TheWeight) {
521 strcpy(TheRoom, mptr->march_name);
522 TheFloor = mptr->march_floor;
523 TheOrder = mptr->march_order;
531 /* Goto next room having unread messages.
532 * We want to skip over rooms that the user has already been to, and take the
533 * user back to the lobby when done. The room we end up in is placed in
534 * newroom - which is set to 0 (the lobby) initially.
535 * We start the search in the current room rather than the beginning to prevent
536 * two or more concurrent users from dragging each other back to the same room.
541 struct march *mptr, *mptr2;
544 /* First check to see if the march-mode list is already allocated.
545 * If it is, pop the first room off the list and go there.
548 if (WC->march == NULL) {
552 while (serv_gets(buf), strcmp(buf, "000")) {
553 mptr = (struct march *) malloc(sizeof(struct march));
555 extract(mptr->march_name, buf, 0);
556 mptr->march_floor = extract_int(buf, 2);
557 mptr->march_order = extract_int(buf, 3);
558 if (WC->march == NULL) {
562 while (mptr2->next != NULL)
567 /* add _BASEROOM_ to the end of the march list, so the user will end up
568 * in the system base room (usually the Lobby>) at the end of the loop
570 mptr = (struct march *) malloc(sizeof(struct march));
572 strcpy(mptr->march_name, "_BASEROOM_");
573 if (WC->march == NULL) {
577 while (mptr2->next != NULL)
582 * ...and remove the room we're currently in, so a <G>oto doesn't make us
583 * walk around in circles
585 remove_march(WC->wc_roomname);
587 if (WC->march != NULL) {
588 strcpy(next_room, pop_march(-1));
590 strcpy(next_room, "_BASEROOM_");
594 smart_goto(next_room);
598 void smart_goto(char *next_room) {
599 gotoroom(next_room, 0);
606 * mark all messages in current room as having been read
608 void slrp_highest(void)
613 serv_puts("SLRP HIGHEST");
616 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
623 * un-goto the previous room
629 if (!strcmp(WC->ugname, "")) {
630 smart_goto(WC->wc_roomname);
633 serv_printf("GOTO %s", WC->ugname);
636 smart_goto(WC->wc_roomname);
639 if (WC->uglsn >= 0L) {
640 serv_printf("SLRP %ld", WC->uglsn);
643 strcpy(buf, WC->ugname);
644 strcpy(WC->ugname, "");
653 * Set/clear/read the "self-service list subscribe" flag for a room
655 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
656 * Always returns the new value.
659 int self_service(int newval) {
660 int current_value = 0;
666 int flags, floor, order, view, flags2;
670 if (buf[0] != '2') return(0);
672 extract(name, &buf[4], 0);
673 extract(password, &buf[4], 1);
674 extract(dirname, &buf[4], 2);
675 flags = extract_int(&buf[4], 3);
676 floor = extract_int(&buf[4], 4);
677 order = extract_int(&buf[4], 5);
678 view = extract_int(&buf[4], 6);
679 flags2 = extract_int(&buf[4], 7);
681 if (flags2 & QR2_SELFLIST) {
689 flags2 = flags2 | QR2_SELFLIST;
691 else if (newval == 0) {
692 flags2 = flags2 & ~QR2_SELFLIST;
695 return(current_value);
698 if (newval != current_value) {
699 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
700 name, password, dirname, flags,
701 floor, order, view, flags2);
715 * display the form for editing a room
717 void display_editroom(void)
724 char er_password[10];
726 char er_roomaide[26];
732 char *not_shared_with;
735 if (strlen(tab) == 0) tab = "admin";
741 display_error(&buf[4]);
744 extract(er_name, &buf[4], 0);
745 extract(er_password, &buf[4], 1);
746 extract(er_dirname, &buf[4], 2);
747 er_flags = extract_int(&buf[4], 3);
748 er_floor = extract_int(&buf[4], 4);
752 /* print the tabbed dialog */
753 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
754 "<TR ALIGN=CENTER BGCOLOR=\"#FFFFFF\">"
755 "<TD> </TD>\n");
757 if (!strcmp(tab, "admin")) {
758 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
761 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=admin\">");
763 wprintf("Room administration");
764 if (!strcmp(tab, "admin")) {
765 wprintf("</SPAN></TD>\n");
768 wprintf("</A></TD>\n");
771 wprintf("<TD> </TD>\n");
773 if (!strcmp(tab, "config")) {
774 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
777 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=config\">");
779 wprintf("Room configuration");
780 if (!strcmp(tab, "config")) {
781 wprintf("</SPAN></TD>\n");
784 wprintf("</A></TD>\n");
787 wprintf("<TD> </TD>\n");
789 if (!strcmp(tab, "sharing")) {
790 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
793 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=sharing\">");
796 if (!strcmp(tab, "sharing")) {
797 wprintf("</SPAN></TD>\n");
800 wprintf("</A></TD>\n");
803 wprintf("<TD> </TD>\n");
805 if (!strcmp(tab, "listserv")) {
806 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
809 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=listserv\">");
811 wprintf("Mailing list service");
812 if (!strcmp(tab, "listserv")) {
813 wprintf("</SPAN></TD>\n");
816 wprintf("</A></TD>\n");
819 wprintf("<TD> </TD></TR>"
820 "<TR><TD BGCOLOR=\"#000077\" COLSPAN=9 HEIGHT=5> </TD></TR>"
823 /* end tabbed dialog */
826 if (!strcmp(tab, "admin")) {
828 "<LI><A HREF=\"/confirm_delete_room\">\n"
829 "Delete this room</A>\n"
830 "<LI><A HREF=\"/display_editroompic\">\n"
831 "Set or change the graphic for this room's banner</A>\n"
832 "<LI><A HREF=\"/display_editinfo\">\n"
833 "Edit this room's Info file</A>\n"
837 if (!strcmp(tab, "config")) {
838 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
840 wprintf("<UL><LI>Name of room: ");
841 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
843 wprintf("<LI>Resides on floor: ");
845 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
846 for (i = 0; i < 128; ++i)
847 if (strlen(floorlist[i]) > 0) {
850 wprintf("SELECTED ");
851 wprintf("VALUE=\"%d\">", i);
852 escputs(floorlist[i]);
853 wprintf("</OPTION>\n");
855 wprintf("</SELECT>\n");
857 wprintf("<LI>Type of room:<UL>\n");
859 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
860 if ((er_flags & QR_PRIVATE) == 0)
862 wprintf("> Public room\n");
864 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
865 if ((er_flags & QR_PRIVATE) &&
866 (er_flags & QR_GUESSNAME))
868 wprintf("> Private - guess name\n");
870 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
871 if ((er_flags & QR_PRIVATE) &&
872 (er_flags & QR_PASSWORDED))
874 wprintf("> Private - require password:\n");
875 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
877 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
878 if ((er_flags & QR_PRIVATE)
879 && ((er_flags & QR_GUESSNAME) == 0)
880 && ((er_flags & QR_PASSWORDED) == 0))
882 wprintf("> Private - invitation only\n");
884 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
885 wprintf("> If private, cause current users to forget room\n");
889 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
890 if (er_flags & QR_PREFONLY)
892 wprintf("> Preferred users only\n");
894 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
895 if (er_flags & QR_READONLY)
897 wprintf("> Read-only room\n");
899 /* directory stuff */
900 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
901 if (er_flags & QR_DIRECTORY)
903 wprintf("> File directory room\n");
905 wprintf("<UL><LI>Directory name: ");
906 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
908 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
909 if (er_flags & QR_UPLOAD)
911 wprintf("> Uploading allowed\n");
913 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
914 if (er_flags & QR_DOWNLOAD)
916 wprintf("> Downloading allowed\n");
918 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
919 if (er_flags & QR_VISDIR)
921 wprintf("> Visible directory</UL>\n");
923 /* end of directory stuff */
925 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
926 if (er_flags & QR_NETWORK)
928 wprintf("> Network shared room\n");
930 /* start of anon options */
932 wprintf("<LI>Anonymous messages<UL>\n");
934 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
935 if (((er_flags & QR_ANONONLY) == 0)
936 && ((er_flags & QR_ANONOPT) == 0))
938 wprintf("> No anonymous messages\n");
940 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
941 if (er_flags & QR_ANONONLY)
943 wprintf("> All messages are anonymous\n");
945 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
946 if (er_flags & QR_ANONOPT)
948 wprintf("> Prompt user when entering messages</UL>\n");
950 /* end of anon options */
952 wprintf("<LI>Room aide: \n");
956 wprintf("<EM>%s</EM>\n", &buf[4]);
958 extract(er_roomaide, &buf[4], 0);
959 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
962 wprintf("</UL><CENTER>\n");
963 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
964 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
965 wprintf("</CENTER>\n");
969 /* Sharing the room with other Citadel nodes... */
970 if (!strcmp(tab, "sharing")) {
972 shared_with = strdup("");
973 not_shared_with = strdup("");
975 /* Learn the current configuration */
976 serv_puts("CONF getsys|application/x-citadel-ignet-config");
978 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
979 extract(node, buf, 0);
980 not_shared_with = realloc(not_shared_with,
981 strlen(not_shared_with) + 32);
982 strcat(not_shared_with, node);
983 strcat(not_shared_with, "|");
988 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
989 extract(cmd, buf, 0);
990 extract(node, buf, 1);
991 if (!strcasecmp(cmd, "ignet_push_share")) {
992 shared_with = realloc(shared_with,
993 strlen(shared_with) + 32);
994 strcat(shared_with, node);
995 strcat(shared_with, "|");
999 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1000 extract(node, shared_with, i);
1001 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
1002 extract(cmd, not_shared_with, j);
1003 if (!strcasecmp(node, cmd)) {
1004 remove_token(not_shared_with, j, '|');
1009 /* Display the stuff */
1010 wprintf("<CENTER><BR>"
1011 "<TABLE border=1 cellpadding=5><TR>"
1012 "<TD><B><I>Shared with</I></B></TD>"
1013 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1016 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1017 extract(node, shared_with, i);
1018 if (strlen(node) > 0) {
1019 wprintf("%s ", node);
1020 wprintf("<A HREF=\"/netedit&cmd=remove&line="
1021 "ignet_push_share|");
1023 wprintf("&tab=sharing\">(unshare)</A><BR>");
1027 wprintf("</TD><TD>\n");
1029 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
1030 extract(node, not_shared_with, i);
1031 if (strlen(node) > 0) {
1032 wprintf("%s ", node);
1033 wprintf("<A HREF=\"/netedit&cmd=add&line="
1034 "ignet_push_share|");
1036 wprintf("&tab=sharing\">(share)</A><BR>");
1040 wprintf("</TD></TR>"
1042 "<I><B>Reminder:</B> When sharing a room, "
1043 "it must be shared from both ends. Adding a node to "
1044 "the 'shared' list sends messages out, but in order to"
1045 " receive messages, the other nodes must be configured"
1046 " to send messages out to your system as well.</I><BR>"
1051 /* Mailing list management */
1052 if (!strcmp(tab, "listserv")) {
1054 wprintf("<BR><center>"
1055 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1056 "<TR><TD VALIGN=TOP>");
1058 wprintf("<i>The contents of this room are being "
1059 "mailed <b>as individual messages</b> "
1060 "to the following list recipients:"
1065 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1066 extract(cmd, buf, 0);
1067 if (!strcasecmp(cmd, "listrecp")) {
1068 extract(recp, buf, 1);
1071 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1074 wprintf("&tab=listserv\">(remove)</A><BR>");
1078 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1079 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1080 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1081 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1082 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1083 wprintf("</FORM>\n");
1085 wprintf("</TD><TD VALIGN=TOP>\n");
1087 wprintf("<i>The contents of this room are being "
1088 "mailed <b>in digest form</b> "
1089 "to the following list recipients:"
1094 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1095 extract(cmd, buf, 0);
1096 if (!strcasecmp(cmd, "digestrecp")) {
1097 extract(recp, buf, 1);
1100 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1103 wprintf("&tab=listserv\">(remove)</A><BR>");
1107 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1108 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1109 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1110 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1111 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1112 wprintf("</FORM>\n");
1114 wprintf("</TD></TR></TABLE><HR>\n");
1116 if (self_service(999) == 1) {
1117 wprintf("This room is configured to allow "
1118 "self-service subscribe/unsubscribe requests."
1119 " <A HREF=\"/toggle_self_service?newval=0&"
1121 "Click to disable.</A><BR>\n"
1122 "The URL for subscribe/unsubscribe is: "
1123 "<TT>http://%s/listsub</TT><BR>\n",
1128 wprintf("This room is <i>not</i> configured to allow "
1129 "self-service subscribe/unsubscribe requests."
1130 " <A HREF=\"/toggle_self_service?newval=1&"
1132 "Click to enable.</A><BR>\n"
1137 wprintf("</CENTER>\n");
1145 * Toggle self-service list subscription
1147 void toggle_self_service(void) {
1150 newval = atoi(bstr("newval"));
1151 self_service(newval);
1158 * save new parameters for a room
1164 char er_password[10];
1165 char er_dirname[15];
1166 char er_roomaide[26];
1172 if (strcmp(bstr("sc"), "OK")) {
1173 display_error("Cancelled. Changes were not saved.");
1179 if (buf[0] != '2') {
1180 display_error(&buf[4]);
1183 extract(er_name, &buf[4], 0);
1184 extract(er_password, &buf[4], 1);
1185 extract(er_dirname, &buf[4], 2);
1186 er_flags = extract_int(&buf[4], 3);
1188 strcpy(er_roomaide, bstr("er_roomaide"));
1189 if (strlen(er_roomaide) == 0) {
1192 if (buf[0] != '2') {
1193 strcpy(er_roomaide, "");
1195 extract(er_roomaide, &buf[4], 0);
1198 strcpy(buf, bstr("er_name"));
1200 if (strlen(buf) > 0)
1201 strcpy(er_name, buf);
1203 strcpy(buf, bstr("er_password"));
1205 if (strlen(buf) > 0)
1206 strcpy(er_password, buf);
1208 strcpy(buf, bstr("er_dirname"));
1210 if (strlen(buf) > 0)
1211 strcpy(er_dirname, buf);
1213 strcpy(buf, bstr("type"));
1214 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1216 if (!strcmp(buf, "invonly")) {
1217 er_flags |= (QR_PRIVATE);
1219 if (!strcmp(buf, "guessname")) {
1220 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1222 if (!strcmp(buf, "passworded")) {
1223 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1225 if (!strcmp(bstr("prefonly"), "yes")) {
1226 er_flags |= QR_PREFONLY;
1228 er_flags &= ~QR_PREFONLY;
1231 if (!strcmp(bstr("readonly"), "yes")) {
1232 er_flags |= QR_READONLY;
1234 er_flags &= ~QR_READONLY;
1237 if (!strcmp(bstr("network"), "yes")) {
1238 er_flags |= QR_NETWORK;
1240 er_flags &= ~QR_NETWORK;
1243 if (!strcmp(bstr("directory"), "yes")) {
1244 er_flags |= QR_DIRECTORY;
1246 er_flags &= ~QR_DIRECTORY;
1249 if (!strcmp(bstr("ulallowed"), "yes")) {
1250 er_flags |= QR_UPLOAD;
1252 er_flags &= ~QR_UPLOAD;
1255 if (!strcmp(bstr("dlallowed"), "yes")) {
1256 er_flags |= QR_DOWNLOAD;
1258 er_flags &= ~QR_DOWNLOAD;
1261 if (!strcmp(bstr("visdir"), "yes")) {
1262 er_flags |= QR_VISDIR;
1264 er_flags &= ~QR_VISDIR;
1267 strcpy(buf, bstr("anon"));
1269 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1270 if (!strcmp(buf, "anononly"))
1271 er_flags |= QR_ANONONLY;
1272 if (!strcmp(buf, "anon2"))
1273 er_flags |= QR_ANONOPT;
1276 if (!strcmp(bstr("bump"), "yes"))
1279 er_floor = atoi(bstr("er_floor"));
1281 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1282 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1285 if (buf[0] != '2') {
1286 display_error(&buf[4]);
1289 gotoroom(er_name, 0);
1291 if (strlen(er_roomaide) > 0) {
1292 sprintf(buf, "SETA %s", er_roomaide);
1295 if (buf[0] != '2') {
1296 display_error(&buf[4]);
1300 smart_goto(er_name);
1304 * Invite, Kick, and show Who Knows a room
1306 void display_whok(void)
1308 char buf[SIZ], room[SIZ], username[SIZ];
1313 if (buf[0] != '2') {
1314 display_error(&buf[4]);
1317 extract(room, &buf[4], 0);
1319 strcpy(username, bstr("username"));
1323 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
1324 wprintf("<SPAN CLASS=\"titlebar\">Access control list for ");
1325 escputs(WC->wc_roomname);
1326 wprintf("</SPAN></TD></TR></TABLE>\n");
1328 if(!strcmp(bstr("sc"), "Kick")) {
1329 sprintf(buf, "KICK %s", username);
1333 if (buf[0] != '2') {
1334 display_error(&buf[4]);
1337 wprintf("<B><I>User %s kicked out of room %s.</I></B>\n",
1340 } else if(!strcmp(bstr("sc"), "Invite")) {
1341 sprintf(buf, "INVT %s", username);
1345 if (buf[0] != '2') {
1346 display_error(&buf[4]);
1349 wprintf("<B><I>User %s invited to room %s.</I></B>\n",
1356 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1357 "<TD>The users listed below have access to this room. "
1358 "To remove a user from the access list, select the user "
1359 "name from the list and click 'Kick'.<BR><BR>");
1361 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1362 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1365 if (buf[0] == '1') {
1366 while (serv_gets(buf), strcmp(buf, "000")) {
1367 extract(username, buf, 0);
1368 wprintf("<OPTION>");
1373 wprintf("</SELECT><BR>\n");
1375 wprintf("<input type=submit name=sc value=\"Kick\">");
1376 wprintf("</FORM></CENTER>\n");
1379 "To grant another user access to this room, enter the "
1380 "user name in the box below and click 'Invite'.<BR><BR>");
1382 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1383 wprintf("Invite: ");
1384 wprintf("<input type=text name=username><BR>\n"
1385 "<input type=hidden name=sc value=\"Invite\">"
1386 "<input type=submit value=\"Invite\">"
1387 "</FORM></CENTER>\n");
1389 wprintf("</TD></TR></TABLE>\n");
1396 * display the form for entering a new room
1398 void display_entroom(void)
1403 serv_puts("CRE8 0");
1406 if (buf[0] != '2') {
1407 display_error(&buf[4]);
1412 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>");
1413 wprintf("<SPAN CLASS=\"titlebar\">Enter (create) a new room</SPAN>\n");
1414 wprintf("</TD></TR></TABLE>\n");
1416 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1418 wprintf("<UL><LI>Name of room: ");
1419 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1421 wprintf("<LI>Type of room:<UL>\n");
1423 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1424 wprintf("CHECKED > Public room\n");
1426 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1427 wprintf("> Private - guess name\n");
1429 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1430 wprintf("> Private - require password:\n");
1431 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1433 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1434 wprintf("> Private - invitation only\n");
1437 wprintf("<LI>Resides on floor: ");
1439 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1440 for (i = 0; i < 128; ++i)
1441 if (strlen(floorlist[i]) > 0) {
1442 wprintf("<OPTION ");
1443 wprintf("VALUE=\"%d\">", i);
1444 escputs(floorlist[i]);
1445 wprintf("</OPTION>\n");
1447 wprintf("</SELECT>\n");
1451 wprintf("<CENTER>\n");
1452 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1453 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1454 wprintf("</CENTER>\n");
1455 wprintf("</FORM>\n<HR>");
1456 serv_printf("MESG roomaccess");
1458 if (buf[0] == '1') {
1474 char er_password[10];
1478 if (strcmp(bstr("sc"), "OK")) {
1479 display_error("Cancelled. No new room was created.");
1482 strcpy(er_name, bstr("er_name"));
1483 strcpy(er_type, bstr("type"));
1484 strcpy(er_password, bstr("er_password"));
1485 er_floor = atoi(bstr("er_floor"));
1488 if (!strcmp(er_type, "guessname"))
1490 if (!strcmp(er_type, "passworded"))
1492 if (!strcmp(er_type, "invonly"))
1495 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1496 er_name, er_num_type, er_password, er_floor);
1499 if (buf[0] != '2') {
1500 display_error(&buf[4]);
1503 smart_goto(er_name);
1508 * display the screen to enter a private room
1510 void display_private(char *rname, int req_pass)
1515 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1516 wprintf("<SPAN CLASS=\"titlebar\">Goto a private room</SPAN>\n");
1517 wprintf("</TD></TR></TABLE>\n");
1519 wprintf("<CENTER>\n");
1520 wprintf("If you know the name of a hidden (guess-name) or\n");
1521 wprintf("passworded room, you can enter that room by typing\n");
1522 wprintf("its name below. Once you gain access to a private\n");
1523 wprintf("room, it will appear in your regular room listings\n");
1524 wprintf("so you don't have to keep returning here.\n");
1525 wprintf("<BR><BR>");
1527 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1529 wprintf("<TABLE border><TR><TD>");
1530 wprintf("Enter room name:</TD><TD>");
1531 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1534 wprintf("</TD></TR><TR><TD>");
1535 wprintf("Enter room password:</TD><TD>");
1536 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1538 wprintf("</TD></TR></TABLE>\n");
1540 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1541 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1542 wprintf("</FORM>\n");
1547 * goto a private room
1549 void goto_private(void)
1554 if (strcasecmp(bstr("sc"), "OK")) {
1555 display_main_menu();
1558 strcpy(hold_rm, WC->wc_roomname);
1559 strcpy(buf, "GOTO ");
1560 strcat(buf, bstr("gr_name"));
1562 strcat(buf, bstr("gr_pass"));
1566 if (buf[0] == '2') {
1567 smart_goto(bstr("gr_name"));
1570 if (!strncmp(buf, "540", 3)) {
1571 display_private(bstr("gr_name"), 1);
1575 wprintf("%s\n", &buf[4]);
1582 * display the screen to zap a room
1584 void display_zap(void)
1588 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1589 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1590 wprintf("</TD></TR></TABLE>\n");
1592 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1593 wprintf("disappear from your room list. Is this what you wish ");
1594 wprintf("to do?<BR>\n");
1596 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1597 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1598 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1599 wprintf("</FORM>\n");
1610 char final_destination[SIZ];
1612 /* If the forget-room routine fails for any reason, we fall back
1613 * to the current room; otherwise, we go to the Lobby
1615 strcpy(final_destination, WC->wc_roomname);
1617 if (!strcasecmp(bstr("sc"), "OK")) {
1618 serv_printf("GOTO %s", WC->wc_roomname);
1620 if (buf[0] != '2') {
1621 /* ExpressMessageCat(&buf[4]); */
1625 if (buf[0] != '2') {
1626 /* ExpressMessageCat(&buf[4]); */
1628 strcpy(final_destination, "_BASEROOM_");
1632 smart_goto(final_destination);
1639 * Confirm deletion of the current room
1641 void confirm_delete_room(void)
1645 serv_puts("KILL 0");
1647 if (buf[0] != '2') {
1648 display_error(&buf[4]);
1652 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1653 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1654 wprintf("</TD></TR></TABLE>\n");
1656 wprintf("<CENTER>");
1657 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1659 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1660 escputs(WC->wc_roomname);
1661 wprintf("</FONT>?<BR>\n");
1663 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1664 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1666 wprintf("</FORM></CENTER>\n");
1672 * Delete the current room
1674 void delete_room(void)
1679 strcpy(sc, bstr("sc"));
1681 if (strcasecmp(sc, "Delete")) {
1682 display_error("Cancelled. This room was not deleted.");
1685 serv_puts("KILL 1");
1687 if (buf[0] != '2') {
1688 display_error(&buf[4]);
1690 smart_goto("_BASEROOM_");
1697 * Perform changes to a room's network configuration
1699 void netedit(void) {
1704 if (strlen(bstr("line"))==0) {
1709 strcpy(line, bstr("prefix"));
1710 strcat(line, bstr("line"));
1711 strcat(line, bstr("suffix"));
1721 if (buf[0] != '1') {
1727 /* This loop works for add *or* remove. Spiffy, eh? */
1728 while (serv_gets(buf), strcmp(buf, "000")) {
1729 if (strcasecmp(buf, line)) {
1730 fprintf(fp, "%s\n", buf);
1737 if (buf[0] != '4') {
1743 while (fgets(buf, sizeof buf, fp) != NULL) {
1744 buf[strlen(buf)-1] = 0;
1748 if (!strcasecmp(bstr("cmd"), "add")) {
1760 * Convert a room name to a folder-ish-looking name.
1762 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1767 * For mailboxes, just do it straight...
1770 sprintf(folder, "My folders|%s", room);
1774 * Otherwise, prefix the floor name as a "public folders" moniker
1777 sprintf(folder, "%s|%s", floorlist[floor], room);
1781 * Replace "\" characters with "|" for pseudo-folder-delimiting
1783 for (i=0; i<strlen(folder); ++i) {
1784 if (folder[i] == '\\') folder[i] = '|';
1795 * Change the view for this room
1797 void change_view(void) {
1801 view = atol(bstr("view"));
1803 serv_printf("VIEW %d", view);
1805 smart_goto(WC->wc_roomname);
1810 * One big expanded tree list view --- like a folder list
1812 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1814 int levels, oldlevels;
1820 for (i=0; i<max_folders; ++i) {
1822 levels = num_tokens(fold[i].name, '|');
1825 for (t=0; t<levels; ++t) wprintf(" ");
1826 if (fold[i].selectable) {
1827 wprintf("<A HREF=\"/dotgoto?room=");
1828 urlescputs(fold[i].room);
1834 if (fold[i].hasnewmsgs) wprintf("<B>");
1835 extract(buf, fold[i].name, levels-1);
1837 if (fold[i].hasnewmsgs) wprintf("</B>");
1838 if (fold[i].selectable) {
1844 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1845 wprintf(" (INBOX)");
1852 * Boxes and rooms and lists ... oh my!
1854 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1857 int levels, oldlevels;
1860 static int columns = 3;
1861 int boxes_per_column = 0;
1862 int current_column = 0;
1864 boxes_per_column = (num_floors / columns);
1865 if (boxes_per_column < 1) boxes_per_column = 1;
1867 /* Outer table (for columnization) */
1868 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1869 "<TR><TD VALIGN=TOP>");
1873 for (i=0; i<max_folders; ++i) {
1875 levels = num_tokens(fold[i].name, '|');
1877 if ((levels == 1) && (oldlevels == 2)) {
1880 do_template("endbox");
1883 if ((num_boxes % boxes_per_column) == 0) {
1885 if (current_column < columns) {
1886 wprintf("</TD><TD VALIGN=TOP>\n");
1893 /* Begin inner box */
1894 extract(buf, fold[i].name, levels-1);
1895 stresc(boxtitle, buf, 1);
1896 svprintf("BOXTITLE", WCS_STRING, boxtitle);
1897 do_template("beginbox");
1905 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
1906 if (fold[i].selectable) {
1907 wprintf("<A HREF=\"/dotgoto?room=");
1908 urlescputs(fold[i].room);
1914 if (fold[i].hasnewmsgs) wprintf("<B>");
1915 extract(buf, fold[i].name, levels-1);
1917 if (fold[i].hasnewmsgs) wprintf("</B>");
1918 if (fold[i].selectable) {
1924 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1925 wprintf(" (INBOX)");
1930 /* End the final inner box */
1931 do_template("endbox");
1933 wprintf("</TD></TR></TABLE>\n");
1938 * Show the room list. (only should get called by
1939 * knrooms() because that's where output_headers() is called from)
1942 void list_all_rooms_by_floor(char *viewpref) {
1945 struct folder *fold = NULL;
1947 int max_folders = 0;
1948 int alloc_folders = 0;
1952 int num_floors = 1; /* add an extra one for private folders */
1954 /* Start with the mailboxes */
1957 fold = malloc(sizeof(struct folder));
1958 memset(fold, 0, sizeof(struct folder));
1959 strcpy(fold[0].name, "My folders");
1960 fold[0].is_mailbox = 1;
1962 /* Then add floors */
1965 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1966 if (max_folders >= alloc_folders) {
1967 alloc_folders = max_folders + 100;
1968 fold = realloc(fold,
1969 alloc_folders * sizeof(struct folder));
1971 memset(&fold[max_folders], 0, sizeof(struct folder));
1972 extract(fold[max_folders].name, buf, 1);
1980 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1981 if (max_folders >= alloc_folders) {
1982 alloc_folders = max_folders + 100;
1983 fold = realloc(fold,
1984 alloc_folders * sizeof(struct folder));
1986 memset(&fold[max_folders], 0, sizeof(struct folder));
1987 extract(fold[max_folders].room, buf, 0);
1988 ra_flags = extract_int(buf, 5);
1989 flags = extract_int(buf, 1);
1990 fold[max_folders].floor = extract_int(buf, 2);
1991 fold[max_folders].hasnewmsgs =
1992 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
1993 if (flags & QR_MAILBOX) {
1994 fold[max_folders].is_mailbox = 1;
1996 room_to_folder(fold[max_folders].name,
1997 fold[max_folders].room,
1998 fold[max_folders].floor,
1999 fold[max_folders].is_mailbox);
2000 fold[max_folders].selectable = 1;
2004 /* Bubble-sort the folder list */
2005 for (i=0; i<max_folders; ++i) {
2006 for (j=0; j<(max_folders-1)-i; ++j) {
2007 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2008 swap = strcasecmp(fold[j].name, fold[j+1].name);
2011 if ( (fold[j+1].is_mailbox)
2012 && (!fold[j].is_mailbox)) {
2020 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2021 memcpy(&fold[j], &fold[j+1],
2022 sizeof(struct folder));
2023 memcpy(&fold[j+1], &ftmp,
2024 sizeof(struct folder));
2029 if (!strcasecmp(viewpref, "folders")) {
2030 do_folder_view(fold, max_folders, num_floors);
2033 do_rooms_view(fold, max_folders, num_floors);
2041 /* Do either a known rooms list or a folders list, depending on the
2045 char listviewpref[SIZ];
2050 /* Determine whether the user is trying to change views */
2051 if (bstr("view") != NULL) {
2052 if (strlen(bstr("view")) > 0) {
2053 set_preference("roomlistview", bstr("view"));
2057 get_preference("roomlistview", listviewpref);
2059 if ( (strcasecmp(listviewpref, "folders"))
2060 && (strcasecmp(listviewpref, "boxes")) ) {
2061 strcpy(listviewpref, "rooms");
2065 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>"
2066 "<SPAN CLASS=\"titlebar\">"
2068 if (!strcasecmp(listviewpref, "rooms")) {
2069 wprintf("Room list");
2071 if (!strcasecmp(listviewpref, "boxes")) {
2072 wprintf("Room list");
2074 if (!strcasecmp(listviewpref, "folders")) {
2075 wprintf("Folder list");
2077 wprintf("</SPAN></TD>\n");
2080 /* offer the ability to switch views */
2081 wprintf("<TD><FORM NAME=\"roomlistomatic\">\n"
2082 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2083 "OnChange=\"location.href=roomlistomatic.newview.options"
2084 "[selectedIndex].value\">\n");
2086 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2089 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2092 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2093 "View as folder list"
2095 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2098 wprintf("<OPTION %s VALUE=\"/knrooms&view=boxes\">"
2101 ( !strcasecmp(listviewpref, "boxes") ? "SELECTED" : "" )
2104 wprintf("</SELECT></FORM></TD><TD>\n");
2106 wprintf("</TD></TR></TABLE><BR>\n");
2108 /* Display the room list in the user's preferred format */
2109 if (!strcasecmp(listviewpref, "rooms")) {
2110 tabular_room_list();
2113 list_all_rooms_by_floor(listviewpref);