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>
38 #include "serv_info.h"
40 #include "routines2.h"
45 #include "client_chat.h"
46 #include "client_passwords.h"
47 #include "citadel_decls.h"
50 #include "client_crypto.h"
60 char march_name[ROOMNAMELEN];
65 #define IFEXPERT if (userflags&US_EXPERT)
66 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
67 #define IFAIDE if (axlevel>=6)
68 #define IFNAIDE if (axlevel<6)
70 struct march *march = NULL;
72 /* globals associated with the client program */
73 char temp[PATH_MAX]; /* Name of general temp file */
74 char temp2[PATH_MAX]; /* Name of general temp file */
75 char tempdir[PATH_MAX]; /* Name of general temp dir */
76 char editor_path[SIZ]; /* path to external editor */
77 char printcmd[SIZ]; /* print command */
78 int editor_pid = (-1);
81 struct CtdlServInfo serv_info; /* Info on the server connected */
85 char room_name[ROOMNAMELEN];
86 char ugname[ROOMNAMELEN];
87 long uglsn; /* holds <u>ngoto info */
88 char is_mail = 0; /* nonzero when we're in a mail room */
89 char axlevel = 0; /* access level */
90 char is_room_aide = 0; /* boolean flag, 1 if room aide */
94 long usernum = 0L; /* user number */
95 time_t lastcall = 0L; /* Date/time of previous login */
97 long highest_msg_read; /* used for <A>bandon room cmd */
98 long maxmsgnum; /* used for <G>oto */
100 char have_xterm = 0; /* are we running on an xterm? */
101 char rc_username[32];
102 char rc_password[32];
107 char curr_floor = 0; /* number of current floor */
108 char floorlist[128][SIZ]; /* names of floors */
109 char express_msgs = 0; /* express messages waiting! */
110 int termn8 = 0; /* Set to nonzero to cause a logoff */
112 extern int rc_ansi_color; /* ansi color value from citadel.rc */
115 * here is our 'clean up gracefully and exit' routine
117 void logoff(int code)
119 if (editor_pid > 0) { /* kill the editor if it's running */
120 kill(editor_pid, SIGHUP);
122 /* shut down the server... but not if the logoff code is 3, because
123 * that means we're exiting because we already lost the server
129 * now clean up various things
138 /* Violently kill off any child processes if Citadel is
141 if (getppid() == 1) {
142 kill(0 - getpgrp(), SIGTERM);
144 kill(0 - getpgrp(), SIGKILL);
146 sttybbs(SB_RESTORE); /* return the old terminal settings */
147 exit(code); /* exit with the proper exit code */
153 * signal catching function for hangups...
155 void dropcarr(int signum)
163 * catch SIGCONT to reset terminal modes when were are put back into the
166 void catch_sigcont(int signum)
169 signal(SIGCONT, catch_sigcont);
174 /* general purpose routines */
176 void formout(char *name)
177 { /* display a file */
179 snprintf(cmd, sizeof cmd, "MESG %s", name);
183 scr_printf("%s\n", &cmd[4]);
186 fmout(screenwidth, NULL,
187 ((userflags & US_PAGINATOR) ? 1 : 0),
192 void userlist(char *patn)
202 pprintf("%s\n", &buf[4]);
205 pprintf(" User Name Num L LastCall Calls Posts\n");
206 pprintf("------------------------- ----- - ---------- ----- -----\n");
207 while (serv_gets(buf), strcmp(buf, "000")) {
208 if (sigcaught == 0) {
210 if (pattern(fl, patn) >= 0) {
211 pprintf("%-25s ", fl);
212 pprintf("%5ld %d ", extract_long(buf, 2),
213 extract_int(buf, 1));
214 lc = extract_long(buf, 3);
215 tmbuf = (struct tm *) localtime(&lc);
216 pprintf("%02d/%02d/%04d ",
219 (tmbuf->tm_year + 1900));
220 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
230 * grab assorted info about the user...
232 void load_user_info(char *params)
234 extract(fullname, params, 0);
235 axlevel = extract_int(params, 1);
236 timescalled = extract_int(params, 2);
237 posted = extract_int(params, 3);
238 userflags = extract_int(params, 4);
239 usernum = extract_long(params, 5);
240 lastcall = extract_long(params, 6);
245 * Remove a room from the march list. 'floornum' is ignored unless
246 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
247 * floor will be removed from the march list.
249 void remove_march(char *roomname, int floornum)
251 struct march *mptr, *mptr2;
256 if ((!strcasecmp(march->march_name, roomname))
257 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
264 for (mptr = march; mptr != NULL; mptr = mptr->next) {
266 if ((!strcasecmp(mptr->march_name, roomname))
267 || ((!strcasecmp(roomname, "_FLOOR_"))
268 && (mptr->march_floor == floornum))) {
270 mptr2->next = mptr->next;
281 * Locate the room on the march list which we most want to go to. Each room
282 * is measured given a "weight" of preference based on various factors.
284 char *pop_march(int desired_floor)
286 static char TheRoom[ROOMNAMELEN];
288 int TheOrder = 32767;
291 struct march *mptr = NULL;
293 strcpy(TheRoom, "_BASEROOM_");
297 for (mptr = march; mptr != NULL; mptr = mptr->next) {
299 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
300 weight = weight + 10000;
301 if (mptr->march_floor == desired_floor)
302 weight = weight + 5000;
304 weight = weight + ((128 - (mptr->march_floor)) * 128);
305 weight = weight + (128 - (mptr->march_order));
307 if (weight > TheWeight) {
309 strcpy(TheRoom, mptr->march_name);
310 TheFloor = mptr->march_floor;
311 TheOrder = mptr->march_order;
319 * jump directly to a room
321 void dotgoto(char *towhere, int display_name)
323 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
326 static int oldmailcount = (-1);
327 int partial_match, best_match;
330 /* store ungoto information */
331 strcpy(ugname, room_name);
334 /* first try an exact match */
335 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
340 if (!strncmp(aaa, "54", 2)) {
341 newprompt("Enter room password: ", bbb, 9);
342 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
348 if (!strncmp(aaa, "54", 2)) {
349 scr_printf("Wrong password.\n");
353 * If a match is not found, try a partial match.
354 * Partial matches anywhere in the string carry a weight of 1,
355 * left-aligned matches carry a weight of 2. Pick the room that
356 * has the highest-weighted match.
364 while (serv_gets(aaa), strcmp(aaa, "000")) {
365 extract(psearch, aaa, 0);
367 if (pattern(psearch, towhere) >= 0) {
370 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
373 if (partial_match > best_match) {
374 strcpy(bbb, psearch);
375 best_match = partial_match;
378 if (strlen(bbb) == 0) {
379 scr_printf("No room '%s'.\n", towhere);
382 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
389 scr_printf("%s\n", aaa);
392 extract(room_name, &aaa[4], 0);
393 room_flags = extract_int(&aaa[4], 4);
394 from_floor = curr_floor;
395 curr_floor = extract_int(&aaa[4], 10);
397 remove_march(room_name, 0);
398 if (!strcasecmp(towhere, "_BASEROOM_"))
399 remove_march(towhere, 0);
400 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
401 if (floorlist[(int) curr_floor][0] == 0)
403 scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
405 if (display_name == 1) {
407 scr_printf("%s ", room_name);
411 if (display_name != 2) {
412 color(BRIGHT_YELLOW);
413 scr_printf("%d ", extract_int(&aaa[4], 1));
415 scr_printf("new of ");
416 color(BRIGHT_YELLOW);
417 scr_printf("%d ", extract_int(&aaa[4], 2));
419 scr_printf("messages.\n");
421 highest_msg_read = extract_int(&aaa[4], 6);
422 maxmsgnum = extract_int(&aaa[4], 5);
423 is_mail = (char) extract_int(&aaa[4], 7);
424 is_room_aide = (char) extract_int(&aaa[4], 8);
425 ls = extract_long(&aaa[4], 6);
427 /* read info file if necessary */
428 if (extract_int(&aaa[4], 3) > 0)
431 /* check for newly arrived mail if we can */
432 if (num_parms(&aaa[4]) >= 10) {
433 newmailcount = extract_int(&aaa[4], 9);
434 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
436 scr_printf("*** You have new mail\n");
439 oldmailcount = newmailcount;
443 /* Goto next room having unread messages.
444 * We want to skip over rooms that the user has already been to, and take the
445 * user back to the lobby when done. The room we end up in is placed in
446 * newroom - which is set to 0 (the lobby) initially.
451 struct march *mptr, *mptr2;
452 char next_room[ROOMNAMELEN];
454 /* Check to see if the march-mode list is already allocated.
455 * If it is, pop the first room off the list and go there.
461 while (serv_gets(buf), strcmp(buf, "000")) {
462 mptr = (struct march *) malloc(sizeof(struct march));
464 extract(mptr->march_name, buf, 0);
465 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
466 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
471 while (mptr2->next != NULL)
476 /* add _BASEROOM_ to the end of the march list, so the user will end up
477 * in the system base room (usually the Lobby>) at the end of the loop
479 mptr = (struct march *) malloc(sizeof(struct march));
481 strcpy(mptr->march_name, "_BASEROOM_");
486 while (mptr2->next != NULL)
491 * ...and remove the room we're currently in, so a <G>oto doesn't make us
492 * walk around in circles
494 remove_march(room_name, 0);
497 strcpy(next_room, pop_march(curr_floor));
499 strcpy(next_room, "_BASEROOM_");
501 remove_march(next_room, 0);
502 dotgoto(next_room, 1);
506 * forget all rooms on a given floor
508 void forget_all_rooms_on(int ffloor)
511 struct march *flist, *fptr;
513 scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
515 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
519 scr_printf("%-72s\n", &buf[4]);
523 while (serv_gets(buf), strcmp(buf, "000")) {
524 fptr = (struct march *) malloc(sizeof(struct march));
527 extract(fptr->march_name, buf, 0);
529 while (flist != NULL) {
530 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
541 scr_printf("%-72s\r", "");
546 * routine called by gotofloor() to move to a new room on a new floor
548 void gf_toroom(char *towhere, int mode)
550 int floor_being_left;
552 floor_being_left = curr_floor;
554 if (mode == GF_GOTO) { /* <;G>oto mode */
558 if (mode == GF_SKIP) { /* <;S>kip mode */
560 remove_march("_FLOOR_", floor_being_left);
562 if (mode == GF_ZAP) { /* <;Z>ap mode */
564 remove_march("_FLOOR_", floor_being_left);
565 forget_all_rooms_on(floor_being_left);
573 void gotofloor(char *towhere, int mode)
577 char buf[SIZ], targ[SIZ];
579 if (floorlist[0][0] == 0)
582 for (a = 0; a < 128; ++a)
583 if (!strcasecmp(&floorlist[a][0], towhere))
587 for (a = 0; a < 128; ++a) {
588 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
594 for (a = 0; a < 128; ++a)
595 if (pattern(towhere, &floorlist[a][0]) > 0)
599 scr_printf("No floor '%s'.\n", towhere);
602 for (mptr = march; mptr != NULL; mptr = mptr->next) {
603 if ((mptr->march_floor) == tofloor)
604 gf_toroom(mptr->march_name, mode);
609 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
613 while (serv_gets(buf), strcmp(buf, "000")) {
614 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
615 extract(targ, buf, 0);
617 if (strlen(targ) > 0) {
618 gf_toroom(targ, mode);
620 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
626 * forget all rooms on current floor
628 void forget_this_floor(void)
631 if (curr_floor == 0) {
632 scr_printf("Can't forget this floor.\n");
635 if (floorlist[0][0] == 0)
637 scr_printf("Are you sure you want to forget all rooms on %s? ",
638 &floorlist[(int) curr_floor][0]);
642 gf_toroom("_BASEROOM_", GF_ZAP);
647 * Figure out the physical screen dimensions, if we can
648 * WARNING: this is now called from a signal handler!
650 void check_screen_dims(void)
654 unsigned short height; /* rows */
655 unsigned short width; /* columns */
656 unsigned short xpixels;
657 unsigned short ypixels; /* pixels */
660 if (scr_set_windowsize())
663 if (have_xterm) { /* dynamically size screen if on an xterm */
664 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
666 screenheight = (int) xwinsz.height;
668 screenwidth = (int) xwinsz.width;
676 * set floor mode depending on client, server, and user settings
678 void set_floor_mode(void)
680 if (serv_info.serv_ok_floors == 0) {
681 floor_mode = 0; /* Don't use floors if the server */
683 /* doesn't support them! */
685 if (rc_floor_mode == RC_NO) { /* never use floors */
688 if (rc_floor_mode == RC_YES) { /* always use floors */
691 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
692 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
698 * Set or change the user's password
700 int set_password(void)
706 if (strlen(rc_password) > 0) {
707 strcpy(pass1, rc_password);
708 strcpy(pass2, rc_password);
710 IFNEXPERT formout("changepw");
711 newprompt("Enter a new password: ", pass1, -19);
712 newprompt("Enter it again to confirm: ", pass2, -19);
716 if (!strcasecmp(pass1, pass2)) {
717 snprintf(buf, sizeof buf, "SETP %s", pass1);
720 scr_printf("%s\n", &buf[4]);
721 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
724 scr_printf("*** They don't match... try again.\n");
732 * get info about the server we've connected to
734 void get_serv_info(char *supplied_hostname)
738 CtdlInternalGetServInfo(&serv_info);
740 /* be nice and identify ourself to the server */
741 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
742 SERVER_TYPE, 0, REV_LEVEL,
743 (server_is_local ? "local" : CITADEL));
745 /* Append a hostname */
746 if (supplied_hostname != NULL) {
747 strcat(buf, supplied_hostname);
750 locate_host(&buf[strlen(buf)]); /* append to the end */
754 serv_gets(buf); /* we don't care about the result code */
762 * Display list of users currently logged on to the server
764 void who_is_online(int longlist)
766 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
768 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
769 char tbuf[SIZ], clientsoft[SIZ];
771 time_t idletime, idlehours, idlemins, idlesecs;
772 int last_session = (-1);
776 if (tbuf[0] == '2') {
777 timenow = extract_long(&tbuf[4], 0);
785 pprintf("FLG ### User Name Room From host\n");
787 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
792 while (serv_gets(buf), strcmp(buf, "000")) {
793 extract(username, buf, 1);
794 extract(roomname, buf, 2);
795 extract(fromhost, buf, 3);
796 extract(clientsoft, buf, 4);
797 extract(flags, buf, 7);
799 idletime = timenow - extract_long(buf, 5);
800 idlehours = idletime / 3600;
801 idlemins = (idletime - (idlehours * 3600)) / 60;
802 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
804 if (idletime > 900) {
805 while (strlen(roomname) < 20) {
806 strcat(roomname, " ");
808 strcpy(&roomname[14], "[idle]");
813 extract(actual_user, buf, 8);
814 extract(actual_room, buf, 9);
815 extract(actual_host, buf, 10);
817 pprintf(" Flags: %s\n", flags);
818 pprintf("Session: %d\n", extract_int(buf, 0));
819 pprintf(" Name: %s\n", username);
820 pprintf("In room: %s\n", roomname);
821 pprintf(" Host: %s\n", fromhost);
822 pprintf(" Client: %s\n", clientsoft);
823 pprintf(" Idle: %ld:%02ld:%02ld\n",
828 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
830 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
831 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
832 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
838 if (extract_int(buf, 0) == last_session) {
841 color(BRIGHT_MAGENTA);
842 pprintf("%-3s ", flags);
844 pprintf("%-3d ", extract_int(buf, 0));
846 last_session = extract_int(buf, 0);
848 pprintf("%-25s ", username);
849 color(BRIGHT_MAGENTA);
851 pprintf("%-20s ", roomname);
854 pprintf("%-24s\n", fromhost);
861 void enternew(char *desc, char *buf, int maxlen)
864 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
865 newprompt(bbb, buf, maxlen);
870 int shift(int argc, char **argv, int start, int count) {
873 for (i=start; i<(argc-count); ++i) {
874 argv[i] = argv[i+count];
883 int main(int argc, char **argv)
886 char aaa[100], bbb[100];/* general purpose variables */
887 char argbuf[32]; /* command line buf */
888 char nonce[NONCE_SIZE];
889 char *telnet_client_host = NULL;
890 char *sptr, *sptr2; /* USed to extract the nonce */
891 char hexstring[MD5_HEXSTRING_SIZE];
892 int stored_password = 0;
895 /* Permissions sanity check - don't run citadel setuid/setgid */
896 if (getuid() != geteuid()) {
897 err_printf("Please do not run citadel setuid!\n");
899 } else if (getgid() != getegid()) {
900 err_printf("Please do not run citadel setgid!\n");
904 sttybbs(SB_SAVE); /* Store the old terminal parameters */
905 load_command_set(); /* parse the citadel.rc file */
906 sttybbs(SB_NO_INTR); /* Install the new ones */
907 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
908 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
909 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
911 arg_encrypt = RC_DEFAULT;
912 arg_screen = RC_DEFAULT;
915 * Handle command line options as if we were called like /bin/login
916 * (i.e. from in.telnetd)
918 for (a=0; a<argc; ++a) {
919 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
920 telnet_client_host = argv[a+1];
921 argc = shift(argc, argv, a, 2);
923 if (!strcmp(argv[a], "-x")) {
925 argc = shift(argc, argv, a, 1);
927 if (!strcmp(argv[a], "-X")) {
928 arg_encrypt = RC_YES;
929 argc = shift(argc, argv, a, 1);
931 if (!strcmp(argv[a], "-s")) {
933 argc = shift(argc, argv, a, 1);
935 if (!strcmp(argv[a], "-S")) {
937 argc = shift(argc, argv, a, 1);
939 if (!strcmp(argv[a], "-p")) {
942 if (chdir(BBSDIR) < 0) {
943 perror("can't change to " BBSDIR);
948 * Drop privileges if necessary. We stat
949 * citadel.config to get the uid/gid since it's
950 * guaranteed to have the uid/gid we want.
952 if (!getuid() || !getgid()) {
953 if (stat(BBSDIR "/citadel.config", &st) < 0) {
954 perror("couldn't stat citadel.config");
957 if (!getgid() && (setgid(st.st_gid) < 0)) {
958 perror("couldn't change gid");
961 if (!getuid() && (setuid(st.st_uid) < 0)) {
962 perror("couldn't change uid");
966 scr_printf("Privileges changed to uid %d gid %d\n",
970 argc = shift(argc, argv, a, 1);
976 sln_printf("Attaching to server... \r");
978 attach_to_server(argc, argv, hostbuf, portbuf);
982 scr_printf("%s\n", &aaa[4]);
986 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
990 if ((sptr = strchr(aaa, '<')) == NULL)
996 if ((sptr2 = strchr(sptr, '>')) == NULL)
1004 strncpy(nonce, sptr, NONCE_SIZE);
1008 get_serv_info(telnet_client_host);
1011 sln_printf("Session will not be encrypted.\n");
1014 scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1015 serv_info.serv_bbs_city);
1017 screenwidth = 80; /* default screen dimensions */
1020 scr_printf(" pause next stop\n");
1021 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1022 formout("hello"); /* print the opening greeting */
1025 GSTA: /* See if we have a username and password on disk */
1026 if (rc_remember_passwords) {
1027 get_stored_password(hostbuf, portbuf, fullname, password);
1028 if (strlen(fullname) > 0) {
1029 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1034 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1036 else /* Else no APOP */
1038 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1043 if (aaa[0] == '2') {
1044 load_user_info(&aaa[4]);
1045 stored_password = 1;
1049 set_stored_password(hostbuf, portbuf, "", "");
1057 if (strlen(rc_username) > 0) {
1058 strcpy(fullname, rc_username);
1060 newprompt("Enter your name: ", fullname, 29);
1063 if (!strcasecmp(fullname, "new")) { /* just in case */
1064 scr_printf("Please enter the name you wish to log in with.\n");
1067 (!strcasecmp(fullname, "bbs"))
1068 || (!strcasecmp(fullname, "new"))
1069 || (strlen(fullname) == 0));
1071 if (!strcasecmp(fullname, "off")) {
1075 /* sign on to the server */
1076 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1082 /* password authentication */
1083 if (strlen(rc_password) > 0) {
1084 strcpy(password, rc_password);
1086 newprompt("\rPlease enter your password: ", password, -19);
1092 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1094 else /* Else no APOP */
1096 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1101 if (aaa[0] == '2') {
1102 load_user_info(&aaa[4]);
1103 offer_to_remember_password(hostbuf, portbuf,
1104 fullname, password);
1107 scr_printf("<< wrong password >>\n");
1108 if (strlen(rc_password) > 0)
1112 NEWUSR: if (strlen(rc_password) == 0) {
1113 scr_printf("No record. Enter as new user? ");
1117 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1120 if (aaa[0] != '2') {
1121 scr_printf("%s\n", aaa);
1124 load_user_info(&aaa[4]);
1126 while (set_password() != 0);;
1132 /* Switch color support on or off if we're in user mode */
1133 if (rc_ansi_color == 3) {
1134 if (userflags & US_COLOR)
1140 scr_printf("%s\nAccess level: %d (%s)\n"
1141 "User #%ld / Login #%d",
1142 fullname, axlevel, axdefs[(int) axlevel],
1143 usernum, timescalled);
1144 if (lastcall > 0L) {
1145 scr_printf(" / Last login: %s\n",
1146 asctime(localtime(&lastcall)) );
1152 if (aaa[0] == '2') {
1153 b = extract_int(&aaa[4], 0);
1157 scr_printf("*** You have a new private message in Mail>\n");
1159 scr_printf("*** You have %d new private messages in Mail>\n", b);
1162 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1163 scr_printf("*** Users need validation\n");
1165 if (extract_int(&aaa[4], 1) > 0) {
1166 scr_printf("*** Please register.\n");
1167 formout("register");
1171 /* Make up some temporary filenames for use in various parts of the
1172 * program. Don't mess with these once they've been set, because we
1173 * will be unlinking them later on in the program and we don't
1174 * want to delete something that we didn't create. */
1175 snprintf(temp, sizeof temp, tmpnam(NULL));
1176 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1177 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1179 /* Get screen dimensions. First we go to a default of 80x24. Then
1180 * we try to get the user's actual screen dimensions off the server.
1181 * However, if we're running on an xterm, all this stuff is
1182 * irrelevant because we're going to dynamically size the screen
1183 * during the session.
1189 if (aaa[0] == '2') {
1190 screenwidth = extract_int(&aaa[4], 0);
1191 screenheight = extract_int(&aaa[4], 1);
1193 if (getenv("TERM") != NULL)
1194 if (!strcmp(getenv("TERM"), "xterm")) {
1198 check_screen_dims();
1204 /* Enter the lobby */
1205 dotgoto("_BASEROOM_", 1);
1207 /* Main loop for the system... user is logged in. */
1216 /* MAIN COMMAND LOOP */
1218 mcmd = getcmd(argbuf); /* Get keyboard command */
1221 check_screen_dims(); /* if xterm, get screen size */
1239 newprompt("What do you want your username to be? ", aaa, 32);
1240 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1243 if (strncmp("200", aaa, 3))
1244 scr_printf("\n%s\n", aaa);
1253 if (!rc_alt_semantics)
1258 if (!rc_alt_semantics)
1264 dotgoto("_MAIL_", 1);
1271 if (rc_alt_semantics)
1285 readmsgs(0, (-1), 0);
1288 readmsgs(2, (-1), 0);
1291 readmsgs(3, 1, atoi(argbuf));
1364 if (!rc_alt_semantics)
1369 if (!rc_alt_semantics)
1380 cli_image_upload("_userpic_");
1383 cli_image_upload("_roompic_");
1387 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1388 cli_image_upload(aaa);
1392 enternew("roomname", aaa, 20);
1393 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1396 if (strncmp("200", aaa, 3))
1397 scr_printf("\n%s\n", aaa);
1400 enternew("hostname", aaa, 25);
1401 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1404 if (strncmp("200", aaa, 3))
1405 scr_printf("\n%s\n", aaa);
1408 enternew("username", aaa, 32);
1409 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1412 if (strncmp("200", aaa, 3))
1413 scr_printf("\n%s\n", aaa);
1423 display_help(argbuf);
1427 formout("register");
1432 scr_printf("Are you sure (y/n)? ");
1441 scr_printf("All users will be disconnected! "
1442 "Really terminate the server? ");
1446 scr_printf("%s\n", &aaa[4]);
1456 scr_printf("Do you really want to schedule a "
1457 "server shutdown? ");
1459 serv_puts("SCDN 1");
1462 if (atoi(&aaa[4])) {
1464 "The Citadel server will terminate when all users are logged off.\n"
1469 "The Citadel server will not terminate.\n"
1477 network_config_management("listrecp",
1478 "Mailing list recipients");
1482 network_config_management("ignet_push_share",
1483 "Nodes with which we share this room");
1487 do_ignet_configuration();
1491 if (rc_alt_semantics)
1501 if (server_is_local) {
1503 sttybbs(SB_RESTORE);
1504 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1505 "exec ./subsystem %ld %d %d", fullname,
1506 usernum, screenwidth, axlevel);
1508 sttybbs(SB_NO_INTR);
1511 scr_printf("*** Can't run doors when server is not local.\n");
1524 do_system_configuration();
1528 do_internet_configuration();
1532 check_message_base();
1554 gotofloor(argbuf, GF_GOTO);
1558 gotofloor(argbuf, GF_SKIP);
1562 forget_this_floor();
1590 knrooms(floor_mode);
1600 misc_server_cmd(argbuf);
1604 edit_system_message(argbuf);
1629 } while (termn8 == 0);
1631 TERMN8: scr_printf("%s logged out.\n", fullname);
1632 while (march != NULL) {
1633 remove_march(march->march_name, 0);
1636 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
1638 snprintf(aaa, sizeof aaa, "LOUT");
1642 sttybbs(SB_RESTORE);
1643 if ((mcmd == 29) || (mcmd == 15)) {