From 9030b1a961e910be3a1eb6ca18d4dfa15c30f20a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 9 Dec 2020 22:59:46 -0500 Subject: [PATCH] Ugh. The sloppiness of the code in the text client really reflects how bad I was at this 30+ years ago. --- textclient/commands.c | 38 ++++++++++++++++---------------------- textclient/messages.c | 24 ++++++++++++++---------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/textclient/commands.c b/textclient/commands.c index bdd2dc4e5..07af8770b 100644 --- a/textclient/commands.c +++ b/textclient/commands.c @@ -52,12 +52,13 @@ char *helptexts[] = { " Z Zap (forget) room. (Removes the room from your list)\n" " + - Goto next, previous room on current floor.\n" " > < Goto next, previous floor.\n" - " * Enter any locally installed 'doors'.\n" " \n" " In addition, there are dot commands. You hit the . (dot), then press the\n" "first letter of each word of the command. As you hit the letters, the words\n" "pop onto your screen. Exceptions: after you hit .Help or .Goto, the remainder\n" - "of the command is a help file name or room name.\n" " \n" " *** USE .elp ? for additional help *** \n", + "of the command is a help file name or room name.\n" + " \n" + " *** USE .elp ? for additional help *** \n", "The following commands are available only to Admins. A subset of these\n" "commands are available to room aides when they are currently in the room\n" @@ -433,7 +434,6 @@ int next_lazy_cmd = 5; extern int screenwidth, screenheight; extern int termn8; extern CtdlIPC *ipc_for_signal_handlers; /* KLUDGE cover your eyes */ - struct citcmd *cmdlist = NULL; @@ -444,13 +444,10 @@ time_t AnsiDetect; /* when did we send the detect code? */ int enable_color = 0; /* nonzero for ANSI color */ - - /* * If an interesting key has been pressed, return its value, otherwise 0 */ -char was_a_key_pressed(void) -{ +char was_a_key_pressed(void) { fd_set rfds; struct timeval tv; int the_character; @@ -470,21 +467,18 @@ char was_a_key_pressed(void) set_keepalives(KA_NO); the_character = inkey(); set_keepalives(KA_YES); - } else { + } + else { the_character = 0; } return (the_character); } - - - /* * print_instant() - print instant messages if there are any */ -void print_instant(void) -{ +void print_instant(void) { char buf[1024]; FILE *outpipe; time_t timestamp; @@ -495,12 +489,14 @@ void print_instant(void) char *listing = NULL; int r; /* IPC result code */ - if (instant_msgs == 0) + if (instant_msgs == 0) { return; + } if (rc_exp_beep) { ctdl_beep(); } + if (IsEmptyStr(rc_exp_cmd)) { color(BRIGHT_RED); scr_printf("\r---"); @@ -508,8 +504,9 @@ void print_instant(void) while (instant_msgs != 0) { r = CtdlIPCGetInstantMessage(ipc_for_signal_handlers, &listing, buf); - if (r / 100 != 1) + if (r / 100 != 1) { return; + } instant_msgs = extract_int(buf, 0); timestamp = extract_long(buf, 1); @@ -595,19 +592,16 @@ void print_instant(void) } -void set_keepalives(int s) -{ +void set_keepalives(int s) { keepalives_enabled = (char) s; } + /* * This loop handles the "keepalive" messages sent to the server when idling. */ - static time_t idlet = 0; -static void really_do_keepalive(void) -{ - +static void really_do_keepalive(void) { time(&idlet); /* This may sometimes get called before we are actually connected @@ -640,6 +634,7 @@ static void really_do_keepalive(void) } } + /* I changed this from static to not because I need to call it from * screen.c, either that or make something in screen.c not static. * Fix it how you like. Why all the staticness? stu @@ -661,7 +656,6 @@ void do_keepalive(void) } - int inkey(void) { /* get a character from the keyboard, with */ int a; /* the watchdog timer in effect if necessary */ diff --git a/textclient/messages.c b/textclient/messages.c index cb5e4dd1b..731854b3a 100644 --- a/textclient/messages.c +++ b/textclient/messages.c @@ -390,10 +390,11 @@ void mini_2047_decode(char *s) /* * Read a message from the server */ -int read_message(CtdlIPC * ipc, long num, /* message number */ - int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */ - FILE * dest) -{ /* Destination file, NULL for screen */ +int read_message(CtdlIPC *ipc, + long num, /* message number */ + int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */ + FILE *dest /* Destination file, NULL for screen */ +) { char buf[SIZ]; char now[256]; int format_type = 0; @@ -432,7 +433,8 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (dest) { fprintf(dest, "\n "); - } else { + } + else { scr_printf("\n"); if (pagin != 2) { scr_printf(" "); @@ -452,8 +454,7 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (!IsEmptyStr(message->email)) { scr_printf("rfca=%s\n", message->email); } - scr_printf("room=%s\ntime=%s", message->room, asctime(localtime(&message->time)) - ); + scr_printf("room=%s\ntime=%s", message->room, asctime(localtime(&message->time))); if (!IsEmptyStr(message->recipient)) { scr_printf("rcpt=%s\n", message->recipient); } @@ -488,10 +489,12 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (nhdr == 1 && !is_room_aide) { if (dest) { fprintf(dest, " ****"); - } else { + } + else { scr_printf(" ****"); } - } else { + } + else { struct tm thetime; localtime_r(&message->time, &thetime); strftime(now, sizeof now, "%F %R", &thetime); @@ -500,7 +503,8 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (!IsEmptyStr(message->email)) { fprintf(dest, "<%s> ", message->email); } - } else { + } + else { color(BRIGHT_CYAN); scr_printf("%s ", now); color(DIM_WHITE); -- 2.39.2