5 * Client-side functions which perform room operations
17 #include <sys/types.h>
23 #include "citadel_ipc.h"
24 #include "citadel_decls.h"
34 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
37 void sttybbs(int cmd);
38 void hit_any_key(void);
39 void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto);
40 void progress(long int curr, long int cmax);
41 int pattern(char *search, char *patn);
42 int file_checksum(char *filename);
43 int nukedir(char *dirname);
45 extern unsigned room_flags;
46 extern char room_name[];
48 extern char tempdir[];
49 extern int editor_pid;
50 extern char editor_path[];
51 extern int screenwidth;
52 extern int screenheight;
53 extern char fullname[];
54 extern char sigcaught;
55 extern char floor_mode;
56 extern char curr_floor;
61 extern char *uglist[];
62 extern long uglistlsn[];
63 extern int uglistsize;
65 extern char floorlist[128][SIZ];
68 void load_floorlist(CtdlIPC *ipc)
73 int r; /* IPC response code */
75 for (a = 0; a < 128; ++a)
78 r = CtdlIPCFloorListing(ipc, &listing, buf);
80 strcpy(floorlist[0], "Main Floor");
83 while (*listing && strlen(listing)) {
84 extract_token(buf, listing, 0, '\n');
85 remove_token(listing, 0, '\n');
86 extract(floorlist[extract_int(buf, 0)], buf, 1);
92 void room_tree_list(struct roomlisting *rp)
95 char rmname[ROOMNAMELEN];
103 if (rp->lnext != NULL) {
104 room_tree_list(rp->lnext);
107 if (sigcaught == 0) {
108 strcpy(rmname, rp->rlname);
110 if ((c + strlen(rmname) + 4) > screenwidth) {
112 /* line break, check the paginator */
116 if (f & QR_MAILBOX) {
117 color(BRIGHT_YELLOW);
118 } else if (f & QR_PRIVATE) {
123 pprintf("%s", rmname);
124 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
126 else if (f & QR_DIRECTORY)
128 else if (f & QR_NETWORK)
132 c = c + strlen(rmname) + 3;
135 if (rp->rnext != NULL) {
136 room_tree_list(rp->rnext);
144 * Room ordering stuff (compare first by floor, then by order)
146 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
148 if ((r1 == NULL) && (r2 == NULL))
154 if (r1->rlfloor < r2->rlfloor)
156 if (r1->rlfloor > r2->rlfloor)
158 if (r1->rlorder < r2->rlorder)
160 if (r1->rlorder > r2->rlorder)
167 * Common code for all room listings
169 static void listrms(CtdlIPC *ipc, enum RoomList variety, int floor)
172 struct march *listing = NULL;
173 struct march *tmp = NULL;
174 struct roomlisting *rl = NULL;
175 struct roomlisting *rp;
176 struct roomlisting *rs;
177 int r; /* IPC response code */
179 /* Ask the server for a room list */
180 r = CtdlIPCKnownRooms(ipc, variety, floor, &listing, buf);
185 rp = malloc(sizeof(struct roomlisting));
186 strncpy(rp->rlname, listing->march_name, ROOMNAMELEN);
187 rp->rlflags = listing->march_flags;
188 rp->rlfloor = listing->march_floor;
189 rp->rlorder = listing->march_order;
202 if (rordercmp(rp, rs) < 0) {
203 if (rs->lnext == NULL) {
210 if (rs->rnext == NULL) {
221 room_tree_list(NULL);
227 void list_other_floors(void)
232 for (a = 0; a < 128; ++a) {
233 if ((strlen(floorlist[a]) > 0) && (a != curr_floor)) {
234 if ((c + strlen(floorlist[a]) + 4) > screenwidth) {
238 pprintf("%s: ", floorlist[a]);
239 c = c + strlen(floorlist[a]) + 3;
246 * List known rooms. kn_floor_mode should be set to 0 for a 'flat' listing,
247 * 1 to list rooms on the current floor, or 1 to list rooms on all floors.
249 void knrooms(CtdlIPC *ipc, int kn_floor_mode)
255 if (kn_floor_mode == 0) {
257 pprintf("\n Rooms with unread messages:\n");
258 listrms(ipc, SubscribedRoomsWithNewMessages, -1);
260 pprintf("\n\n No unseen messages in:\n");
261 listrms(ipc, SubscribedRoomsWithNoNewMessages, -1);
265 if (kn_floor_mode == 1) {
267 pprintf("\n Rooms with unread messages on %s:\n",
268 floorlist[(int) curr_floor]);
269 listrms(ipc, SubscribedRoomsWithNewMessages, curr_floor);
271 pprintf("\n\n Rooms with no new messages on %s:\n",
272 floorlist[(int) curr_floor]);
273 listrms(ipc, SubscribedRoomsWithNoNewMessages, curr_floor);
275 pprintf("\n\n Other floors:\n");
280 if (kn_floor_mode == 2) {
281 for (a = 0; a < 128; ++a) {
282 if (floorlist[a][0] != 0) {
284 pprintf("\n Rooms on %s:\n",
286 listrms(ipc, AllAccessibleRooms, a);
293 IFNEXPERT hit_any_key();
297 void listzrooms(CtdlIPC *ipc)
298 { /* list public forgotten rooms */
300 pprintf("\n Forgotten public rooms:\n");
301 listrms(ipc, UnsubscribedRooms, -1);
304 IFNEXPERT hit_any_key();
308 int set_room_attr(CtdlIPC *ipc, int ibuf, char *prompt, unsigned int sbit)
312 a = boolprompt(prompt, (ibuf & sbit));
313 ibuf = (ibuf | sbit);
315 ibuf = (ibuf ^ sbit);
323 * Select a floor (used in several commands)
324 * The supplied argument is the 'default' floor number.
325 * This function returns the selected floor number.
327 int select_floor(CtdlIPC *ipc, int rfloor)
332 if (floor_mode == 1) {
333 if (floorlist[(int) curr_floor][0] == 0) {
339 safestrncpy(floorstr, floorlist[rfloor],
341 for (a = 0; a < 128; ++a) {
343 (floorstr, &floorlist[a][0]))
348 (floorstr, &floorlist[a][0],
352 && (pattern(&floorlist[a][0], floorstr)
357 scr_printf("\n One of:\n");
358 for (a = 0; a < 128; ++a) {
359 if (floorlist[a][0] != 0) {
365 } while (newfloor < 0);
375 * .<A>ide <E>dit room
377 void editthisroom(CtdlIPC *ipc)
382 struct quickroom *attr = NULL;
383 struct ExpirePolicy *eptr = NULL;
384 int r; /* IPC response code */
386 /* Fetch the existing room config */
387 r = CtdlIPCGetRoomAttributes(ipc, &attr, buf);
389 scr_printf("%s\n", buf);
392 eptr = &(attr->QRep);
394 /* Fetch the name of the current room aide */
395 r = CtdlIPCGetRoomAide(ipc, buf);
397 safestrncpy(raide, buf, sizeof raide);
401 if (strlen(raide) == 0) {
402 strcpy(raide, "none");
405 /* Fetch the expire policy (this will silently fail on old servers,
406 * resulting in "default" policy)
408 r = CtdlIPCGetMessageExpirationPolicy(ipc, 0, &eptr, buf);
410 /* Now interact with the user. */
412 attr->QRfloor = select_floor(ipc, attr->QRfloor);
413 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Private room", QR_PRIVATE);
414 if (attr->QRflags & QR_PRIVATE) {
415 attr->QRflags = set_room_attr(ipc, attr->QRflags,
416 "Accessible by guessing room name",
420 /* if it's public, clear the privacy classes */
421 if ((attr->QRflags & QR_PRIVATE) == 0) {
422 if (attr->QRflags & QR_GUESSNAME) {
423 attr->QRflags = attr->QRflags - QR_GUESSNAME;
425 if (attr->QRflags & QR_PASSWORDED) {
426 attr->QRflags = attr->QRflags - QR_PASSWORDED;
430 /* if it's private, choose the privacy classes */
431 if ((attr->QRflags & QR_PRIVATE)
432 && ((attr->QRflags & QR_GUESSNAME) == 0)) {
433 attr->QRflags = set_room_attr(ipc, attr->QRflags,
434 "Accessible by entering a password",
437 if ((attr->QRflags & QR_PRIVATE)
438 && ((attr->QRflags & QR_PASSWORDED) == QR_PASSWORDED)) {
439 strprompt("Room password", attr->QRpasswd, 9);
442 if ((attr->QRflags & QR_PRIVATE) == QR_PRIVATE) {
443 rbump = boolprompt("Cause current users to forget room", 0);
446 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Preferred users only", QR_PREFONLY);
447 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Read-only room", QR_READONLY);
448 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Directory room", QR_DIRECTORY);
449 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Permanent room", QR_PERMANENT);
450 if (attr->QRflags & QR_DIRECTORY) {
451 strprompt("Directory name", attr->QRdirname, 14);
453 set_room_attr(ipc, attr->QRflags, "Uploading allowed", QR_UPLOAD);
455 set_room_attr(ipc, attr->QRflags, "Downloading allowed",
458 set_room_attr(ipc, attr->QRflags, "Visible directory", QR_VISDIR);
460 attr->QRflags = set_room_attr(ipc, attr->QRflags, "Network shared room", QR_NETWORK);
461 attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
462 "Self-service list subscribe/unsubscribe",
464 attr->QRflags = set_room_attr(ipc, attr->QRflags,
465 "Automatically make all messages anonymous",
467 if ((attr->QRflags & QR_ANONONLY) == 0) {
468 attr->QRflags = set_room_attr(ipc, attr->QRflags,
469 "Ask users whether to make messages anonymous",
472 attr->QRorder = intprompt("Listing order", attr->QRorder, 1, 127);
474 /* Ask about the room aide */
476 strprompt("Room aide (or 'none')", raide, 29);
477 if (!strcasecmp(raide, "none")) {
481 r = CtdlIPCQueryUsername(ipc, raide, buf);
483 scr_printf("%s\n", buf);
485 } while (r / 100 != 2);
487 /* FIXME: Duplicate code??? */
488 if (!strcasecmp(raide, "none")) {
492 /* Angels and demons dancing in my head... */
494 snprintf(buf, sizeof buf, "%d", attr->QRep.expire_mode);
495 strprompt("Message expire policy (? for list)", buf, 1);
498 "0. Use the default for this floor\n"
499 "1. Never automatically expire messages\n"
500 "2. Expire by message count\n"
501 "3. Expire by message age\n");
503 } while ((buf[0] < 48) || (buf[0] > 51));
504 attr->QRep.expire_mode = buf[0] - 48;
506 /* ...lunatics and monsters underneath my bed */
507 if (attr->QRep.expire_mode == 2) {
508 snprintf(buf, sizeof buf, "%d", attr->QRep.expire_value);
509 strprompt("Keep how many messages online?", buf, 10);
510 attr->QRep.expire_value = atol(buf);
513 if (attr->QRep.expire_mode == 3) {
514 snprintf(buf, sizeof buf, "%d", attr->QRep.expire_value);
515 strprompt("Keep messages for how many days?", buf, 10);
516 attr->QRep.expire_value = atol(buf);
519 /* Give 'em a chance to change their minds */
520 scr_printf("Save changes (y/n)? ");
523 r = CtdlIPCSetRoomAide(ipc, raide, buf);
525 scr_printf("%s\n", buf);
528 r = CtdlIPCSetMessageExpirationPolicy(ipc, 0, eptr, buf);
530 scr_printf("%s\n", buf);
533 r = CtdlIPCSetRoomAttributes(ipc, rbump, attr, buf);
534 scr_printf("%s\n", buf);
535 strncpy(buf, attr->QRname, ROOMNAMELEN);
538 dotgoto(ipc, buf, 2, 0);
545 * un-goto the previous room
547 void ungoto(CtdlIPC *ipc)
554 snprintf(buf, sizeof buf, "GOTO %s", uglist[uglistsize-1]);
555 CtdlIPC_putline(ipc, buf);
556 CtdlIPC_getline(ipc, buf);
558 scr_printf("%s\n", &buf[4]);
561 snprintf(buf, sizeof buf, "SLRP %ld", uglistlsn[uglistsize-1]);
562 CtdlIPC_putline(ipc, buf);
563 CtdlIPC_getline(ipc, buf);
565 scr_printf("%s\n", &buf[4]);
567 safestrncpy (buf, uglist[uglistsize-1], sizeof(buf));
569 free(uglist[uglistsize]);
570 /* Don't queue ungoto info or we end up in a loop */
571 dotgoto(ipc, buf, 0, 1);
576 * saves filelen bytes from file at pathname
578 int save_buffer(void *file, size_t filelen, const char *pathname)
581 size_t bytes_written = 0;
584 fp = fopen(pathname, "w");
586 err_printf("Cannot open '%s': %s\n", pathname, strerror(errno));
590 block = fwrite(file + bytes_written, 1,
591 filelen - bytes_written, fp);
592 bytes_written += block;
593 } while (errno == EINTR && bytes_written < filelen);
596 if (bytes_written < filelen) {
597 err_printf("Trouble saving '%s': %s\n", pathname,
606 * Save supplied_filename in dest directory; gets the name only
608 void destination_directory(char *dest, const char *supplied_filename)
610 scr_printf("Enter the name of the directory to save '%s'\n"
611 "to, or press return for the current directory.\n",
613 newprompt("Directory: ", dest, PATH_MAX);
614 if (strlen(dest) == 0) {
619 strcat(dest, supplied_filename);
624 * download() - download a file or files. The argument passed to this
625 * function determines which protocol to use.
626 * proto - 0 = paginate, 1 = xmodem, 2 = raw, 3 = ymodem, 4 = zmodem, 5 = save
628 void download(CtdlIPC *ipc, int proto)
631 char filename[PATH_MAX];
632 char tempname[PATH_MAX];
633 char transmit_cmd[SIZ];
637 void *file = NULL; /* The downloaded file */
638 long filelen = 0L; /* The downloaded file length */
640 if ((room_flags & QR_DOWNLOAD) == 0) {
641 scr_printf("*** You cannot download from this room.\n");
645 newprompt("Enter filename: ", filename, PATH_MAX);
647 /* Save to local disk, for folks with their own copy of the client */
649 destination_directory(tempname, filename);
650 r = CtdlIPCFileDownload(ipc, filename, &file, 0, progress, buf);
652 scr_printf("%s\n", buf);
655 save_buffer(file, extract_long(buf, 0), tempname);
660 r = CtdlIPCFileDownload(ipc, filename, &file, 0, progress, buf);
662 scr_printf("%s\n", buf);
665 filelen = extract_long(buf, 0);
667 /* Meta-download for public clients */
668 /* scr_printf("Fetching file from Citadel server...\n"); */
669 mkdir(tempdir, 0700);
670 snprintf(tempname, sizeof tempname, "%s/%s", tempdir, filename);
671 tpipe = fopen(tempname, "wb");
672 if (fwrite(file, filelen, 1, tpipe) < filelen) {
676 if (file) free(file);
679 /* FIXME: display internally instead */
680 snprintf(transmit_cmd, sizeof transmit_cmd,
681 "SHELL=/dev/null; export SHELL; TERM=dumb; export TERM; exec more -d <%s",
685 snprintf(transmit_cmd, sizeof transmit_cmd, "exec sx %s", tempname);
687 snprintf(transmit_cmd, sizeof transmit_cmd, "exec sb %s", tempname);
689 snprintf(transmit_cmd, sizeof transmit_cmd, "exec sz %s", tempname);
691 /* FIXME: display internally instead */
692 snprintf(transmit_cmd, sizeof transmit_cmd, "exec cat %s", tempname);
696 system(transmit_cmd);
700 /* clean up the temporary directory */
702 scr_putc(7); /* Beep beep! */
707 * read directory of this room
709 void roomdir(CtdlIPC *ipc)
716 CtdlIPC_putline(ipc, "RDIR");
717 CtdlIPC_getline(ipc, buf);
719 pprintf("%s\n", &buf[4]);
723 extract(comment, &buf[4], 0);
724 extract(flnm, &buf[4], 1);
725 pprintf("\nDirectory of %s on %s\n", flnm, comment);
726 pprintf("-----------------------\n");
727 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
728 extract(flnm, buf, 0);
729 extract(flsz, buf, 1);
730 extract(comment, buf, 2);
731 if (strlen(flnm) <= 14)
732 pprintf("%-14s %8s %s\n", flnm, flsz, comment);
734 pprintf("%s\n%14s %8s %s\n", flnm, "", flsz,
741 * add a user to a private room
743 void invite(CtdlIPC *ipc)
745 char username[USERNAME_SIZE];
747 int r; /* IPC response code */
749 newprompt("Name of user? ", username, USERNAME_SIZE);
750 if (username[0] == 0)
753 r = CtdlIPCInviteUserToRoom(ipc, username, buf);
754 scr_printf("%s\n", buf);
759 * kick a user out of a room
761 void kickout(CtdlIPC *ipc)
763 char username[USERNAME_SIZE];
765 int r; /* IPC response code */
767 newprompt("Name of user? ", username, USERNAME_SIZE);
768 if (username[0] == 0)
771 r = CtdlIPCKickoutUserFromRoom(ipc, username, buf);
772 scr_printf("%s\n", buf);
777 * aide command: kill the current room
779 void killroom(CtdlIPC *ipc)
784 r = CtdlIPCDeleteRoom(ipc, 0, aaa);
786 scr_printf("%s\n", aaa);
790 scr_printf("Are you sure you want to kill this room? ");
794 r = CtdlIPCDeleteRoom(ipc, 1, aaa);
795 scr_printf("%s\n", aaa);
798 dotgoto(ipc, "_BASEROOM_", 0, 0);
801 void forget(CtdlIPC *ipc)
802 { /* forget the current room */
805 scr_printf("Are you sure you want to forget this room? ");
809 if (CtdlIPCForgetRoom(ipc, buf) / 100 != 2) {
810 scr_printf("%s\n", buf);
814 /* now return to the lobby */
815 dotgoto(ipc, "_BASEROOM_", 0, 0);
822 void entroom(CtdlIPC *ipc)
825 char new_room_name[ROOMNAMELEN];
827 char new_room_pass[10];
830 int r; /* IPC response code */
832 /* Check permission to create room */
833 r = CtdlIPCCreateRoom(ipc, 0, "", 1, "", 0, buf);
835 scr_printf("%s\n", buf);
839 newprompt("Name for new room? ", new_room_name, ROOMNAMELEN - 1);
840 if (strlen(new_room_name) == 0) {
843 for (a = 0; a < strlen(new_room_name); ++a) {
844 if (new_room_name[a] == '|') {
845 new_room_name[a] = '_';
849 new_room_floor = select_floor(ipc, (int) curr_floor);
851 IFNEXPERT formout(ipc, "roomaccess");
853 scr_printf("<?>Help\n<1>Public room\n<2>Guess-name room\n"
854 "<3>Passworded room\n<4>Invitation-only room\n"
856 "Enter room type: ");
859 } while (((b < '1') || (b > '5')) && (b != '?'));
862 formout(ipc, "roomaccess");
864 } while ((b < '1') || (b > '5'));
865 b -= '0'; /* Portable */
866 scr_printf("%d\n", b);
867 new_room_type = b - 1;
868 if (new_room_type == 2) {
869 newprompt("Enter a room password: ", new_room_pass, 9);
870 for (a = 0; a < strlen(new_room_pass); ++a)
871 if (new_room_pass[a] == '|')
872 new_room_pass[a] = '_';
874 strcpy(new_room_pass, "");
877 scr_printf("\042%s\042, a", new_room_name);
879 scr_printf(" public room.");
881 scr_printf(" guess-name room.");
883 scr_printf(" passworded room, password: %s", new_room_pass);
885 scr_printf("n invitation-only room.");
887 scr_printf(" personal room.");
888 scr_printf("\nInstall it? (y/n) : ");
893 r = CtdlIPCCreateRoom(ipc, 1, new_room_name, new_room_type,
894 new_room_pass, new_room_floor, buf);
896 scr_printf("%s\n", buf);
900 /* command succeeded... now GO to the new room! */
901 dotgoto(ipc, new_room_name, 0, 0);
906 void readinfo(CtdlIPC *ipc)
907 { /* read info file for current room */
910 int r; /* IPC response code */
913 /* Name of currernt room aide */
914 r = CtdlIPCGetRoomAide(ipc, buf);
916 safestrncpy(raide, buf, sizeof raide);
920 if (strlen(raide) > 0)
921 scr_printf("Room aide is %s.\n\n", raide);
923 r = CtdlIPCRoomInfo(ipc, &text, buf);
928 fmout(screenwidth, NULL, text, NULL,
929 ((userflags & US_PAGINATOR) ? 1 : 0), screenheight,
930 (*raide) ? 2 : 0, 1);
937 * <W>ho knows room...
939 void whoknows(CtdlIPC *ipc)
942 CtdlIPC_putline(ipc, "WHOK");
943 CtdlIPC_getline(ipc, buf);
945 pprintf("%s\n", &buf[4]);
948 while (CtdlIPC_getline(ipc, buf), strncmp(buf, "000", 3)) {
950 pprintf("%s\n", buf);
955 void do_edit(CtdlIPC *ipc,
956 char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
960 int b, cksum, editor_exit;
963 if (strlen(editor_path) == 0) {
964 scr_printf("Do you wish to re-enter %s? ", desc);
969 fp = fopen(temp, "w");
972 CtdlIPC_putline(ipc, check_cmd);
973 CtdlIPC_getline(ipc, cmd);
975 scr_printf("%s\n", &cmd[4]);
979 if (strlen(editor_path) > 0) {
980 CtdlIPC_putline(ipc, read_cmd);
981 CtdlIPC_getline(ipc, cmd);
983 fp = fopen(temp, "w");
984 while (CtdlIPC_getline(ipc, cmd), strcmp(cmd, "000")) {
985 fprintf(fp, "%s\n", cmd);
991 cksum = file_checksum(temp);
993 if (strlen(editor_path) > 0) {
996 snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc);
999 if (editor_pid == 0) {
1002 sttybbs(SB_RESTORE);
1003 execlp(editor_path, editor_path, temp, NULL);
1009 b = wait(&editor_exit);
1010 } while ((b != editor_pid) && (b >= 0));
1012 scr_printf("Executed %s\n", editor_path);
1016 scr_printf("Entering %s. "
1017 "Press return twice when finished.\n", desc);
1018 fp = fopen(temp, "r+");
1023 if (file_checksum(temp) == cksum) {
1024 scr_printf("*** Aborted.\n");
1028 CtdlIPC_putline(ipc, write_cmd);
1029 CtdlIPC_getline(ipc, cmd);
1030 if (cmd[0] != '4') {
1031 scr_printf("%s\n", &cmd[4]);
1035 fp = fopen(temp, "r");
1036 while (fgets(cmd, SIZ - 1, fp) != NULL) {
1037 cmd[strlen(cmd) - 1] = 0;
1038 CtdlIPC_putline(ipc, cmd);
1041 CtdlIPC_putline(ipc, "000");
1048 void enterinfo(CtdlIPC *ipc)
1049 { /* edit info file for current room */
1050 do_edit(ipc, "the Info file for this room", "RINF", "EINF 0", "EINF 1");
1053 void enter_bio(CtdlIPC *ipc)
1056 snprintf(cmd, sizeof cmd, "RBIO %s", fullname);
1057 do_edit(ipc, "your Bio", cmd, "NOOP", "EBIO");
1061 * create a new floor
1063 void create_floor(CtdlIPC *ipc)
1066 char newfloorname[SIZ];
1067 int r; /* IPC response code */
1069 load_floorlist(ipc);
1071 r = CtdlIPCCreateFloor(ipc, 0, "", buf);
1073 scr_printf("%s\n", buf);
1077 newprompt("Name for new floor: ", newfloorname, 255);
1078 r = CtdlIPCCreateFloor(ipc, 1, newfloorname, buf);
1080 scr_printf("Floor has been created.\n");
1082 scr_printf("%s\n", buf);
1085 load_floorlist(ipc);
1089 * edit the current floor
1091 void edit_floor(CtdlIPC *ipc)
1094 struct ExpirePolicy *ep = NULL;
1095 int r; /* IPC response code */
1097 load_floorlist(ipc);
1099 /* Fetch the expire policy (this will silently fail on old servers,
1100 * resulting in "default" policy)
1102 r = CtdlIPCGetMessageExpirationPolicy(ipc, 1, &ep, buf);
1104 /* Interact with the user */
1105 scr_printf("You are editing the floor called \"%s\"\n",
1106 &floorlist[(int) curr_floor][0] );
1107 strprompt("Floor name", &floorlist[(int) curr_floor][0], 255);
1109 /* Angels and demons dancing in my head... */
1111 snprintf(buf, sizeof buf, "%d", ep->expire_mode);
1113 ("Floor default message expire policy (? for list)",
1115 if (buf[0] == '?') {
1117 "0. Use the system default\n"
1118 "1. Never automatically expire messages\n"
1119 "2. Expire by message count\n"
1120 "3. Expire by message age\n");
1122 } while ((buf[0] < '0') || (buf[0] > '3'));
1123 ep->expire_mode = buf[0] - '0';
1125 /* ...lunatics and monsters underneath my bed */
1126 if (ep->expire_mode == 2) {
1127 snprintf(buf, sizeof buf, "%d", ep->expire_value);
1128 strprompt("Keep how many messages online?", buf, 10);
1129 ep->expire_value = atol(buf);
1132 if (ep->expire_mode == 3) {
1133 snprintf(buf, sizeof buf, "%d", ep->expire_value);
1134 strprompt("Keep messages for how many days?", buf, 10);
1135 ep->expire_value = atol(buf);
1139 r = CtdlIPCSetMessageExpirationPolicy(ipc, 1, ep, buf);
1140 r = CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int)curr_floor][0], buf);
1141 scr_printf("%s\n", buf);
1142 load_floorlist(ipc);
1149 * kill the current floor
1151 void kill_floor(CtdlIPC *ipc)
1153 int floornum_to_delete, a;
1156 load_floorlist(ipc);
1158 floornum_to_delete = (-1);
1159 scr_printf("(Press return to abort)\n");
1160 newprompt("Delete which floor? ", buf, 255);
1161 if (strlen(buf) == 0)
1163 for (a = 0; a < 128; ++a)
1164 if (!strcasecmp(&floorlist[a][0], buf))
1165 floornum_to_delete = a;
1166 if (floornum_to_delete < 0) {
1167 scr_printf("No such floor. Select one of:\n");
1168 for (a = 0; a < 128; ++a)
1169 if (floorlist[a][0] != 0)
1170 scr_printf("%s\n", &floorlist[a][0]);
1172 } while (floornum_to_delete < 0);
1173 CtdlIPCDeleteFloor(ipc, 1, floornum_to_delete, buf);
1174 scr_printf("%s\n", buf);
1175 load_floorlist(ipc);