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 sln_printf_if("%s at %s in %s | %s | %d unread mail\n",
442 serv_info.serv_humannode,
443 serv_info.serv_bbs_city,
445 secure ? "Secure" : "Not secure",
448 sln_printf_if("%s at %s in %s | %s\n",
449 serv_info.serv_humannode,
450 serv_info.serv_bbs_city,
452 secure ? "Secure" : "Not secure");
456 /* Goto next room having unread messages.
457 * We want to skip over rooms that the user has already been to, and take the
458 * user back to the lobby when done. The room we end up in is placed in
459 * newroom - which is set to 0 (the lobby) initially.
464 struct march *mptr, *mptr2;
465 char next_room[ROOMNAMELEN];
467 /* Check to see if the march-mode list is already allocated.
468 * If it is, pop the first room off the list and go there.
474 while (serv_gets(buf), strcmp(buf, "000")) {
475 mptr = (struct march *) malloc(sizeof(struct march));
477 extract(mptr->march_name, buf, 0);
478 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
479 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
484 while (mptr2->next != NULL)
489 /* add _BASEROOM_ to the end of the march list, so the user will end up
490 * in the system base room (usually the Lobby>) at the end of the loop
492 mptr = (struct march *) malloc(sizeof(struct march));
494 strcpy(mptr->march_name, "_BASEROOM_");
499 while (mptr2->next != NULL)
504 * ...and remove the room we're currently in, so a <G>oto doesn't make us
505 * walk around in circles
507 remove_march(room_name, 0);
510 strcpy(next_room, pop_march(curr_floor));
512 strcpy(next_room, "_BASEROOM_");
514 remove_march(next_room, 0);
515 dotgoto(next_room, 1);
519 * forget all rooms on a given floor
521 void forget_all_rooms_on(int ffloor)
524 struct march *flist, *fptr;
526 scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
528 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
532 scr_printf("%-72s\n", &buf[4]);
536 while (serv_gets(buf), strcmp(buf, "000")) {
537 fptr = (struct march *) malloc(sizeof(struct march));
540 extract(fptr->march_name, buf, 0);
542 while (flist != NULL) {
543 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
554 scr_printf("%-72s\r", "");
559 * routine called by gotofloor() to move to a new room on a new floor
561 void gf_toroom(char *towhere, int mode)
563 int floor_being_left;
565 floor_being_left = curr_floor;
567 if (mode == GF_GOTO) { /* <;G>oto mode */
571 if (mode == GF_SKIP) { /* <;S>kip mode */
573 remove_march("_FLOOR_", floor_being_left);
575 if (mode == GF_ZAP) { /* <;Z>ap mode */
577 remove_march("_FLOOR_", floor_being_left);
578 forget_all_rooms_on(floor_being_left);
586 void gotofloor(char *towhere, int mode)
590 char buf[SIZ], targ[SIZ];
592 if (floorlist[0][0] == 0)
595 for (a = 0; a < 128; ++a)
596 if (!strcasecmp(&floorlist[a][0], towhere))
600 for (a = 0; a < 128; ++a) {
601 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
607 for (a = 0; a < 128; ++a)
608 if (pattern(towhere, &floorlist[a][0]) > 0)
612 scr_printf("No floor '%s'.\n", towhere);
615 for (mptr = march; mptr != NULL; mptr = mptr->next) {
616 if ((mptr->march_floor) == tofloor)
617 gf_toroom(mptr->march_name, mode);
622 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
626 while (serv_gets(buf), strcmp(buf, "000")) {
627 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
628 extract(targ, buf, 0);
630 if (strlen(targ) > 0) {
631 gf_toroom(targ, mode);
633 scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
639 * forget all rooms on current floor
641 void forget_this_floor(void)
644 if (curr_floor == 0) {
645 scr_printf("Can't forget this floor.\n");
648 if (floorlist[0][0] == 0)
650 scr_printf("Are you sure you want to forget all rooms on %s? ",
651 &floorlist[(int) curr_floor][0]);
655 gf_toroom("_BASEROOM_", GF_ZAP);
660 * Figure out the physical screen dimensions, if we can
661 * WARNING: this is now called from a signal handler!
663 void check_screen_dims(void)
667 unsigned short height; /* rows */
668 unsigned short width; /* columns */
669 unsigned short xpixels;
670 unsigned short ypixels; /* pixels */
673 if (scr_set_windowsize())
676 if (have_xterm) { /* dynamically size screen if on an xterm */
677 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
679 screenheight = (int) xwinsz.height;
681 screenwidth = (int) xwinsz.width;
689 * set floor mode depending on client, server, and user settings
691 void set_floor_mode(void)
693 if (serv_info.serv_ok_floors == 0) {
694 floor_mode = 0; /* Don't use floors if the server */
696 /* doesn't support them! */
698 if (rc_floor_mode == RC_NO) { /* never use floors */
701 if (rc_floor_mode == RC_YES) { /* always use floors */
704 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
705 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
711 * Set or change the user's password
713 int set_password(void)
719 if (strlen(rc_password) > 0) {
720 strcpy(pass1, rc_password);
721 strcpy(pass2, rc_password);
723 IFNEXPERT formout("changepw");
724 newprompt("Enter a new password: ", pass1, -19);
725 newprompt("Enter it again to confirm: ", pass2, -19);
729 if (!strcasecmp(pass1, pass2)) {
730 snprintf(buf, sizeof buf, "SETP %s", pass1);
733 scr_printf("%s\n", &buf[4]);
734 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
737 scr_printf("*** They don't match... try again.\n");
745 * get info about the server we've connected to
747 void get_serv_info(char *supplied_hostname)
751 CtdlInternalGetServInfo(&serv_info);
753 /* be nice and identify ourself to the server */
754 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
755 SERVER_TYPE, 0, REV_LEVEL,
756 (server_is_local ? "local" : CITADEL));
758 /* Append a hostname */
759 if (supplied_hostname != NULL) {
760 strcat(buf, supplied_hostname);
763 locate_host(&buf[strlen(buf)]); /* append to the end */
767 serv_gets(buf); /* we don't care about the result code */
775 * Display list of users currently logged on to the server
777 void who_is_online(int longlist)
779 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
781 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
782 char tbuf[SIZ], clientsoft[SIZ];
784 time_t idletime, idlehours, idlemins, idlesecs;
785 int last_session = (-1);
789 if (tbuf[0] == '2') {
790 timenow = extract_long(&tbuf[4], 0);
798 pprintf("FLG ### User Name Room From host\n");
800 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
805 while (serv_gets(buf), strcmp(buf, "000")) {
806 extract(username, buf, 1);
807 extract(roomname, buf, 2);
808 extract(fromhost, buf, 3);
809 extract(clientsoft, buf, 4);
810 extract(flags, buf, 7);
812 idletime = timenow - extract_long(buf, 5);
813 idlehours = idletime / 3600;
814 idlemins = (idletime - (idlehours * 3600)) / 60;
815 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
817 if (idletime > 900) {
818 while (strlen(roomname) < 20) {
819 strcat(roomname, " ");
821 strcpy(&roomname[14], "[idle]");
826 extract(actual_user, buf, 8);
827 extract(actual_room, buf, 9);
828 extract(actual_host, buf, 10);
830 pprintf(" Flags: %s\n", flags);
831 pprintf("Session: %d\n", extract_int(buf, 0));
832 pprintf(" Name: %s\n", username);
833 pprintf("In room: %s\n", roomname);
834 pprintf(" Host: %s\n", fromhost);
835 pprintf(" Client: %s\n", clientsoft);
836 pprintf(" Idle: %ld:%02ld:%02ld\n",
841 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
843 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
844 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
845 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
851 if (extract_int(buf, 0) == last_session) {
854 color(BRIGHT_MAGENTA);
855 pprintf("%-3s ", flags);
857 pprintf("%-3d ", extract_int(buf, 0));
859 last_session = extract_int(buf, 0);
861 pprintf("%-25s ", username);
862 color(BRIGHT_MAGENTA);
864 pprintf("%-20s ", roomname);
867 pprintf("%-24s\n", fromhost);
874 void enternew(char *desc, char *buf, int maxlen)
877 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
878 newprompt(bbb, buf, maxlen);
883 int shift(int argc, char **argv, int start, int count) {
886 for (i=start; i<(argc-count); ++i) {
887 argv[i] = argv[i+count];
896 int main(int argc, char **argv)
899 char aaa[100], bbb[100];/* general purpose variables */
900 char argbuf[32]; /* command line buf */
901 char nonce[NONCE_SIZE];
902 char *telnet_client_host = NULL;
903 char *sptr, *sptr2; /* USed to extract the nonce */
904 char hexstring[MD5_HEXSTRING_SIZE];
905 int stored_password = 0;
908 /* Permissions sanity check - don't run citadel setuid/setgid */
909 if (getuid() != geteuid()) {
910 err_printf("Please do not run citadel setuid!\n");
912 } else if (getgid() != getegid()) {
913 err_printf("Please do not run citadel setgid!\n");
917 sttybbs(SB_SAVE); /* Store the old terminal parameters */
918 load_command_set(); /* parse the citadel.rc file */
919 sttybbs(SB_NO_INTR); /* Install the new ones */
920 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
921 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
922 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
924 arg_encrypt = RC_DEFAULT;
925 arg_screen = RC_DEFAULT;
928 * Handle command line options as if we were called like /bin/login
929 * (i.e. from in.telnetd)
931 for (a=0; a<argc; ++a) {
932 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
933 telnet_client_host = argv[a+1];
934 argc = shift(argc, argv, a, 2);
936 if (!strcmp(argv[a], "-x")) {
938 argc = shift(argc, argv, a, 1);
940 if (!strcmp(argv[a], "-X")) {
941 arg_encrypt = RC_YES;
942 argc = shift(argc, argv, a, 1);
944 if (!strcmp(argv[a], "-s")) {
946 argc = shift(argc, argv, a, 1);
948 if (!strcmp(argv[a], "-S")) {
950 argc = shift(argc, argv, a, 1);
952 if (!strcmp(argv[a], "-p")) {
955 if (chdir(BBSDIR) < 0) {
956 perror("can't change to " BBSDIR);
961 * Drop privileges if necessary. We stat
962 * citadel.config to get the uid/gid since it's
963 * guaranteed to have the uid/gid we want.
965 if (!getuid() || !getgid()) {
966 if (stat(BBSDIR "/citadel.config", &st) < 0) {
967 perror("couldn't stat citadel.config");
970 if (!getgid() && (setgid(st.st_gid) < 0)) {
971 perror("couldn't change gid");
974 if (!getuid() && (setuid(st.st_uid) < 0)) {
975 perror("couldn't change uid");
979 scr_printf("Privileges changed to uid %d gid %d\n",
983 argc = shift(argc, argv, a, 1);
989 sln_printf("Attaching to server... \r");
991 attach_to_server(argc, argv, hostbuf, portbuf);
995 scr_printf("%s\n", &aaa[4]);
999 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
1003 if ((sptr = strchr(aaa, '<')) == NULL)
1009 if ((sptr2 = strchr(sptr, '>')) == NULL)
1017 strncpy(nonce, sptr, NONCE_SIZE);
1021 get_serv_info(telnet_client_host);
1023 scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1024 serv_info.serv_bbs_city);
1027 secure = starttls();
1028 sln_printf_if("%s at %s | %s\n",
1029 serv_info.serv_humannode,
1030 serv_info.serv_bbs_city,
1031 secure ? "Secure" : "Not secure");
1033 screenwidth = 80; /* default screen dimensions */
1036 scr_printf(" pause next stop\n");
1037 scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
1038 formout("hello"); /* print the opening greeting */
1041 GSTA: /* See if we have a username and password on disk */
1042 if (rc_remember_passwords) {
1043 get_stored_password(hostbuf, portbuf, fullname, password);
1044 if (strlen(fullname) > 0) {
1045 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1050 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1052 else /* Else no APOP */
1054 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1059 if (aaa[0] == '2') {
1060 load_user_info(&aaa[4]);
1061 stored_password = 1;
1065 set_stored_password(hostbuf, portbuf, "", "");
1073 if (strlen(rc_username) > 0) {
1074 strcpy(fullname, rc_username);
1076 newprompt("Enter your name: ", fullname, 29);
1079 if (!strcasecmp(fullname, "new")) { /* just in case */
1080 scr_printf("Please enter the name you wish to log in with.\n");
1083 (!strcasecmp(fullname, "bbs"))
1084 || (!strcasecmp(fullname, "new"))
1085 || (strlen(fullname) == 0));
1087 if (!strcasecmp(fullname, "off")) {
1091 /* sign on to the server */
1092 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1098 /* password authentication */
1099 if (strlen(rc_password) > 0) {
1100 strcpy(password, rc_password);
1102 newprompt("\rPlease enter your password: ", password, -19);
1108 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1110 else /* Else no APOP */
1112 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1117 if (aaa[0] == '2') {
1118 load_user_info(&aaa[4]);
1119 offer_to_remember_password(hostbuf, portbuf,
1120 fullname, password);
1123 scr_printf("<< wrong password >>\n");
1124 if (strlen(rc_password) > 0)
1128 NEWUSR: if (strlen(rc_password) == 0) {
1129 scr_printf("No record. Enter as new user? ");
1133 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1136 if (aaa[0] != '2') {
1137 scr_printf("%s\n", aaa);
1140 load_user_info(&aaa[4]);
1142 while (set_password() != 0);;
1148 /* Switch color support on or off if we're in user mode */
1149 if (rc_ansi_color == 3) {
1150 if (userflags & US_COLOR)
1156 scr_printf("%s\nAccess level: %d (%s)\n"
1157 "User #%ld / Login #%d",
1158 fullname, axlevel, axdefs[(int) axlevel],
1159 usernum, timescalled);
1160 if (lastcall > 0L) {
1161 scr_printf(" / Last login: %s\n",
1162 asctime(localtime(&lastcall)) );
1168 if (aaa[0] == '2') {
1169 b = extract_int(&aaa[4], 0);
1173 scr_printf("*** You have a new private message in Mail>\n");
1175 scr_printf("*** You have %d new private messages in Mail>\n", b);
1178 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1179 scr_printf("*** Users need validation\n");
1181 if (extract_int(&aaa[4], 1) > 0) {
1182 scr_printf("*** Please register.\n");
1183 formout("register");
1187 /* Make up some temporary filenames for use in various parts of the
1188 * program. Don't mess with these once they've been set, because we
1189 * will be unlinking them later on in the program and we don't
1190 * want to delete something that we didn't create. */
1191 snprintf(temp, sizeof temp, tmpnam(NULL));
1192 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1193 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1195 /* Get screen dimensions. First we go to a default of 80x24. Then
1196 * we try to get the user's actual screen dimensions off the server.
1197 * However, if we're running on an xterm, all this stuff is
1198 * irrelevant because we're going to dynamically size the screen
1199 * during the session.
1205 if (aaa[0] == '2') {
1206 screenwidth = extract_int(&aaa[4], 0);
1207 screenheight = extract_int(&aaa[4], 1);
1209 if (getenv("TERM") != NULL)
1210 if (!strcmp(getenv("TERM"), "xterm")) {
1214 check_screen_dims();
1220 /* Enter the lobby */
1221 dotgoto("_BASEROOM_", 1);
1223 /* Main loop for the system... user is logged in. */
1232 /* MAIN COMMAND LOOP */
1234 mcmd = getcmd(argbuf); /* Get keyboard command */
1237 check_screen_dims(); /* if xterm, get screen size */
1255 newprompt("What do you want your username to be? ", aaa, 32);
1256 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1259 if (strncmp("200", aaa, 3))
1260 scr_printf("\n%s\n", aaa);
1269 if (!rc_alt_semantics)
1274 if (!rc_alt_semantics)
1280 dotgoto("_MAIL_", 1);
1287 if (rc_alt_semantics)
1301 readmsgs(0, (-1), 0);
1304 readmsgs(2, (-1), 0);
1307 readmsgs(3, 1, atoi(argbuf));
1380 if (!rc_alt_semantics)
1385 if (!rc_alt_semantics)
1396 cli_image_upload("_userpic_");
1399 cli_image_upload("_roompic_");
1403 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1404 cli_image_upload(aaa);
1408 enternew("roomname", aaa, 20);
1409 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1412 if (strncmp("200", aaa, 3))
1413 scr_printf("\n%s\n", aaa);
1416 enternew("hostname", aaa, 25);
1417 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1420 if (strncmp("200", aaa, 3))
1421 scr_printf("\n%s\n", aaa);
1424 enternew("username", aaa, 32);
1425 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1428 if (strncmp("200", aaa, 3))
1429 scr_printf("\n%s\n", aaa);
1439 display_help(argbuf);
1443 formout("register");
1448 scr_printf("Are you sure (y/n)? ");
1457 scr_printf("All users will be disconnected! "
1458 "Really terminate the server? ");
1462 scr_printf("%s\n", &aaa[4]);
1472 scr_printf("Do you really want to schedule a "
1473 "server shutdown? ");
1475 serv_puts("SCDN 1");
1478 if (atoi(&aaa[4])) {
1480 "The Citadel server will terminate when all users are logged off.\n"
1485 "The Citadel server will not terminate.\n"
1493 network_config_management("listrecp",
1494 "Mailing list recipients");
1498 network_config_management("ignet_push_share",
1499 "Nodes with which we share this room");
1503 do_ignet_configuration();
1507 if (rc_alt_semantics)
1517 if (server_is_local) {
1519 sttybbs(SB_RESTORE);
1520 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1521 "exec ./subsystem %ld %d %d", fullname,
1522 usernum, screenwidth, axlevel);
1524 sttybbs(SB_NO_INTR);
1527 scr_printf("*** Can't run doors when server is not local.\n");
1540 do_system_configuration();
1544 do_internet_configuration();
1548 check_message_base();
1570 gotofloor(argbuf, GF_GOTO);
1574 gotofloor(argbuf, GF_SKIP);
1578 forget_this_floor();
1606 knrooms(floor_mode);
1616 misc_server_cmd(argbuf);
1620 edit_system_message(argbuf);
1645 } while (termn8 == 0);
1647 TERMN8: scr_printf("%s logged out.\n", fullname);
1648 while (march != NULL) {
1649 remove_march(march->march_name, 0);
1652 sln_printf("\n\nType 'off' to disconnect, or next user...\n");
1654 snprintf(aaa, sizeof aaa, "LOUT");
1658 sttybbs(SB_RESTORE);
1659 if ((mcmd == 29) || (mcmd == 15)) {