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 mptr->march_order = 0;
521 mptr->march_floor = 0;
522 strcpy(mptr->march_name, "_BASEROOM_");
527 while (mptr2->next != NULL)
532 * ...and remove the room we're currently in, so a <G>oto doesn't make us
533 * walk around in circles
535 remove_march(room_name, 0);
538 strcpy(next_room, pop_march(curr_floor, march));
540 strcpy(next_room, "_BASEROOM_");
542 remove_march(next_room, 0);
543 dotgoto(ipc, next_room, 1, 0);
547 * forget all rooms on a given floor
549 void forget_all_rooms_on(CtdlIPC *ipc, int ffloor)
552 struct march *flist = NULL;
553 struct march *fptr = NULL;
554 struct ctdlipcroom *room = NULL;
555 int r; /* IPC response code */
557 scr_printf("Forgetting all rooms on %s...\n", &floorlist[ffloor][0]);
559 remove_march("_FLOOR_", ffloor);
560 r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, ffloor, &flist, buf);
562 scr_printf("Error %d: %s\n", r, buf);
566 r = CtdlIPCGotoRoom(ipc, flist->march_name, "", &room, buf);
568 r = CtdlIPCForgetRoom(ipc, buf);
570 scr_printf("Error %d: %s\n", r, buf);
578 if (room) free(room);
583 * routine called by gotofloor() to move to a new room on a new floor
585 void gf_toroom(CtdlIPC *ipc, char *towhere, int mode)
587 int floor_being_left;
589 floor_being_left = curr_floor;
591 if (mode == GF_GOTO) { /* <;G>oto mode */
593 dotgoto(ipc, towhere, 1, 0);
595 else if (mode == GF_SKIP) { /* <;S>kip mode */
596 dotgoto(ipc, towhere, 1, 0);
597 remove_march("_FLOOR_", floor_being_left);
599 else if (mode == GF_ZAP) { /* <;Z>ap mode */
600 dotgoto(ipc, towhere, 1, 0);
601 remove_march("_FLOOR_", floor_being_left);
602 forget_all_rooms_on(ipc, floor_being_left);
610 void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
613 int r; /* IPC response code */
615 char buf[SIZ], targ[SIZ];
617 if (floorlist[0][0] == 0)
620 for (a = 0; a < 128; ++a)
621 if (!strcasecmp(&floorlist[a][0], towhere))
625 for (a = 0; a < 128; ++a) {
626 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
632 for (a = 0; a < 128; ++a)
633 if (pattern(towhere, &floorlist[a][0]) > 0)
637 scr_printf("No floor '%s'.\n", towhere);
640 for (mptr = march; mptr != NULL; mptr = mptr->next) {
641 if ((mptr->march_floor) == tofloor) {
642 gf_toroom(ipc, mptr->march_name, mode);
647 /* Find first known room on the floor */
651 r = CtdlIPCKnownRooms(ipc, SubscribedRooms, tofloor, &mptr, buf);
653 struct march *tmp = mptr;
655 /*. . . according to room order */
657 strcpy(targ, pop_march(tofloor, mptr));
664 if (!IsEmptyStr(targ)) {
665 gf_toroom(ipc, targ, mode);
669 /* No known rooms on the floor; unzap the first one then */
673 r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, tofloor, &mptr, buf);
675 struct march *tmp = mptr;
677 /*. . . according to room order */
679 strcpy(targ, pop_march(tofloor, mptr));
686 if (!IsEmptyStr(targ)) {
687 gf_toroom(ipc, targ, mode);
689 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
694 * Indexing mechanism for a room list, called by gotoroomstep()
696 void room_tree_list_query(struct ctdlroomlisting *rp, char *findrmname, int findrmslot, char *rmname, int *rmslot, int *rmtotal)
698 char roomname[ROOMNAMELEN];
699 static int cur_rmslot = 0;
706 if (rp->lnext != NULL) {
707 room_tree_list_query(rp->lnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
710 if (sigcaught == 0) {
711 strcpy(roomname, rp->rlname);
713 if (rmname != NULL) {
714 if (cur_rmslot == findrmslot) {
715 strcpy(rmname, roomname);
718 if (rmslot != NULL) {
719 if (!strcmp(roomname, findrmname)) {
720 *rmslot = cur_rmslot;
726 if (rp->rnext != NULL) {
727 room_tree_list_query(rp->rnext, findrmname, findrmslot, rmname, rmslot, rmtotal);
730 if ((rmname == NULL) && (rmslot == NULL))
733 if (rmtotal != NULL) {
734 *rmtotal = cur_rmslot;
739 * step through rooms on current floor
741 void gotoroomstep(CtdlIPC *ipc, int direction, int mode)
743 struct march *listing = NULL;
745 int r; /* IPC response code */
747 struct ctdlroomlisting *rl = NULL;
748 struct ctdlroomlisting *rp;
749 struct ctdlroomlisting *rs;
751 char rmname[ROOMNAMELEN];
754 struct ctdlroom *attr = NULL;
756 /* Fetch the existing room config */
757 r = CtdlIPCGetRoomAttributes(ipc, &attr, buf);
759 scr_printf("%s\n", buf);
762 strcpy (room_name , attr->QRname);
765 /* Ask the server for a room list */
766 r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
773 for (mptr = listing; mptr != NULL; mptr = mptr->next) {
777 && (mptr->march_floor != curr_floor))
781 rp = malloc(sizeof(struct ctdlroomlisting));
782 strncpy(rp->rlname, mptr->march_name, ROOMNAMELEN);
783 rp->rlflags = mptr->march_flags;
784 rp->rlfloor = mptr->march_floor;
785 rp->rlorder = mptr->march_order;
794 if (rordercmp(rp, rs) < 0) {
795 if (rs->lnext == NULL) {
802 if (rs->rnext == NULL) {
814 /* Find position of current room */
815 room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
816 room_tree_list_query(rl, room_name, 0, NULL, &rmslot, &rmtotal);
818 if (direction == 0) { /* Previous room */
819 /* If we're at the first room, wrap to the last room */
821 rmslot = rmtotal - 1;
825 } else { /* Next room */
826 /* If we're at the last room, wrap to the first room */
827 if (rmslot == rmtotal - 1) {
834 /* Get name of next/previous room */
835 room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
836 room_tree_list_query(rl, NULL, rmslot, rmname, NULL, NULL);
839 room_tree_list_query(rl, NULL, 0, NULL, NULL, NULL);
841 if (mode == 0) { /* not skipping */
844 if (rc_alt_semantics) {
849 /* Free the room list */
851 mptr = listing->next;
856 dotgoto(ipc, rmname, 1, 0);
861 * step through floors on system
863 void gotofloorstep(CtdlIPC *ipc, int direction, int mode)
867 if (floorlist[0][0] == 0)
872 if (direction == 0) { /* Previous floor */
873 if (curr_floor) tofloor = curr_floor - 1;
876 while (!floorlist[tofloor][0]) tofloor--;
877 } else { /* Next floor */
878 if (curr_floor < 127) tofloor = curr_floor + 1;
881 while (!floorlist[tofloor][0] && tofloor < 127) tofloor++;
882 if (!floorlist[tofloor][0]) tofloor = 0;
884 /* ;g works when not in floor mode so . . . */
886 scr_printf("(%s)\n", floorlist[tofloor] );
889 gotofloor(ipc, floorlist[tofloor], mode);
890 if (curr_floor != tofloor) { /* gotofloor failed */
891 curr_floor = tofloor;
892 goto empty_keep_going;
897 * Display user 'preferences'.
899 extern int rc_prompt_control;
900 void read_config(CtdlIPC *ipc)
904 int r; /* IPC response code */
905 char _fullname[USERNAME_SIZE];
907 int _axlevel, _timescalled, _posted;
909 struct ctdluser *user = NULL;
911 /* get misc user info */
912 r = CtdlIPCGetBio(ipc, fullname, &resp, buf);
914 pprintf("%s\n", buf);
917 extract_token(_fullname, buf, 1, '|', sizeof fullname);
918 _usernum = extract_long(buf, 2);
919 _axlevel = extract_int(buf, 3);
920 _lastcall = extract_long(buf, 4);
921 _timescalled = extract_int(buf, 5);
922 _posted = extract_int(buf, 6);
926 /* get preferences */
927 r = CtdlIPCGetConfig(ipc, &user, buf);
929 scr_printf("%s\n", buf);
934 /* show misc user info */
935 scr_printf("%s\nAccess level: %d (%s)\n"
936 "User #%ld / %d Calls / %d Posts",
937 _fullname, _axlevel, axdefs[(int) _axlevel],
938 _usernum, _timescalled, _posted);
939 if (_lastcall > 0L) {
940 scr_printf(" / Curr login: %s",
941 asctime(localtime(&_lastcall)));
945 /* show preferences */
946 scr_printf("Your screen width: "); color(BRIGHT_CYAN); scr_printf("%d", /*user->USscreenwidth*/ screenwidth); color(DIM_WHITE);
947 scr_printf(", height: "); color(BRIGHT_CYAN); scr_printf("%d\n", /*user->USscreenheight*/ screenheight); color(DIM_WHITE);
948 scr_printf("Are you an experienced Citadel user: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No"); color(DIM_WHITE);
949 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);
950 scr_printf("Prompt after each message: "); color(BRIGHT_CYAN); scr_printf("%s\n", (!(user->flags & US_NOPROMPT))? "Yes" : "No"); color(DIM_WHITE);
951 if ((user->flags & US_NOPROMPT) == 0) {
952 scr_printf("Use 'disappearing' prompts: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_DISAPPEAR)? "Yes" : "No"); color(DIM_WHITE);
954 scr_printf("Pause after each screenful of text: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PAGINATOR)? "Yes" : "No"); color(DIM_WHITE);
955 if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) {
956 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);
958 if (rc_floor_mode == RC_DEFAULT) {
959 scr_printf("View rooms by floor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_FLOORS)? "Yes" : "No"); color(DIM_WHITE);
961 if (rc_ansi_color == 3) {
962 scr_printf("Enable color support: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_COLOR)? "Yes" : "No"); color(DIM_WHITE);
964 scr_printf("Be unlisted in userlog: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_UNLISTED)? "Yes" : "No"); color(DIM_WHITE);
965 if (!IsEmptyStr(editor_paths[0])) {
966 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);
972 * Display system statistics.
974 void system_info(CtdlIPC *ipc)
979 int mrtg_users, mrtg_active_users;
980 char mrtg_server_uptime[40];
982 int ret; /* IPC response code */
984 /* get #users, #active & server uptime */
985 ret = CtdlIPCGenericCommand(ipc, "MRTG|users", NULL, 0, &resp, &bytes, buf);
986 mrtg_users = extract_int(resp, 0);
987 remove_token(resp, 0, '\n');
988 mrtg_active_users = extract_int(resp, 0);
989 remove_token(resp, 0, '\n');
990 extract_token(mrtg_server_uptime, resp, 0, '\n', sizeof mrtg_server_uptime);
994 /* get high message# */
995 ret = CtdlIPCGenericCommand(ipc, "MRTG|messages", NULL, 0, &resp, &bytes, buf);
996 mrtg_himessage = extract_long(resp, 0);
1000 /* refresh server info just in case */
1001 CtdlIPCServerInfo(ipc, buf);
1003 scr_printf("You are connected to %s (%s) @%s\n", ipc->ServInfo.nodename, ipc->ServInfo.humannode, ipc->ServInfo.fqdn);
1004 scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)REV_LEVEL/100);
1005 scr_printf("and located in %s.\n", ipc->ServInfo.site_location);
1006 scr_printf("Connected users %d / Active users %d / Highest message #%ld\n", mrtg_users, mrtg_active_users, mrtg_himessage);
1007 scr_printf("Server uptime: %s\n", mrtg_server_uptime);
1008 scr_printf("Your system administrator is %s.\n", ipc->ServInfo.sysadm);
1009 scr_printf("Copyright (C)1987-2007 by the Citadel development team\n");
1013 * forget all rooms on current floor
1015 void forget_this_floor(CtdlIPC *ipc)
1017 if (curr_floor == 0) {
1018 scr_printf("Can't forget this floor.\n");
1021 if (floorlist[0][0] == 0) {
1022 load_floorlist(ipc);
1024 scr_printf("Are you sure you want to forget all rooms on %s? ",
1025 &floorlist[(int) curr_floor][0]);
1030 gf_toroom(ipc, "_BASEROOM_", GF_ZAP);
1035 * Figure out the physical screen dimensions, if we can
1036 * WARNING: this is now called from a signal handler!
1038 void check_screen_dims(void)
1042 unsigned short height; /* rows */
1043 unsigned short width; /* columns */
1044 unsigned short xpixels;
1045 unsigned short ypixels; /* pixels */
1048 if (have_xterm) { /* dynamically size screen if on an xterm */
1049 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
1051 screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
1053 screenwidth = (int) xwinsz.width;
1061 * set floor mode depending on client, server, and user settings
1063 void set_floor_mode(CtdlIPC* ipc)
1065 if (ipc->ServInfo.ok_floors == 0) {
1066 floor_mode = 0; /* Don't use floors if the server */
1068 /* doesn't support them! */
1070 if (rc_floor_mode == RC_NO) { /* never use floors */
1073 if (rc_floor_mode == RC_YES) { /* always use floors */
1076 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
1077 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
1083 * Set or change the user's password
1085 int set_password(CtdlIPC *ipc)
1091 if (!IsEmptyStr(rc_password)) {
1092 strcpy(pass1, rc_password);
1093 strcpy(pass2, rc_password);
1095 IFNEXPERT formout(ipc, "changepw");
1096 newprompt("Enter a new password: ", pass1, -19);
1097 newprompt("Enter it again to confirm: ", pass2, -19);
1101 if (!strcasecmp(pass1, pass2)) {
1102 CtdlIPCChangePassword(ipc, pass1, buf);
1103 scr_printf("%s\n", buf);
1104 offer_to_remember_password(ipc, hostbuf, portbuf, fullname, pass1);
1107 scr_printf("*** They don't match... try again.\n");
1115 * get info about the server we've connected to
1117 void get_serv_info(CtdlIPC *ipc, char *supplied_hostname)
1121 CtdlIPCServerInfo(ipc, buf);
1123 /* be nice and identify ourself to the server */
1124 CtdlIPCIdentifySoftware(ipc, SERVER_TYPE, 0, REV_LEVEL,
1125 (ipc->isLocal ? "local" : CITADEL),
1126 (supplied_hostname) ? supplied_hostname :
1127 /* Look up the , in the bible if you're confused */
1128 (locate_host(ipc, buf), buf), buf);
1131 * Tell the server what our preferred content formats are.
1133 * Originally we preferred HTML over plain text because we can format
1134 * it to the reader's screen width, but since our HTML-to-text parser
1135 * isn't really all that great, it's probably better to just go with
1136 * the plain text when we have it available.
1138 if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "text/plain|text/html") / 100 )== 2) {
1146 * Record compare function for SortOnlineUsers()
1148 int idlecmp(const void *rec1, const void *rec2) {
1151 i1 = extract_long(rec1, 5);
1152 i2 = extract_long(rec2, 5);
1154 if (i1 < i2) return(1);
1155 if (i1 > i2) return(-1);
1161 * Sort the list of online users by idle time.
1162 * This function frees the supplied buffer, and returns a new one
1163 * to the caller. The caller is responsible for freeing the returned buffer.
1165 char *SortOnlineUsers(char *listing) {
1172 rows = num_tokens(listing, '\n');
1173 sortbuf = malloc(rows * SIZ);
1174 if (sortbuf == NULL) return(listing);
1175 retbuf = malloc(rows * SIZ);
1176 if (retbuf == NULL) {
1181 /* Copy the list into a fixed-record-size array for sorting */
1182 for (i=0; i<rows; ++i) {
1183 memset(buf, 0, SIZ);
1184 extract_token(buf, listing, i, '\n', sizeof buf);
1185 memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
1189 qsort(sortbuf, rows, SIZ, idlecmp);
1191 /* Copy back to a \n delimited list */
1193 for (i=0; i<rows; ++i) {
1194 strcat(retbuf, &sortbuf[i*SIZ]);
1195 if (i<(rows-1)) strcat(retbuf, "\n");
1205 * Display list of users currently logged on to the server
1207 void who_is_online(CtdlIPC *ipc, int longlist)
1209 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
1211 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
1212 char clientsoft[SIZ];
1214 time_t idletime, idlehours, idlemins, idlesecs;
1215 int last_session = (-1);
1217 char *listing = NULL;
1218 int r; /* IPC response code */
1220 if (longlist == 2) {
1226 color(BRIGHT_WHITE);
1227 pprintf(" User Name Room ");
1228 if (screenwidth >= 80) pprintf(" Idle From host");
1231 pprintf(" ------------------------- --------------------");
1232 if (screenwidth >= 80) pprintf(" ---- ------------------------");
1235 r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
1236 listing = SortOnlineUsers(listing);
1238 while (!IsEmptyStr(listing)) {
1241 /* Get another line */
1242 extract_token(buf, listing, 0, '\n', sizeof buf);
1243 remove_token(listing, 0, '\n');
1245 extract_token(username, buf, 1, '|', sizeof username);
1246 extract_token(roomname, buf, 2, '|', sizeof roomname);
1247 extract_token(fromhost, buf, 3, '|', sizeof fromhost);
1248 extract_token(clientsoft, buf, 4, '|', sizeof clientsoft);
1249 extract_token(flags, buf, 7, '|', sizeof flags);
1251 idletime = timenow - extract_long(buf, 5);
1252 idlehours = idletime / 3600;
1253 idlemins = (idletime - (idlehours * 3600)) / 60;
1254 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
1256 if (idletime > rc_idle_threshold) {
1263 extract_token(actual_user, buf, 8, '|', sizeof actual_user);
1264 extract_token(actual_room, buf, 9, '|', sizeof actual_room);
1265 extract_token(actual_host, buf, 10, '|', sizeof actual_host);
1267 pprintf(" Flags: %s\n", flags);
1268 pprintf("Session: %d\n", extract_int(buf, 0));
1269 pprintf(" Name: %s\n", username);
1270 pprintf("In room: %s\n", roomname);
1271 pprintf(" Host: %s\n", fromhost);
1272 pprintf(" Client: %s\n", clientsoft);
1273 pprintf(" Idle: %ld:%02ld:%02ld\n",
1278 if ( (!IsEmptyStr(actual_user)&&
1279 !IsEmptyStr(actual_room)&&
1280 !IsEmptyStr(actual_host))) {
1281 pprintf("(really ");
1282 if (!IsEmptyStr(actual_user)) pprintf("<%s> ", actual_user);
1283 if (!IsEmptyStr(actual_room)) pprintf("in <%s> ", actual_room);
1284 if (!IsEmptyStr(actual_host)) pprintf("from <%s> ", actual_host);
1291 if (extract_int(buf, 0) == last_session) {
1295 color(BRIGHT_MAGENTA);
1296 pprintf("%-3s", flags);
1298 last_session = extract_int(buf, 0);
1300 pprintf("%-25s ", username);
1301 color(BRIGHT_MAGENTA);
1303 pprintf("%-20s", roomname);
1305 if (screenwidth >= 80) {
1307 if (idletime > rc_idle_threshold) {
1308 /* over 1000d, must be gone fishing */
1309 if (idlehours > 23999) {
1312 } else if (idlehours > 239) {
1313 pprintf("%3ldd", idlehours / 24);
1315 } else if (idlehours > 9) {
1316 pprintf("%1ldd%02ld",
1319 /* less than 10 hours */
1322 pprintf("%1ld:%02ld", idlehours, idlemins);
1330 fromhost[24] = '\0';
1331 pprintf("%-24s", fromhost);
1342 void enternew(CtdlIPC *ipc, char *desc, char *buf, int maxlen)
1345 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
1346 newprompt(bbb, buf, maxlen);
1351 int shift(int argc, char **argv, int start, int count) {
1354 for (i=start; i<(argc-count); ++i) {
1355 argv[i] = argv[i+count];
1357 argc = argc - count;
1361 static void statusHook(char *s) {
1369 int main(int argc, char **argv)
1372 char aaa[100], bbb[100];/* general purpose variables */
1373 char argbuf[64]; /* command line buf */
1374 char nonce[NONCE_SIZE];
1375 char *telnet_client_host = NULL;
1376 char *sptr, *sptr2; /* USed to extract the nonce */
1377 char hexstring[MD5_HEXSTRING_SIZE];
1378 int stored_password = 0;
1380 struct ctdlipcmisc chek;
1381 struct ctdluser *myself = NULL;
1382 CtdlIPC* ipc; /* Our server connection */
1383 int r; /* IPC result code */
1387 char relhome[PATH_MAX]="";
1388 char ctdldir[PATH_MAX]=CTDLDIR;
1392 calc_dirs_n_files(relh, home, relhome, ctdldir);
1394 setIPCDeathHook(screen_delete);
1395 setIPCErrorPrintf(err_printf);
1396 setCryptoStatusHook(statusHook);
1398 /* Permissions sanity check - don't run citadel setuid/setgid */
1399 if (getuid() != geteuid()) {
1400 err_printf("Please do not run citadel setuid!\n");
1402 } else if (getgid() != getegid()) {
1403 err_printf("Please do not run citadel setgid!\n");
1407 stty_ctdl(SB_SAVE); /* Store the old terminal parameters */
1408 load_command_set(); /* parse the citadel.rc file */
1409 stty_ctdl(SB_NO_INTR); /* Install the new ones */
1410 /* signal(SIGHUP, dropcarr);FIXME */ /* Cleanup gracefully if carrier is dropped */
1411 signal(SIGPIPE, dropcarr); /* Cleanup gracefully if local conn. dropped */
1412 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
1413 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
1415 signal(SIGWINCH, scr_winch); /* Window resize signal */
1419 arg_encrypt = RC_DEFAULT;
1421 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1422 arg_screen = RC_DEFAULT;
1426 * Handle command line options as if we were called like /bin/login
1427 * (i.e. from in.telnetd)
1429 for (a=0; a<argc; ++a) {
1430 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
1431 telnet_client_host = argv[a+1];
1432 argc = shift(argc, argv, a, 2);
1434 if (!strcmp(argv[a], "-x")) {
1436 arg_encrypt = RC_NO;
1438 argc = shift(argc, argv, a, 1);
1440 if (!strcmp(argv[a], "-X")) {
1442 arg_encrypt = RC_YES;
1443 argc = shift(argc, argv, a, 1);
1445 fprintf(stderr, "Not compiled with encryption support");
1449 if (!strcmp(argv[a], "-s")) {
1450 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1453 argc = shift(argc, argv, a, 1);
1455 if (!strcmp(argv[a], "-S")) {
1456 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1457 arg_screen = RC_YES;
1459 argc = shift(argc, argv, a, 1);
1461 if (!strcmp(argv[a], "-p")) {
1464 if (chdir(CTDLDIR) < 0) {
1465 perror("can't change to " CTDLDIR);
1470 * Drop privileges if necessary. We stat
1471 * citadel.config to get the uid/gid since it's
1472 * guaranteed to have the uid/gid we want.
1474 if (!getuid() || !getgid()) {
1475 if (stat(file_citadel_config, &st) < 0) {
1476 perror("couldn't stat citadel.config");
1479 if (!getgid() && (setgid(st.st_gid) < 0)) {
1480 perror("couldn't change gid");
1483 if (!getuid() && (setuid(st.st_uid) < 0)) {
1484 perror("couldn't change uid");
1488 scr_printf("Privileges changed to uid %d gid %d\n",
1489 getuid(), getgid());
1492 argc = shift(argc, argv, a, 1);
1500 newprompt("Connect to (return for local server): ", hostbuf, 64);
1503 sln_printf("Attaching to server... \r");
1505 ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
1508 error_printf("Can't connect: %s\n", strerror(errno));
1511 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
1512 CtdlIPC_SetNetworkStatusCallback(ipc, wait_indicator);
1514 ipc_for_signal_handlers = ipc; /* KLUDGE cover your eyes */
1516 CtdlIPC_chat_recv(ipc, aaa);
1517 if (aaa[0] != '2') {
1518 scr_printf("%s\n", &aaa[4]);
1519 logoff(ipc, atoi(aaa));
1522 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
1526 if ((sptr = strchr(aaa, '<')) == NULL)
1532 if ((sptr2 = strchr(sptr, '>')) == NULL)
1540 strncpy(nonce, sptr, (size_t)NONCE_SIZE);
1545 /* Evaluate encryption preferences */
1546 if (arg_encrypt != RC_NO && rc_encrypt != RC_NO) {
1547 if (!ipc->isLocal || arg_encrypt == RC_YES || rc_encrypt == RC_YES) {
1548 secure = (CtdlIPCStartEncryption(ipc, aaa) / 100 == 2) ? 1 : 0;
1550 error_printf("Can't encrypt: %s\n", aaa);
1555 get_serv_info(ipc, telnet_client_host);
1556 scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
1557 ipc->ServInfo.site_location);
1560 status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location, NULL,
1563 screenwidth = 80; /* default screen dimensions */
1566 scr_printf(" pause next stop\n");
1567 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1568 formout(ipc, "hello"); /* print the opening greeting */
1571 GSTA: /* See if we have a username and password on disk */
1572 if (rc_remember_passwords) {
1573 get_stored_password(hostbuf, portbuf, fullname, password);
1574 if (!IsEmptyStr(fullname)) {
1575 r = CtdlIPCTryLogin(ipc, fullname, aaa);
1578 r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
1580 r = CtdlIPCTryPassword(ipc, password, aaa);
1585 load_user_info(aaa);
1586 stored_password = 1;
1589 set_stored_password(hostbuf, portbuf, "", "");
1597 if (!IsEmptyStr(rc_username)) {
1598 strcpy(fullname, rc_username);
1600 newprompt("Enter your name: ", fullname, 29);
1603 if (!strcasecmp(fullname, "new")) { /* just in case */
1604 scr_printf("Please enter the name you wish to log in with.\n");
1607 (!strcasecmp(fullname, "bbs"))
1608 || (!strcasecmp(fullname, "new"))
1609 || (IsEmptyStr(fullname)));
1611 if (!strcasecmp(fullname, "off")) {
1615 /* sign on to the server */
1616 r = CtdlIPCTryLogin(ipc, fullname, aaa);
1620 /* password authentication */
1621 if (!IsEmptyStr(rc_password)) {
1622 strcpy(password, rc_password);
1624 newprompt("\rPlease enter your password: ", password, -19);
1629 r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
1631 r = CtdlIPCTryPassword(ipc, password, aaa);
1635 load_user_info(aaa);
1636 offer_to_remember_password(ipc, hostbuf, portbuf,
1637 fullname, password);
1640 scr_printf("<< wrong password >>\n");
1641 if (!IsEmptyStr(rc_password))
1645 NEWUSR: if (IsEmptyStr(rc_password)) {
1646 scr_printf("'%s' not found.\n", fullname);
1647 scr_printf("Type 'off' if you would like to exit.\n");
1648 if (ipc->ServInfo.newuser_disabled == 1) {
1651 scr_printf("Do you want to create a new user account called '%s'? ",
1658 r = CtdlIPCCreateUser(ipc, fullname, 1, aaa);
1660 scr_printf("%s\n", aaa);
1663 load_user_info(aaa);
1665 while (set_password(ipc) != 0);
1668 enter_config(ipc, 1);
1671 /* Switch color support on or off if we're in user mode */
1672 if (rc_ansi_color == 3) {
1673 if (userflags & US_COLOR)
1679 color(BRIGHT_WHITE);
1680 scr_printf("\n%s\nAccess level: %d (%s)\n"
1681 "User #%ld / Login #%d",
1682 fullname, axlevel, axdefs[(int) axlevel],
1683 usernum, timescalled);
1684 if (lastcall > 0L) {
1685 scr_printf(" / Last login: %s",
1686 asctime(localtime(&lastcall)));
1690 r = CtdlIPCMiscCheck(ipc, &chek, aaa);
1696 scr_printf("*** You have a new private message in Mail>\n");
1698 scr_printf("*** You have %d new private messages in Mail>\n", b);
1700 if (!IsEmptyStr(rc_gotmail_cmd)) {
1701 system(rc_gotmail_cmd);
1704 if ((axlevel >= 6) && (chek.needvalid > 0)) {
1705 scr_printf("*** Users need validation\n");
1707 if (chek.needregis > 0) {
1708 scr_printf("*** Please register.\n");
1709 formout(ipc, "register");
1713 /* Make up some temporary filenames for use in various parts of the
1714 * program. Don't mess with these once they've been set, because we
1715 * will be unlinking them later on in the program and we don't
1716 * want to delete something that we didn't create. */
1717 CtdlMakeTempFileName(temp, sizeof temp);
1718 CtdlMakeTempFileName(temp2, sizeof temp2);
1719 CtdlMakeTempFileName(tempdir, sizeof tempdir);
1721 /* Get screen dimensions. First we go to a default of 80x24. Then
1722 * we try to get the user's actual screen dimensions off the server.
1723 * However, if we're running on an xterm, all this stuff is
1724 * irrelevant because we're going to dynamically size the screen
1725 * during the session.
1729 r = CtdlIPCGetConfig(ipc, &myself, aaa);
1731 screenwidth = myself->USscreenwidth;
1732 screenheight = myself->USscreenheight;
1734 if (getenv("TERM") != NULL)
1735 if (!strcmp(getenv("TERM"), "xterm")) {
1739 check_screen_dims();
1742 set_floor_mode(ipc);
1744 /* Enter the lobby */
1745 dotgoto(ipc, "_BASEROOM_", 1, 0);
1747 /* Main loop for the system... user is logged in. */
1752 readmsgs(ipc, LastMessages, ReadForward, 5);
1754 readmsgs(ipc, NewMessages, ReadForward, 0);
1756 /* MAIN COMMAND LOOP */
1758 mcmd = getcmd(ipc, argbuf); /* Get keyboard command */
1761 check_screen_dims(); /* if xterm, get screen size */
1767 formout(ipc, "help");
1770 entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 0);
1773 entmsg(ipc, 0, 1, 0);
1776 entmsg(ipc, 0, 2, 0);
1779 entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 1);
1781 case 5: /* <G>oto */
1785 case 47: /* <A>bandon */
1786 if (!rc_alt_semantics) {
1791 case 90: /* <.A>bandon */
1792 if (!rc_alt_semantics)
1794 dotgoto(ipc, argbuf, 0, 0);
1796 case 58: /* <M>ail */
1798 dotgoto(ipc, "_MAIL_", 1, 0);
1801 if (!IsEmptyStr(argbuf)) {
1803 dotgoto(ipc, argbuf, 0, 0);
1807 if (!IsEmptyStr(argbuf)) {
1808 if (rc_alt_semantics) {
1811 dotgoto(ipc, argbuf, 0, 0);
1814 case 95: /* what exactly is the numbering scheme supposed to be anyway? --Ford, there isn't one. -IO */
1815 dotungoto(ipc, argbuf);
1818 readmsgs(ipc, AllMessages, ReadForward, 0);
1821 readmsgs(ipc, LastMessages, ReadForward, 5);
1824 readmsgs(ipc, NewMessages, ReadForward, 0);
1827 readmsgs(ipc, AllMessages, ReadReverse, 0);
1830 readmsgs(ipc, OldMessages, ReadReverse, 0);
1833 readmsgs(ipc, LastMessages, ReadForward,
1850 userlist(ipc, argbuf);
1908 if (!rc_alt_semantics) {
1920 cli_image_upload(ipc, "_userpic_");
1923 cli_image_upload(ipc, "_roompic_");
1927 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1928 cli_image_upload(ipc, aaa);
1932 enternew(ipc, "roomname", aaa, 20);
1933 r = CtdlIPCChangeRoomname(ipc, aaa, bbb);
1935 scr_printf("\n%s\n", bbb);
1938 enternew(ipc, "hostname", aaa, 25);
1939 r = CtdlIPCChangeHostname(ipc, aaa, bbb);
1941 scr_printf("\n%s\n", bbb);
1944 enternew(ipc, "username", aaa, 32);
1945 r = CtdlIPCChangeUsername(ipc, aaa, bbb);
1947 scr_printf("\n%s\n", bbb);
1957 display_help(ipc, argbuf);
1961 formout(ipc, "register");
1966 scr_printf("Are you sure (y/n)? ");
1968 if (!rc_alt_semantics)
1976 scr_printf("All users will be disconnected! "
1977 "Really terminate the server? ");
1979 if (!rc_alt_semantics)
1981 r = CtdlIPCTerminateServerNow(ipc, aaa);
1982 scr_printf("%s\n", aaa);
1991 scr_printf("Do you really want to schedule a "
1992 "server shutdown? ");
1994 r = CtdlIPCTerminateServerScheduled(ipc, 1, aaa);
1998 "The Citadel server will terminate when all users are logged off.\n"
2002 "The Citadel server will not terminate.\n"
2010 network_config_management(ipc, "listrecp",
2011 "Message-by-message mailing list recipients");
2015 network_config_management(ipc, "digestrecp",
2016 "Digest mailing list recipients");
2020 network_config_management(ipc, "ignet_push_share",
2021 "Nodes with which we share this room");
2025 do_ignet_configuration(ipc);
2029 do_filterlist_configuration(ipc);
2033 if (rc_alt_semantics) {
2046 stty_ctdl(SB_RESTORE);
2047 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
2048 "exec ./subsystem %ld %d %d", fullname,
2049 usernum, screenwidth, axlevel);
2051 stty_ctdl(SB_NO_INTR);
2054 scr_printf("*** Can't run doors when server is not local.\n");
2059 who_is_online(ipc, 0);
2063 who_is_online(ipc, 1);
2067 who_is_online(ipc, 2);
2071 do_system_configuration(ipc);
2075 do_internet_configuration(ipc);
2079 check_message_base(ipc);
2091 enter_config(ipc, 2);
2095 enter_config(ipc, 0);
2096 set_floor_mode(ipc);
2100 enter_config(ipc, 3);
2101 set_floor_mode(ipc);
2105 gotofloor(ipc, argbuf, GF_GOTO);
2109 gotofloor(ipc, argbuf, GF_SKIP);
2113 forget_this_floor(ipc);
2145 knrooms(ipc, floor_mode);
2155 misc_server_cmd(ipc, argbuf);
2159 edit_system_message(ipc, argbuf);
2183 case 110: /* <+> Next room */
2184 gotoroomstep(ipc, 1, 0);
2187 case 111: /* <-> Previous room */
2188 gotoroomstep(ipc, 0, 0);
2191 case 112: /* <>> Next floor */
2192 gotofloorstep(ipc, 1, GF_GOTO);
2195 case 113: /* <<> Previous floor */
2196 gotofloorstep(ipc, 0, GF_GOTO);
2199 case 116: /* <.> skip to <+> Next room */
2200 gotoroomstep(ipc, 1, 1);
2203 case 117: /* <.> skip to <-> Previous room */
2204 gotoroomstep(ipc, 0, 1);
2207 case 118: /* <.> skip to <>> Next floor */
2208 gotofloorstep(ipc, 1, GF_SKIP);
2211 case 119: /* <.> skip to <<> Previous floor */
2212 gotofloorstep(ipc, 0, GF_SKIP);
2223 case 120: /* .KAnonymous */
2224 dotknown(ipc, 0, NULL);
2227 case 121: /* .KDirectory */
2228 dotknown(ipc, 1, NULL);
2231 case 122: /* .KMatch */
2232 dotknown(ipc, 2, argbuf);
2235 case 123: /* .KpreferredOnly */
2236 dotknown(ipc, 3, NULL);
2239 case 124: /* .KPrivate */
2240 dotknown(ipc, 4, NULL);
2243 case 125: /* .KRead only */
2244 dotknown(ipc, 5, NULL);
2247 case 126: /* .KShared */
2248 dotknown(ipc, 6, NULL);
2251 default: /* allow some math on the command */
2252 /* commands 100... to 100+MAX_EDITORS-1 will
2253 call the appropriate editor... in other
2254 words, command numbers 100+ will match
2255 the citadel.rc keys editor0, editor1, etc.*/
2256 if (mcmd >= 100 && mcmd < (100+MAX_EDITORS))
2258 /* entmsg mode >=2 select editor */
2259 entmsg(ipc, 0, mcmd - 100 + 2, 0);
2263 } while (termn8 == 0);
2265 TERMN8: scr_printf("%s logged out.", fullname);
2267 color(ORIGINAL_PAIR);
2269 while (march != NULL) {
2270 remove_march(march->march_name, 0);
2273 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
2276 if ((mcmd == 29) || (mcmd == 15)) {
2278 stty_ctdl(SB_RESTORE);
2279 formout(ipc, "goodbye");
2282 /* Free the ungoto list */
2283 for (lp = 0; lp < uglistsize; lp++) {