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"
58 char march_name[ROOMNAMELEN];
63 #define IFEXPERT if (userflags&US_EXPERT)
64 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
65 #define IFAIDE if (axlevel>=6)
66 #define IFNAIDE if (axlevel<6)
68 struct march *march = NULL;
70 /* globals associated with the client program */
71 char temp[PATH_MAX]; /* Name of general temp file */
72 char temp2[PATH_MAX]; /* Name of general temp file */
73 char tempdir[PATH_MAX]; /* Name of general temp dir */
74 char editor_path[SIZ]; /* path to external editor */
75 char printcmd[SIZ]; /* print command */
76 int editor_pid = (-1);
79 struct CtdlServInfo serv_info; /* Info on the server connected */
83 char room_name[ROOMNAMELEN];
84 char ugname[ROOMNAMELEN];
85 long uglsn; /* holds <u>ngoto info */
86 char is_mail = 0; /* nonzero when we're in a mail room */
87 char axlevel = 0; /* access level */
88 char is_room_aide = 0; /* boolean flag, 1 if room aide */
92 long usernum = 0L; /* user number */
94 long highest_msg_read; /* used for <A>bandon room cmd */
95 long maxmsgnum; /* used for <G>oto */
97 char have_xterm = 0; /* are we running on an xterm? */
104 char curr_floor = 0; /* number of current floor */
105 char floorlist[128][SIZ]; /* names of floors */
106 char express_msgs = 0; /* express messages waiting! */
107 int termn8 = 0; /* Set to nonzero to cause a logoff */
109 extern int rc_ansi_color; /* ansi color value from citadel.rc */
112 * here is our 'clean up gracefully and exit' routine
114 void logoff(int code)
116 if (editor_pid > 0) { /* kill the editor if it's running */
117 kill(editor_pid, SIGHUP);
119 /* shut down the server... but not if the logoff code is 3, because
120 * that means we're exiting because we already lost the server
126 * now clean up various things
133 /* Violently kill off any child processes if Citadel is
136 if (getppid() == 1) {
137 kill(0 - getpgrp(), SIGTERM);
139 kill(0 - getpgrp(), SIGKILL);
141 sttybbs(SB_RESTORE); /* return the old terminal settings */
142 exit(code); /* exit with the proper exit code */
148 * signal catching function for hangups...
150 void dropcarr(int signum)
158 * catch SIGCONT to reset terminal modes when were are put back into the
161 void catch_sigcont(int signum)
164 signal(SIGCONT, catch_sigcont);
169 /* general purpose routines */
171 void formout(char *name)
172 { /* display a file */
174 snprintf(cmd, sizeof cmd, "MESG %s", name);
178 printf("%s\n", &cmd[4]);
181 fmout(screenwidth, NULL,
182 ((userflags & US_PAGINATOR) ? 1 : 0),
187 void userlist(char *patn)
197 pprintf("%s\n", &buf[4]);
200 pprintf(" User Name Num L LastCall Calls Posts\n");
201 pprintf("------------------------- ----- - ---------- ----- -----\n");
202 while (serv_gets(buf), strcmp(buf, "000")) {
203 if (sigcaught == 0) {
205 if (pattern(fl, patn) >= 0) {
206 pprintf("%-25s ", fl);
207 pprintf("%5ld %d ", extract_long(buf, 2),
208 extract_int(buf, 1));
209 lc = extract_long(buf, 3);
210 tmbuf = (struct tm *) localtime(&lc);
211 pprintf("%02d/%02d/%04d ",
214 (tmbuf->tm_year + 1900));
215 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
225 * grab assorted info about the user...
227 void load_user_info(char *params)
229 extract(fullname, params, 0);
230 axlevel = extract_int(params, 1);
231 timescalled = extract_int(params, 2);
232 posted = extract_int(params, 3);
233 userflags = extract_int(params, 4);
234 usernum = extract_long(params, 5);
239 * Remove a room from the march list. 'floornum' is ignored unless
240 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
241 * floor will be removed from the march list.
243 void remove_march(char *roomname, int floornum)
245 struct march *mptr, *mptr2;
250 if ((!strcasecmp(march->march_name, roomname))
251 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
258 for (mptr = march; mptr != NULL; mptr = mptr->next) {
260 if ((!strcasecmp(mptr->march_name, roomname))
261 || ((!strcasecmp(roomname, "_FLOOR_"))
262 && (mptr->march_floor == floornum))) {
264 mptr2->next = mptr->next;
275 * Locate the room on the march list which we most want to go to. Each room
276 * is measured given a "weight" of preference based on various factors.
278 char *pop_march(int desired_floor)
280 static char TheRoom[ROOMNAMELEN];
282 int TheOrder = 32767;
285 struct march *mptr = NULL;
287 strcpy(TheRoom, "_BASEROOM_");
291 for (mptr = march; mptr != NULL; mptr = mptr->next) {
293 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
294 weight = weight + 10000;
295 if (mptr->march_floor == desired_floor)
296 weight = weight + 5000;
298 weight = weight + ((128 - (mptr->march_floor)) * 128);
299 weight = weight + (128 - (mptr->march_order));
301 if (weight > TheWeight) {
303 strcpy(TheRoom, mptr->march_name);
304 TheFloor = mptr->march_floor;
305 TheOrder = mptr->march_order;
313 * jump directly to a room
315 void dotgoto(char *towhere, int display_name)
317 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
320 static int oldmailcount = (-1);
321 int partial_match, best_match;
324 /* store ungoto information */
325 strcpy(ugname, room_name);
328 /* first try an exact match */
329 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
334 if (!strncmp(aaa, "54", 2)) {
335 newprompt("Enter room password: ", bbb, 9);
336 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
342 if (!strncmp(aaa, "54", 2)) {
343 printf("Wrong password.\n");
347 * If a match is not found, try a partial match.
348 * Partial matches anywhere in the string carry a weight of 1,
349 * left-aligned matches carry a weight of 2. Pick the room that
350 * has the highest-weighted match.
358 while (serv_gets(aaa), strcmp(aaa, "000")) {
359 extract(psearch, aaa, 0);
361 if (pattern(psearch, towhere) >= 0) {
364 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
367 if (partial_match > best_match) {
368 strcpy(bbb, psearch);
369 best_match = partial_match;
372 if (strlen(bbb) == 0) {
373 printf("No room '%s'.\n", towhere);
376 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
386 extract(room_name, &aaa[4], 0);
387 room_flags = extract_int(&aaa[4], 4);
388 from_floor = curr_floor;
389 curr_floor = extract_int(&aaa[4], 10);
391 remove_march(room_name, 0);
392 if (!strcasecmp(towhere, "_BASEROOM_"))
393 remove_march(towhere, 0);
394 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
395 if (floorlist[(int) curr_floor][0] == 0)
397 printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
399 if (display_name == 1) {
401 printf("%s ", room_name);
405 if (display_name != 2) {
406 color(BRIGHT_YELLOW);
407 printf("%d ", extract_int(&aaa[4], 1));
410 color(BRIGHT_YELLOW);
411 printf("%d ", extract_int(&aaa[4], 2));
413 printf("messages.\n");
415 highest_msg_read = extract_int(&aaa[4], 6);
416 maxmsgnum = extract_int(&aaa[4], 5);
417 is_mail = (char) extract_int(&aaa[4], 7);
418 is_room_aide = (char) extract_int(&aaa[4], 8);
419 ls = extract_long(&aaa[4], 6);
421 /* read info file if necessary */
422 if (extract_int(&aaa[4], 3) > 0)
425 /* check for newly arrived mail if we can */
426 if (num_parms(&aaa[4]) >= 10) {
427 newmailcount = extract_int(&aaa[4], 9);
428 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
430 printf("*** You have new mail\n");
433 oldmailcount = newmailcount;
437 /* Goto next room having unread messages.
438 * We want to skip over rooms that the user has already been to, and take the
439 * user back to the lobby when done. The room we end up in is placed in
440 * newroom - which is set to 0 (the lobby) initially.
445 struct march *mptr, *mptr2;
446 char next_room[ROOMNAMELEN];
448 /* Check to see if the march-mode list is already allocated.
449 * If it is, pop the first room off the list and go there.
455 while (serv_gets(buf), strcmp(buf, "000")) {
456 mptr = (struct march *) malloc(sizeof(struct march));
458 extract(mptr->march_name, buf, 0);
459 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
460 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
465 while (mptr2->next != NULL)
470 /* add _BASEROOM_ to the end of the march list, so the user will end up
471 * in the system base room (usually the Lobby>) at the end of the loop
473 mptr = (struct march *) malloc(sizeof(struct march));
475 strcpy(mptr->march_name, "_BASEROOM_");
480 while (mptr2->next != NULL)
485 * ...and remove the room we're currently in, so a <G>oto doesn't make us
486 * walk around in circles
488 remove_march(room_name, 0);
491 strcpy(next_room, pop_march(curr_floor));
493 strcpy(next_room, "_BASEROOM_");
495 remove_march(next_room, 0);
496 dotgoto(next_room, 1);
500 * forget all rooms on a given floor
502 void forget_all_rooms_on(int ffloor)
505 struct march *flist, *fptr;
507 printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
509 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
513 printf("%-72s\n", &buf[4]);
517 while (serv_gets(buf), strcmp(buf, "000")) {
518 fptr = (struct march *) malloc(sizeof(struct march));
521 extract(fptr->march_name, buf, 0);
523 while (flist != NULL) {
524 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
535 printf("%-72s\r", "");
540 * routine called by gotofloor() to move to a new room on a new floor
542 void gf_toroom(char *towhere, int mode)
544 int floor_being_left;
546 floor_being_left = curr_floor;
548 if (mode == GF_GOTO) { /* <;G>oto mode */
552 if (mode == GF_SKIP) { /* <;S>kip mode */
554 remove_march("_FLOOR_", floor_being_left);
556 if (mode == GF_ZAP) { /* <;Z>ap mode */
558 remove_march("_FLOOR_", floor_being_left);
559 forget_all_rooms_on(floor_being_left);
567 void gotofloor(char *towhere, int mode)
571 char buf[SIZ], targ[SIZ];
573 if (floorlist[0][0] == 0)
576 for (a = 0; a < 128; ++a)
577 if (!strcasecmp(&floorlist[a][0], towhere))
581 for (a = 0; a < 128; ++a) {
582 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
588 for (a = 0; a < 128; ++a)
589 if (pattern(towhere, &floorlist[a][0]) > 0)
593 printf("No floor '%s'.\n", towhere);
596 for (mptr = march; mptr != NULL; mptr = mptr->next) {
597 if ((mptr->march_floor) == tofloor)
598 gf_toroom(mptr->march_name, mode);
603 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
607 while (serv_gets(buf), strcmp(buf, "000")) {
608 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
609 extract(targ, buf, 0);
611 if (strlen(targ) > 0) {
612 gf_toroom(targ, mode);
614 printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
620 * forget all rooms on current floor
622 void forget_this_floor(void)
625 if (curr_floor == 0) {
626 printf("Can't forget this floor.\n");
629 if (floorlist[0][0] == 0)
631 printf("Are you sure you want to forget all rooms on %s? ",
632 &floorlist[(int) curr_floor][0]);
636 gf_toroom("_BASEROOM_", GF_ZAP);
641 * Figure out the physical screen dimensions, if we can
643 void check_screen_dims(void)
647 unsigned short height; /* rows */
648 unsigned short width; /* columns */
649 unsigned short xpixels;
650 unsigned short ypixels; /* pixels */
653 if (have_xterm) { /* dynamically size screen if on an xterm */
654 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
656 screenheight = (int) xwinsz.height;
658 screenwidth = (int) xwinsz.width;
666 * set floor mode depending on client, server, and user settings
668 void set_floor_mode(void)
670 if (serv_info.serv_ok_floors == 0) {
671 floor_mode = 0; /* Don't use floors if the server */
673 /* doesn't support them! */
675 if (rc_floor_mode == RC_NO) { /* never use floors */
678 if (rc_floor_mode == RC_YES) { /* always use floors */
681 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
682 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
688 * Set or change the user's password
690 int set_password(void)
696 if (strlen(rc_password) > 0) {
697 strcpy(pass1, rc_password);
698 strcpy(pass2, rc_password);
700 IFNEXPERT formout("changepw");
701 newprompt("Enter a new password: ", pass1, -19);
702 newprompt("Enter it again to confirm: ", pass2, -19);
706 if (!strcasecmp(pass1, pass2)) {
707 snprintf(buf, sizeof buf, "SETP %s", pass1);
710 printf("%s\n", &buf[4]);
711 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
714 printf("*** They don't match... try again.\n");
722 * get info about the server we've connected to
724 void get_serv_info(char *supplied_hostname)
728 CtdlInternalGetServInfo(&serv_info);
730 /* be nice and identify ourself to the server */
731 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
732 SERVER_TYPE, 0, REV_LEVEL,
733 (server_is_local ? "local" : CITADEL));
735 /* Append a hostname */
736 if (supplied_hostname != NULL) {
737 strcat(buf, supplied_hostname);
740 locate_host(&buf[strlen(buf)]); /* append to the end */
744 serv_gets(buf); /* we don't care about the result code */
752 * Display list of users currently logged on to the server
754 void who_is_online(int longlist)
756 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
758 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
759 char tbuf[SIZ], clientsoft[SIZ];
761 time_t idletime, idlehours, idlemins, idlesecs;
762 int last_session = (-1);
766 if (tbuf[0] == '2') {
767 timenow = extract_long(&tbuf[4], 0);
775 pprintf("FLG ### User Name Room From host\n");
777 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
782 while (serv_gets(buf), strcmp(buf, "000")) {
783 extract(username, buf, 1);
784 extract(roomname, buf, 2);
785 extract(fromhost, buf, 3);
786 extract(clientsoft, buf, 4);
787 extract(flags, buf, 7);
789 idletime = timenow - extract_long(buf, 5);
790 idlehours = idletime / 3600;
791 idlemins = (idletime - (idlehours * 3600)) / 60;
792 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
794 if (idletime > 900) {
795 while (strlen(roomname) < 20) {
796 strcat(roomname, " ");
798 strcpy(&roomname[14], "[idle]");
803 extract(actual_user, buf, 8);
804 extract(actual_room, buf, 9);
805 extract(actual_host, buf, 10);
807 pprintf(" Flags: %s\n", flags);
808 pprintf("Session: %d\n", extract_int(buf, 0));
809 pprintf(" Name: %s\n", username);
810 pprintf("In room: %s\n", roomname);
811 pprintf(" Host: %s\n", fromhost);
812 pprintf(" Client: %s\n", clientsoft);
813 pprintf(" Idle: %ld:%02ld:%02ld\n",
818 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
820 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
821 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
822 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
828 if (extract_int(buf, 0) == last_session) {
831 color(BRIGHT_MAGENTA);
832 pprintf("%-3s ", flags);
834 pprintf("%-3d ", extract_int(buf, 0));
836 last_session = extract_int(buf, 0);
838 pprintf("%-25s ", username);
839 color(BRIGHT_MAGENTA);
841 pprintf("%-20s ", roomname);
844 pprintf("%-24s\n", fromhost);
851 void enternew(char *desc, char *buf, int maxlen)
854 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
855 newprompt(bbb, buf, maxlen);
860 int shift(int argc, char **argv, int start, int count) {
863 for (i=start; i<(argc-count); ++i) {
864 argv[i] = argv[i+count];
873 int main(int argc, char **argv)
876 char aaa[100], bbb[100];/* general purpose variables */
877 char argbuf[32]; /* command line buf */
878 char nonce[NONCE_SIZE];
879 char *telnet_client_host = NULL;
880 char *sptr, *sptr2; /* USed to extract the nonce */
881 char hexstring[MD5_HEXSTRING_SIZE];
882 int stored_password = 0;
885 /* Permissions sanity check - don't run citadel setuid/setgid */
886 if (getuid() != geteuid()) {
887 fprintf(stderr, "Please do not run citadel setuid!\n");
889 } else if (getgid() != getegid()) {
890 fprintf(stderr, "Please do not run citadel setgid!\n");
894 sttybbs(SB_SAVE); /* Store the old terminal parameters */
895 load_command_set(); /* parse the citadel.rc file */
896 sttybbs(SB_NO_INTR); /* Install the new ones */
897 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
898 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
899 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
902 * Handle command line options as if we were called like /bin/login
903 * (i.e. from in.telnetd)
905 for (a=0; a<argc; ++a) {
906 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
907 telnet_client_host = argv[a+1];
908 argc = shift(argc, argv, a, 2);
910 if (!strcmp(argv[a], "-p")) {
913 if (chdir(BBSDIR) < 0) {
914 perror("can't change to " BBSDIR);
919 * Drop privileges if necessary. We stat
920 * citadel.config to get the uid/gid since it's
921 * guaranteed to have the uid/gid we want.
923 if (!getuid() || !getgid()) {
924 if (stat(BBSDIR "/citadel.config", &st) < 0) {
925 perror("couldn't stat citadel.config");
928 if (!getgid() && (setgid(st.st_gid) < 0)) {
929 perror("couldn't change gid");
932 if (!getuid() && (setuid(st.st_uid) < 0)) {
933 perror("couldn't change uid");
937 printf("Privileges changed to uid %d gid %d\n",
941 argc = shift(argc, argv, a, 1);
945 printf("Attaching to server... \r");
947 attach_to_server(argc, argv, hostbuf, portbuf);
953 printf("%s\n", &aaa[4]);
957 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
961 if ((sptr = strchr(aaa, '<')) == NULL)
967 if ((sptr2 = strchr(sptr, '>')) == NULL)
975 strncpy(nonce, sptr, NONCE_SIZE);
979 get_serv_info(telnet_client_host);
985 printf("%-23s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
986 serv_info.serv_bbs_city);
987 screenwidth = 80; /* default screen dimensions */
990 printf(" pause next stop\n");
991 printf(" ctrl-s ctrl-o ctrl-c\n\n");
992 formout("hello"); /* print the opening greeting */
995 GSTA: /* See if we have a username and password on disk */
996 if (rc_remember_passwords) {
997 get_stored_password(hostbuf, portbuf, fullname, password);
998 if (strlen(fullname) > 0) {
999 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1004 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1006 else /* Else no APOP */
1008 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1013 if (aaa[0] == '2') {
1014 load_user_info(&aaa[4]);
1015 stored_password = 1;
1019 set_stored_password(hostbuf, portbuf, "", "");
1027 if (strlen(rc_username) > 0) {
1028 strcpy(fullname, rc_username);
1030 newprompt("Enter your name: ", fullname, 29);
1033 if (!strcasecmp(fullname, "new")) { /* just in case */
1034 printf("Please enter the name you wish to log in with.\n");
1037 (!strcasecmp(fullname, "bbs"))
1038 || (!strcasecmp(fullname, "new"))
1039 || (strlen(fullname) == 0));
1041 if (!strcasecmp(fullname, "off")) {
1045 /* sign on to the server */
1046 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1052 /* password authentication */
1053 if (strlen(rc_password) > 0) {
1054 strcpy(password, rc_password);
1056 newprompt("\rPlease enter your password: ", password, -19);
1062 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1064 else /* Else no APOP */
1066 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1071 if (aaa[0] == '2') {
1072 load_user_info(&aaa[4]);
1073 offer_to_remember_password(hostbuf, portbuf,
1074 fullname, password);
1077 printf("<< wrong password >>\n");
1078 if (strlen(rc_password) > 0)
1082 NEWUSR: if (strlen(rc_password) == 0) {
1083 printf("No record. Enter as new user? ");
1087 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1090 if (aaa[0] != '2') {
1091 printf("%s\n", aaa);
1094 load_user_info(&aaa[4]);
1096 while (set_password() != 0);;
1102 /* Switch color support on or off if we're in user mode */
1103 if (rc_ansi_color == 3) {
1104 if (userflags & US_COLOR)
1110 printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
1111 fullname, axlevel, axdefs[(int) axlevel],
1112 usernum, timescalled);
1116 if (aaa[0] == '2') {
1117 b = extract_int(&aaa[4], 0);
1121 printf("*** You have a new private message in Mail>\n");
1123 printf("*** You have %d new private messages in Mail>\n", b);
1126 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1127 printf("*** Users need validation\n");
1129 if (extract_int(&aaa[4], 1) > 0) {
1130 printf("*** Please register.\n");
1131 formout("register");
1135 /* Make up some temporary filenames for use in various parts of the
1136 * program. Don't mess with these once they've been set, because we
1137 * will be unlinking them later on in the program and we don't
1138 * want to delete something that we didn't create. */
1139 snprintf(temp, sizeof temp, tmpnam(NULL));
1140 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1141 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1143 /* Get screen dimensions. First we go to a default of 80x24. Then
1144 * we try to get the user's actual screen dimensions off the server.
1145 * However, if we're running on an xterm, all this stuff is
1146 * irrelevant because we're going to dynamically size the screen
1147 * during the session.
1153 if (aaa[0] == '2') {
1154 screenwidth = extract_int(&aaa[4], 0);
1155 screenheight = extract_int(&aaa[4], 1);
1157 if (getenv("TERM") != NULL)
1158 if (!strcmp(getenv("TERM"), "xterm")) {
1162 check_screen_dims();
1168 /* Enter the lobby */
1169 dotgoto("_BASEROOM_", 1);
1171 /* Main loop for the system... user is logged in. */
1180 /* MAIN COMMAND LOOP */
1182 mcmd = getcmd(argbuf); /* Get keyboard command */
1185 check_screen_dims(); /* if xterm, get screen size */
1203 newprompt("What do you want your username to be? ", aaa, 32);
1204 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1207 if (strncmp("200", aaa, 3))
1208 printf("\n%s\n", aaa);
1222 dotgoto("_MAIL_", 1);
1239 readmsgs(0, (-1), 0);
1242 readmsgs(2, (-1), 0);
1245 readmsgs(3, 1, atoi(argbuf));
1332 cli_image_upload("_userpic_");
1335 cli_image_upload("_roompic_");
1339 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1340 cli_image_upload(aaa);
1344 enternew("roomname", aaa, 20);
1345 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1348 if (strncmp("200", aaa, 3))
1349 printf("\n%s\n", aaa);
1352 enternew("hostname", aaa, 25);
1353 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1356 if (strncmp("200", aaa, 3))
1357 printf("\n%s\n", aaa);
1360 enternew("username", aaa, 32);
1361 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1364 if (strncmp("200", aaa, 3))
1365 printf("\n%s\n", aaa);
1375 display_help(argbuf);
1379 formout("register");
1384 printf("Are you sure (y/n)? ");
1393 printf("All users will be disconnected! "
1394 "Really terminate the server? ");
1398 printf("%s\n", &aaa[4]);
1408 printf("Do you really want to schedule a "
1409 "server shutdown? ");
1411 serv_puts("SCDN 1");
1414 if (atoi(&aaa[4])) {
1416 "The Citadel server will terminate when all users are logged off.\n"
1421 "The Citadel server will not terminate.\n"
1429 network_config_management("listrecp",
1430 "Mailing list recipients");
1434 network_config_management("ignet_push_share",
1435 "Nodes with which we share this room");
1439 do_ignet_configuration();
1451 if (server_is_local) {
1452 sttybbs(SB_RESTORE);
1453 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1454 "exec ./subsystem %ld %d %d", fullname,
1455 usernum, screenwidth, axlevel);
1457 sttybbs(SB_NO_INTR);
1459 printf("*** Can't run doors when server is not local.\n");
1472 do_system_configuration();
1476 do_internet_configuration();
1480 check_message_base();
1502 gotofloor(argbuf, GF_GOTO);
1506 gotofloor(argbuf, GF_SKIP);
1510 forget_this_floor();
1538 knrooms(floor_mode);
1548 misc_server_cmd(argbuf);
1552 edit_system_message(argbuf);
1577 } while (termn8 == 0);
1579 TERMN8: printf("%s logged out.\n", fullname);
1580 while (march != NULL) {
1581 remove_march(march->march_name, 0);
1584 printf("\n\nType 'off' to hang up, or next user...\n");
1586 snprintf(aaa, sizeof aaa, "LOUT");
1589 if ((mcmd == 29) || (mcmd == 15)) {