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"
59 char march_name[ROOMNAMELEN];
64 #define IFEXPERT if (userflags&US_EXPERT)
65 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
66 #define IFAIDE if (axlevel>=6)
67 #define IFNAIDE if (axlevel<6)
69 struct march *march = NULL;
71 /* globals associated with the client program */
72 char temp[PATH_MAX]; /* Name of general temp file */
73 char temp2[PATH_MAX]; /* Name of general temp file */
74 char tempdir[PATH_MAX]; /* Name of general temp dir */
75 char editor_path[SIZ]; /* path to external editor */
76 char printcmd[SIZ]; /* print command */
77 int editor_pid = (-1);
80 struct CtdlServInfo serv_info; /* Info on the server connected */
84 char room_name[ROOMNAMELEN];
85 char ugname[ROOMNAMELEN];
86 long uglsn; /* holds <u>ngoto info */
87 char is_mail = 0; /* nonzero when we're in a mail room */
88 char axlevel = 0; /* access level */
89 char is_room_aide = 0; /* boolean flag, 1 if room aide */
93 long usernum = 0L; /* user number */
94 time_t lastcall = 0L; /* Date/time of previous login */
96 long highest_msg_read; /* used for <A>bandon room cmd */
97 long maxmsgnum; /* used for <G>oto */
99 char have_xterm = 0; /* are we running on an xterm? */
100 char rc_username[32];
101 char rc_password[32];
106 char curr_floor = 0; /* number of current floor */
107 char floorlist[128][SIZ]; /* names of floors */
108 char express_msgs = 0; /* express messages waiting! */
109 int termn8 = 0; /* Set to nonzero to cause a logoff */
111 extern int rc_ansi_color; /* ansi color value from citadel.rc */
114 * here is our 'clean up gracefully and exit' routine
116 void logoff(int code)
118 if (editor_pid > 0) { /* kill the editor if it's running */
119 kill(editor_pid, SIGHUP);
121 /* shut down the server... but not if the logoff code is 3, because
122 * that means we're exiting because we already lost the server
128 * now clean up various things
135 /* Violently kill off any child processes if Citadel is
138 if (getppid() == 1) {
139 kill(0 - getpgrp(), SIGTERM);
141 kill(0 - getpgrp(), SIGKILL);
143 sttybbs(SB_RESTORE); /* return the old terminal settings */
144 exit(code); /* exit with the proper exit code */
150 * signal catching function for hangups...
152 void dropcarr(int signum)
160 * catch SIGCONT to reset terminal modes when were are put back into the
163 void catch_sigcont(int signum)
166 signal(SIGCONT, catch_sigcont);
171 /* general purpose routines */
173 void formout(char *name)
174 { /* display a file */
176 snprintf(cmd, sizeof cmd, "MESG %s", name);
180 printf("%s\n", &cmd[4]);
183 fmout(screenwidth, NULL,
184 ((userflags & US_PAGINATOR) ? 1 : 0),
189 void userlist(char *patn)
199 pprintf("%s\n", &buf[4]);
202 pprintf(" User Name Num L LastCall Calls Posts\n");
203 pprintf("------------------------- ----- - ---------- ----- -----\n");
204 while (serv_gets(buf), strcmp(buf, "000")) {
205 if (sigcaught == 0) {
207 if (pattern(fl, patn) >= 0) {
208 pprintf("%-25s ", fl);
209 pprintf("%5ld %d ", extract_long(buf, 2),
210 extract_int(buf, 1));
211 lc = extract_long(buf, 3);
212 tmbuf = (struct tm *) localtime(&lc);
213 pprintf("%02d/%02d/%04d ",
216 (tmbuf->tm_year + 1900));
217 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
227 * grab assorted info about the user...
229 void load_user_info(char *params)
231 extract(fullname, params, 0);
232 axlevel = extract_int(params, 1);
233 timescalled = extract_int(params, 2);
234 posted = extract_int(params, 3);
235 userflags = extract_int(params, 4);
236 usernum = extract_long(params, 5);
237 lastcall = extract_long(params, 6);
242 * Remove a room from the march list. 'floornum' is ignored unless
243 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
244 * floor will be removed from the march list.
246 void remove_march(char *roomname, int floornum)
248 struct march *mptr, *mptr2;
253 if ((!strcasecmp(march->march_name, roomname))
254 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
261 for (mptr = march; mptr != NULL; mptr = mptr->next) {
263 if ((!strcasecmp(mptr->march_name, roomname))
264 || ((!strcasecmp(roomname, "_FLOOR_"))
265 && (mptr->march_floor == floornum))) {
267 mptr2->next = mptr->next;
278 * Locate the room on the march list which we most want to go to. Each room
279 * is measured given a "weight" of preference based on various factors.
281 char *pop_march(int desired_floor)
283 static char TheRoom[ROOMNAMELEN];
285 int TheOrder = 32767;
288 struct march *mptr = NULL;
290 strcpy(TheRoom, "_BASEROOM_");
294 for (mptr = march; mptr != NULL; mptr = mptr->next) {
296 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
297 weight = weight + 10000;
298 if (mptr->march_floor == desired_floor)
299 weight = weight + 5000;
301 weight = weight + ((128 - (mptr->march_floor)) * 128);
302 weight = weight + (128 - (mptr->march_order));
304 if (weight > TheWeight) {
306 strcpy(TheRoom, mptr->march_name);
307 TheFloor = mptr->march_floor;
308 TheOrder = mptr->march_order;
316 * jump directly to a room
318 void dotgoto(char *towhere, int display_name)
320 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
323 static int oldmailcount = (-1);
324 int partial_match, best_match;
327 /* store ungoto information */
328 strcpy(ugname, room_name);
331 /* first try an exact match */
332 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
337 if (!strncmp(aaa, "54", 2)) {
338 newprompt("Enter room password: ", bbb, 9);
339 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
345 if (!strncmp(aaa, "54", 2)) {
346 printf("Wrong password.\n");
350 * If a match is not found, try a partial match.
351 * Partial matches anywhere in the string carry a weight of 1,
352 * left-aligned matches carry a weight of 2. Pick the room that
353 * has the highest-weighted match.
361 while (serv_gets(aaa), strcmp(aaa, "000")) {
362 extract(psearch, aaa, 0);
364 if (pattern(psearch, towhere) >= 0) {
367 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
370 if (partial_match > best_match) {
371 strcpy(bbb, psearch);
372 best_match = partial_match;
375 if (strlen(bbb) == 0) {
376 printf("No room '%s'.\n", towhere);
379 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
389 extract(room_name, &aaa[4], 0);
390 room_flags = extract_int(&aaa[4], 4);
391 from_floor = curr_floor;
392 curr_floor = extract_int(&aaa[4], 10);
394 remove_march(room_name, 0);
395 if (!strcasecmp(towhere, "_BASEROOM_"))
396 remove_march(towhere, 0);
397 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
398 if (floorlist[(int) curr_floor][0] == 0)
400 printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
402 if (display_name == 1) {
404 printf("%s ", room_name);
408 if (display_name != 2) {
409 color(BRIGHT_YELLOW);
410 printf("%d ", extract_int(&aaa[4], 1));
413 color(BRIGHT_YELLOW);
414 printf("%d ", extract_int(&aaa[4], 2));
416 printf("messages.\n");
418 highest_msg_read = extract_int(&aaa[4], 6);
419 maxmsgnum = extract_int(&aaa[4], 5);
420 is_mail = (char) extract_int(&aaa[4], 7);
421 is_room_aide = (char) extract_int(&aaa[4], 8);
422 ls = extract_long(&aaa[4], 6);
424 /* read info file if necessary */
425 if (extract_int(&aaa[4], 3) > 0)
428 /* check for newly arrived mail if we can */
429 if (num_parms(&aaa[4]) >= 10) {
430 newmailcount = extract_int(&aaa[4], 9);
431 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
433 printf("*** You have new mail\n");
436 oldmailcount = newmailcount;
440 /* Goto next room having unread messages.
441 * We want to skip over rooms that the user has already been to, and take the
442 * user back to the lobby when done. The room we end up in is placed in
443 * newroom - which is set to 0 (the lobby) initially.
448 struct march *mptr, *mptr2;
449 char next_room[ROOMNAMELEN];
451 /* Check to see if the march-mode list is already allocated.
452 * If it is, pop the first room off the list and go there.
458 while (serv_gets(buf), strcmp(buf, "000")) {
459 mptr = (struct march *) malloc(sizeof(struct march));
461 extract(mptr->march_name, buf, 0);
462 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
463 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
468 while (mptr2->next != NULL)
473 /* add _BASEROOM_ to the end of the march list, so the user will end up
474 * in the system base room (usually the Lobby>) at the end of the loop
476 mptr = (struct march *) malloc(sizeof(struct march));
478 strcpy(mptr->march_name, "_BASEROOM_");
483 while (mptr2->next != NULL)
488 * ...and remove the room we're currently in, so a <G>oto doesn't make us
489 * walk around in circles
491 remove_march(room_name, 0);
494 strcpy(next_room, pop_march(curr_floor));
496 strcpy(next_room, "_BASEROOM_");
498 remove_march(next_room, 0);
499 dotgoto(next_room, 1);
503 * forget all rooms on a given floor
505 void forget_all_rooms_on(int ffloor)
508 struct march *flist, *fptr;
510 printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
512 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
516 printf("%-72s\n", &buf[4]);
520 while (serv_gets(buf), strcmp(buf, "000")) {
521 fptr = (struct march *) malloc(sizeof(struct march));
524 extract(fptr->march_name, buf, 0);
526 while (flist != NULL) {
527 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
538 printf("%-72s\r", "");
543 * routine called by gotofloor() to move to a new room on a new floor
545 void gf_toroom(char *towhere, int mode)
547 int floor_being_left;
549 floor_being_left = curr_floor;
551 if (mode == GF_GOTO) { /* <;G>oto mode */
555 if (mode == GF_SKIP) { /* <;S>kip mode */
557 remove_march("_FLOOR_", floor_being_left);
559 if (mode == GF_ZAP) { /* <;Z>ap mode */
561 remove_march("_FLOOR_", floor_being_left);
562 forget_all_rooms_on(floor_being_left);
570 void gotofloor(char *towhere, int mode)
574 char buf[SIZ], targ[SIZ];
576 if (floorlist[0][0] == 0)
579 for (a = 0; a < 128; ++a)
580 if (!strcasecmp(&floorlist[a][0], towhere))
584 for (a = 0; a < 128; ++a) {
585 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
591 for (a = 0; a < 128; ++a)
592 if (pattern(towhere, &floorlist[a][0]) > 0)
596 printf("No floor '%s'.\n", towhere);
599 for (mptr = march; mptr != NULL; mptr = mptr->next) {
600 if ((mptr->march_floor) == tofloor)
601 gf_toroom(mptr->march_name, mode);
606 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
610 while (serv_gets(buf), strcmp(buf, "000")) {
611 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
612 extract(targ, buf, 0);
614 if (strlen(targ) > 0) {
615 gf_toroom(targ, mode);
617 printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
623 * forget all rooms on current floor
625 void forget_this_floor(void)
628 if (curr_floor == 0) {
629 printf("Can't forget this floor.\n");
632 if (floorlist[0][0] == 0)
634 printf("Are you sure you want to forget all rooms on %s? ",
635 &floorlist[(int) curr_floor][0]);
639 gf_toroom("_BASEROOM_", GF_ZAP);
644 * Figure out the physical screen dimensions, if we can
646 void check_screen_dims(void)
650 unsigned short height; /* rows */
651 unsigned short width; /* columns */
652 unsigned short xpixels;
653 unsigned short ypixels; /* pixels */
656 if (have_xterm) { /* dynamically size screen if on an xterm */
657 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
659 screenheight = (int) xwinsz.height;
661 screenwidth = (int) xwinsz.width;
669 * set floor mode depending on client, server, and user settings
671 void set_floor_mode(void)
673 if (serv_info.serv_ok_floors == 0) {
674 floor_mode = 0; /* Don't use floors if the server */
676 /* doesn't support them! */
678 if (rc_floor_mode == RC_NO) { /* never use floors */
681 if (rc_floor_mode == RC_YES) { /* always use floors */
684 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
685 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
691 * Set or change the user's password
693 int set_password(void)
699 if (strlen(rc_password) > 0) {
700 strcpy(pass1, rc_password);
701 strcpy(pass2, rc_password);
703 IFNEXPERT formout("changepw");
704 newprompt("Enter a new password: ", pass1, -19);
705 newprompt("Enter it again to confirm: ", pass2, -19);
709 if (!strcasecmp(pass1, pass2)) {
710 snprintf(buf, sizeof buf, "SETP %s", pass1);
713 printf("%s\n", &buf[4]);
714 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
717 printf("*** They don't match... try again.\n");
725 * get info about the server we've connected to
727 void get_serv_info(char *supplied_hostname)
731 CtdlInternalGetServInfo(&serv_info);
733 /* be nice and identify ourself to the server */
734 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
735 SERVER_TYPE, 0, REV_LEVEL,
736 (server_is_local ? "local" : CITADEL));
738 /* Append a hostname */
739 if (supplied_hostname != NULL) {
740 strcat(buf, supplied_hostname);
743 locate_host(&buf[strlen(buf)]); /* append to the end */
747 serv_gets(buf); /* we don't care about the result code */
755 * Display list of users currently logged on to the server
757 void who_is_online(int longlist)
759 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
761 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
762 char tbuf[SIZ], clientsoft[SIZ];
764 time_t idletime, idlehours, idlemins, idlesecs;
765 int last_session = (-1);
769 if (tbuf[0] == '2') {
770 timenow = extract_long(&tbuf[4], 0);
778 pprintf("FLG ### User Name Room From host\n");
780 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
785 while (serv_gets(buf), strcmp(buf, "000")) {
786 extract(username, buf, 1);
787 extract(roomname, buf, 2);
788 extract(fromhost, buf, 3);
789 extract(clientsoft, buf, 4);
790 extract(flags, buf, 7);
792 idletime = timenow - extract_long(buf, 5);
793 idlehours = idletime / 3600;
794 idlemins = (idletime - (idlehours * 3600)) / 60;
795 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
797 if (idletime > 900) {
798 while (strlen(roomname) < 20) {
799 strcat(roomname, " ");
801 strcpy(&roomname[14], "[idle]");
806 extract(actual_user, buf, 8);
807 extract(actual_room, buf, 9);
808 extract(actual_host, buf, 10);
810 pprintf(" Flags: %s\n", flags);
811 pprintf("Session: %d\n", extract_int(buf, 0));
812 pprintf(" Name: %s\n", username);
813 pprintf("In room: %s\n", roomname);
814 pprintf(" Host: %s\n", fromhost);
815 pprintf(" Client: %s\n", clientsoft);
816 pprintf(" Idle: %ld:%02ld:%02ld\n",
821 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
823 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
824 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
825 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
831 if (extract_int(buf, 0) == last_session) {
834 color(BRIGHT_MAGENTA);
835 pprintf("%-3s ", flags);
837 pprintf("%-3d ", extract_int(buf, 0));
839 last_session = extract_int(buf, 0);
841 pprintf("%-25s ", username);
842 color(BRIGHT_MAGENTA);
844 pprintf("%-20s ", roomname);
847 pprintf("%-24s\n", fromhost);
854 void enternew(char *desc, char *buf, int maxlen)
857 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
858 newprompt(bbb, buf, maxlen);
863 int shift(int argc, char **argv, int start, int count) {
866 for (i=start; i<(argc-count); ++i) {
867 argv[i] = argv[i+count];
876 int main(int argc, char **argv)
879 char aaa[100], bbb[100];/* general purpose variables */
880 char argbuf[32]; /* command line buf */
881 char nonce[NONCE_SIZE];
882 char *telnet_client_host = NULL;
883 char *sptr, *sptr2; /* USed to extract the nonce */
884 char hexstring[MD5_HEXSTRING_SIZE];
885 int stored_password = 0;
888 /* Permissions sanity check - don't run citadel setuid/setgid */
889 if (getuid() != geteuid()) {
890 fprintf(stderr, "Please do not run citadel setuid!\n");
892 } else if (getgid() != getegid()) {
893 fprintf(stderr, "Please do not run citadel setgid!\n");
897 sttybbs(SB_SAVE); /* Store the old terminal parameters */
898 load_command_set(); /* parse the citadel.rc file */
899 sttybbs(SB_NO_INTR); /* Install the new ones */
900 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
901 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
902 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
904 arg_encrypt = RC_DEFAULT;
907 * Handle command line options as if we were called like /bin/login
908 * (i.e. from in.telnetd)
910 for (a=0; a<argc; ++a) {
911 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
912 telnet_client_host = argv[a+1];
913 argc = shift(argc, argv, a, 2);
915 if (!strcmp(argv[a], "-x")) {
917 argc = shift(argc, argv, a, 1);
919 if (!strcmp(argv[a], "-X")) {
920 arg_encrypt = RC_YES;
921 argc = shift(argc, argv, a, 1);
923 if (!strcmp(argv[a], "-p")) {
926 if (chdir(BBSDIR) < 0) {
927 perror("can't change to " BBSDIR);
932 * Drop privileges if necessary. We stat
933 * citadel.config to get the uid/gid since it's
934 * guaranteed to have the uid/gid we want.
936 if (!getuid() || !getgid()) {
937 if (stat(BBSDIR "/citadel.config", &st) < 0) {
938 perror("couldn't stat citadel.config");
941 if (!getgid() && (setgid(st.st_gid) < 0)) {
942 perror("couldn't change gid");
945 if (!getuid() && (setuid(st.st_uid) < 0)) {
946 perror("couldn't change uid");
950 printf("Privileges changed to uid %d gid %d\n",
954 argc = shift(argc, argv, a, 1);
958 printf("Attaching to server... \r");
960 attach_to_server(argc, argv, hostbuf, portbuf);
966 printf("%s\n", &aaa[4]);
970 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
974 if ((sptr = strchr(aaa, '<')) == NULL)
980 if ((sptr2 = strchr(sptr, '>')) == NULL)
988 strncpy(nonce, sptr, NONCE_SIZE);
992 get_serv_info(telnet_client_host);
995 printf("Session will not be encrypted.\n");
1002 printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
1003 serv_info.serv_bbs_city);
1004 screenwidth = 80; /* default screen dimensions */
1007 printf(" pause next stop\n");
1008 printf(" ctrl-s ctrl-o ctrl-c\n\n");
1009 formout("hello"); /* print the opening greeting */
1012 GSTA: /* See if we have a username and password on disk */
1013 if (rc_remember_passwords) {
1014 get_stored_password(hostbuf, portbuf, fullname, password);
1015 if (strlen(fullname) > 0) {
1016 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1021 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1023 else /* Else no APOP */
1025 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1030 if (aaa[0] == '2') {
1031 load_user_info(&aaa[4]);
1032 stored_password = 1;
1036 set_stored_password(hostbuf, portbuf, "", "");
1044 if (strlen(rc_username) > 0) {
1045 strcpy(fullname, rc_username);
1047 newprompt("Enter your name: ", fullname, 29);
1050 if (!strcasecmp(fullname, "new")) { /* just in case */
1051 printf("Please enter the name you wish to log in with.\n");
1054 (!strcasecmp(fullname, "bbs"))
1055 || (!strcasecmp(fullname, "new"))
1056 || (strlen(fullname) == 0));
1058 if (!strcasecmp(fullname, "off")) {
1062 /* sign on to the server */
1063 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1069 /* password authentication */
1070 if (strlen(rc_password) > 0) {
1071 strcpy(password, rc_password);
1073 newprompt("\rPlease enter your password: ", password, -19);
1079 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1081 else /* Else no APOP */
1083 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1088 if (aaa[0] == '2') {
1089 load_user_info(&aaa[4]);
1090 offer_to_remember_password(hostbuf, portbuf,
1091 fullname, password);
1094 printf("<< wrong password >>\n");
1095 if (strlen(rc_password) > 0)
1099 NEWUSR: if (strlen(rc_password) == 0) {
1100 printf("No record. Enter as new user? ");
1104 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1107 if (aaa[0] != '2') {
1108 printf("%s\n", aaa);
1111 load_user_info(&aaa[4]);
1113 while (set_password() != 0);;
1119 /* Switch color support on or off if we're in user mode */
1120 if (rc_ansi_color == 3) {
1121 if (userflags & US_COLOR)
1127 printf("%s\nAccess level: %d (%s)\n"
1128 "User #%ld / Login #%d",
1129 fullname, axlevel, axdefs[(int) axlevel],
1130 usernum, timescalled);
1131 if (lastcall > 0L) {
1132 printf(" / Last login: %s\n",
1133 asctime(localtime(&lastcall)) );
1139 if (aaa[0] == '2') {
1140 b = extract_int(&aaa[4], 0);
1144 printf("*** You have a new private message in Mail>\n");
1146 printf("*** You have %d new private messages in Mail>\n", b);
1149 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1150 printf("*** Users need validation\n");
1152 if (extract_int(&aaa[4], 1) > 0) {
1153 printf("*** Please register.\n");
1154 formout("register");
1158 /* Make up some temporary filenames for use in various parts of the
1159 * program. Don't mess with these once they've been set, because we
1160 * will be unlinking them later on in the program and we don't
1161 * want to delete something that we didn't create. */
1162 snprintf(temp, sizeof temp, tmpnam(NULL));
1163 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1164 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1166 /* Get screen dimensions. First we go to a default of 80x24. Then
1167 * we try to get the user's actual screen dimensions off the server.
1168 * However, if we're running on an xterm, all this stuff is
1169 * irrelevant because we're going to dynamically size the screen
1170 * during the session.
1176 if (aaa[0] == '2') {
1177 screenwidth = extract_int(&aaa[4], 0);
1178 screenheight = extract_int(&aaa[4], 1);
1180 if (getenv("TERM") != NULL)
1181 if (!strcmp(getenv("TERM"), "xterm")) {
1185 check_screen_dims();
1191 /* Enter the lobby */
1192 dotgoto("_BASEROOM_", 1);
1194 /* Main loop for the system... user is logged in. */
1203 /* MAIN COMMAND LOOP */
1205 mcmd = getcmd(argbuf); /* Get keyboard command */
1208 check_screen_dims(); /* if xterm, get screen size */
1226 newprompt("What do you want your username to be? ", aaa, 32);
1227 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1230 if (strncmp("200", aaa, 3))
1231 printf("\n%s\n", aaa);
1245 dotgoto("_MAIL_", 1);
1262 readmsgs(0, (-1), 0);
1265 readmsgs(2, (-1), 0);
1268 readmsgs(3, 1, atoi(argbuf));
1355 cli_image_upload("_userpic_");
1358 cli_image_upload("_roompic_");
1362 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1363 cli_image_upload(aaa);
1367 enternew("roomname", aaa, 20);
1368 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1371 if (strncmp("200", aaa, 3))
1372 printf("\n%s\n", aaa);
1375 enternew("hostname", aaa, 25);
1376 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1379 if (strncmp("200", aaa, 3))
1380 printf("\n%s\n", aaa);
1383 enternew("username", aaa, 32);
1384 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1387 if (strncmp("200", aaa, 3))
1388 printf("\n%s\n", aaa);
1398 display_help(argbuf);
1402 formout("register");
1407 printf("Are you sure (y/n)? ");
1416 printf("All users will be disconnected! "
1417 "Really terminate the server? ");
1421 printf("%s\n", &aaa[4]);
1431 printf("Do you really want to schedule a "
1432 "server shutdown? ");
1434 serv_puts("SCDN 1");
1437 if (atoi(&aaa[4])) {
1439 "The Citadel server will terminate when all users are logged off.\n"
1444 "The Citadel server will not terminate.\n"
1452 network_config_management("listrecp",
1453 "Mailing list recipients");
1457 network_config_management("ignet_push_share",
1458 "Nodes with which we share this room");
1462 do_ignet_configuration();
1474 if (server_is_local) {
1475 sttybbs(SB_RESTORE);
1476 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1477 "exec ./subsystem %ld %d %d", fullname,
1478 usernum, screenwidth, axlevel);
1480 sttybbs(SB_NO_INTR);
1482 printf("*** Can't run doors when server is not local.\n");
1495 do_system_configuration();
1499 do_internet_configuration();
1503 check_message_base();
1525 gotofloor(argbuf, GF_GOTO);
1529 gotofloor(argbuf, GF_SKIP);
1533 forget_this_floor();
1561 knrooms(floor_mode);
1571 misc_server_cmd(argbuf);
1575 edit_system_message(argbuf);
1600 } while (termn8 == 0);
1602 TERMN8: printf("%s logged out.\n", fullname);
1603 while (march != NULL) {
1604 remove_march(march->march_name, 0);
1607 printf("\n\nType 'off' to disconnect, or next user...\n");
1609 snprintf(aaa, sizeof aaa, "LOUT");
1612 if ((mcmd == 29) || (mcmd == 15)) {