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 do_template("beginbox_nt");
228 wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
229 wprintf("<TH>Rooms with new messages</TH>");
230 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
232 for (a = 0; a < 128; ++a)
233 if (floorlist[a][0] != 0) {
235 /* Floor name column */
238 serv_printf("OIMG _floorpic_|%d", a);
243 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
244 a, &floorlist[a][0]);
246 escputs(&floorlist[a][0]);
251 /* Rooms with new messages column */
253 sprintf(buf, "LKRN %d", a);
255 wprintf("</TD>\n<TD>");
257 /* Rooms with old messages column */
258 sprintf(buf, "LKRO %d", a);
260 wprintf("</TD></TR>\n");
262 wprintf("</TABLE>\n");
263 do_template("endbox");
276 * list all forgotten rooms
278 void zapped_list(void)
282 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
283 do_template("beginbox");
287 wprintf("<BR><BR>\n");
288 wprintf("Click on any room to un-zap it and goto that room.\n");
289 do_template("endbox");
295 * read this room's info file (set v to 1 for verbose mode)
304 fmout(NULL, "CENTER");
311 /* Display room graphic. The server doesn't actually
312 * need the room name, but we supply it in order to
313 * keep the browser from using a cached graphic from
316 void embed_room_graphic(void) {
319 serv_puts("OIMG _roompic_");
322 wprintf("<TD BGCOLOR=\"#444455\">");
323 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
324 urlescputs(WC->wc_roomname);
333 /* Let the user know if new mail has arrived
335 void embed_newmail_button(void) {
336 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
338 "<A HREF=\"/dotgoto?room=_MAIL_\">"
339 "<IMG SRC=\"/static/mail.gif\" border=0 "
340 "ALT=\"You have new mail\">"
341 "<BR><SPAN CLASS=\"youhavemail\">"
342 "%d new mail</SPAN></A>", WC->new_mail);
343 WC->remember_new_mail = WC->new_mail;
350 * Display the current view and offer an option to change it
352 void embed_view_o_matic(void) {
355 wprintf("<FORM NAME=\"viewomatic\">\n"
356 "<SELECT NAME=\"newview\" SIZE=\"1\" "
357 "OnChange=\"location.href=viewomatic.newview.options"
358 "[selectedIndex].value\">\n");
360 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
362 * Only offer the views that make sense, given the default
363 * view for the room. For example, don't offer a Calendar
364 * view in a non-Calendar room.
368 || (i == WC->wc_default_view)
369 || ( (i == 0) && (WC->wc_default_view == 1) )
370 || ( (i == 1) && (WC->wc_default_view == 0) )
373 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
374 ((i == WC->wc_view) ? "SELECTED" : ""),
376 escputs(viewdefs[i]);
377 wprintf("</OPTION>\n");
380 wprintf("</SELECT></FORM>\n");
385 void embed_room_banner(char *got) {
388 /* We need to have the information returned by a GOTO server command.
389 * If it isn't supplied, we fake it by issuing our own GOTO.
392 serv_printf("GOTO %s", WC->wc_roomname);
397 /* If the user happens to select the "make this my start page" link,
398 * we want it to remember the URL as a "/dotskip" one instead of
399 * a "skip" or "gotonext" or something like that.
401 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
404 /* Check for new mail. */
405 WC->new_mail = extract_int(&got[4], 9);
406 WC->wc_view = extract_int(&got[4], 11);
408 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
409 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
410 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
411 svcallback("ROOMPIC", embed_room_graphic);
412 svcallback("ROOMINFO", readinfo);
413 svcallback("YOUHAVEMAIL", embed_newmail_button);
414 svcallback("VIEWOMATIC", embed_view_o_matic);
415 svcallback("START", offer_start_page);
417 do_template("roombanner");
418 clear_local_substs();
426 * generic routine to take the session to a new room
428 * display_name values: 0 = goto only
429 * 1 = goto and display
432 void gotoroom(char *gname, int display_name)
435 static long ls = (-1L);
440 wprintf("Pragma: no-cache\n");
441 wprintf("Cache-Control: no-store\n");
443 wprintf("<HTML><HEAD>\n"
444 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
445 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
446 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
447 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
449 do_template("background");
451 if (display_name != 2) {
452 /* store ungoto information */
453 strcpy(WC->ugname, WC->wc_roomname);
456 /* move to the new room */
457 serv_printf("GOTO %s", gname);
460 serv_puts("GOTO _BASEROOM_");
465 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
470 extract(WC->wc_roomname, &buf[4], 0);
471 WC->room_flags = extract_int(&buf[4], 4);
472 /* highest_msg_read = extract_int(&buf[4],6);
473 maxmsgnum = extract_int(&buf[4],5);
474 is_mail = (char) extract_int(&buf[4],7); */
475 ls = extract_long(&buf[4], 6);
478 WC->is_room_aide = WC->is_aide;
480 WC->is_room_aide = (char) extract_int(&buf[4], 8);
482 remove_march(WC->wc_roomname);
483 if (!strcasecmp(gname, "_BASEROOM_"))
486 /* Display the room banner */
488 embed_room_banner(buf);
491 strcpy(WC->wc_roomname, WC->wc_roomname);
492 WC->wc_view = extract_int(&buf[4], 11);
493 WC->wc_default_view = extract_int(&buf[4], 12);
498 * Locate the room on the march list which we most want to go to. Each room
499 * is measured given a "weight" of preference based on various factors.
501 char *pop_march(int desired_floor)
503 static char TheRoom[128];
505 int TheOrder = 32767;
508 struct march *mptr = NULL;
510 strcpy(TheRoom, "_BASEROOM_");
511 if (WC->march == NULL)
514 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
516 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
517 weight = weight + 10000;
518 if (mptr->march_floor == desired_floor)
519 weight = weight + 5000;
521 weight = weight + ((128 - (mptr->march_floor)) * 128);
522 weight = weight + (128 - (mptr->march_order));
524 if (weight > TheWeight) {
526 strcpy(TheRoom, mptr->march_name);
527 TheFloor = mptr->march_floor;
528 TheOrder = mptr->march_order;
536 /* Goto next room having unread messages.
537 * We want to skip over rooms that the user has already been to, and take the
538 * user back to the lobby when done. The room we end up in is placed in
539 * newroom - which is set to 0 (the lobby) initially.
540 * We start the search in the current room rather than the beginning to prevent
541 * two or more concurrent users from dragging each other back to the same room.
546 struct march *mptr, *mptr2;
549 /* First check to see if the march-mode list is already allocated.
550 * If it is, pop the first room off the list and go there.
553 if (WC->march == NULL) {
557 while (serv_gets(buf), strcmp(buf, "000")) {
558 mptr = (struct march *) malloc(sizeof(struct march));
560 extract(mptr->march_name, buf, 0);
561 mptr->march_floor = extract_int(buf, 2);
562 mptr->march_order = extract_int(buf, 3);
563 if (WC->march == NULL) {
567 while (mptr2->next != NULL)
572 /* add _BASEROOM_ to the end of the march list, so the user will end up
573 * in the system base room (usually the Lobby>) at the end of the loop
575 mptr = (struct march *) malloc(sizeof(struct march));
577 strcpy(mptr->march_name, "_BASEROOM_");
578 if (WC->march == NULL) {
582 while (mptr2->next != NULL)
587 * ...and remove the room we're currently in, so a <G>oto doesn't make us
588 * walk around in circles
590 remove_march(WC->wc_roomname);
592 if (WC->march != NULL) {
593 strcpy(next_room, pop_march(-1));
595 strcpy(next_room, "_BASEROOM_");
599 smart_goto(next_room);
603 void smart_goto(char *next_room) {
604 gotoroom(next_room, 0);
611 * mark all messages in current room as having been read
613 void slrp_highest(void)
618 serv_puts("SLRP HIGHEST");
621 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
628 * un-goto the previous room
634 if (!strcmp(WC->ugname, "")) {
635 smart_goto(WC->wc_roomname);
638 serv_printf("GOTO %s", WC->ugname);
641 smart_goto(WC->wc_roomname);
644 if (WC->uglsn >= 0L) {
645 serv_printf("SLRP %ld", WC->uglsn);
648 strcpy(buf, WC->ugname);
649 strcpy(WC->ugname, "");
658 * Set/clear/read the "self-service list subscribe" flag for a room
660 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
661 * Always returns the new value.
664 int self_service(int newval) {
665 int current_value = 0;
671 int flags, floor, order, view, flags2;
675 if (buf[0] != '2') return(0);
677 extract(name, &buf[4], 0);
678 extract(password, &buf[4], 1);
679 extract(dirname, &buf[4], 2);
680 flags = extract_int(&buf[4], 3);
681 floor = extract_int(&buf[4], 4);
682 order = extract_int(&buf[4], 5);
683 view = extract_int(&buf[4], 6);
684 flags2 = extract_int(&buf[4], 7);
686 if (flags2 & QR2_SELFLIST) {
694 flags2 = flags2 | QR2_SELFLIST;
696 else if (newval == 0) {
697 flags2 = flags2 & ~QR2_SELFLIST;
700 return(current_value);
703 if (newval != current_value) {
704 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
705 name, password, dirname, flags,
706 floor, order, view, flags2);
720 * display the form for editing a room
722 void display_editroom(void)
729 char er_password[10];
731 char er_roomaide[26];
737 char *not_shared_with;
740 if (strlen(tab) == 0) tab = "admin";
746 strcpy(WC->ImportantMessage, &buf[4]);
750 extract(er_name, &buf[4], 0);
751 extract(er_password, &buf[4], 1);
752 extract(er_dirname, &buf[4], 2);
753 er_flags = extract_int(&buf[4], 3);
754 er_floor = extract_int(&buf[4], 4);
758 /* print the tabbed dialog */
759 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
761 "<TD> </TD>\n");
763 if (!strcmp(tab, "admin")) {
764 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
767 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=admin\">");
769 wprintf("Room administration");
770 if (!strcmp(tab, "admin")) {
771 wprintf("</SPAN></TD>\n");
774 wprintf("</A></TD>\n");
777 wprintf("<TD> </TD>\n");
779 if (!strcmp(tab, "config")) {
780 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
783 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=config\">");
785 wprintf("Room configuration");
786 if (!strcmp(tab, "config")) {
787 wprintf("</SPAN></TD>\n");
790 wprintf("</A></TD>\n");
793 wprintf("<TD> </TD>\n");
795 if (!strcmp(tab, "sharing")) {
796 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
799 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=sharing\">");
802 if (!strcmp(tab, "sharing")) {
803 wprintf("</SPAN></TD>\n");
806 wprintf("</A></TD>\n");
809 wprintf("<TD> </TD>\n");
811 if (!strcmp(tab, "listserv")) {
812 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
815 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=listserv\">");
817 wprintf("Mailing list service");
818 if (!strcmp(tab, "listserv")) {
819 wprintf("</SPAN></TD>\n");
822 wprintf("</A></TD>\n");
825 wprintf("</TR></TABLE>\n");
826 /* end tabbed dialog */
828 /* begin content of whatever tab is open now */
829 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
832 if (!strcmp(tab, "admin")) {
834 "<LI><A HREF=\"/confirm_delete_room\">\n"
835 "Delete this room</A>\n"
836 "<LI><A HREF=\"/display_editroompic\">\n"
837 "Set or change the graphic for this room's banner</A>\n"
838 "<LI><A HREF=\"/display_editinfo\">\n"
839 "Edit this room's Info file</A>\n"
843 if (!strcmp(tab, "config")) {
844 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
846 wprintf("<UL><LI>Name of room: ");
847 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
849 wprintf("<LI>Resides on floor: ");
851 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
852 for (i = 0; i < 128; ++i)
853 if (strlen(floorlist[i]) > 0) {
856 wprintf("SELECTED ");
857 wprintf("VALUE=\"%d\">", i);
858 escputs(floorlist[i]);
859 wprintf("</OPTION>\n");
861 wprintf("</SELECT>\n");
863 wprintf("<LI>Type of room:<UL>\n");
865 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
866 if ((er_flags & QR_PRIVATE) == 0)
868 wprintf("> Public room\n");
870 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
871 if ((er_flags & QR_PRIVATE) &&
872 (er_flags & QR_GUESSNAME))
874 wprintf("> Private - guess name\n");
876 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
877 if ((er_flags & QR_PRIVATE) &&
878 (er_flags & QR_PASSWORDED))
880 wprintf("> Private - require password:\n");
881 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
883 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
884 if ((er_flags & QR_PRIVATE)
885 && ((er_flags & QR_GUESSNAME) == 0)
886 && ((er_flags & QR_PASSWORDED) == 0))
888 wprintf("> Private - invitation only\n");
890 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
891 wprintf("> If private, cause current users to forget room\n");
895 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
896 if (er_flags & QR_PREFONLY)
898 wprintf("> Preferred users only\n");
900 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
901 if (er_flags & QR_READONLY)
903 wprintf("> Read-only room\n");
905 /* directory stuff */
906 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
907 if (er_flags & QR_DIRECTORY)
909 wprintf("> File directory room\n");
911 wprintf("<UL><LI>Directory name: ");
912 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
914 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
915 if (er_flags & QR_UPLOAD)
917 wprintf("> Uploading allowed\n");
919 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
920 if (er_flags & QR_DOWNLOAD)
922 wprintf("> Downloading allowed\n");
924 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
925 if (er_flags & QR_VISDIR)
927 wprintf("> Visible directory</UL>\n");
929 /* end of directory stuff */
931 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
932 if (er_flags & QR_NETWORK)
934 wprintf("> Network shared room\n");
936 /* start of anon options */
938 wprintf("<LI>Anonymous messages<UL>\n");
940 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
941 if (((er_flags & QR_ANONONLY) == 0)
942 && ((er_flags & QR_ANONOPT) == 0))
944 wprintf("> No anonymous messages\n");
946 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
947 if (er_flags & QR_ANONONLY)
949 wprintf("> All messages are anonymous\n");
951 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
952 if (er_flags & QR_ANONOPT)
954 wprintf("> Prompt user when entering messages</UL>\n");
956 /* end of anon options */
958 wprintf("<LI>Room aide: \n");
962 wprintf("<EM>%s</EM>\n", &buf[4]);
964 extract(er_roomaide, &buf[4], 0);
965 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
968 wprintf("</UL><CENTER>\n");
969 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
970 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
971 wprintf("</CENTER>\n");
975 /* Sharing the room with other Citadel nodes... */
976 if (!strcmp(tab, "sharing")) {
978 shared_with = strdup("");
979 not_shared_with = strdup("");
981 /* Learn the current configuration */
982 serv_puts("CONF getsys|application/x-citadel-ignet-config");
984 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
985 extract(node, buf, 0);
986 not_shared_with = realloc(not_shared_with,
987 strlen(not_shared_with) + 32);
988 strcat(not_shared_with, node);
989 strcat(not_shared_with, "|");
994 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
995 extract(cmd, buf, 0);
996 extract(node, buf, 1);
997 if (!strcasecmp(cmd, "ignet_push_share")) {
998 shared_with = realloc(shared_with,
999 strlen(shared_with) + 32);
1000 strcat(shared_with, node);
1001 strcat(shared_with, "|");
1005 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1006 extract(node, shared_with, i);
1007 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
1008 extract(cmd, not_shared_with, j);
1009 if (!strcasecmp(node, cmd)) {
1010 remove_token(not_shared_with, j, '|');
1015 /* Display the stuff */
1016 wprintf("<CENTER><BR>"
1017 "<TABLE border=1 cellpadding=5><TR>"
1018 "<TD><B><I>Shared with</I></B></TD>"
1019 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1022 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1023 extract(node, shared_with, i);
1024 if (strlen(node) > 0) {
1025 wprintf("%s ", node);
1026 wprintf("<A HREF=\"/netedit&cmd=remove&line="
1027 "ignet_push_share|");
1029 wprintf("&tab=sharing\">(unshare)</A><BR>");
1033 wprintf("</TD><TD>\n");
1035 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
1036 extract(node, not_shared_with, i);
1037 if (strlen(node) > 0) {
1038 wprintf("%s ", node);
1039 wprintf("<A HREF=\"/netedit&cmd=add&line="
1040 "ignet_push_share|");
1042 wprintf("&tab=sharing\">(share)</A><BR>");
1046 wprintf("</TD></TR>"
1048 "<I><B>Reminder:</B> When sharing a room, "
1049 "it must be shared from both ends. Adding a node to "
1050 "the 'shared' list sends messages out, but in order to"
1051 " receive messages, the other nodes must be configured"
1052 " to send messages out to your system as well.</I><BR>"
1057 /* Mailing list management */
1058 if (!strcmp(tab, "listserv")) {
1060 wprintf("<BR><center>"
1061 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1062 "<TR><TD VALIGN=TOP>");
1064 wprintf("<i>The contents of this room are being "
1065 "mailed <b>as individual messages</b> "
1066 "to the following list recipients:"
1071 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1072 extract(cmd, buf, 0);
1073 if (!strcasecmp(cmd, "listrecp")) {
1074 extract(recp, buf, 1);
1077 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1080 wprintf("&tab=listserv\">(remove)</A><BR>");
1084 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1085 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1086 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1087 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1088 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1089 wprintf("</FORM>\n");
1091 wprintf("</TD><TD VALIGN=TOP>\n");
1093 wprintf("<i>The contents of this room are being "
1094 "mailed <b>in digest form</b> "
1095 "to the following list recipients:"
1100 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1101 extract(cmd, buf, 0);
1102 if (!strcasecmp(cmd, "digestrecp")) {
1103 extract(recp, buf, 1);
1106 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1109 wprintf("&tab=listserv\">(remove)</A><BR>");
1113 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1114 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1115 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1116 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1117 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1118 wprintf("</FORM>\n");
1120 wprintf("</TD></TR></TABLE><HR>\n");
1122 if (self_service(999) == 1) {
1123 wprintf("This room is configured to allow "
1124 "self-service subscribe/unsubscribe requests."
1125 " <A HREF=\"/toggle_self_service?newval=0&"
1127 "Click to disable.</A><BR>\n"
1128 "The URL for subscribe/unsubscribe is: "
1129 "<TT>http://%s/listsub</TT><BR>\n",
1134 wprintf("This room is <i>not</i> configured to allow "
1135 "self-service subscribe/unsubscribe requests."
1136 " <A HREF=\"/toggle_self_service?newval=1&"
1138 "Click to enable.</A><BR>\n"
1143 wprintf("</CENTER>\n");
1146 /* end content of whatever tab is open now */
1147 wprintf("</TD></TR></TABLE>\n");
1154 * Toggle self-service list subscription
1156 void toggle_self_service(void) {
1159 newval = atoi(bstr("newval"));
1160 self_service(newval);
1167 * save new parameters for a room
1173 char er_password[10];
1174 char er_dirname[15];
1175 char er_roomaide[26];
1181 if (strcmp(bstr("sc"), "OK")) {
1182 strcpy(WC->ImportantMessage,
1183 "Cancelled. Changes were not saved.");
1184 display_main_menu();
1190 if (buf[0] != '2') {
1191 strcpy(WC->ImportantMessage, &buf[4]);
1192 display_main_menu();
1195 extract(er_name, &buf[4], 0);
1196 extract(er_password, &buf[4], 1);
1197 extract(er_dirname, &buf[4], 2);
1198 er_flags = extract_int(&buf[4], 3);
1200 strcpy(er_roomaide, bstr("er_roomaide"));
1201 if (strlen(er_roomaide) == 0) {
1204 if (buf[0] != '2') {
1205 strcpy(er_roomaide, "");
1207 extract(er_roomaide, &buf[4], 0);
1210 strcpy(buf, bstr("er_name"));
1212 if (strlen(buf) > 0)
1213 strcpy(er_name, buf);
1215 strcpy(buf, bstr("er_password"));
1217 if (strlen(buf) > 0)
1218 strcpy(er_password, buf);
1220 strcpy(buf, bstr("er_dirname"));
1222 if (strlen(buf) > 0)
1223 strcpy(er_dirname, buf);
1225 strcpy(buf, bstr("type"));
1226 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1228 if (!strcmp(buf, "invonly")) {
1229 er_flags |= (QR_PRIVATE);
1231 if (!strcmp(buf, "guessname")) {
1232 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1234 if (!strcmp(buf, "passworded")) {
1235 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1237 if (!strcmp(bstr("prefonly"), "yes")) {
1238 er_flags |= QR_PREFONLY;
1240 er_flags &= ~QR_PREFONLY;
1243 if (!strcmp(bstr("readonly"), "yes")) {
1244 er_flags |= QR_READONLY;
1246 er_flags &= ~QR_READONLY;
1249 if (!strcmp(bstr("network"), "yes")) {
1250 er_flags |= QR_NETWORK;
1252 er_flags &= ~QR_NETWORK;
1255 if (!strcmp(bstr("directory"), "yes")) {
1256 er_flags |= QR_DIRECTORY;
1258 er_flags &= ~QR_DIRECTORY;
1261 if (!strcmp(bstr("ulallowed"), "yes")) {
1262 er_flags |= QR_UPLOAD;
1264 er_flags &= ~QR_UPLOAD;
1267 if (!strcmp(bstr("dlallowed"), "yes")) {
1268 er_flags |= QR_DOWNLOAD;
1270 er_flags &= ~QR_DOWNLOAD;
1273 if (!strcmp(bstr("visdir"), "yes")) {
1274 er_flags |= QR_VISDIR;
1276 er_flags &= ~QR_VISDIR;
1279 strcpy(buf, bstr("anon"));
1281 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1282 if (!strcmp(buf, "anononly"))
1283 er_flags |= QR_ANONONLY;
1284 if (!strcmp(buf, "anon2"))
1285 er_flags |= QR_ANONOPT;
1288 if (!strcmp(bstr("bump"), "yes"))
1291 er_floor = atoi(bstr("er_floor"));
1293 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1294 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1297 if (buf[0] != '2') {
1298 strcpy(WC->ImportantMessage, &buf[4]);
1299 display_main_menu();
1302 gotoroom(er_name, 0);
1304 if (strlen(er_roomaide) > 0) {
1305 sprintf(buf, "SETA %s", er_roomaide);
1308 if (buf[0] != '2') {
1309 strcpy(WC->ImportantMessage, &buf[4]);
1310 display_main_menu();
1314 smart_goto(er_name);
1318 * Invite, Kick, and show Who Knows a room
1320 void display_whok(void)
1322 char buf[SIZ], room[SIZ], username[SIZ];
1327 if (buf[0] != '2') {
1328 strcpy(WC->ImportantMessage, &buf[4]);
1329 display_main_menu();
1332 extract(room, &buf[4], 0);
1334 strcpy(username, bstr("username"));
1336 if(!strcmp(bstr("sc"), "Kick")) {
1337 sprintf(buf, "KICK %s", username);
1341 if (buf[0] != '2') {
1342 strcpy(WC->ImportantMessage, &buf[4]);
1344 sprintf(WC->ImportantMessage,
1345 "<B><I>User %s kicked out of room %s.</I></B>\n",
1348 } else if(!strcmp(bstr("sc"), "Invite")) {
1349 sprintf(buf, "INVT %s", username);
1353 if (buf[0] != '2') {
1354 strcpy(WC->ImportantMessage, &buf[4]);
1356 sprintf(WC->ImportantMessage,
1357 "<B><I>User %s invited to room %s.</I></B>\n",
1363 stresc(buf, WC->wc_roomname, 1);
1364 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1365 do_template("beginbox");
1367 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1368 "<TD>The users listed below have access to this room. "
1369 "To remove a user from the access list, select the user "
1370 "name from the list and click 'Kick'.<BR><BR>");
1372 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1373 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1376 if (buf[0] == '1') {
1377 while (serv_gets(buf), strcmp(buf, "000")) {
1378 extract(username, buf, 0);
1379 wprintf("<OPTION>");
1384 wprintf("</SELECT><BR>\n");
1386 wprintf("<input type=submit name=sc value=\"Kick\">");
1387 wprintf("</FORM></CENTER>\n");
1390 "To grant another user access to this room, enter the "
1391 "user name in the box below and click 'Invite'.<BR><BR>");
1393 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1394 wprintf("Invite: ");
1395 wprintf("<input type=text name=username><BR>\n"
1396 "<input type=hidden name=sc value=\"Invite\">"
1397 "<input type=submit value=\"Invite\">"
1398 "</FORM></CENTER>\n");
1400 wprintf("</TD></TR></TABLE>\n");
1401 do_template("endbox");
1408 * display the form for entering a new room
1410 void display_entroom(void)
1415 serv_puts("CRE8 0");
1418 if (buf[0] != '2') {
1419 strcpy(WC->ImportantMessage, &buf[4]);
1420 display_main_menu();
1424 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1425 do_template("beginbox");
1427 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1429 wprintf("<UL><LI>Name of room: ");
1430 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1432 wprintf("<LI>Type of room:<UL>\n");
1434 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1435 wprintf("CHECKED > Public room\n");
1437 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1438 wprintf("> Private - guess name\n");
1440 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1441 wprintf("> Private - require password:\n");
1442 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1444 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1445 wprintf("> Private - invitation only\n");
1447 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1448 wprintf("> Personal (mailbox for you only)\n");
1451 wprintf("<LI>Resides on floor: ");
1453 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1454 for (i = 0; i < 128; ++i)
1455 if (strlen(floorlist[i]) > 0) {
1456 wprintf("<OPTION ");
1457 wprintf("VALUE=\"%d\">", i);
1458 escputs(floorlist[i]);
1459 wprintf("</OPTION>\n");
1461 wprintf("</SELECT>\n");
1465 wprintf("<CENTER>\n");
1466 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1467 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1468 wprintf("</CENTER>\n");
1469 wprintf("</FORM>\n<HR>");
1470 serv_printf("MESG roomaccess");
1472 if (buf[0] == '1') {
1473 fmout(NULL, "CENTER");
1475 do_template("endbox");
1489 char er_password[10];
1493 if (strcmp(bstr("sc"), "OK")) {
1494 strcpy(WC->ImportantMessage,
1495 "Cancelled. No new room was created.");
1496 display_main_menu();
1499 strcpy(er_name, bstr("er_name"));
1500 strcpy(er_type, bstr("type"));
1501 strcpy(er_password, bstr("er_password"));
1502 er_floor = atoi(bstr("er_floor"));
1505 if (!strcmp(er_type, "guessname"))
1507 if (!strcmp(er_type, "passworded"))
1509 if (!strcmp(er_type, "invonly"))
1511 if (!strcmp(er_type, "personal"))
1514 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1515 er_name, er_num_type, er_password, er_floor);
1518 if (buf[0] != '2') {
1519 strcpy(WC->ImportantMessage, &buf[4]);
1520 display_main_menu();
1523 smart_goto(er_name);
1528 * display the screen to enter a private room
1530 void display_private(char *rname, int req_pass)
1535 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1536 do_template("beginbox");
1538 wprintf("<CENTER>\n");
1539 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1540 wprintf("passworded room, you can enter that room by typing\n");
1541 wprintf("its name below. Once you gain access to a private\n");
1542 wprintf("room, it will appear in your regular room listings\n");
1543 wprintf("so you don't have to keep returning here.\n");
1544 wprintf("<BR><BR>");
1546 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1548 wprintf("<table border=\"0\" cellspacing=\"5\" "
1549 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1551 "Enter room name:</TD><TD>"
1552 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1553 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1556 wprintf("</TD></TR><TR><TD>");
1557 wprintf("Enter room password:</TD><TD>");
1558 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1560 wprintf("</TD></TR></TABLE><BR>\n");
1562 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1564 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1565 wprintf("</FORM>\n");
1566 do_template("endbox");
1571 * goto a private room
1573 void goto_private(void)
1578 if (strcasecmp(bstr("sc"), "OK")) {
1579 display_main_menu();
1582 strcpy(hold_rm, WC->wc_roomname);
1583 strcpy(buf, "GOTO ");
1584 strcat(buf, bstr("gr_name"));
1586 strcat(buf, bstr("gr_pass"));
1590 if (buf[0] == '2') {
1591 smart_goto(bstr("gr_name"));
1594 if (!strncmp(buf, "540", 3)) {
1595 display_private(bstr("gr_name"), 1);
1599 wprintf("%s\n", &buf[4]);
1606 * display the screen to zap a room
1608 void display_zap(void)
1612 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1613 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1614 wprintf("</TD></TR></TABLE>\n");
1616 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1617 wprintf("disappear from your room list. Is this what you wish ");
1618 wprintf("to do?<BR>\n");
1620 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1621 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1622 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1623 wprintf("</FORM>\n");
1634 char final_destination[SIZ];
1636 /* If the forget-room routine fails for any reason, we fall back
1637 * to the current room; otherwise, we go to the Lobby
1639 strcpy(final_destination, WC->wc_roomname);
1641 if (!strcasecmp(bstr("sc"), "OK")) {
1642 serv_printf("GOTO %s", WC->wc_roomname);
1644 if (buf[0] != '2') {
1645 /* ExpressMessageCat(&buf[4]); */
1649 if (buf[0] != '2') {
1650 /* ExpressMessageCat(&buf[4]); */
1652 strcpy(final_destination, "_BASEROOM_");
1656 smart_goto(final_destination);
1663 * Confirm deletion of the current room
1665 void confirm_delete_room(void)
1669 serv_puts("KILL 0");
1671 if (buf[0] != '2') {
1672 strcpy(WC->ImportantMessage, &buf[4]);
1673 display_main_menu();
1677 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1678 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1679 wprintf("</TD></TR></TABLE>\n");
1681 wprintf("<CENTER>");
1682 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1684 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1685 escputs(WC->wc_roomname);
1686 wprintf("</FONT>?<BR>\n");
1688 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1689 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1691 wprintf("</FORM></CENTER>\n");
1697 * Delete the current room
1699 void delete_room(void)
1704 strcpy(sc, bstr("sc"));
1706 if (strcasecmp(sc, "Delete")) {
1707 strcpy(WC->ImportantMessage,
1708 "Cancelled. This room was not deleted.");
1709 display_main_menu();
1712 serv_puts("KILL 1");
1714 if (buf[0] != '2') {
1715 strcpy(WC->ImportantMessage, &buf[4]);
1716 display_main_menu();
1719 smart_goto("_BASEROOM_");
1726 * Perform changes to a room's network configuration
1728 void netedit(void) {
1733 if (strlen(bstr("line"))==0) {
1738 strcpy(line, bstr("prefix"));
1739 strcat(line, bstr("line"));
1740 strcat(line, bstr("suffix"));
1750 if (buf[0] != '1') {
1756 /* This loop works for add *or* remove. Spiffy, eh? */
1757 while (serv_gets(buf), strcmp(buf, "000")) {
1758 if (strcasecmp(buf, line)) {
1759 fprintf(fp, "%s\n", buf);
1766 if (buf[0] != '4') {
1772 while (fgets(buf, sizeof buf, fp) != NULL) {
1773 buf[strlen(buf)-1] = 0;
1777 if (!strcasecmp(bstr("cmd"), "add")) {
1789 * Convert a room name to a folder-ish-looking name.
1791 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1796 * For mailboxes, just do it straight...
1799 sprintf(folder, "My folders|%s", room);
1803 * Otherwise, prefix the floor name as a "public folders" moniker
1806 sprintf(folder, "%s|%s", floorlist[floor], room);
1810 * Replace "\" characters with "|" for pseudo-folder-delimiting
1812 for (i=0; i<strlen(folder); ++i) {
1813 if (folder[i] == '\\') folder[i] = '|';
1824 * Change the view for this room
1826 void change_view(void) {
1830 view = atol(bstr("view"));
1832 serv_printf("VIEW %d", view);
1834 smart_goto(WC->wc_roomname);
1839 * One big expanded tree list view --- like a folder list
1841 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1843 int levels, oldlevels;
1846 do_template("beginbox_nt");
1849 for (i=0; i<max_folders; ++i) {
1851 levels = num_tokens(fold[i].name, '|');
1854 for (t=0; t<levels; ++t) wprintf(" ");
1855 if (fold[i].selectable) {
1856 wprintf("<A HREF=\"/dotgoto?room=");
1857 urlescputs(fold[i].room);
1863 if (fold[i].hasnewmsgs) {
1864 wprintf("<SPAN CLASS=\"roomlist_new\">");
1867 wprintf("<SPAN CLASS=\"roomlist_old\">");
1869 extract(buf, fold[i].name, levels-1);
1872 if (fold[i].selectable) {
1878 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1879 wprintf(" (INBOX)");
1883 do_template("endbox");
1887 * Boxes and rooms and lists ... oh my!
1889 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1892 int levels, oldlevels;
1895 static int columns = 3;
1896 int boxes_per_column = 0;
1897 int current_column = 0;
1901 while (nf % columns != 0) ++nf;
1902 boxes_per_column = (nf / columns);
1903 if (boxes_per_column < 1) boxes_per_column = 1;
1905 /* Outer table (for columnization) */
1906 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1907 "<TR><TD VALIGN=TOP>");
1911 for (i=0; i<max_folders; ++i) {
1913 levels = num_tokens(fold[i].name, '|');
1915 if ((levels == 1) && (oldlevels == 2)) {
1918 do_template("endbox");
1921 if ((num_boxes % boxes_per_column) == 0) {
1923 if (current_column < columns) {
1924 wprintf("</TD><TD VALIGN=TOP>\n");
1931 /* Begin inner box */
1932 extract(buf, fold[i].name, levels-1);
1933 stresc(boxtitle, buf, 1);
1934 svprintf("BOXTITLE", WCS_STRING, boxtitle);
1935 do_template("beginbox");
1943 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
1944 if (fold[i].selectable) {
1945 wprintf("<A HREF=\"/dotgoto?room=");
1946 urlescputs(fold[i].room);
1952 if (fold[i].hasnewmsgs) {
1953 wprintf("<SPAN CLASS=\"roomlist_new\">");
1956 wprintf("<SPAN CLASS=\"roomlist_old\">");
1958 extract(buf, fold[i].name, levels-1);
1961 if (fold[i].selectable) {
1967 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1968 wprintf(" (INBOX)");
1973 /* End the final inner box */
1974 do_template("endbox");
1976 wprintf("</TD></TR></TABLE>\n");
1981 * Show the room list. (only should get called by
1982 * knrooms() because that's where output_headers() is called from)
1985 void list_all_rooms_by_floor(char *viewpref) {
1988 struct folder *fold = NULL;
1990 int max_folders = 0;
1991 int alloc_folders = 0;
1995 int num_floors = 1; /* add an extra one for private folders */
1997 /* Start with the mailboxes */
2000 fold = malloc(sizeof(struct folder));
2001 memset(fold, 0, sizeof(struct folder));
2002 strcpy(fold[0].name, "My folders");
2003 fold[0].is_mailbox = 1;
2005 /* Then add floors */
2008 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2009 if (max_folders >= alloc_folders) {
2010 alloc_folders = max_folders + 100;
2011 fold = realloc(fold,
2012 alloc_folders * sizeof(struct folder));
2014 memset(&fold[max_folders], 0, sizeof(struct folder));
2015 extract(fold[max_folders].name, buf, 1);
2023 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2024 if (max_folders >= alloc_folders) {
2025 alloc_folders = max_folders + 100;
2026 fold = realloc(fold,
2027 alloc_folders * sizeof(struct folder));
2029 memset(&fold[max_folders], 0, sizeof(struct folder));
2030 extract(fold[max_folders].room, buf, 0);
2031 ra_flags = extract_int(buf, 5);
2032 flags = extract_int(buf, 1);
2033 fold[max_folders].floor = extract_int(buf, 2);
2034 fold[max_folders].hasnewmsgs =
2035 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2036 if (flags & QR_MAILBOX) {
2037 fold[max_folders].is_mailbox = 1;
2039 room_to_folder(fold[max_folders].name,
2040 fold[max_folders].room,
2041 fold[max_folders].floor,
2042 fold[max_folders].is_mailbox);
2043 fold[max_folders].selectable = 1;
2047 /* Bubble-sort the folder list */
2048 for (i=0; i<max_folders; ++i) {
2049 for (j=0; j<(max_folders-1)-i; ++j) {
2050 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2051 swap = strcasecmp(fold[j].name, fold[j+1].name);
2054 if ( (fold[j+1].is_mailbox)
2055 && (!fold[j].is_mailbox)) {
2063 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2064 memcpy(&fold[j], &fold[j+1],
2065 sizeof(struct folder));
2066 memcpy(&fold[j+1], &ftmp,
2067 sizeof(struct folder));
2072 if (!strcasecmp(viewpref, "folders")) {
2073 do_folder_view(fold, max_folders, num_floors);
2076 do_rooms_view(fold, max_folders, num_floors);
2084 /* Do either a known rooms list or a folders list, depending on the
2088 char listviewpref[SIZ];
2093 /* Determine whether the user is trying to change views */
2094 if (bstr("view") != NULL) {
2095 if (strlen(bstr("view")) > 0) {
2096 set_preference("roomlistview", bstr("view"));
2100 get_preference("roomlistview", listviewpref);
2102 if ( (strcasecmp(listviewpref, "folders"))
2103 && (strcasecmp(listviewpref, "table")) ) {
2104 strcpy(listviewpref, "rooms");
2108 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>"
2109 "<SPAN CLASS=\"titlebar\">"
2111 if (!strcasecmp(listviewpref, "rooms")) {
2112 wprintf("Room list");
2114 if (!strcasecmp(listviewpref, "folders")) {
2115 wprintf("Folder list");
2117 if (!strcasecmp(listviewpref, "table")) {
2118 wprintf("Room list");
2120 wprintf("</SPAN></TD>\n");
2123 /* offer the ability to switch views */
2124 wprintf("<TD><FORM NAME=\"roomlistomatic\">\n"
2125 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2126 "OnChange=\"location.href=roomlistomatic.newview.options"
2127 "[selectedIndex].value\">\n");
2129 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2132 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2135 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2136 "View as folder list"
2138 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2141 wprintf("<OPTION %s VALUE=\"/knrooms&view=table\">"
2142 "Classic table view"
2144 ( !strcasecmp(listviewpref, "table") ? "SELECTED" : "" )
2147 wprintf("</SELECT></FORM></TD><TD>\n");
2149 wprintf("</TD></TR></TABLE>\n");
2151 /* Display the room list in the user's preferred format */
2152 if (!strcasecmp(listviewpref, "table")) {
2153 tabular_room_list();
2156 list_all_rooms_by_floor(listviewpref);