4 * Main source module for the client program.
15 #if TIME_WITH_SYS_TIME
16 # include <sys/time.h>
20 # include <sys/time.h>
27 #include <sys/types.h>
30 #include <sys/ioctl.h>
37 #include "citadel_ipc.h"
40 #include "routines2.h"
44 #include "client_chat.h"
45 #include "client_passwords.h"
46 #include "citadel_decls.h"
53 #include "citadel_dirs.h"
57 #define IFEXPERT if (userflags&US_EXPERT)
58 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
59 #define IFAIDE if (axlevel>=6)
60 #define IFNAIDE if (axlevel<6)
62 int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2);
64 struct march *march = NULL;
66 /* globals associated with the client program */
67 char temp[PATH_MAX]; /* Name of general-purpose temp file */
68 char temp2[PATH_MAX]; /* Name of general-purpose temp file */
69 char tempdir[PATH_MAX]; /* Name of general-purpose temp directory */
70 char editor_paths[MAX_EDITORS][SIZ]; /* paths to external editors */
71 char printcmd[SIZ]; /* print command */
72 int editor_pid = (-1);
73 char fullname[USERNAME_SIZE];
78 char room_name[ROOMNAMELEN];
79 char *uglist[UGLISTLEN]; /* size of the ungoto list */
80 long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
82 char is_mail = 0; /* nonzero when we're in a mail room */
83 char axlevel = 0; /* access level */
84 char is_room_aide = 0; /* boolean flag, 1 if room aide */
88 long usernum = 0L; /* user number */
89 time_t lastcall = 0L; /* Date/time of previous login */
91 long highest_msg_read; /* used for <A>bandon room cmd */
92 long maxmsgnum; /* used for <G>oto */
94 char have_xterm = 0; /* are we running on an xterm? */
95 char rc_username[USERNAME_SIZE];
101 char curr_floor = 0; /* number of current floor */
102 char floorlist[128][SIZ]; /* names of floors */
103 int termn8 = 0; /* Set to nonzero to cause a logoff */
104 int secure; /* Set to nonzero when wire is encrypted */
105 int can_do_msg4 = 0; /* Set to nonzero if the server can handle MSG4 commands */
107 extern char instant_msgs; /* instant messages waiting! */
108 extern int rc_ansi_color; /* ansi color value from citadel.rc */
109 extern int next_lazy_cmd;
111 CtdlIPC *ipc_for_signal_handlers; /* KLUDGE cover your eyes */
114 * here is our 'clean up gracefully and exit' routine
116 void ctdl_logoff(char *file, int line, CtdlIPC *ipc, int code)
120 if (editor_pid > 0) { /* kill the editor if it's running */
121 kill(editor_pid, SIGHUP);
124 /* Free the ungoto list */
125 for (lp = 0; lp < uglistsize; lp++) {
129 /* Shut down the server connection ... but not if the logoff code is 3,
130 * because that means we're exiting because we already lost the server.
137 * now clean up various things
145 /* Violently kill off any child processes if Citadel is
148 if (getppid() == 1) {
149 kill(0 - getpgrp(), SIGTERM);
151 kill(0 - getpgrp(), SIGKILL);
153 color(ORIGINAL_PAIR); /* Restore the old color settings */
154 stty_ctdl(SB_RESTORE); /* return the old terminal settings */
156 * uncomment the following if you need to know why Citadel exited
157 printf("*** Exit code %d at %s:%d\n", code, file, line);
160 exit(code); /* exit with the proper exit code */
166 * signal catching function for hangups...
168 void dropcarr(int signum)
170 logoff(NULL, 3); /* No IPC when server's already gone! */
176 * catch SIGCONT to reset terminal modes when were are put back into the
179 void catch_sigcont(int signum)
182 signal(SIGCONT, catch_sigcont);
186 /* general purpose routines */
189 void formout(CtdlIPC *ipc, char *name)
191 int r; /* IPC return code */
195 r = CtdlIPCSystemMessage(ipc, name, &text, buf);
197 scr_printf("%s\n", buf);
201 fmout(screenwidth, NULL, text, NULL,
202 ((userflags & US_PAGINATOR) ? 1 : 0),
209 void userlist(CtdlIPC *ipc, char *patn)
215 int r; /* IPC response code */
216 char *listing = NULL;
218 r = CtdlIPCUserListing(ipc, patn, &listing, buf);
220 pprintf("%s\n", buf);
224 pprintf(" User Name Num L LastCall Calls Posts\n");
225 pprintf("------------------------- ----- - ---------- ----- -----\n");
226 if (listing != NULL) while (!IsEmptyStr(listing)) {
227 extract_token(buf, listing, 0, '\n', sizeof buf);
228 remove_token(listing, 0, '\n');
230 if (sigcaught == 0) {
231 extract_token(fl, buf, 0, '|', sizeof fl);
232 if (pattern(fl, patn) >= 0) {
233 pprintf("%-25s ", fl);
234 pprintf("%5ld %d ", extract_long(buf, 2),
235 extract_int(buf, 1));
236 lc = extract_long(buf, 3);
237 localtime_r(&lc, &tmbuf);
238 pprintf("%02d/%02d/%04d ",
241 (tmbuf.tm_year + 1900));
242 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
253 * grab assorted info about the user...
255 void load_user_info(char *params)
257 extract_token(fullname, params, 0, '|', sizeof fullname);
258 axlevel = extract_int(params, 1);
259 timescalled = extract_int(params, 2);
260 posted = extract_int(params, 3);
261 userflags = extract_int(params, 4);
262 usernum = extract_long(params, 5);
263 lastcall = extract_long(params, 6);
268 * Remove a room from the march list. 'floornum' is ignored unless
269 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
270 * floor will be removed from the march list.
272 void remove_march(char *roomname, int floornum)
274 struct march *mptr, *mptr2;
279 if ((!strcasecmp(march->march_name, roomname))
280 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
287 for (mptr = march; mptr != NULL; mptr = mptr->next) {
289 if ((!strcasecmp(mptr->march_name, roomname))
290 || ((!strcasecmp(roomname, "_FLOOR_"))
291 && (mptr->march_floor == floornum))) {
293 mptr2->next = mptr->next;
304 * Locate the room on the march list which we most want to go to. Each room
305 * is measured given a "weight" of preference based on various factors.
307 char *pop_march(int desired_floor, struct march *_march)
309 static char TheRoom[ROOMNAMELEN];
311 int TheOrder = 32767;
314 struct march *mptr = NULL;
316 strcpy(TheRoom, "_BASEROOM_");
320 for (mptr = _march; mptr != NULL; mptr = mptr->next) {
322 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
323 weight = weight + 10000;
324 if (mptr->march_floor == desired_floor)
325 weight = weight + 5000;
327 weight = weight + ((128 - (mptr->march_floor)) * 128);
328 weight = weight + (128 - (mptr->march_order));
330 if (weight > TheWeight) {
332 strcpy(TheRoom, mptr->march_name);
333 TheFloor = mptr->march_floor;
334 TheOrder = mptr->march_order;
342 * jump directly to a room
344 void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
346 char aaa[SIZ], bbb[SIZ];
348 int newmailcount = 0;
349 int partial_match, best_match;
351 int ugpos = uglistsize;
352 int r; /* IPC result code */
353 struct ctdlipcroom *room = NULL;
355 /* store ungoto information */
356 if (fromungoto == 0) {
357 /* sloppy slide them all down, hey it's the client, who cares. :-) */
358 if (uglistsize >= (UGLISTLEN-1)) {
361 for (lp = 0; lp < (UGLISTLEN-1); lp++) {
362 uglist[lp] = uglist[lp+1];
363 uglistlsn[lp] = uglistlsn[lp+1];
370 uglist[ugpos] = malloc(strlen(room_name)+1);
371 strcpy(uglist[ugpos], room_name);
372 uglistlsn[ugpos] = ls;
375 /* first try an exact match */
376 r = CtdlIPCGotoRoom(ipc, towhere, "", &room, aaa);
378 newprompt("Enter room password: ", bbb, 9);
379 r = CtdlIPCGotoRoom(ipc, towhere, bbb, &room, aaa);
381 scr_printf("Wrong password.\n");
387 * If a match is not found, try a partial match.
388 * Partial matches anywhere in the string carry a weight of 1,
389 * left-aligned matches carry a weight of 2. Pick the room that
390 * has the highest-weighted match. Do not match on forgotten
394 struct march *march = NULL;
399 r = CtdlIPCKnownRooms(ipc, SubscribedRooms, AllFloors, &march, aaa);
401 /* Run the roomlist; free the data as we go */
402 struct march *mp = march; /* Current */
406 if (pattern(mp->march_name, towhere) >= 0) {
409 if (!strncasecmp(mp->march_name, towhere, strlen(towhere))) {
412 if (partial_match > best_match) {
413 strcpy(bbb, mp->march_name);
414 best_match = partial_match;
416 /* Both pointers are NULL at end of list */
423 if (IsEmptyStr(bbb)) {
424 scr_printf("No room '%s'.\n", towhere);
427 r = CtdlIPCGotoRoom(ipc, bbb, "", &room, aaa);
429 if (r / 100 != 1 && r / 100 != 2) {
430 scr_printf("%s\n", aaa);
433 safestrncpy(room_name, room->RRname, ROOMNAMELEN);
434 room_flags = room->RRflags;
435 room_flags2 = room->RRflags2;
436 from_floor = curr_floor;
437 curr_floor = room->RRfloor;
439 remove_march(room_name, 0);
440 if (!strcasecmp(towhere, "_BASEROOM_"))
441 remove_march(towhere, 0);
443 next_lazy_cmd = 5; /* Don't read new if no new msgs */
444 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
445 if (floorlist[(int) curr_floor][0] == 0)
447 scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
449 if (display_name == 1) {
451 scr_printf("%s ", room_name);
455 if (display_name != 2) {
456 color(BRIGHT_YELLOW);
457 scr_printf("%d ", room->RRunread);
459 scr_printf("new of ");
460 color(BRIGHT_YELLOW);
461 scr_printf("%d ", room->RRtotal);
463 scr_printf("messages.\n");
465 highest_msg_read = room->RRlastread;
466 maxmsgnum = room->RRhighest;
467 is_mail = room->RRismailbox;
468 is_room_aide = room->RRaide;
469 ls = room->RRlastread;
471 /* read info file if necessary */
472 if (room->RRinfoupdated > 0)
475 /* check for newly arrived mail if we can */
476 newmailcount = room->RRnewmail;
477 if (newmailcount > 0) {
479 if (newmailcount == 1) {
480 scr_printf("*** A new mail message has arrived.\n");
483 scr_printf("*** %d new mail messages have arrived.\n",
487 if (!IsEmptyStr(rc_gotmail_cmd)) {
488 system(rc_gotmail_cmd);
491 status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location,
492 room_name, secure, newmailcount);
496 /* Goto next room having unread messages.
497 * We want to skip over rooms that the user has already been to, and take the
498 * user back to the lobby when done. The room we end up in is placed in
499 * newroom - which is set to 0 (the lobby) initially.
501 void gotonext(CtdlIPC *ipc)
504 struct march *mptr, *mptr2;
505 char next_room[ROOMNAMELEN];
506 int r; /* IPC response code */
508 /* Check to see if the march-mode list is already allocated.
509 * If it is, pop the first room off the list and go there.
512 r = CtdlIPCKnownRooms(ipc, SubscribedRoomsWithNewMessages,
513 AllFloors, &march, buf);
515 /* add _BASEROOM_ to the end of the march list, so the user will end up
516 * in the system base room (usually the Lobby>) at the end of the loop
518 mptr = (struct march *) malloc(sizeof(struct march));
520 strcpy(mptr->march_name, "_BASEROOM_");
525 while (mptr2->next != NULL)
530 * ...and remove the room we're currently in, so a <G>oto doesn't make us
531 * walk around in circles
533 remove_march(room_name, 0);
536 strcpy(next_room, pop_march(curr_floor, march));
538 strcpy(next_room, "_BASEROOM_");
540 remove_march(next_room, 0);
541 dotgoto(ipc, next_room, 1, 0);
545 * forget all rooms on a given floor
547 void forget_all_rooms_on(CtdlIPC *ipc, int ffloor)
550 struct march *flist = NULL;
551 struct march *fptr = NULL;
552 struct ctdlipcroom *room = NULL;
553 int r; /* IPC response code */
555 scr_printf("Forgetting all rooms on %s...\n", &floorlist[ffloor][0]);
557 remove_march("_FLOOR_", ffloor);
558 r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, ffloor, &flist, buf);
560 scr_printf("Error %d: %s\n", r, buf);
564 r = CtdlIPCGotoRoom(ipc, flist->march_name, "", &room, buf);
566 r = CtdlIPCForgetRoom(ipc, buf);
568 scr_printf("Error %d: %s\n", r, buf);
576 if (room) free(room);
581 * routine called by gotofloor() to move to a new room on a new floor
583 void gf_toroom(CtdlIPC *ipc, char *towhere, int mode)
585 int floor_being_left;
587 floor_being_left = curr_floor;
589 if (mode == GF_GOTO) { /* <;G>oto mode */
591 dotgoto(ipc, towhere, 1, 0);
593 else if (mode == GF_SKIP) { /* <;S>kip mode */
594 dotgoto(ipc, towhere, 1, 0);
595 remove_march("_FLOOR_", floor_being_left);
597 else if (mode == GF_ZAP) { /* <;Z>ap mode */
598 dotgoto(ipc, towhere, 1, 0);
599 remove_march("_FLOOR_", floor_being_left);
600 forget_all_rooms_on(ipc, floor_being_left);
608 void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
611 int r; /* IPC response code */
613 char buf[SIZ], targ[SIZ];
615 if (floorlist[0][0] == 0)
618 for (a = 0; a < 128; ++a)
619 if (!strcasecmp(&floorlist[a][0], towhere))
623 for (a = 0; a < 128; ++a) {
624 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
630 for (a = 0; a < 128; ++a)
631 if (pattern(towhere, &floorlist[a][0]) > 0)
635 scr_printf("No floor '%s'.\n", towhere);
638 for (mptr = march; mptr != NULL; mptr = mptr->next) {
639 if ((mptr->march_floor) == tofloor) {
640 gf_toroom(ipc, mptr->march_name, mode);
645 /* Find first known room on the floor */
649 r = CtdlIPCKnownRooms(ipc, SubscribedRooms, tofloor, &mptr, buf);
651 struct march *tmp = mptr;
653 /*. . . according to room order */
655 strcpy(targ, pop_march(tofloor, mptr));
662 if (!IsEmptyStr(targ)) {
663 gf_toroom(ipc, targ, mode);
667 /* No known rooms on the floor; unzap the first one then */
671 r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, tofloor, &mptr, buf);
673 struct march *tmp = mptr;
675 /*. . . according to room order */
677 strcpy(targ, pop_march(tofloor, mptr));
684 if (!IsEmptyStr(targ)) {
685 gf_toroom(ipc, targ, mode);
687 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
692 * Indexing mechanism for a room list, called by gotoroomstep()
694 void room_tree_list_query(struct ctdlroomlisting *rp, char *findrmname, int findrmslot, char *rmname, int *rmslot, int *rmtotal)
696 char roomname[ROOMNAMELEN];
697 static int cur_rmslot = 0;
704 if (rp->lnext != NULL) {
705 room_tree_list_query(rp->lnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
708 if (sigcaught == 0) {
709 strcpy(roomname, rp->rlname);
711 if (rmname != NULL) {
712 if (cur_rmslot == findrmslot) {
713 strcpy(rmname, roomname);
716 if (rmslot != NULL) {
717 if (!strcmp(roomname, findrmname)) {
718 *rmslot = cur_rmslot;
724 if (rp->rnext != NULL) {
725 room_tree_list_query(rp->rnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
728 if ((rmname == NULL) && (rmslot == NULL))
731 if (rmtotal != NULL) {
732 *rmtotal = cur_rmslot;
737 * step through rooms on current floor
739 void gotoroomstep(CtdlIPC *ipc, int direction, int mode)
741 struct march *listing = NULL;
743 int r; /* IPC response code */
745 struct ctdlroomlisting *rl = NULL;
746 struct ctdlroomlisting *rp;
747 struct ctdlroomlisting *rs;
749 char rmname[ROOMNAMELEN];
753 /* Ask the server for a room list */
754 r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
761 for (mptr = listing; mptr != NULL; mptr = mptr->next) {
765 && (mptr->march_floor != curr_floor))
769 rp = malloc(sizeof(struct ctdlroomlisting));
770 strncpy(rp->rlname, mptr->march_name, ROOMNAMELEN);
771 rp->rlflags = mptr->march_flags;
772 rp->rlfloor = mptr->march_floor;
773 rp->rlorder = mptr->march_order;
782 if (rordercmp(rp, rs) < 0) {
783 if (rs->lnext == NULL) {
790 if (rs->rnext == NULL) {
802 /* Find position of current room */
803 room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
804 room_tree_list_query(rl, room_name, 0, NULL, &rmslot, &rmtotal);
806 if (direction == 0) { /* Previous room */
807 /* If we're at the first room, wrap to the last room */
809 rmslot = rmtotal - 1;
813 } else { /* Next room */
814 /* If we're at the last room, wrap to the first room */
815 if (rmslot == rmtotal - 1) {
822 /* Get name of next/previous room */
823 room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
824 room_tree_list_query(rl, NULL, rmslot, rmname, NULL, NULL);
827 room_tree_list_query(rl, NULL, 0, NULL, NULL, NULL);
829 if (mode == 0) { /* not skipping */
832 if (rc_alt_semantics) {
837 /* Free the room list */
839 mptr = listing->next;
844 dotgoto(ipc, rmname, 1, 0);
849 * step through floors on system
851 void gotofloorstep(CtdlIPC *ipc, int direction, int mode)
855 if (floorlist[0][0] == 0)
860 if (direction == 0) { /* Previous floor */
861 if (curr_floor) tofloor = curr_floor - 1;
864 while (!floorlist[tofloor][0]) tofloor--;
865 } else { /* Next floor */
866 if (curr_floor < 127) tofloor = curr_floor + 1;
869 while (!floorlist[tofloor][0] && tofloor < 127) tofloor++;
870 if (!floorlist[tofloor][0]) tofloor = 0;
872 /* ;g works when not in floor mode so . . . */
874 scr_printf("(%s)\n", floorlist[tofloor] );
877 gotofloor(ipc, floorlist[tofloor], mode);
878 if (curr_floor != tofloor) { /* gotofloor failed */
879 curr_floor = tofloor;
880 goto empty_keep_going;
885 * Display user 'preferences'.
887 extern int rc_prompt_control;
888 void read_config(CtdlIPC *ipc)
892 int r; /* IPC response code */
893 char _fullname[USERNAME_SIZE];
895 int _axlevel, _timescalled, _posted;
897 struct ctdluser *user = NULL;
899 /* get misc user info */
900 r = CtdlIPCGetBio(ipc, fullname, &resp, buf);
902 pprintf("%s\n", buf);
905 extract_token(_fullname, buf, 1, '|', sizeof fullname);
906 _usernum = extract_long(buf, 2);
907 _axlevel = extract_int(buf, 3);
908 _lastcall = extract_long(buf, 4);
909 _timescalled = extract_int(buf, 5);
910 _posted = extract_int(buf, 6);
914 /* get preferences */
915 r = CtdlIPCGetConfig(ipc, &user, buf);
917 scr_printf("%s\n", buf);
922 /* show misc user info */
923 scr_printf("%s\nAccess level: %d (%s)\n"
924 "User #%ld / %d Calls / %d Posts",
925 _fullname, _axlevel, axdefs[(int) _axlevel],
926 _usernum, _timescalled, _posted);
927 if (_lastcall > 0L) {
928 scr_printf(" / Curr login: %s",
929 asctime(localtime(&_lastcall)));
933 /* show preferences */
934 scr_printf("Your screen width: "); color(BRIGHT_CYAN); scr_printf("%d", /*user->USscreenwidth*/ screenwidth); color(DIM_WHITE);
935 scr_printf(", height: "); color(BRIGHT_CYAN); scr_printf("%d\n", /*user->USscreenheight*/ screenheight); color(DIM_WHITE);
936 scr_printf("Are you an experienced Citadel user: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No"); color(DIM_WHITE);
937 scr_printf("Print last old message on New message request: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_LASTOLD)? "Yes" : "No"); color(DIM_WHITE);
938 scr_printf("Prompt after each message: "); color(BRIGHT_CYAN); scr_printf("%s\n", (!(user->flags & US_NOPROMPT))? "Yes" : "No"); color(DIM_WHITE);
939 if ((user->flags & US_NOPROMPT) == 0) {
940 scr_printf("Use 'disappearing' prompts: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_DISAPPEAR)? "Yes" : "No"); color(DIM_WHITE);
942 scr_printf("Pause after each screenful of text: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PAGINATOR)? "Yes" : "No"); color(DIM_WHITE);
943 if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) {
944 scr_printf("<N>ext and <S>top work at paginator prompt: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PROMPTCTL)? "Yes" : "No"); color(DIM_WHITE);
946 if (rc_floor_mode == RC_DEFAULT) {
947 scr_printf("View rooms by floor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_FLOORS)? "Yes" : "No"); color(DIM_WHITE);
949 if (rc_ansi_color == 3) {
950 scr_printf("Enable color support: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_COLOR)? "Yes" : "No"); color(DIM_WHITE);
952 scr_printf("Be unlisted in userlog: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_UNLISTED)? "Yes" : "No"); color(DIM_WHITE);
953 if (!IsEmptyStr(editor_paths[0])) {
954 scr_printf("Always enter messages with the full-screen editor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXTEDIT)? "Yes" : "No"); color(DIM_WHITE);
960 * Display system statistics.
962 void system_info(CtdlIPC *ipc)
967 int mrtg_users, mrtg_active_users;
968 char mrtg_server_uptime[40];
970 int ret; /* IPC response code */
972 /* get #users, #active & server uptime */
973 ret = CtdlIPCGenericCommand(ipc, "MRTG|users", NULL, 0, &resp, &bytes, buf);
974 mrtg_users = extract_int(resp, 0);
975 remove_token(resp, 0, '\n');
976 mrtg_active_users = extract_int(resp, 0);
977 remove_token(resp, 0, '\n');
978 extract_token(mrtg_server_uptime, resp, 0, '\n', sizeof mrtg_server_uptime);
982 /* get high message# */
983 ret = CtdlIPCGenericCommand(ipc, "MRTG|messages", NULL, 0, &resp, &bytes, buf);
984 mrtg_himessage = extract_long(resp, 0);
988 /* refresh server info just in case */
989 CtdlIPCServerInfo(ipc, buf);
991 scr_printf("You are connected to %s (%s) @%s\n", ipc->ServInfo.nodename, ipc->ServInfo.humannode, ipc->ServInfo.fqdn);
992 scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)REV_LEVEL/100);
993 scr_printf("and located in %s.\n", ipc->ServInfo.site_location);
994 scr_printf("Connected users %d / Active users %d / Highest message #%ld\n", mrtg_users, mrtg_active_users, mrtg_himessage);
995 scr_printf("Server uptime: %s\n", mrtg_server_uptime);
996 scr_printf("Your system administrator is %s.\n", ipc->ServInfo.sysadm);
997 scr_printf("Copyright (C)1987-2007 by the Citadel development team\n");
1001 * forget all rooms on current floor
1003 void forget_this_floor(CtdlIPC *ipc)
1005 if (curr_floor == 0) {
1006 scr_printf("Can't forget this floor.\n");
1009 if (floorlist[0][0] == 0) {
1010 load_floorlist(ipc);
1012 scr_printf("Are you sure you want to forget all rooms on %s? ",
1013 &floorlist[(int) curr_floor][0]);
1018 gf_toroom(ipc, "_BASEROOM_", GF_ZAP);
1023 * Figure out the physical screen dimensions, if we can
1024 * WARNING: this is now called from a signal handler!
1026 void check_screen_dims(void)
1030 unsigned short height; /* rows */
1031 unsigned short width; /* columns */
1032 unsigned short xpixels;
1033 unsigned short ypixels; /* pixels */
1036 if (have_xterm) { /* dynamically size screen if on an xterm */
1037 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
1039 screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
1041 screenwidth = (int) xwinsz.width;
1049 * set floor mode depending on client, server, and user settings
1051 void set_floor_mode(CtdlIPC* ipc)
1053 if (ipc->ServInfo.ok_floors == 0) {
1054 floor_mode = 0; /* Don't use floors if the server */
1056 /* doesn't support them! */
1058 if (rc_floor_mode == RC_NO) { /* never use floors */
1061 if (rc_floor_mode == RC_YES) { /* always use floors */
1064 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
1065 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
1071 * Set or change the user's password
1073 int set_password(CtdlIPC *ipc)
1079 if (!IsEmptyStr(rc_password)) {
1080 strcpy(pass1, rc_password);
1081 strcpy(pass2, rc_password);
1083 IFNEXPERT formout(ipc, "changepw");
1084 newprompt("Enter a new password: ", pass1, -19);
1085 newprompt("Enter it again to confirm: ", pass2, -19);
1089 if (!strcasecmp(pass1, pass2)) {
1090 CtdlIPCChangePassword(ipc, pass1, buf);
1091 scr_printf("%s\n", buf);
1092 offer_to_remember_password(ipc, hostbuf, portbuf, fullname, pass1);
1095 scr_printf("*** They don't match... try again.\n");
1103 * get info about the server we've connected to
1105 void get_serv_info(CtdlIPC *ipc, char *supplied_hostname)
1109 CtdlIPCServerInfo(ipc, buf);
1111 /* be nice and identify ourself to the server */
1112 CtdlIPCIdentifySoftware(ipc, SERVER_TYPE, 0, REV_LEVEL,
1113 (ipc->isLocal ? "local" : CITADEL),
1114 (supplied_hostname) ? supplied_hostname :
1115 /* Look up the , in the bible if you're confused */
1116 (locate_host(ipc, buf), buf), buf);
1119 * Tell the server what our preferred content formats are.
1121 * Originally we preferred HTML over plain text because we can format
1122 * it to the reader's screen width, but since our HTML-to-text parser
1123 * isn't really all that great, it's probably better to just go with
1124 * the plain text when we have it available.
1126 if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "text/plain|text/html") / 100 )== 2) {
1134 * Record compare function for SortOnlineUsers()
1136 int idlecmp(const void *rec1, const void *rec2) {
1139 i1 = extract_long(rec1, 5);
1140 i2 = extract_long(rec2, 5);
1142 if (i1 < i2) return(1);
1143 if (i1 > i2) return(-1);
1149 * Sort the list of online users by idle time.
1150 * This function frees the supplied buffer, and returns a new one
1151 * to the caller. The caller is responsible for freeing the returned buffer.
1153 char *SortOnlineUsers(char *listing) {
1160 rows = num_tokens(listing, '\n');
1161 sortbuf = malloc(rows * SIZ);
1162 if (sortbuf == NULL) return(listing);
1163 retbuf = malloc(rows * SIZ);
1164 if (retbuf == NULL) {
1169 /* Copy the list into a fixed-record-size array for sorting */
1170 for (i=0; i<rows; ++i) {
1171 memset(buf, 0, SIZ);
1172 extract_token(buf, listing, i, '\n', sizeof buf);
1173 memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
1177 qsort(sortbuf, rows, SIZ, idlecmp);
1179 /* Copy back to a \n delimited list */
1181 for (i=0; i<rows; ++i) {
1182 strcat(retbuf, &sortbuf[i*SIZ]);
1183 if (i<(rows-1)) strcat(retbuf, "\n");
1193 * Display list of users currently logged on to the server
1195 void who_is_online(CtdlIPC *ipc, int longlist)
1197 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
1199 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
1200 char clientsoft[SIZ];
1202 time_t idletime, idlehours, idlemins, idlesecs;
1203 int last_session = (-1);
1205 char *listing = NULL;
1206 int r; /* IPC response code */
1208 if (longlist == 2) {
1214 color(BRIGHT_WHITE);
1215 pprintf(" User Name Room ");
1216 if (screenwidth >= 80) pprintf(" Idle From host");
1219 pprintf(" ------------------------- --------------------");
1220 if (screenwidth >= 80) pprintf(" ---- ------------------------");
1223 r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
1224 listing = SortOnlineUsers(listing);
1226 while (!IsEmptyStr(listing)) {
1229 /* Get another line */
1230 extract_token(buf, listing, 0, '\n', sizeof buf);
1231 remove_token(listing, 0, '\n');
1233 extract_token(username, buf, 1, '|', sizeof username);
1234 extract_token(roomname, buf, 2, '|', sizeof roomname);
1235 extract_token(fromhost, buf, 3, '|', sizeof fromhost);
1236 extract_token(clientsoft, buf, 4, '|', sizeof clientsoft);
1237 extract_token(flags, buf, 7, '|', sizeof flags);
1239 idletime = timenow - extract_long(buf, 5);
1240 idlehours = idletime / 3600;
1241 idlemins = (idletime - (idlehours * 3600)) / 60;
1242 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
1244 if (idletime > rc_idle_threshold) {
1251 extract_token(actual_user, buf, 8, '|', sizeof actual_user);
1252 extract_token(actual_room, buf, 9, '|', sizeof actual_room);
1253 extract_token(actual_host, buf, 10, '|', sizeof actual_host);
1255 pprintf(" Flags: %s\n", flags);
1256 pprintf("Session: %d\n", extract_int(buf, 0));
1257 pprintf(" Name: %s\n", username);
1258 pprintf("In room: %s\n", roomname);
1259 pprintf(" Host: %s\n", fromhost);
1260 pprintf(" Client: %s\n", clientsoft);
1261 pprintf(" Idle: %ld:%02ld:%02ld\n",
1266 if ( (!IsEmptyStr(actual_user)&&
1267 !IsEmptyStr(actual_room)&&
1268 !IsEmptyStr(actual_host))) {
1269 pprintf("(really ");
1270 if (!IsEmptyStr(actual_user)) pprintf("<%s> ", actual_user);
1271 if (!IsEmptyStr(actual_room)) pprintf("in <%s> ", actual_room);
1272 if (!IsEmptyStr(actual_host)) pprintf("from <%s> ", actual_host);
1279 if (extract_int(buf, 0) == last_session) {
1283 color(BRIGHT_MAGENTA);
1284 pprintf("%-3s", flags);
1286 last_session = extract_int(buf, 0);
1288 pprintf("%-25s ", username);
1289 color(BRIGHT_MAGENTA);
1291 pprintf("%-20s", roomname);
1293 if (screenwidth >= 80) {
1295 if (idletime > rc_idle_threshold) {
1296 /* over 1000d, must be gone fishing */
1297 if (idlehours > 23999) {
1300 } else if (idlehours > 239) {
1301 pprintf("%3ldd", idlehours / 24);
1303 } else if (idlehours > 9) {
1304 pprintf("%1ldd%02ld",
1307 /* less than 10 hours */
1310 pprintf("%1ld:%02ld", idlehours, idlemins);
1318 fromhost[24] = '\0';
1319 pprintf("%-24s", fromhost);
1330 void enternew(CtdlIPC *ipc, char *desc, char *buf, int maxlen)
1333 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
1334 newprompt(bbb, buf, maxlen);
1339 int shift(int argc, char **argv, int start, int count) {
1342 for (i=start; i<(argc-count); ++i) {
1343 argv[i] = argv[i+count];
1345 argc = argc - count;
1349 static void statusHook(char *s) {
1357 int main(int argc, char **argv)
1360 char aaa[100], bbb[100];/* general purpose variables */
1361 char argbuf[64]; /* command line buf */
1362 char nonce[NONCE_SIZE];
1363 char *telnet_client_host = NULL;
1364 char *sptr, *sptr2; /* USed to extract the nonce */
1365 char hexstring[MD5_HEXSTRING_SIZE];
1366 int stored_password = 0;
1368 struct ctdlipcmisc chek;
1369 struct ctdluser *myself = NULL;
1370 CtdlIPC* ipc; /* Our server connection */
1371 int r; /* IPC result code */
1375 char relhome[PATH_MAX]="";
1376 char ctdldir[PATH_MAX]=CTDLDIR;
1380 calc_dirs_n_files(relh, home, relhome, ctdldir);
1382 setIPCDeathHook(screen_delete);
1383 setIPCErrorPrintf(err_printf);
1384 setCryptoStatusHook(statusHook);
1386 /* Permissions sanity check - don't run citadel setuid/setgid */
1387 if (getuid() != geteuid()) {
1388 err_printf("Please do not run citadel setuid!\n");
1390 } else if (getgid() != getegid()) {
1391 err_printf("Please do not run citadel setgid!\n");
1395 stty_ctdl(SB_SAVE); /* Store the old terminal parameters */
1396 load_command_set(); /* parse the citadel.rc file */
1397 stty_ctdl(SB_NO_INTR); /* Install the new ones */
1398 /* signal(SIGHUP, dropcarr);FIXME */ /* Cleanup gracefully if carrier is dropped */
1399 signal(SIGPIPE, dropcarr); /* Cleanup gracefully if local conn. dropped */
1400 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
1401 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
1403 signal(SIGWINCH, scr_winch); /* Window resize signal */
1407 arg_encrypt = RC_DEFAULT;
1409 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1410 arg_screen = RC_DEFAULT;
1414 * Handle command line options as if we were called like /bin/login
1415 * (i.e. from in.telnetd)
1417 for (a=0; a<argc; ++a) {
1418 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
1419 telnet_client_host = argv[a+1];
1420 argc = shift(argc, argv, a, 2);
1422 if (!strcmp(argv[a], "-x")) {
1424 arg_encrypt = RC_NO;
1426 argc = shift(argc, argv, a, 1);
1428 if (!strcmp(argv[a], "-X")) {
1430 arg_encrypt = RC_YES;
1431 argc = shift(argc, argv, a, 1);
1433 fprintf(stderr, "Not compiled with encryption support");
1437 if (!strcmp(argv[a], "-s")) {
1438 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1441 argc = shift(argc, argv, a, 1);
1443 if (!strcmp(argv[a], "-S")) {
1444 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1445 arg_screen = RC_YES;
1447 argc = shift(argc, argv, a, 1);
1449 if (!strcmp(argv[a], "-p")) {
1452 if (chdir(CTDLDIR) < 0) {
1453 perror("can't change to " CTDLDIR);
1458 * Drop privileges if necessary. We stat
1459 * citadel.config to get the uid/gid since it's
1460 * guaranteed to have the uid/gid we want.
1462 if (!getuid() || !getgid()) {
1463 if (stat(file_citadel_config, &st) < 0) {
1464 perror("couldn't stat citadel.config");
1467 if (!getgid() && (setgid(st.st_gid) < 0)) {
1468 perror("couldn't change gid");
1471 if (!getuid() && (setuid(st.st_uid) < 0)) {
1472 perror("couldn't change uid");
1476 scr_printf("Privileges changed to uid %d gid %d\n",
1477 getuid(), getgid());
1480 argc = shift(argc, argv, a, 1);
1488 newprompt("Connect to (return for local server): ", hostbuf, 64);
1491 sln_printf("Attaching to server... \r");
1493 ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
1496 error_printf("Can't connect: %s\n", strerror(errno));
1499 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1500 CtdlIPC_SetNetworkStatusCallback(ipc, wait_indicator);
1502 ipc_for_signal_handlers = ipc; /* KLUDGE cover your eyes */
1504 CtdlIPC_chat_recv(ipc, aaa);
1505 if (aaa[0] != '2') {
1506 scr_printf("%s\n", &aaa[4]);
1507 logoff(ipc, atoi(aaa));
1510 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
1514 if ((sptr = strchr(aaa, '<')) == NULL)
1520 if ((sptr2 = strchr(sptr, '>')) == NULL)
1528 strncpy(nonce, sptr, (size_t)NONCE_SIZE);
1533 /* Evaluate encryption preferences */
1534 if (arg_encrypt != RC_NO && rc_encrypt != RC_NO) {
1535 if (!ipc->isLocal || arg_encrypt == RC_YES || rc_encrypt == RC_YES) {
1536 secure = (CtdlIPCStartEncryption(ipc, aaa) / 100 == 2) ? 1 : 0;
1538 error_printf("Can't encrypt: %s\n", aaa);
1543 get_serv_info(ipc, telnet_client_host);
1544 scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
1545 ipc->ServInfo.site_location);
1548 status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location, NULL,
1551 screenwidth = 80; /* default screen dimensions */
1554 scr_printf(" pause next stop\n");
1555 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1556 formout(ipc, "hello"); /* print the opening greeting */
1559 GSTA: /* See if we have a username and password on disk */
1560 if (rc_remember_passwords) {
1561 get_stored_password(hostbuf, portbuf, fullname, password);
1562 if (!IsEmptyStr(fullname)) {
1563 r = CtdlIPCTryLogin(ipc, fullname, aaa);
1566 r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
1568 r = CtdlIPCTryPassword(ipc, password, aaa);
1573 load_user_info(aaa);
1574 stored_password = 1;
1577 set_stored_password(hostbuf, portbuf, "", "");
1585 if (!IsEmptyStr(rc_username)) {
1586 strcpy(fullname, rc_username);
1588 newprompt("Enter your name: ", fullname, 29);
1591 if (!strcasecmp(fullname, "new")) { /* just in case */
1592 scr_printf("Please enter the name you wish to log in with.\n");
1595 (!strcasecmp(fullname, "bbs"))
1596 || (!strcasecmp(fullname, "new"))
1597 || (IsEmptyStr(fullname)));
1599 if (!strcasecmp(fullname, "off")) {
1603 /* sign on to the server */
1604 r = CtdlIPCTryLogin(ipc, fullname, aaa);
1608 /* password authentication */
1609 if (!IsEmptyStr(rc_password)) {
1610 strcpy(password, rc_password);
1612 newprompt("\rPlease enter your password: ", password, -19);
1617 r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
1619 r = CtdlIPCTryPassword(ipc, password, aaa);
1623 load_user_info(aaa);
1624 offer_to_remember_password(ipc, hostbuf, portbuf,
1625 fullname, password);
1628 scr_printf("<< wrong password >>\n");
1629 if (!IsEmptyStr(rc_password))
1633 NEWUSR: if (IsEmptyStr(rc_password)) {
1634 scr_printf("'%s' not found.\n", fullname);
1635 scr_printf("Type 'off' if you would like to exit.\n");
1636 if (ipc->ServInfo.newuser_disabled == 1) {
1639 scr_printf("Do you want to create a new user account called '%s'? ",
1646 r = CtdlIPCCreateUser(ipc, fullname, 1, aaa);
1648 scr_printf("%s\n", aaa);
1651 load_user_info(aaa);
1653 while (set_password(ipc) != 0);
1656 enter_config(ipc, 1);
1659 /* Switch color support on or off if we're in user mode */
1660 if (rc_ansi_color == 3) {
1661 if (userflags & US_COLOR)
1667 color(BRIGHT_WHITE);
1668 scr_printf("\n%s\nAccess level: %d (%s)\n"
1669 "User #%ld / Login #%d",
1670 fullname, axlevel, axdefs[(int) axlevel],
1671 usernum, timescalled);
1672 if (lastcall > 0L) {
1673 scr_printf(" / Last login: %s",
1674 asctime(localtime(&lastcall)));
1678 r = CtdlIPCMiscCheck(ipc, &chek, aaa);
1684 scr_printf("*** You have a new private message in Mail>\n");
1686 scr_printf("*** You have %d new private messages in Mail>\n", b);
1688 if (!IsEmptyStr(rc_gotmail_cmd)) {
1689 system(rc_gotmail_cmd);
1692 if ((axlevel >= 6) && (chek.needvalid > 0)) {
1693 scr_printf("*** Users need validation\n");
1695 if (chek.needregis > 0) {
1696 scr_printf("*** Please register.\n");
1697 formout(ipc, "register");
1701 /* Make up some temporary filenames for use in various parts of the
1702 * program. Don't mess with these once they've been set, because we
1703 * will be unlinking them later on in the program and we don't
1704 * want to delete something that we didn't create. */
1705 CtdlMakeTempFileName(temp, sizeof temp);
1706 CtdlMakeTempFileName(temp2, sizeof temp2);
1707 CtdlMakeTempFileName(tempdir, sizeof tempdir);
1709 /* Get screen dimensions. First we go to a default of 80x24. Then
1710 * we try to get the user's actual screen dimensions off the server.
1711 * However, if we're running on an xterm, all this stuff is
1712 * irrelevant because we're going to dynamically size the screen
1713 * during the session.
1717 r = CtdlIPCGetConfig(ipc, &myself, aaa);
1719 screenwidth = myself->USscreenwidth;
1720 screenheight = myself->USscreenheight;
1722 if (getenv("TERM") != NULL)
1723 if (!strcmp(getenv("TERM"), "xterm")) {
1727 check_screen_dims();
1730 set_floor_mode(ipc);
1732 /* Enter the lobby */
1733 dotgoto(ipc, "_BASEROOM_", 1, 0);
1735 /* Main loop for the system... user is logged in. */
1740 readmsgs(ipc, LastMessages, ReadForward, 5);
1742 readmsgs(ipc, NewMessages, ReadForward, 0);
1744 /* MAIN COMMAND LOOP */
1746 mcmd = getcmd(ipc, argbuf); /* Get keyboard command */
1749 check_screen_dims(); /* if xterm, get screen size */
1755 formout(ipc, "help");
1758 entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 0);
1761 entmsg(ipc, 0, 1, 0);
1764 entmsg(ipc, 0, 2, 0);
1767 entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 1);
1769 case 5: /* <G>oto */
1773 case 47: /* <A>bandon */
1774 if (!rc_alt_semantics) {
1779 case 90: /* <.A>bandon */
1780 if (!rc_alt_semantics)
1782 dotgoto(ipc, argbuf, 0, 0);
1784 case 58: /* <M>ail */
1786 dotgoto(ipc, "_MAIL_", 1, 0);
1789 if (!IsEmptyStr(argbuf)) {
1791 dotgoto(ipc, argbuf, 0, 0);
1795 if (!IsEmptyStr(argbuf)) {
1796 if (rc_alt_semantics) {
1799 dotgoto(ipc, argbuf, 0, 0);
1802 case 95: /* what exactly is the numbering scheme supposed to be anyway? --Ford, there isn't one. -IO */
1803 dotungoto(ipc, argbuf);
1806 readmsgs(ipc, AllMessages, ReadForward, 0);
1809 readmsgs(ipc, LastMessages, ReadForward, 5);
1812 readmsgs(ipc, NewMessages, ReadForward, 0);
1815 readmsgs(ipc, AllMessages, ReadReverse, 0);
1818 readmsgs(ipc, OldMessages, ReadReverse, 0);
1821 readmsgs(ipc, LastMessages, ReadForward,
1838 userlist(ipc, argbuf);
1896 if (!rc_alt_semantics) {
1908 cli_image_upload(ipc, "_userpic_");
1911 cli_image_upload(ipc, "_roompic_");
1915 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1916 cli_image_upload(ipc, aaa);
1920 enternew(ipc, "roomname", aaa, 20);
1921 r = CtdlIPCChangeRoomname(ipc, aaa, bbb);
1923 scr_printf("\n%s\n", bbb);
1926 enternew(ipc, "hostname", aaa, 25);
1927 r = CtdlIPCChangeHostname(ipc, aaa, bbb);
1929 scr_printf("\n%s\n", bbb);
1932 enternew(ipc, "username", aaa, 32);
1933 r = CtdlIPCChangeUsername(ipc, aaa, bbb);
1935 scr_printf("\n%s\n", bbb);
1945 display_help(ipc, argbuf);
1949 formout(ipc, "register");
1954 scr_printf("Are you sure (y/n)? ");
1956 if (!rc_alt_semantics)
1964 scr_printf("All users will be disconnected! "
1965 "Really terminate the server? ");
1967 if (!rc_alt_semantics)
1969 r = CtdlIPCTerminateServerNow(ipc, aaa);
1970 scr_printf("%s\n", aaa);
1979 scr_printf("Do you really want to schedule a "
1980 "server shutdown? ");
1982 r = CtdlIPCTerminateServerScheduled(ipc, 1, aaa);
1986 "The Citadel server will terminate when all users are logged off.\n"
1990 "The Citadel server will not terminate.\n"
1998 network_config_management(ipc, "listrecp",
1999 "Message-by-message mailing list recipients");
2003 network_config_management(ipc, "digestrecp",
2004 "Digest mailing list recipients");
2008 network_config_management(ipc, "ignet_push_share",
2009 "Nodes with which we share this room");
2013 do_ignet_configuration(ipc);
2017 do_filterlist_configuration(ipc);
2021 if (rc_alt_semantics) {
2034 stty_ctdl(SB_RESTORE);
2035 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
2036 "exec ./subsystem %ld %d %d", fullname,
2037 usernum, screenwidth, axlevel);
2039 stty_ctdl(SB_NO_INTR);
2042 scr_printf("*** Can't run doors when server is not local.\n");
2047 who_is_online(ipc, 0);
2051 who_is_online(ipc, 1);
2055 who_is_online(ipc, 2);
2059 do_system_configuration(ipc);
2063 do_internet_configuration(ipc);
2067 check_message_base(ipc);
2079 enter_config(ipc, 2);
2083 enter_config(ipc, 0);
2084 set_floor_mode(ipc);
2088 enter_config(ipc, 3);
2089 set_floor_mode(ipc);
2093 gotofloor(ipc, argbuf, GF_GOTO);
2097 gotofloor(ipc, argbuf, GF_SKIP);
2101 forget_this_floor(ipc);
2133 knrooms(ipc, floor_mode);
2143 misc_server_cmd(ipc, argbuf);
2147 edit_system_message(ipc, argbuf);
2171 case 110: /* <+> Next room */
2172 gotoroomstep(ipc, 1, 0);
2175 case 111: /* <-> Previous room */
2176 gotoroomstep(ipc, 0, 0);
2179 case 112: /* <>> Next floor */
2180 gotofloorstep(ipc, 1, GF_GOTO);
2183 case 113: /* <<> Previous floor */
2184 gotofloorstep(ipc, 0, GF_GOTO);
2187 case 116: /* <.> skip to <+> Next room */
2188 gotoroomstep(ipc, 1, 1);
2191 case 117: /* <.> skip to <-> Previous room */
2192 gotoroomstep(ipc, 0, 1);
2195 case 118: /* <.> skip to <>> Next floor */
2196 gotofloorstep(ipc, 1, GF_SKIP);
2199 case 119: /* <.> skip to <<> Previous floor */
2200 gotofloorstep(ipc, 0, GF_SKIP);
2211 case 120: /* .KAnonymous */
2212 dotknown(ipc, 0, NULL);
2215 case 121: /* .KDirectory */
2216 dotknown(ipc, 1, NULL);
2219 case 122: /* .KMatch */
2220 dotknown(ipc, 2, argbuf);
2223 case 123: /* .KpreferredOnly */
2224 dotknown(ipc, 3, NULL);
2227 case 124: /* .KPrivate */
2228 dotknown(ipc, 4, NULL);
2231 case 125: /* .KRead only */
2232 dotknown(ipc, 5, NULL);
2235 case 126: /* .KShared */
2236 dotknown(ipc, 6, NULL);
2239 default: /* allow some math on the command */
2240 /* commands 100... to 100+MAX_EDITORS-1 will
2241 call the appropriate editor... in other
2242 words, command numbers 100+ will match
2243 the citadel.rc keys editor0, editor1, etc.*/
2244 if (mcmd >= 100 && mcmd < (100+MAX_EDITORS))
2246 /* entmsg mode >=2 select editor */
2247 entmsg(ipc, 0, mcmd - 100 + 2, 0);
2251 } while (termn8 == 0);
2253 TERMN8: scr_printf("%s logged out.", fullname);
2255 color(ORIGINAL_PAIR);
2257 while (march != NULL) {
2258 remove_march(march->march_name, 0);
2261 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
2264 if ((mcmd == 29) || (mcmd == 15)) {
2266 stty_ctdl(SB_RESTORE);
2267 formout(ipc, "goodbye");
2270 /* Free the ungoto list */
2271 for (lp = 0; lp < uglistsize; lp++) {