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 */
93 time_t lastcall = 0L; /* Date/time of previous login */
95 long highest_msg_read; /* used for <A>bandon room cmd */
96 long maxmsgnum; /* used for <G>oto */
98 char have_xterm = 0; /* are we running on an xterm? */
100 char rc_password[32];
105 char curr_floor = 0; /* number of current floor */
106 char floorlist[128][SIZ]; /* names of floors */
107 char express_msgs = 0; /* express messages waiting! */
108 int termn8 = 0; /* Set to nonzero to cause a logoff */
110 extern int rc_ansi_color; /* ansi color value from citadel.rc */
113 * here is our 'clean up gracefully and exit' routine
115 void logoff(int code)
117 if (editor_pid > 0) { /* kill the editor if it's running */
118 kill(editor_pid, SIGHUP);
120 /* shut down the server... but not if the logoff code is 3, because
121 * that means we're exiting because we already lost the server
127 * now clean up various things
134 /* Violently kill off any child processes if Citadel is
137 if (getppid() == 1) {
138 kill(0 - getpgrp(), SIGTERM);
140 kill(0 - getpgrp(), SIGKILL);
142 sttybbs(SB_RESTORE); /* return the old terminal settings */
143 exit(code); /* exit with the proper exit code */
149 * signal catching function for hangups...
151 void dropcarr(int signum)
159 * catch SIGCONT to reset terminal modes when were are put back into the
162 void catch_sigcont(int signum)
165 signal(SIGCONT, catch_sigcont);
170 /* general purpose routines */
172 void formout(char *name)
173 { /* display a file */
175 snprintf(cmd, sizeof cmd, "MESG %s", name);
179 printf("%s\n", &cmd[4]);
182 fmout(screenwidth, NULL,
183 ((userflags & US_PAGINATOR) ? 1 : 0),
188 void userlist(char *patn)
198 pprintf("%s\n", &buf[4]);
201 pprintf(" User Name Num L LastCall Calls Posts\n");
202 pprintf("------------------------- ----- - ---------- ----- -----\n");
203 while (serv_gets(buf), strcmp(buf, "000")) {
204 if (sigcaught == 0) {
206 if (pattern(fl, patn) >= 0) {
207 pprintf("%-25s ", fl);
208 pprintf("%5ld %d ", extract_long(buf, 2),
209 extract_int(buf, 1));
210 lc = extract_long(buf, 3);
211 tmbuf = (struct tm *) localtime(&lc);
212 pprintf("%02d/%02d/%04d ",
215 (tmbuf->tm_year + 1900));
216 pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
226 * grab assorted info about the user...
228 void load_user_info(char *params)
230 extract(fullname, params, 0);
231 axlevel = extract_int(params, 1);
232 timescalled = extract_int(params, 2);
233 posted = extract_int(params, 3);
234 userflags = extract_int(params, 4);
235 usernum = extract_long(params, 5);
236 lastcall = extract_long(params, 6);
241 * Remove a room from the march list. 'floornum' is ignored unless
242 * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
243 * floor will be removed from the march list.
245 void remove_march(char *roomname, int floornum)
247 struct march *mptr, *mptr2;
252 if ((!strcasecmp(march->march_name, roomname))
253 || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
260 for (mptr = march; mptr != NULL; mptr = mptr->next) {
262 if ((!strcasecmp(mptr->march_name, roomname))
263 || ((!strcasecmp(roomname, "_FLOOR_"))
264 && (mptr->march_floor == floornum))) {
266 mptr2->next = mptr->next;
277 * Locate the room on the march list which we most want to go to. Each room
278 * is measured given a "weight" of preference based on various factors.
280 char *pop_march(int desired_floor)
282 static char TheRoom[ROOMNAMELEN];
284 int TheOrder = 32767;
287 struct march *mptr = NULL;
289 strcpy(TheRoom, "_BASEROOM_");
293 for (mptr = march; mptr != NULL; mptr = mptr->next) {
295 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
296 weight = weight + 10000;
297 if (mptr->march_floor == desired_floor)
298 weight = weight + 5000;
300 weight = weight + ((128 - (mptr->march_floor)) * 128);
301 weight = weight + (128 - (mptr->march_order));
303 if (weight > TheWeight) {
305 strcpy(TheRoom, mptr->march_name);
306 TheFloor = mptr->march_floor;
307 TheOrder = mptr->march_order;
315 * jump directly to a room
317 void dotgoto(char *towhere, int display_name)
319 char aaa[SIZ], bbb[SIZ], psearch[SIZ];
322 static int oldmailcount = (-1);
323 int partial_match, best_match;
326 /* store ungoto information */
327 strcpy(ugname, room_name);
330 /* first try an exact match */
331 snprintf(aaa, sizeof aaa, "GOTO %s", towhere);
336 if (!strncmp(aaa, "54", 2)) {
337 newprompt("Enter room password: ", bbb, 9);
338 snprintf(aaa, sizeof aaa, "GOTO %s|%s", towhere, bbb);
344 if (!strncmp(aaa, "54", 2)) {
345 printf("Wrong password.\n");
349 * If a match is not found, try a partial match.
350 * Partial matches anywhere in the string carry a weight of 1,
351 * left-aligned matches carry a weight of 2. Pick the room that
352 * has the highest-weighted match.
360 while (serv_gets(aaa), strcmp(aaa, "000")) {
361 extract(psearch, aaa, 0);
363 if (pattern(psearch, towhere) >= 0) {
366 if (!strncasecmp(towhere, psearch, strlen(towhere))) {
369 if (partial_match > best_match) {
370 strcpy(bbb, psearch);
371 best_match = partial_match;
374 if (strlen(bbb) == 0) {
375 printf("No room '%s'.\n", towhere);
378 snprintf(aaa, sizeof aaa, "GOTO %s", bbb);
388 extract(room_name, &aaa[4], 0);
389 room_flags = extract_int(&aaa[4], 4);
390 from_floor = curr_floor;
391 curr_floor = extract_int(&aaa[4], 10);
393 remove_march(room_name, 0);
394 if (!strcasecmp(towhere, "_BASEROOM_"))
395 remove_march(towhere, 0);
396 if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
397 if (floorlist[(int) curr_floor][0] == 0)
399 printf("(Entering floor: %s)\n", &floorlist[(int) curr_floor][0]);
401 if (display_name == 1) {
403 printf("%s ", room_name);
407 if (display_name != 2) {
408 color(BRIGHT_YELLOW);
409 printf("%d ", extract_int(&aaa[4], 1));
412 color(BRIGHT_YELLOW);
413 printf("%d ", extract_int(&aaa[4], 2));
415 printf("messages.\n");
417 highest_msg_read = extract_int(&aaa[4], 6);
418 maxmsgnum = extract_int(&aaa[4], 5);
419 is_mail = (char) extract_int(&aaa[4], 7);
420 is_room_aide = (char) extract_int(&aaa[4], 8);
421 ls = extract_long(&aaa[4], 6);
423 /* read info file if necessary */
424 if (extract_int(&aaa[4], 3) > 0)
427 /* check for newly arrived mail if we can */
428 if (num_parms(&aaa[4]) >= 10) {
429 newmailcount = extract_int(&aaa[4], 9);
430 if ((oldmailcount >= 0) && (newmailcount > oldmailcount)) {
432 printf("*** You have new mail\n");
435 oldmailcount = newmailcount;
439 /* Goto next room having unread messages.
440 * We want to skip over rooms that the user has already been to, and take the
441 * user back to the lobby when done. The room we end up in is placed in
442 * newroom - which is set to 0 (the lobby) initially.
447 struct march *mptr, *mptr2;
448 char next_room[ROOMNAMELEN];
450 /* Check to see if the march-mode list is already allocated.
451 * If it is, pop the first room off the list and go there.
457 while (serv_gets(buf), strcmp(buf, "000")) {
458 mptr = (struct march *) malloc(sizeof(struct march));
460 extract(mptr->march_name, buf, 0);
461 mptr->march_floor = (char) (extract_int(buf, 2) & 0x7F);
462 mptr->march_order = (char) (extract_int(buf, 3) & 0x7F);
467 while (mptr2->next != NULL)
472 /* add _BASEROOM_ to the end of the march list, so the user will end up
473 * in the system base room (usually the Lobby>) at the end of the loop
475 mptr = (struct march *) malloc(sizeof(struct march));
477 strcpy(mptr->march_name, "_BASEROOM_");
482 while (mptr2->next != NULL)
487 * ...and remove the room we're currently in, so a <G>oto doesn't make us
488 * walk around in circles
490 remove_march(room_name, 0);
493 strcpy(next_room, pop_march(curr_floor));
495 strcpy(next_room, "_BASEROOM_");
497 remove_march(next_room, 0);
498 dotgoto(next_room, 1);
502 * forget all rooms on a given floor
504 void forget_all_rooms_on(int ffloor)
507 struct march *flist, *fptr;
509 printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
511 snprintf(buf, sizeof buf, "LKRA %d", ffloor);
515 printf("%-72s\n", &buf[4]);
519 while (serv_gets(buf), strcmp(buf, "000")) {
520 fptr = (struct march *) malloc(sizeof(struct march));
523 extract(fptr->march_name, buf, 0);
525 while (flist != NULL) {
526 snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
537 printf("%-72s\r", "");
542 * routine called by gotofloor() to move to a new room on a new floor
544 void gf_toroom(char *towhere, int mode)
546 int floor_being_left;
548 floor_being_left = curr_floor;
550 if (mode == GF_GOTO) { /* <;G>oto mode */
554 if (mode == GF_SKIP) { /* <;S>kip mode */
556 remove_march("_FLOOR_", floor_being_left);
558 if (mode == GF_ZAP) { /* <;Z>ap mode */
560 remove_march("_FLOOR_", floor_being_left);
561 forget_all_rooms_on(floor_being_left);
569 void gotofloor(char *towhere, int mode)
573 char buf[SIZ], targ[SIZ];
575 if (floorlist[0][0] == 0)
578 for (a = 0; a < 128; ++a)
579 if (!strcasecmp(&floorlist[a][0], towhere))
583 for (a = 0; a < 128; ++a) {
584 if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
590 for (a = 0; a < 128; ++a)
591 if (pattern(towhere, &floorlist[a][0]) > 0)
595 printf("No floor '%s'.\n", towhere);
598 for (mptr = march; mptr != NULL; mptr = mptr->next) {
599 if ((mptr->march_floor) == tofloor)
600 gf_toroom(mptr->march_name, mode);
605 snprintf(buf, sizeof buf, "LKRA %d", tofloor);
609 while (serv_gets(buf), strcmp(buf, "000")) {
610 if ((extract_int(buf, 2) == tofloor) && (strlen(targ) == 0))
611 extract(targ, buf, 0);
613 if (strlen(targ) > 0) {
614 gf_toroom(targ, mode);
616 printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]);
622 * forget all rooms on current floor
624 void forget_this_floor(void)
627 if (curr_floor == 0) {
628 printf("Can't forget this floor.\n");
631 if (floorlist[0][0] == 0)
633 printf("Are you sure you want to forget all rooms on %s? ",
634 &floorlist[(int) curr_floor][0]);
638 gf_toroom("_BASEROOM_", GF_ZAP);
643 * Figure out the physical screen dimensions, if we can
645 void check_screen_dims(void)
649 unsigned short height; /* rows */
650 unsigned short width; /* columns */
651 unsigned short xpixels;
652 unsigned short ypixels; /* pixels */
655 if (have_xterm) { /* dynamically size screen if on an xterm */
656 if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
658 screenheight = (int) xwinsz.height;
660 screenwidth = (int) xwinsz.width;
668 * set floor mode depending on client, server, and user settings
670 void set_floor_mode(void)
672 if (serv_info.serv_ok_floors == 0) {
673 floor_mode = 0; /* Don't use floors if the server */
675 /* doesn't support them! */
677 if (rc_floor_mode == RC_NO) { /* never use floors */
680 if (rc_floor_mode == RC_YES) { /* always use floors */
683 if (rc_floor_mode == RC_DEFAULT) { /* user choice */
684 floor_mode = ((userflags & US_FLOORS) ? 1 : 0);
690 * Set or change the user's password
692 int set_password(void)
698 if (strlen(rc_password) > 0) {
699 strcpy(pass1, rc_password);
700 strcpy(pass2, rc_password);
702 IFNEXPERT formout("changepw");
703 newprompt("Enter a new password: ", pass1, -19);
704 newprompt("Enter it again to confirm: ", pass2, -19);
708 if (!strcasecmp(pass1, pass2)) {
709 snprintf(buf, sizeof buf, "SETP %s", pass1);
712 printf("%s\n", &buf[4]);
713 offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
716 printf("*** They don't match... try again.\n");
724 * get info about the server we've connected to
726 void get_serv_info(char *supplied_hostname)
730 CtdlInternalGetServInfo(&serv_info);
732 /* be nice and identify ourself to the server */
733 snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
734 SERVER_TYPE, 0, REV_LEVEL,
735 (server_is_local ? "local" : CITADEL));
737 /* Append a hostname */
738 if (supplied_hostname != NULL) {
739 strcat(buf, supplied_hostname);
742 locate_host(&buf[strlen(buf)]); /* append to the end */
746 serv_gets(buf); /* we don't care about the result code */
754 * Display list of users currently logged on to the server
756 void who_is_online(int longlist)
758 char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
760 char actual_user[SIZ], actual_room[SIZ], actual_host[SIZ];
761 char tbuf[SIZ], clientsoft[SIZ];
763 time_t idletime, idlehours, idlemins, idlesecs;
764 int last_session = (-1);
768 if (tbuf[0] == '2') {
769 timenow = extract_long(&tbuf[4], 0);
777 pprintf("FLG ### User Name Room From host\n");
779 pprintf("--- --- ------------------------- -------------------- ------------------------\n");
784 while (serv_gets(buf), strcmp(buf, "000")) {
785 extract(username, buf, 1);
786 extract(roomname, buf, 2);
787 extract(fromhost, buf, 3);
788 extract(clientsoft, buf, 4);
789 extract(flags, buf, 7);
791 idletime = timenow - extract_long(buf, 5);
792 idlehours = idletime / 3600;
793 idlemins = (idletime - (idlehours * 3600)) / 60;
794 idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
796 if (idletime > 900) {
797 while (strlen(roomname) < 20) {
798 strcat(roomname, " ");
800 strcpy(&roomname[14], "[idle]");
805 extract(actual_user, buf, 8);
806 extract(actual_room, buf, 9);
807 extract(actual_host, buf, 10);
809 pprintf(" Flags: %s\n", flags);
810 pprintf("Session: %d\n", extract_int(buf, 0));
811 pprintf(" Name: %s\n", username);
812 pprintf("In room: %s\n", roomname);
813 pprintf(" Host: %s\n", fromhost);
814 pprintf(" Client: %s\n", clientsoft);
815 pprintf(" Idle: %ld:%02ld:%02ld\n",
820 if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) {
822 if (strlen(actual_user)>0) pprintf("<%s> ", actual_user);
823 if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room);
824 if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host);
830 if (extract_int(buf, 0) == last_session) {
833 color(BRIGHT_MAGENTA);
834 pprintf("%-3s ", flags);
836 pprintf("%-3d ", extract_int(buf, 0));
838 last_session = extract_int(buf, 0);
840 pprintf("%-25s ", username);
841 color(BRIGHT_MAGENTA);
843 pprintf("%-20s ", roomname);
846 pprintf("%-24s\n", fromhost);
853 void enternew(char *desc, char *buf, int maxlen)
856 snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
857 newprompt(bbb, buf, maxlen);
862 int shift(int argc, char **argv, int start, int count) {
865 for (i=start; i<(argc-count); ++i) {
866 argv[i] = argv[i+count];
875 int main(int argc, char **argv)
878 char aaa[100], bbb[100];/* general purpose variables */
879 char argbuf[32]; /* command line buf */
880 char nonce[NONCE_SIZE];
881 char *telnet_client_host = NULL;
882 char *sptr, *sptr2; /* USed to extract the nonce */
883 char hexstring[MD5_HEXSTRING_SIZE];
884 int stored_password = 0;
887 /* Permissions sanity check - don't run citadel setuid/setgid */
888 if (getuid() != geteuid()) {
889 fprintf(stderr, "Please do not run citadel setuid!\n");
891 } else if (getgid() != getegid()) {
892 fprintf(stderr, "Please do not run citadel setgid!\n");
896 sttybbs(SB_SAVE); /* Store the old terminal parameters */
897 load_command_set(); /* parse the citadel.rc file */
898 sttybbs(SB_NO_INTR); /* Install the new ones */
899 signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
900 signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
901 signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
904 * Handle command line options as if we were called like /bin/login
905 * (i.e. from in.telnetd)
907 for (a=0; a<argc; ++a) {
908 if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
909 telnet_client_host = argv[a+1];
910 argc = shift(argc, argv, a, 2);
912 if (!strcmp(argv[a], "-p")) {
915 if (chdir(BBSDIR) < 0) {
916 perror("can't change to " BBSDIR);
921 * Drop privileges if necessary. We stat
922 * citadel.config to get the uid/gid since it's
923 * guaranteed to have the uid/gid we want.
925 if (!getuid() || !getgid()) {
926 if (stat(BBSDIR "/citadel.config", &st) < 0) {
927 perror("couldn't stat citadel.config");
930 if (!getgid() && (setgid(st.st_gid) < 0)) {
931 perror("couldn't change gid");
934 if (!getuid() && (setuid(st.st_uid) < 0)) {
935 perror("couldn't change uid");
939 printf("Privileges changed to uid %d gid %d\n",
943 argc = shift(argc, argv, a, 1);
947 printf("Attaching to server... \r");
949 attach_to_server(argc, argv, hostbuf, portbuf);
955 printf("%s\n", &aaa[4]);
959 /* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
963 if ((sptr = strchr(aaa, '<')) == NULL)
969 if ((sptr2 = strchr(sptr, '>')) == NULL)
977 strncpy(nonce, sptr, NONCE_SIZE);
981 get_serv_info(telnet_client_host);
987 printf("%-23s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
988 serv_info.serv_bbs_city);
989 screenwidth = 80; /* default screen dimensions */
992 printf(" pause next stop\n");
993 printf(" ctrl-s ctrl-o ctrl-c\n\n");
994 formout("hello"); /* print the opening greeting */
997 GSTA: /* See if we have a username and password on disk */
998 if (rc_remember_passwords) {
999 get_stored_password(hostbuf, portbuf, fullname, password);
1000 if (strlen(fullname) > 0) {
1001 snprintf(aaa, sizeof(aaa)-1, "USER %s", fullname);
1006 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1008 else /* Else no APOP */
1010 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1015 if (aaa[0] == '2') {
1016 load_user_info(&aaa[4]);
1017 stored_password = 1;
1021 set_stored_password(hostbuf, portbuf, "", "");
1029 if (strlen(rc_username) > 0) {
1030 strcpy(fullname, rc_username);
1032 newprompt("Enter your name: ", fullname, 29);
1035 if (!strcasecmp(fullname, "new")) { /* just in case */
1036 printf("Please enter the name you wish to log in with.\n");
1039 (!strcasecmp(fullname, "bbs"))
1040 || (!strcasecmp(fullname, "new"))
1041 || (strlen(fullname) == 0));
1043 if (!strcasecmp(fullname, "off")) {
1047 /* sign on to the server */
1048 snprintf(aaa, sizeof aaa, "USER %s", fullname);
1054 /* password authentication */
1055 if (strlen(rc_password) > 0) {
1056 strcpy(password, rc_password);
1058 newprompt("\rPlease enter your password: ", password, -19);
1064 sprintf(aaa, "PAS2 %s", make_apop_string(password, nonce, hexstring));
1066 else /* Else no APOP */
1068 snprintf(aaa, sizeof(aaa)-1, "PASS %s", password);
1073 if (aaa[0] == '2') {
1074 load_user_info(&aaa[4]);
1075 offer_to_remember_password(hostbuf, portbuf,
1076 fullname, password);
1079 printf("<< wrong password >>\n");
1080 if (strlen(rc_password) > 0)
1084 NEWUSR: if (strlen(rc_password) == 0) {
1085 printf("No record. Enter as new user? ");
1089 snprintf(aaa, sizeof aaa, "NEWU %s", fullname);
1092 if (aaa[0] != '2') {
1093 printf("%s\n", aaa);
1096 load_user_info(&aaa[4]);
1098 while (set_password() != 0);;
1104 /* Switch color support on or off if we're in user mode */
1105 if (rc_ansi_color == 3) {
1106 if (userflags & US_COLOR)
1112 printf("%s\nAccess level: %d (%s)\n"
1113 "User #%ld / Login #%d",
1114 fullname, axlevel, axdefs[(int) axlevel],
1115 usernum, timescalled);
1116 if (lastcall > 0L) {
1117 printf(" / Last login: %s\n",
1118 asctime(localtime(&lastcall)) );
1124 if (aaa[0] == '2') {
1125 b = extract_int(&aaa[4], 0);
1129 printf("*** You have a new private message in Mail>\n");
1131 printf("*** You have %d new private messages in Mail>\n", b);
1134 if ((axlevel >= 6) && (extract_int(&aaa[4], 2) > 0)) {
1135 printf("*** Users need validation\n");
1137 if (extract_int(&aaa[4], 1) > 0) {
1138 printf("*** Please register.\n");
1139 formout("register");
1143 /* Make up some temporary filenames for use in various parts of the
1144 * program. Don't mess with these once they've been set, because we
1145 * will be unlinking them later on in the program and we don't
1146 * want to delete something that we didn't create. */
1147 snprintf(temp, sizeof temp, tmpnam(NULL));
1148 snprintf(temp2, sizeof temp2, tmpnam(NULL));
1149 snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
1151 /* Get screen dimensions. First we go to a default of 80x24. Then
1152 * we try to get the user's actual screen dimensions off the server.
1153 * However, if we're running on an xterm, all this stuff is
1154 * irrelevant because we're going to dynamically size the screen
1155 * during the session.
1161 if (aaa[0] == '2') {
1162 screenwidth = extract_int(&aaa[4], 0);
1163 screenheight = extract_int(&aaa[4], 1);
1165 if (getenv("TERM") != NULL)
1166 if (!strcmp(getenv("TERM"), "xterm")) {
1170 check_screen_dims();
1176 /* Enter the lobby */
1177 dotgoto("_BASEROOM_", 1);
1179 /* Main loop for the system... user is logged in. */
1188 /* MAIN COMMAND LOOP */
1190 mcmd = getcmd(argbuf); /* Get keyboard command */
1193 check_screen_dims(); /* if xterm, get screen size */
1211 newprompt("What do you want your username to be? ", aaa, 32);
1212 snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa);
1215 if (strncmp("200", aaa, 3))
1216 printf("\n%s\n", aaa);
1230 dotgoto("_MAIL_", 1);
1247 readmsgs(0, (-1), 0);
1250 readmsgs(2, (-1), 0);
1253 readmsgs(3, 1, atoi(argbuf));
1340 cli_image_upload("_userpic_");
1343 cli_image_upload("_roompic_");
1347 snprintf(aaa, sizeof aaa, "_floorpic_|%d", curr_floor);
1348 cli_image_upload(aaa);
1352 enternew("roomname", aaa, 20);
1353 snprintf(bbb, sizeof bbb, "RCHG %s", aaa);
1356 if (strncmp("200", aaa, 3))
1357 printf("\n%s\n", aaa);
1360 enternew("hostname", aaa, 25);
1361 snprintf(bbb, sizeof bbb, "HCHG %s", aaa);
1364 if (strncmp("200", aaa, 3))
1365 printf("\n%s\n", aaa);
1368 enternew("username", aaa, 32);
1369 snprintf(bbb, sizeof bbb, "UCHG %s", aaa);
1372 if (strncmp("200", aaa, 3))
1373 printf("\n%s\n", aaa);
1383 display_help(argbuf);
1387 formout("register");
1392 printf("Are you sure (y/n)? ");
1401 printf("All users will be disconnected! "
1402 "Really terminate the server? ");
1406 printf("%s\n", &aaa[4]);
1416 printf("Do you really want to schedule a "
1417 "server shutdown? ");
1419 serv_puts("SCDN 1");
1422 if (atoi(&aaa[4])) {
1424 "The Citadel server will terminate when all users are logged off.\n"
1429 "The Citadel server will not terminate.\n"
1437 network_config_management("listrecp",
1438 "Mailing list recipients");
1442 network_config_management("ignet_push_share",
1443 "Nodes with which we share this room");
1447 do_ignet_configuration();
1459 if (server_is_local) {
1460 sttybbs(SB_RESTORE);
1461 snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
1462 "exec ./subsystem %ld %d %d", fullname,
1463 usernum, screenwidth, axlevel);
1465 sttybbs(SB_NO_INTR);
1467 printf("*** Can't run doors when server is not local.\n");
1480 do_system_configuration();
1484 do_internet_configuration();
1488 check_message_base();
1510 gotofloor(argbuf, GF_GOTO);
1514 gotofloor(argbuf, GF_SKIP);
1518 forget_this_floor();
1546 knrooms(floor_mode);
1556 misc_server_cmd(argbuf);
1560 edit_system_message(argbuf);
1585 } while (termn8 == 0);
1587 TERMN8: printf("%s logged out.\n", fullname);
1588 while (march != NULL) {
1589 remove_march(march->march_name, 0);
1592 printf("\n\nType 'off' to disconnect, or next user...\n");
1594 snprintf(aaa, sizeof aaa, "LOUT");
1597 if ((mcmd == 29) || (mcmd == 15)) {