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 */
111 int secure; /* Set to nonzero when wire is encrypted */
113 extern int rc_ansi_color; /* ansi color value from citadel.rc */
116 * here is our 'clean up gracefully and exit' routine
118 void logoff(int code)
120 if (editor_pid > 0) { /* kill the editor if it's running */
121 kill(editor_pid, SIGHUP);
123 /* shut down the server... but not if the logoff code is 3, because
124 * that means we're exiting because we already lost the server
130 * now clean up various things
139 /* Violently kill off any child processes if Citadel is
142 if (getppid() == 1) {
143 kill(0 - getpgrp(), SIGTERM);
145 kill(0 - getpgrp(), SIGKILL);
147 sttybbs(SB_RESTORE); /* return the old terminal settings */
148 exit(code); /* exit with the proper exit code */
154 * signal catching function for hangups...
156 void dropcarr(int signum)
164 * catch SIGCONT to reset terminal modes when were are put back into the
167 void catch_sigcont(int signum)
170 signal(SIGCONT, catch_sigcont);
175 /* general purpose routines */
177 void formout(char *name)
178 { /* display a file */
180 snprintf(cmd, sizeof cmd, "MESG %s", name);
184 scr_printf("%s\n", &cmd[4]);
187 fmout(screenwidth, NULL,
188 ((userflags & US_PAGINATOR) ? 1 : 0),
193 void userlist(char *patn)
203 pprintf("%s\n", &buf[4]);
206 pprintf(" User Name Num L LastCall Calls Posts\n");
207 pprintf("------------------------- ----- - ---------- ----- -----\n");
208 while (serv_gets(buf), strcmp(buf, "000")) {
209 if (sigcaught == 0) {
211 if (pattern(fl, patn) >= 0) {
212 pprintf("%-25s ", fl);
213 pprintf("%5ld %d ", extract_long(buf, 2),
214 extract_int(buf, 1));
215 lc = extract_long(buf, 3);
216 tmbuf = (struct tm *) localtime(&lc);
217 pprintf("%02d/%02d/%04d ",
220 (tmbuf->tm_year + 1900));
221 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
231 * grab assorted info about the user...
233 void load_user_info(char *params)
235 extract(fullname, params, 0);
236 axlevel = extract_int(params, 1);
237 timescalled = extract_int(params, 2);
238 posted = extract_int(params, 3);
239 userflags = extract_int(params, 4);
240 usernum = extract_long(params, 5);
241 lastcall = extract_long(params, 6);
246 * Remove a room from the march list. 'floornum' is ignored unless
247 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
248 * floor will be removed from the march list.
250 void remove_march(char *roomname, int floornum)
252 struct march *mptr, *mptr2;
257 if ((!strcasecmp(march->march_name, roomname))
258 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
265 for (mptr = march; mptr != NULL; mptr = mptr->next) {
267 if ((!strcasecmp(mptr->march_name, roomname))
268 || ((!strcasecmp(roomname, "_FLOOR_"))
269 && (mptr->march_floor == floornum))) {
271 mptr2->next = mptr->next;
282 * Locate the room on the march list which we most want to go to. Each room
283 * is measured given a "weight" of preference based on various factors.
285 char *pop_march(int desired_floor)
287 static char TheRoom[ROOMNAMELEN];
289 int TheOrder = 32767;
292 struct march *mptr = NULL;
294 strcpy(TheRoom, "_BASEROOM_");
298 for (mptr = march; mptr != NULL; mptr = mptr->next) {
300 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
301 weight = weight + 10000;
302 if (mptr->march_floor == desired_floor)
303 weight = weight + 5000;
305 weight = weight + ((128 - (mptr->march_floor)) * 128);
306 weight = weight + (128 - (mptr->march_order));
308 if (weight > TheWeight) {
310 strcpy(TheRoom, mptr->march_name);
311 TheFloor = mptr->march_floor;
312 TheOrder = mptr->march_order;
320 * jump directly to a room
322 void dotgoto(char *towhere, int display_name)
324 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
326 int newmailcount = 0;
327 static int oldmailcount = (-1);
328 int partial_match, best_match;
331 /* store ungoto information */
332 strcpy(ugname, room_name);
335 /* first try an exact match */
336 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
341 if (!strncmp(aaa, "54", 2)) {
342 newprompt("Enter room password: ", bbb, 9);
343 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
349 if (!strncmp(aaa, "54", 2)) {
350 scr_printf("Wrong password.\n");
354 * If a match is not found, try a partial match.
355 * Partial matches anywhere in the string carry a weight of 1,
356 * left-aligned matches carry a weight of 2. Pick the room that
357 * has the highest-weighted match.
365 while (serv_gets(aaa), strcmp(aaa, "000")) {
366 extract(psearch, aaa, 0);
368 if (pattern(psearch, towhere) >= 0) {
371 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
374 if (partial_match > best_match) {
375 strcpy(bbb, psearch);
376 best_match = partial_match;
379 if (strlen(bbb) == 0) {
380 scr_printf("No room '%s'.\n", towhere);
383 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
390 scr_printf("%s\n", aaa);
393 extract(room_name, &aaa[4], 0);
394 room_flags = extract_int(&aaa[4], 4);
395 from_floor = curr_floor;
396 curr_floor = extract_int(&aaa[4], 10);
398 remove_march(room_name, 0);
399 if (!strcasecmp(towhere, "_BASEROOM_"))
400 remove_march(towhere, 0);
401 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
402 if (floorlist[(int) curr_floor][0] == 0)
404 scr_printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
406 if (display_name == 1) {
408 scr_printf("%s ", room_name);
412 if (display_name != 2) {
413 color(BRIGHT_YELLOW);
414 scr_printf("%d ", extract_int(&aaa[4], 1));
416 scr_printf("new of ");
417 color(BRIGHT_YELLOW);
418 scr_printf("%d ", extract_int(&aaa[4], 2));
420 scr_printf("messages.\n");
422 highest_msg_read = extract_int(&aaa[4], 6);
423 maxmsgnum = extract_int(&aaa[4], 5);
424 is_mail = (char) extract_int(&aaa[4], 7);
425 is_room_aide = (char) extract_int(&aaa[4], 8);
426 ls = extract_long(&aaa[4], 6);
428 /* read info file if necessary */
429 if (extract_int(&aaa[4], 3) > 0)
432 /* check for newly arrived mail if we can */
433 if (num_parms(&aaa[4]) >= 10) {
434 newmailcount = extract_int(&aaa[4], 9);
435 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
437 scr_printf("*** You have new mail\n");
440 oldmailcount = newmailcount;
441 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
442 room_name, secure, newmailcount);
444 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
445 room_name, secure, -1);
449 /* Goto next room having unread messages.
450 * We want to skip over rooms that the user has already been to, and take the
451 * user back to the lobby when done. The room we end up in is placed in
452 * newroom - which is set to 0 (the lobby) initially.
457 struct march *mptr, *mptr2;
458 char next_room[ROOMNAMELEN];
460 /* Check to see if the march-mode list is already allocated.
461 * If it is, pop the first room off the list and go there.
467 while (serv_gets(buf), strcmp(buf, "000")) {
468 mptr = (struct march *) malloc(sizeof(struct march));
470 extract(mptr->march_name, buf, 0);
471 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
472 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
477 while (mptr2->next != NULL)
482 /* add _BASEROOM_ to the end of the march list, so the user will end up
483 * in the system base room (usually the Lobby>) at the end of the loop
485 mptr = (struct march *) malloc(sizeof(struct march));
487 strcpy(mptr->march_name, "_BASEROOM_");
492 while (mptr2->next != NULL)
497 * ...and remove the room we're currently in, so a <G>oto doesn't make us
498 * walk around in circles
500 remove_march(room_name, 0);
503 strcpy(next_room, pop_march(curr_floor));
505 strcpy(next_room, "_BASEROOM_");
507 remove_march(next_room, 0);
508 dotgoto(next_room, 1);
512 * forget all rooms on a given floor
514 void forget_all_rooms_on(int ffloor)
517 struct march *flist, *fptr;
519 scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
521 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
525 scr_printf("%-72s\n", &buf[4]);
529 while (serv_gets(buf), strcmp(buf, "000")) {
530 fptr = (struct march *) malloc(sizeof(struct march));
533 extract(fptr->march_name, buf, 0);
535 while (flist != NULL) {
536 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
547 scr_printf("%-72s\r", "");
552 * routine called by gotofloor() to move to a new room on a new floor
554 void gf_toroom(char *towhere, int mode)
556 int floor_being_left;
558 floor_being_left = curr_floor;
560 if (mode == GF_GOTO) { /* <;G>oto mode */
564 if (mode == GF_SKIP) { /* <;S>kip mode */
566 remove_march("_FLOOR_", floor_being_left);
568 if (mode == GF_ZAP) { /* <;Z>ap mode */
570 remove_march("_FLOOR_", floor_being_left);
571 forget_all_rooms_on(floor_being_left);
579 void gotofloor(char *towhere, int mode)
583 char buf[SIZ], targ[SIZ];
585 if (floorlist[0][0] == 0)
588 for (a = 0; a < 128; ++a)
589 if (!strcasecmp(&floorlist[a][0], towhere))
593 for (a = 0; a < 128; ++a) {
594 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
600 for (a = 0; a < 128; ++a)
601 if (pattern(towhere, &floorlist[a][0]) > 0)
605 scr_printf("No floor '%s'.\n", towhere);
608 for (mptr = march; mptr != NULL; mptr = mptr->next) {
609 if ((mptr->march_floor) == tofloor)
610 gf_toroom(mptr->march_name, mode);
615 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
619 while (serv_gets(buf), strcmp(buf, "000")) {
620 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
621 extract(targ, buf, 0);
623 if (strlen(targ) > 0) {
624 gf_toroom(targ, mode);
626 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
632 * forget all rooms on current floor
634 void forget_this_floor(void)
637 if (curr_floor == 0) {
638 scr_printf("Can't forget this floor.\n");
641 if (floorlist[0][0] == 0)
643 scr_printf("Are you sure you want to forget all rooms on %s? ",
644 &floorlist[(int) curr_floor][0]);
648 gf_toroom("_BASEROOM_", GF_ZAP);
653 * Figure out the physical screen dimensions, if we can
654 * WARNING: this is now called from a signal handler!
656 void check_screen_dims(void)
660 unsigned short height; /* rows */
661 unsigned short width; /* columns */
662 unsigned short xpixels;
663 unsigned short ypixels; /* pixels */
666 if (scr_set_windowsize())
669 if (have_xterm) { /* dynamically size screen if on an xterm */
670 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
672 screenheight = (int) xwinsz.height;
674 screenwidth = (int) xwinsz.width;
682 * set floor mode depending on client, server, and user settings
684 void set_floor_mode(void)
686 if (serv_info.serv_ok_floors == 0) {
687 floor_mode = 0; /* Don't use floors if the server */
689 /* doesn't support them! */
691 if (rc_floor_mode == RC_NO) { /* never use floors */
694 if (rc_floor_mode == RC_YES) { /* always use floors */
697 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
698 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
704 * Set or change the user's password
706 int set_password(void)
712 if (strlen(rc_password) > 0) {
713 strcpy(pass1, rc_password);
714 strcpy(pass2, rc_password);
716 IFNEXPERT formout("changepw");
717 newprompt("Enter a new password: ", pass1, -19);
718 newprompt("Enter it again to confirm: ", pass2, -19);
722 if (!strcasecmp(pass1, pass2)) {
723 snprintf(buf, sizeof buf, "SETP %s", pass1);
726 scr_printf("%s\n", &buf[4]);
727 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
730 scr_printf("*** They don't match... try again.\n");
738 * get info about the server we've connected to
740 void get_serv_info(char *supplied_hostname)
744 CtdlInternalGetServInfo(&serv_info);
746 /* be nice and identify ourself to the server */
747 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
748 SERVER_TYPE, 0, REV_LEVEL,
749 (server_is_local ? "local" : CITADEL));
751 /* Append a hostname */
752 if (supplied_hostname != NULL) {
753 strcat(buf, supplied_hostname);
756 locate_host(&buf[strlen(buf)]); /* append to the end */
760 serv_gets(buf); /* we don't care about the result code */
768 * Display list of users currently logged on to the server
770 void who_is_online(int longlist)
772 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
774 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
775 char tbuf[SIZ], clientsoft[SIZ];
777 time_t idletime, idlehours, idlemins, idlesecs;
778 int last_session = (-1);
782 if (tbuf[0] == '2') {
783 timenow = extract_long(&tbuf[4], 0);
791 pprintf("FLG ### User Name Room From host\n");
793 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
798 while (serv_gets(buf), strcmp(buf, "000")) {
799 extract(username, buf, 1);
800 extract(roomname, buf, 2);
801 extract(fromhost, buf, 3);
802 extract(clientsoft, buf, 4);
803 extract(flags, buf, 7);
805 idletime = timenow - extract_long(buf, 5);
806 idlehours = idletime / 3600;
807 idlemins = (idletime - (idlehours * 3600)) / 60;
808 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
810 if (idletime > 900) {
811 while (strlen(roomname) < 20) {
812 strcat(roomname, " ");
814 strcpy(&roomname[14], "[idle]");
819 extract(actual_user, buf, 8);
820 extract(actual_room, buf, 9);
821 extract(actual_host, buf, 10);
823 pprintf(" Flags: %s\n", flags);
824 pprintf("Session: %d\n", extract_int(buf, 0));
825 pprintf(" Name: %s\n", username);
826 pprintf("In room: %s\n", roomname);
827 pprintf(" Host: %s\n", fromhost);
828 pprintf(" Client: %s\n", clientsoft);
829 pprintf(" Idle: %ld:%02ld:%02ld\n",
834 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
836 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
837 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
838 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
844 if (extract_int(buf, 0) == last_session) {
847 color(BRIGHT_MAGENTA);
848 pprintf("%-3s ", flags);
850 pprintf("%-3d ", extract_int(buf, 0));
852 last_session = extract_int(buf, 0);
854 pprintf("%-25s ", username);
855 color(BRIGHT_MAGENTA);
857 pprintf("%-20s ", roomname);
860 pprintf("%-24s\n", fromhost);
867 void enternew(char *desc, char *buf, int maxlen)
870 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
871 newprompt(bbb, buf, maxlen);
876 int shift(int argc, char **argv, int start, int count) {
879 for (i=start; i<(argc-count); ++i) {
880 argv[i] = argv[i+count];
889 int main(int argc, char **argv)
892 char aaa[100], bbb[100];/* general purpose variables */
893 char argbuf[32]; /* command line buf */
894 char nonce[NONCE_SIZE];
895 char *telnet_client_host = NULL;
896 char *sptr, *sptr2; /* USed to extract the nonce */
897 char hexstring[MD5_HEXSTRING_SIZE];
898 int stored_password = 0;
901 /* Permissions sanity check - don't run citadel setuid/setgid */
902 if (getuid() != geteuid()) {
903 err_printf("Please do not run citadel setuid!\n");
905 } else if (getgid() != getegid()) {
906 err_printf("Please do not run citadel setgid!\n");
910 sttybbs(SB_SAVE); /* Store the old terminal parameters */
911 load_command_set(); /* parse the citadel.rc file */
912 sttybbs(SB_NO_INTR); /* Install the new ones */
913 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
914 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
915 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
917 arg_encrypt = RC_DEFAULT;
918 arg_screen = RC_DEFAULT;
921 * Handle command line options as if we were called like /bin/login
922 * (i.e. from in.telnetd)
924 for (a=0; a<argc; ++a) {
925 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
926 telnet_client_host = argv[a+1];
927 argc = shift(argc, argv, a, 2);
929 if (!strcmp(argv[a], "-x")) {
931 argc = shift(argc, argv, a, 1);
933 if (!strcmp(argv[a], "-X")) {
934 arg_encrypt = RC_YES;
935 argc = shift(argc, argv, a, 1);
937 if (!strcmp(argv[a], "-s")) {
939 argc = shift(argc, argv, a, 1);
941 if (!strcmp(argv[a], "-S")) {
943 argc = shift(argc, argv, a, 1);
945 if (!strcmp(argv[a], "-p")) {
948 if (chdir(BBSDIR) < 0) {
949 perror("can't change to " BBSDIR);
954 * Drop privileges if necessary. We stat
955 * citadel.config to get the uid/gid since it's
956 * guaranteed to have the uid/gid we want.
958 if (!getuid() || !getgid()) {
959 if (stat(BBSDIR "/citadel.config", &st) < 0) {
960 perror("couldn't stat citadel.config");
963 if (!getgid() && (setgid(st.st_gid) < 0)) {
964 perror("couldn't change gid");
967 if (!getuid() && (setuid(st.st_uid) < 0)) {
968 perror("couldn't change uid");
972 scr_printf("Privileges changed to uid %d gid %d\n",
976 argc = shift(argc, argv, a, 1);
982 sln_printf("Attaching to server... \r");
984 attach_to_server(argc, argv, hostbuf, portbuf);
988 scr_printf("%s\n", &aaa[4]);
992 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
996 if ((sptr = strchr(aaa, '<')) == NULL)
1002 if ((sptr2 = strchr(sptr, '>')) == NULL)
1010 strncpy(nonce, sptr, NONCE_SIZE);
1014 get_serv_info(telnet_client_host);
1016 scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1017 serv_info.serv_bbs_city);
1020 secure = starttls();
1021 status_line(serv_info.serv_humannode, serv_info.serv_bbs_city, NULL,
1024 screenwidth = 80; /* default screen dimensions */
1027 scr_printf(" pause next stop\n");
1028 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1029 formout("hello"); /* print the opening greeting */
1032 GSTA: /* See if we have a username and password on disk */
1033 if (rc_remember_passwords) {
1034 get_stored_password(hostbuf, portbuf, fullname, password);
1035 if (strlen(fullname) > 0) {
1036 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1041 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1043 else /* Else no APOP */
1045 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1050 if (aaa[0] == '2') {
1051 load_user_info(&aaa[4]);
1052 stored_password = 1;
1056 set_stored_password(hostbuf, portbuf, "", "");
1064 if (strlen(rc_username) > 0) {
1065 strcpy(fullname, rc_username);
1067 newprompt("Enter your name: ", fullname, 29);
1070 if (!strcasecmp(fullname, "new")) { /* just in case */
1071 scr_printf("Please enter the name you wish to log in with.\n");
1074 (!strcasecmp(fullname, "bbs"))
1075 || (!strcasecmp(fullname, "new"))
1076 || (strlen(fullname) == 0));
1078 if (!strcasecmp(fullname, "off")) {
1082 /* sign on to the server */
1083 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1089 /* password authentication */
1090 if (strlen(rc_password) > 0) {
1091 strcpy(password, rc_password);
1093 newprompt("\rPlease enter your password: ", password, -19);
1099 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1101 else /* Else no APOP */
1103 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1108 if (aaa[0] == '2') {
1109 load_user_info(&aaa[4]);
1110 offer_to_remember_password(hostbuf, portbuf,
1111 fullname, password);
1114 scr_printf("<< wrong password >>\n");
1115 if (strlen(rc_password) > 0)
1119 NEWUSR: if (strlen(rc_password) == 0) {
1120 scr_printf("No record. Enter as new user? ");
1124 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1127 if (aaa[0] != '2') {
1128 scr_printf("%s\n", aaa);
1131 load_user_info(&aaa[4]);
1133 while (set_password() != 0);;
1139 /* Switch color support on or off if we're in user mode */
1140 if (rc_ansi_color == 3) {
1141 if (userflags & US_COLOR)
1147 scr_printf("%s\nAccess level: %d (%s)\n"
1148 "User #%ld / Login #%d",
1149 fullname, axlevel, axdefs[(int) axlevel],
1150 usernum, timescalled);
1151 if (lastcall > 0L) {
1152 scr_printf(" / Last login: %s\n",
1153 asctime(localtime(&lastcall)) );
1159 if (aaa[0] == '2') {
1160 b = extract_int(&aaa[4], 0);
1164 scr_printf("*** You have a new private message in Mail>\n");
1166 scr_printf("*** You have %d new private messages in Mail>\n", b);
1169 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1170 scr_printf("*** Users need validation\n");
1172 if (extract_int(&aaa[4], 1) > 0) {
1173 scr_printf("*** Please register.\n");
1174 formout("register");
1178 /* Make up some temporary filenames for use in various parts of the
1179 * program. Don't mess with these once they've been set, because we
1180 * will be unlinking them later on in the program and we don't
1181 * want to delete something that we didn't create. */
1182 snprintf(temp, sizeof temp, tmpnam(NULL));
1183 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1184 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1186 /* Get screen dimensions. First we go to a default of 80x24. Then
1187 * we try to get the user's actual screen dimensions off the server.
1188 * However, if we're running on an xterm, all this stuff is
1189 * irrelevant because we're going to dynamically size the screen
1190 * during the session.
1196 if (aaa[0] == '2') {
1197 screenwidth = extract_int(&aaa[4], 0);
1198 screenheight = extract_int(&aaa[4], 1);
1200 if (getenv("TERM") != NULL)
1201 if (!strcmp(getenv("TERM"), "xterm")) {
1205 check_screen_dims();
1211 /* Enter the lobby */
1212 dotgoto("_BASEROOM_", 1);
1214 /* Main loop for the system... user is logged in. */
1223 /* MAIN COMMAND LOOP */
1225 mcmd = getcmd(argbuf); /* Get keyboard command */
1228 check_screen_dims(); /* if xterm, get screen size */
1246 newprompt("What do you want your username to be? ", aaa, 32);
1247 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1250 if (strncmp("200", aaa, 3))
1251 scr_printf("\n%s\n", aaa);
1260 if (!rc_alt_semantics)
1265 if (!rc_alt_semantics)
1271 dotgoto("_MAIL_", 1);
1278 if (rc_alt_semantics)
1292 readmsgs(0, (-1), 0);
1295 readmsgs(2, (-1), 0);
1298 readmsgs(3, 1, atoi(argbuf));
1371 if (!rc_alt_semantics)
1376 if (!rc_alt_semantics)
1387 cli_image_upload("_userpic_");
1390 cli_image_upload("_roompic_");
1394 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1395 cli_image_upload(aaa);
1399 enternew("roomname", aaa, 20);
1400 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1403 if (strncmp("200", aaa, 3))
1404 scr_printf("\n%s\n", aaa);
1407 enternew("hostname", aaa, 25);
1408 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1411 if (strncmp("200", aaa, 3))
1412 scr_printf("\n%s\n", aaa);
1415 enternew("username", aaa, 32);
1416 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1419 if (strncmp("200", aaa, 3))
1420 scr_printf("\n%s\n", aaa);
1430 display_help(argbuf);
1434 formout("register");
1439 scr_printf("Are you sure (y/n)? ");
1448 scr_printf("All users will be disconnected! "
1449 "Really terminate the server? ");
1453 scr_printf("%s\n", &aaa[4]);
1463 scr_printf("Do you really want to schedule a "
1464 "server shutdown? ");
1466 serv_puts("SCDN 1");
1469 if (atoi(&aaa[4])) {
1471 "The Citadel server will terminate when all users are logged off.\n"
1476 "The Citadel server will not terminate.\n"
1484 network_config_management("listrecp",
1485 "Mailing list recipients");
1489 network_config_management("ignet_push_share",
1490 "Nodes with which we share this room");
1494 do_ignet_configuration();
1498 if (rc_alt_semantics)
1508 if (server_is_local) {
1510 sttybbs(SB_RESTORE);
1511 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1512 "exec ./subsystem %ld %d %d", fullname,
1513 usernum, screenwidth, axlevel);
1515 sttybbs(SB_NO_INTR);
1518 scr_printf("*** Can't run doors when server is not local.\n");
1531 do_system_configuration();
1535 do_internet_configuration();
1539 check_message_base();
1561 gotofloor(argbuf, GF_GOTO);
1565 gotofloor(argbuf, GF_SKIP);
1569 forget_this_floor();
1597 knrooms(floor_mode);
1607 misc_server_cmd(argbuf);
1611 edit_system_message(argbuf);
1636 } while (termn8 == 0);
1638 TERMN8: scr_printf("%s logged out.\n", fullname);
1639 while (march != NULL) {
1640 remove_march(march->march_name, 0);
1643 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
1645 snprintf(aaa, sizeof aaa, "LOUT");
1649 sttybbs(SB_RESTORE);
1650 if ((mcmd == 29) || (mcmd == 15)) {