From c14b856351576112d18b5cc9a4b7d81605b6fbed Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Tue, 19 Apr 2011 00:14:08 -0400 Subject: [PATCH] Recombine console with netmud using --console switch --- Makefile.in | 11 +- hdrs/mushtype.h | 1 + src/Makefile.in | 18 +-- src/bsd.c | 314 ++++++------------------------------------------ 4 files changed, 44 insertions(+), 300 deletions(-) diff --git a/Makefile.in b/Makefile.in index ae5a5e9..42a2f32 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,7 +27,7 @@ INSTALL=@INSTALL@ INSTALLDIR=$installdir CP=@CP@ CHMOD=@CHMOD@ -INSTALL_LINKS=@LN_S@ ../src/netmud netmush; @LN_S@ ../src/info_slave info_slave; @LN_S@ ../src/console console +INSTALL_LINKS=@LN_S@ ../src/netmud netmush; @LN_S@ ../src/info_slave info_slave # stupid SYS V shell SHELL=/bin/sh @@ -83,11 +83,6 @@ netmud: "SQL_CFLAGS=$(SQL_CFLAGS)" "SQL_LDFLAGS=$(SQL_LDFLAGS)" \ "LDFLAGS=$(LDFLAGS)" "CLIBS=$(CLIBS)" ) -console: - (cd src; make console "CC=$(CC)" CCFLAGS=$(CCFLAGS)" \ - "SQL_CFLAGS=$(SQL_CFLAGS)" "SQL_LDFLAGS=$(SQL_LDFLAGS)" \ - "LDFLAGS=$(LDFLAGS)" CLIBS=$(CLIBS)" ) - access: utils/make_access_cnf.sh game @@ -165,12 +160,12 @@ update-hdr: -@sleep 2 -@@PERL@ utils/update.pl options.h options.h.dist -test: netmud console +test: netmud (cd test; @PERL@ alltests.pl) clean: (cd src; make clean) - (cd game; rm -f netmush info_slave console netmush~ info_slave~ console~) + (cd game; rm -f netmush info_slave netmush~ info_slave~) distclean: (cd hdrs; rm -f *.orig *~ \#* *.rej *.bak funs.h cmds.h buildinf.h patches.h) diff --git a/hdrs/mushtype.h b/hdrs/mushtype.h index ef92e16..6d50ca7 100644 --- a/hdrs/mushtype.h +++ b/hdrs/mushtype.h @@ -150,6 +150,7 @@ typedef struct descriptor_data DESC; */ struct descriptor_data { int descriptor; /**< Connection socket (fd) */ + int outdesc; /**< Use this fd for output */ int connected; /**< Connection status */ char addr[101]; /**< Hostname of connection source */ char ip[101]; /**< IP address of connection source */ diff --git a/src/Makefile.in b/src/Makefile.in index f3948d8..80358e7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -4,7 +4,7 @@ # You shouldn't have to change anything in this file. # ############################################################################### -OUTFILES=buildinf netmud console info_slave +OUTFILES=buildinf netmud info_slave # Libs EXCEPT for SQL ones LIBS=$(CLIBS) @@ -29,8 +29,8 @@ C_FILES=access.c atr_tab.c attrib.c boolexp.c bsd.c bufferq.c chunk.c \ # .o versions of above - these are used in the build -COMMON_O_FILES=access.o atr_tab.o attrib.o boolexp.o bufferq.o chunk.o \ - cmds.o command.o compress.o conf.o cque.o create.o cron.o \ +O_FILES=bsd.o access.o atr_tab.o attrib.o boolexp.o bufferq.o chunk.o \ + cmds.o command.o compress.o conf.o cque.o create.o cron.o \ db.o destroy.o division.o extchat.o extmail.o filecopy.o \ flags.o funcrypt.o fundiv.o function.o fundb.o funlist.o \ funmath.o funmisc.o funstr.o funtime.o funufun.o game.o help.o \ @@ -43,9 +43,6 @@ COMMON_O_FILES=access.o atr_tab.o attrib.o boolexp.o bufferq.o chunk.o \ strtree.o strutil.o tables.o timer.o unparse.o utils.o \ version.o wait.o warnings.o wild.o wiz.o -O_FILES=$(COMMON_O_FILES) bsd.o -CONSOLE_O_FILES=$(COMMON_O_FILES) console.o - # This is a dummy target, in case you type 'make' in the source # directory (likely for emacs users who M-x compile.) # This means that the top-level make had better specifically 'make all' :) @@ -60,11 +57,6 @@ netmud: $(O_FILES) # $(CC) $(CCFLAGS) -o netmud $(O_FILES) $(LDFLAGS) $(SQL_LDFLAGS) $(LIBS) $(LIBTOOL) --mode=link $(CC) -export-dynamic $(LDFLAGS) $(SQL_LDFLAGS) $(CCFLAGS) -o netmud $(O_FILES) $(LIBS) -console: $(CONSOLE_O_FILES) - @echo "Making console." - -mv -f console console~ - $(LIBTOOL) --mode=link $(CC) -export-dynamic $(LDFLAGS) $(SQL_LDFLAGS) $(CCFLAGS) -o console $(CONSOLE_O_FILES) $(LIBS) - # We recompile mysocket.c instead of reusing mysocket.o because we # want to do some error handing differently for info_slave. @@ -166,10 +158,6 @@ portmsg: portmsg.c mysocket.c sig.o wait.o # Some dependencies that make depend doesn't handle well compress.o: comp_h.c comp_w.c comp_w8.c -# CobraMUSH no-network console -console.o: bsd.c - $(CC) $(CFLAGS) -DCOMPILE_CONSOLE -o console.o -c bsd.c - # DO NOT DELETE THIS LINE -- make depend depends on it. access.o: ../config.h diff --git a/src/bsd.c b/src/bsd.c index 7cebfea..5a2e470 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -119,10 +119,6 @@ #include "htab.h" #include "help.h" -#ifdef COMPILE_CONSOLE -#undef INFO_SLAVE -#endif - #ifndef WIN32 #include "wait.h" #ifdef INFO_SLAVE @@ -133,11 +129,9 @@ #include "strtree.h" #include "log.h" #include "mypcre.h" -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL #include "myssl.h" #endif -#endif #include "mymalloc.h" #include "extmail.h" #include "attrib.h" @@ -191,12 +185,10 @@ char errlog[BUFFER_LEN] = { '\0' }; /**< Name of the error log file */ /* Default Connection flags for certain clients */ -#ifndef COMPILE_CONSOLE static CLIENT_DEFAULTS client_maps[] = { {"TINYFUGUE", CONN_PROMPT}, {NULL, -1} }; -#endif /* COMPILE_CONSOLE */ /** Is this descriptor connected to a telnet-compatible terminal? */ @@ -224,7 +216,6 @@ static CLIENT_DEFAULTS client_maps[] = { */ /* Telnet codes */ -#ifndef COMPILE_CONSOLE #define IAC 255 /**< interpret as command: */ #define GOAHEAD 249 /**< Go Ahead command */ #define NOP 241 /**< no operation */ @@ -242,7 +233,6 @@ static CLIENT_DEFAULTS client_maps[] = { static void test_telnet(DESC *d); static void setup_telnet(DESC *d); static int handle_telnet(DESC *d, unsigned char **q, unsigned char *qend); -#endif /* COMPILE_CONSOLE */ static const char *empabb(dbref); static int do_su_exit(DESC *d); @@ -254,12 +244,10 @@ static const char *register_fail = static const char *register_success = "Registration successful! You will receive your password by email."; static const char *shutdown_message = "Going down - Bye"; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL static const char *ssl_shutdown_message = "GAME: SSL connections must be dropped, sorry."; #endif -#endif /** Where we save the descriptor info across reboots. */ #define REBOOTFILE "reboot.db" @@ -286,8 +274,8 @@ dummy_msgs() DESC *descriptor_list = NULL; /**< The linked list of descriptors */ intmap *descs_by_fd = NULL; /**< Map of ports to DESC* objects */ -#ifndef COMPILE_CONSOLE -static int sock; +static bool console_mode = 0; +static int sock = 0; #ifdef HAS_OPENSSL static int sslsock = 0; SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */ @@ -295,7 +283,6 @@ SSL *ssl_master_socket = NULL; /**< Master SSL socket for ssl port */ #ifdef WIN32 static WSADATA wsadata; #endif -#endif /* COMPILE_CONSOLE */ int maxd = 0; int restarting = 0; /**< Are we restarting the server after a reboot? */ static int ndescriptors = 0; @@ -330,14 +317,10 @@ static long int msec_diff(struct timeval *now, struct timeval *then); static struct timeval *msec_add(struct timeval *t, int x); static void update_quotas(struct timeval *last, struct timeval *current); -#ifdef COMPILE_CONSOLE -static void shovechars(void); -#else /* COMPILE_CONSOLE */ static int how_many_fds(void); static void shovechars(Port_t port, Port_t sslport); static int test_connection(int newsock); static DESC *new_connection(int oldsock, int *result, bool use_ssl); -#endif /* COMPILE_CONSOLE */ static void clearstrings(DESC *d); @@ -372,7 +355,7 @@ static void fcache_dump(DESC *d, FBLOCK fp[2], const unsigned char *prefix); static int fcache_read(FBLOCK *cp, const char *filename); static void logout_sock(DESC *d); static void shutdownsock(DESC *d); -DESC *initializesock(int s, char *addr, char *ip, int use_ssl); +DESC *initializesock(int s, int os, char *addr, char *ip, int use_ssl); int process_output(DESC *d); /* Notify.c */ extern void free_text_block(struct text_block *t); @@ -461,8 +444,6 @@ init_rlimit(void) * The real "main" is in win32/services.c */ -/* TODO: Re-implement's Ari's COMPILE_CONSOLE defines.. */ - int mainthread(int argc, char **argv) #else @@ -479,11 +460,7 @@ main(int argc, char **argv) FILE *id; #endif FILE *newerr; -#ifdef COMPILE_CONSOLE - bool detach_session = 0; -#else bool detach_session = 1; -#endif struct module_entry_t *m; void (*handle)(); @@ -525,7 +502,10 @@ main(int argc, char **argv) if (argv[n][0] == '-') { if (strcmp(argv[n], "--no-session") == 0) detach_session = 0; - else if (strncmp(argv[n], "--pid-file", 10) == 0) { + else if (strcmp(argv[n], "--console") == 0) { + console_mode = 1; + detach_session = 0; + } else if (strncmp(argv[n], "--pid-file", 10) == 0) { char *eq; if ((eq = strchr(argv[n], '='))) pidfile = eq + 1; @@ -546,7 +526,6 @@ main(int argc, char **argv) } } -#ifndef COMPILE_CONSOLE #ifdef HAVE_FORK /* Fork off and detach from controlling terminal. */ if (detach_session) { @@ -566,7 +545,6 @@ main(int argc, char **argv) } } #endif -#endif #ifdef HAVE_GETPID if (pidfile) { @@ -704,11 +682,7 @@ main(int argc, char **argv) #endif load_reboot_db(); -#ifdef COMPILE_CONSOLE - shovechars(); -#else shovechars((Port_t) TINYPORT, (Port_t) SSLPORT); -#endif #if defined(CSRI_DEBUG) && defined(CSRI) mal_verify(1); #endif @@ -778,9 +752,7 @@ main(int argc, char **argv) do_rawlog(LT_ERR, T("MUSH shutdown completed.")); -#ifndef COMPILE_CONSOLE closesocket(sock); -#endif #ifdef WIN32 #ifdef WIN32SERVICES shutdown_checkpoint(); @@ -997,7 +969,6 @@ bad_empabb_value: extern slab *text_block_slab; -#ifndef COMPILE_CONSOLE static void setup_desc(int sock, bool use_ssl) { @@ -1013,14 +984,10 @@ setup_desc(int sock, bool use_ssl) maxd = newd->descriptor + 1; } } -#endif static void -#ifdef COMPILE_CONSOLE -shovechars() -#else -shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) -#endif +shovechars(Port_t port __attribute__ ((__unused__)), + Port_t sslport __attribute__ ((__unused__))) { /* this is the main game loop */ @@ -1032,21 +999,31 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) int found; int queue_timeout; DESC *d, *dnext; -#ifndef COMPILE_CONSOLE #ifdef INFO_SLAVE union sockaddr_u addr; socklen_t addr_len; int newsock; #endif int avail_descriptors; -#endif /* COMPILE_CONSOLE */ unsigned long input_ready, output_ready; int notify_fd = -1; + int infd, outfd; -#ifdef COMPILE_CONSOLE - d = initializesock(0, "localhost", "127.0.0.1", 0); -#else - if (!restarting) { + if (console_mode) { + infd = dup(STDIN_FILENO); + outfd = dup(STDOUT_FILENO); + if (infd >= maxd) + maxd = infd + 1; + if (outfd >= maxd) + maxd = outfd + 1; + + d = initializesock(infd, outfd, "localhost", "127.0.0.1", 0); + + sock = 0; +#ifdef HAS_OPENSSL + sslsock = 0; +#endif + } else if (!restarting) { sock = make_socket(port, SOCK_STREAM, NULL, NULL, MUSH_IP_ADDR); if (sock >= maxd) maxd = sock + 1; @@ -1059,10 +1036,8 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) } #endif } -#endif /* COMPILE_CONSOLE */ our_gettimeofday(&last_slice); -#ifndef COMPILE_CONSOLE avail_descriptors = how_many_fds() - 4; #ifdef INFO_SLAVE avail_descriptors -= 2; /* reserve some more for setting up the slave */ @@ -1070,7 +1045,6 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) /* done. print message to the log */ do_rawlog(LT_ERR, "%d file descriptors available.", avail_descriptors); -#endif /* COMPILE_CONSOLE */ do_rawlog(LT_ERR, "RESTART FINISHED."); notify_fd = file_watch_init(); @@ -1165,8 +1139,7 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) FD_ZERO(&input_set); FD_ZERO(&output_set); -#ifndef COMPILE_CONSOLE - if (ndescriptors < avail_descriptors) + if (sock && ndescriptors < avail_descriptors) FD_SET(sock, &input_set); #ifdef HAS_OPENSSL if (sslsock) @@ -1176,40 +1149,20 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) if (info_slave_state == INFO_SLAVE_PENDING) FD_SET(info_slave, &input_set); #endif -#endif /* COMPILE_CONSOLE */ for (d = descriptor_list; d; d = d->next) { if (d->input.head) { timeout.tv_sec = slice_timeout.tv_sec; timeout.tv_usec = slice_timeout.tv_usec; -#ifdef COMPILE_CONSOLE - } else { - if(d->descriptor == 0) - FD_SET(STDIN_FILENO, &input_set); - else - FD_SET(d->descriptor, &input_set); - } - if (d->output.head) { - if(d->descriptor == 0) - FD_SET(STDOUT_FILENO, &output_set); - else - FD_SET(d->descriptor, &output_set); - } -#else /* COMPILE_CONSOLE */ } else FD_SET(d->descriptor, &input_set); if (d->output.head) - FD_SET(d->descriptor, &output_set); -#endif /* COMPILE_CONSOLE */ + FD_SET(d->outdesc, &output_set); } if (notify_fd >= 0) FD_SET(notify_fd, &input_set); -#ifndef COMPILE_CONSOLE found = select(maxd, &input_set, &output_set, (fd_set *) 0, &timeout); -#else - found = select(2, &input_set, &output_set, (fd_set *) 0, &timeout); -#endif if (found < 0) { #ifdef WIN32 if (found == SOCKET_ERROR && WSAGetLastError() != WSAEINTR) @@ -1234,7 +1187,6 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) do_top(options.active_q_chunk); } now = mudtime; -#ifndef COMPILE_CONSOLE #ifdef INFO_SLAVE if (info_slave_state == INFO_SLAVE_PENDING && FD_ISSET(info_slave, &input_set)) { @@ -1285,57 +1237,28 @@ shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) setup_desc(sslsock, true); #endif #endif -#endif /* COMPILE_CONSOLE */ if (notify_fd >= 0 && FD_ISSET(notify_fd, &input_set)) file_watch_event(notify_fd); for (d = descriptor_list; d; d = dnext) { dnext = d->next; -#ifdef COMPILE_CONSOLE - if (d->descriptor == 0) { - input_ready = FD_ISSET(STDIN_FILENO, &input_set); - output_ready = FD_ISSET(STDOUT_FILENO, &output_set); - } else { - input_ready = FD_ISSET(d->descriptor, &input_set); - output_ready = FD_ISSET(d->descriptor, &output_set); - } - if (input_ready) { - if (!process_input(d, output_ready)) { - shutdownsock(d); - if(d->descriptor == 0) - return; - continue; - } - } - if (output_ready) { - if (!process_output(d)) { - shutdownsock(d); - if (d->descriptor == 0) - return; - } - } -#else /* COMPILE_CONSOLE */ input_ready = FD_ISSET(d->descriptor, &input_set); - output_ready = FD_ISSET(d->descriptor, &output_set); + output_ready = FD_ISSET(d->outdesc, &output_set); if (input_ready) { if (!process_input(d, output_ready)) { shutdownsock(d); continue; } } - if (output_ready) { - if (!process_output(d)) { + if (output_ready) + if (!process_output(d)) shutdownsock(d); - } - } -#endif /* COMPILE_CONSOLE */ } } } } -#ifndef COMPILE_CONSOLE static int test_connection(int newsock) { @@ -1407,9 +1330,8 @@ new_connection(int oldsock, int *result, bool use_ssl) } do_rawlog(LT_CONN, T("[%d/%s/%s] Connection opened."), newsock, tbuf1, tbuf2); set_keepalive(newsock); - return initializesock(newsock, tbuf1, tbuf2, use_ssl); + return initializesock(newsock, newsock, tbuf1, tbuf2, use_ssl); } -#endif static void clearstrings(DESC *d) @@ -1666,9 +1588,6 @@ static void shutdownsock(DESC *d) { char tbuf1[BUFFER_LEN]; -#ifdef COMPILE_CONSOLE - int i; -#endif if (d->connected) { do_rawlog(LT_CONN, T("[%d/%s/%s] Logout by %s(#%d)"), @@ -1704,67 +1623,6 @@ shutdownsock(DESC *d) } process_output(d); clearstrings(d); -#ifdef COMPILE_CONSOLE - if (d->descriptor != 0) { - shutdown(d->descriptor, 2); - closesocket(d->descriptor); - } else { - freeqs(d); - d->input_handler = do_command; - d->connected = 0; - d->connected_at = mudtime; - d->output_prefix = 0; - d->output_suffix = 0; - d->output_size = 0; - d->output.head = 0; - d->player = 0; - d->output.tail = &d->output.head; - d->input.head = 0; - d->input.tail = &d->input.head; - d->raw_input = 0; - d->raw_input_at = 0; - d->quota = COMMAND_BURST_SIZE; - d->last_time = mudtime; - d->idle_total = 0; - d->unidle_times = 0; - d->cmds = 0; - d->hide = 0; - d->doing[0] = '\0'; - strncpy(d->addr, "localhost", 100); - d->addr[99] = '\0'; - strncpy(d->ip, "127.0.0.1", 100); - d->ip[99] = '\0'; - d->conn_flags = CONN_DEFAULT; - d->input_chars = 0; - d->output_chars = 0; - d->ttype = mush_strdup("unknown", "terminal description"); - d->checksum[0] = '\0'; - d->su_exit_path = NULL; - d->pinfo.object = NOTHING; - d->pinfo.atr = NULL; - d->pinfo.lock = 0; - d->pinfo.function = NULL; - d->width = 78; - d->height = 24; - welcome_user(d); - for (i = 0; i < MAX_SNOOPS; i++) - d->snooper[i] = -1; - } - if (d->descriptor != 0) { - if (d->prev) - d->prev->next = d->next; - else /* d was the first one! */ - descriptor_list = d->next; - if (d->next) - d->next->prev = d->prev; - } - - if(d->descriptor != 0) { - freeqs(d); - mush_free(d->ttype, "terminal description"); - mush_free((Malloc_t) d, "descriptor"); - } -#else /* COMPILE_CONSOLE */ shutdown(d->descriptor, 2); closesocket(d->descriptor); if (d->prev) @@ -1788,14 +1646,13 @@ shutdownsock(DESC *d) mush_free(d->ttype, "terminal description"); mush_free((Malloc_t) d, "descriptor"); } -#endif /* COMPILE_CONSOLE */ ndescriptors--; } /* ARGSUSED */ DESC * -initializesock(int s, char *addr, char *ip, int use_ssl +initializesock(int s, int os, char *addr, char *ip, int use_ssl __attribute__ ((__unused__))) { DESC *d; @@ -1805,6 +1662,7 @@ initializesock(int s, char *addr, char *ip, int use_ssl if (!d) mush_panic("Out of memory."); d->descriptor = s; + d->outdesc = os; d->input_handler = do_command; d->connected = 0; d->connected_at = mudtime; @@ -1840,11 +1698,9 @@ initializesock(int s, char *addr, char *ip, int use_ssl d->pinfo.atr = NULL; d->pinfo.lock = 0; d->pinfo.function = NULL; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL d->ssl = NULL; d->ssl_state = 0; -#endif #endif im_insert(descs_by_fd, d->descriptor, d); if (descriptor_list) @@ -1854,7 +1710,6 @@ initializesock(int s, char *addr, char *ip, int use_ssl descriptor_list = d; d->width = 78; d->height = 24; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL if (use_ssl && sslsock) { d->ssl = ssl_listen(d->descriptor, &d->ssl_state); @@ -1867,16 +1722,12 @@ initializesock(int s, char *addr, char *ip, int use_ssl } #endif test_telnet(d); -#endif /* COMPILE_CONSOLE */ welcome_user(d); for(n = 0; n < MAX_SNOOPS; n++) d->snooper[n] = -1; return d; } - -/* TODO: Build back in COMPILE_CONSOLE define in here */ - /** Flush pending output for a descriptor. * This function actually sends the queued output over the descriptor's * socket. @@ -1889,7 +1740,6 @@ process_output(DESC *d) { struct text_block **qp, *cur; int cnt; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL int input_ready = 0; #endif @@ -1953,14 +1803,8 @@ process_output(DESC *d) } } #endif -#endif /* COMPILE_CONSOLE */ for (qp = &d->output.head; ((cur = *qp) != NULL);) { -#ifdef COMPILE_CONSOLE - if (d->descriptor == 0) - cnt = write(STDOUT_FILENO, cur->start, cur->nchars); - else { -#else /* COMPILE_CONSOLE */ #ifdef HAVE_WRITEV if (cur->nxt #ifdef HAVE_SSL @@ -2040,7 +1884,6 @@ process_output(DESC *d) return 1; /* Need to retry */ } else #endif /* HAS_OPENSSL */ -#endif /* COMPILE_CONSOLE */ { cnt = send(d->descriptor, cur->start, cur->nchars, 0); if (cnt < 0) { @@ -2097,7 +1940,6 @@ save_command(DESC *d, const unsigned char *command) add_to_queue(&d->input, command, u_strlen(command) + 1); } -#ifndef COMPILE_CONSOLE static void test_telnet(DESC *d) { @@ -2339,7 +2181,6 @@ handle_telnet(DESC *d, unsigned char **q, unsigned char *qend) } return 1; } -#endif /* COMPILE_CONSOLE */ static void process_input_helper(DESC *d, char *tbuf1, int got) @@ -2375,7 +2216,6 @@ process_input_helper(DESC *d, char *tbuf1, int got) } else if (*q == '\b') { if (p > d->raw_input) p--; -#ifndef COMPILE_CONSOLE } else if ((unsigned char) *q == IAC) { /* Telnet option foo */ if (q >= qend) break; @@ -2384,7 +2224,6 @@ process_input_helper(DESC *d, char *tbuf1, int got) if (p < pend && isprint(*q)) *p++ = *q; } -#endif /* COMPILE_CONSOLE */ } else if (p < pend && isprint(*q)) { *p++ = *q; } @@ -2407,7 +2246,6 @@ process_input(DESC *d, int output_ready __attribute__ ((__unused__))) errno = 0; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL if (d->ssl) { /* Insure that we're not in a state where we need an SSL_handshake() */ @@ -2451,16 +2289,8 @@ process_input(DESC *d, int output_ready __attribute__ ((__unused__))) } } else { #endif -#endif /* COMPILE_CONSOLE */ -#ifdef COMPILE_CONSOLE - if (d->descriptor == 0) - got = read(STDIN_FILENO, tbuf1, sizeof tbuf1); - else - got = recv(d->descriptor, tbuf1, sizeof tbuf1, 0); -#else /* COMPILE_CONSOLE */ got = recv(d->descriptor, tbuf1, sizeof tbuf1, 0); -#endif /* COMPILE_CONSOLE */ if (got <= 0) { /* At this point, select() says there's data waiting to be read from * the socket, but we shouldn't assume that read() will actually get it @@ -2475,10 +2305,8 @@ process_input(DESC *d, int output_ready __attribute__ ((__unused__))) else return 0; } -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL } -#endif #endif process_input_helper(d, tbuf1, got); @@ -2995,34 +2823,20 @@ close_sockets(void) for (d = descriptor_list; d; d = dnext) { dnext = d->next; -#ifdef COMPILE_CONSOLE - if(d->descriptor == 0) { - write(STDOUT_FILENO, T(shutdown_message), strlen(T(shutdown_message))); - write(STDOUT_FILENO, "\r\n", 2); - } else { - send(d->descriptor, T(shutdown_message), strlen(T(shutdown_message)), 0); - send(d->descriptor, "\r\n", 2, 0); - if (shutdown(d->descriptor, 2) < 0) - perror("shutdown"); - closesocket(d->descriptor); - } -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL if (!d->ssl) { #endif -#endif #ifdef HAVE_WRITEV struct iovec byebye[2]; byebye[0].iov_base = (char *) shutmsg; byebye[0].iov_len = shutlen; byebye[1].iov_base = (char *) "\r\n"; byebye[1].iov_len = 2; - writev(d->descriptor, byebye, 2); + writev(d->outdesc, byebye, 2); #else - send(d->descriptor, shutmsg, shutlen, 0); - send(d->descriptor, (char *) "\r\n", 2, 0); + send(d->outdesc, shutmsg, shutlen, 0); + send(d->outdesc, (char *) "\r\n", 2, 0); #endif -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL } else { int offset; @@ -3042,7 +2856,6 @@ close_sockets(void) d->ssl_state = 0; } #endif -#endif /* COMPILE_CONSOLE */ if (shutdown(d->descriptor, 2) < 0) penn_perror("shutdown"); closesocket(d->descriptor); @@ -3261,7 +3074,6 @@ reaper(int sig __attribute__ ((__unused__))) pid_t pid; while ((pid = mush_wait(-1, &my_stat, WNOHANG)) > 0) { -#ifndef COMPILE_CONSOLE #ifdef INFO_SLAVE if (info_slave_pid > -1 && pid == info_slave_pid) { do_rawlog(LT_ERR, T("info_slave on pid %d exited!"), pid); @@ -3269,7 +3081,6 @@ reaper(int sig __attribute__ ((__unused__))) info_slave_state = INFO_SLAVE_DOWN; info_slave_pid = -1; } else -#endif #endif if (forked_dump_pid > -1 && pid == forked_dump_pid) { dump_error = forked_dump_pid; @@ -3386,15 +3197,11 @@ dump_users(DESC *call_by, char *match, int doing) time_format_1(now - d->connected_at), time_format_2(now - d->last_time), csite ? d->cmds : 0, csite ? d->descriptor : 0, -#ifdef COMPILE_CONSOLE - ' ', -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL d->ssl ? 'S' : ' ', #else ' ', #endif -#endif /* COMPILE_CONSOLE */ csite ? d->addr : "---"); tbuf1[78] = '\0'; if (Dark(d->player)) { @@ -3412,15 +3219,11 @@ dump_users(DESC *call_by, char *match, int doing) time_format_1(now - d->connected_at), time_format_2(now - d->last_time), csite ? d->cmds : 0, csite ? d->descriptor : 0, -#ifdef COMPILE_CONSOLE - ' ', -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL d->ssl ? 'S' : ' ', #else ' ', #endif -#endif /* COMPILE_CONSOLE */ csite ? d->input_chars : 0, csite ? d->output_chars : 0, csite ? d->output_size : 0); @@ -3459,15 +3262,11 @@ dump_users(DESC *call_by, char *match, int doing) "#-1", time_format_1(now - d->connected_at), time_format_2(now - d->last_time), d->cmds, d->descriptor, -#ifdef COMPILE_CONSOLE - ' ', -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL d->ssl ? 'S' : ' ', #else ' ', #endif -#endif /* COMPILE_CONSOLE */ d->addr); tbuf1[78] = '\0'; @@ -3477,15 +3276,11 @@ dump_users(DESC *call_by, char *match, int doing) T("Connecting..."), "#-1", time_format_1(now - d->connected_at), time_format_2(now - d->last_time), d->cmds, d->descriptor, -#ifdef COMPILE_CONSOLE - ' ', -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL d->ssl ? 'S' : ' ', #else ' ', #endif -#endif /* COMPILE_CONSOLE */ d->input_chars, d->output_chars, d->output_size); } #ifdef COLOREDWHO @@ -4423,9 +4218,6 @@ FUNCTION(fun_ssl) /* Return the status of the ssl flag on the least idle descriptor we * find that matches the player's dbref. */ -#ifdef COMPILE_CONSOLE - safe_boolean(0, buff, bp); -#else /* COMPILE_CONSOLE */ #ifdef HAS_OPENSSL DESC *match; if (!sslsock) { @@ -4443,7 +4235,6 @@ FUNCTION(fun_ssl) #else safe_boolean(0, buff, bp); #endif -#endif /* COMPILE_CONSOLE */ } FUNCTION(fun_width) @@ -4484,11 +4275,9 @@ FUNCTION(fun_terminfo) safe_str(" pueblo", buff, bp); if (match->conn_flags & CONN_TELNET) safe_str(" telnet", buff, bp); -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL if (sslsock && match->ssl) safe_str(" ssl", buff, bp); -#endif #endif } else safe_str(T(e_perm), buff, bp); @@ -4679,7 +4468,6 @@ inactivity_check(void) back, the client probably doesn't understand them */ if ((d->conn_flags & CONN_TELNET_QUERY) && difftime(now, d->connected_at) > 60) d->conn_flags &= ~CONN_TELNET_QUERY; -#ifndef COMPILE_CONSOLE /* If they've been idle for 60 seconds and are set KEEPALIVE and using a telnet-aware client, send a NOP */ if (d->conn_flags & CONN_TELNET && idle_for >= 60 @@ -4688,7 +4476,6 @@ inactivity_check(void) queue_newwrite(d, nopmsg, 2); process_output(d); } -#endif if(d->connected && GoodObject(d->player) && ((a = atr_get(d->player, "IDLE_TIMEOUT"))!=NULL)) { memset(tbuf, '\0', BUFFER_LEN); @@ -4829,12 +4616,6 @@ f_close(stream) #define fclose(x) f_close(x) #endif /* SUN_OS */ -#ifdef COMPILE_CONSOLE -void -close_ssl_connections(void) -{ -} -#else /* COMPILE_CONSOLE */ static int how_many_fds(void) { @@ -4928,7 +4709,6 @@ close_ssl_connections(void) options.ssl_port = 0; } #endif -#endif /* COMPILE_CONSOLE */ /** Dump the descriptor list to our REBOOTFILE so we can restore it on reboot. @@ -4954,11 +4734,7 @@ dump_reboot_db(void) } /* Write out the reboot db flags here */ fprintf(f, "V%ld\n", flags); -#ifdef COMPILE_CONSOLE - putref(f, 0); -#else /* COMPILE_CONSOLE */ putref(f, sock); -#endif /* COMPILE_CONSOLE */ putref(f, maxd); /* First, iterate through all descriptors to get to the end * we do this so the descriptor_list isn't reversed on reboot @@ -5042,11 +4818,7 @@ load_reboot_db(void) ungetc(c, f); } -#ifdef COMPILE_CONSOLE - val = getref(f); -#else /* COMPILE_CONSOLE */ sock = getref(f); -#endif /* COMPILE_CONSOLE */ val = getref(f); if (val > maxd) maxd = val; @@ -5125,11 +4897,9 @@ load_reboot_db(void) d->raw_input = NULL; d->raw_input_at = NULL; d->quota = options.starting_quota; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL d->ssl = NULL; d->ssl_state = 0; -#endif #endif if (d->conn_flags & CONN_CLOSE_READY) { /* This isn't really an open descriptor, we're just tracking @@ -5183,7 +4953,6 @@ load_reboot_db(void) strcpy(poll_msg, getstring_noalloc(f)); globals.first_start_time = getref(f); globals.reboot_count = getref(f) + 1; -#ifndef COMPILE_CONSOLE #ifdef HAS_OPENSSL if (SSLPORT) { sslsock = make_socket(SSLPORT, SOCK_STREAM, NULL, NULL, SSL_IP_ADDR); @@ -5191,7 +4960,6 @@ load_reboot_db(void) if (sslsock >= maxd) maxd = sslsock + 1; } -#endif #endif fclose(f); @@ -5376,12 +5144,8 @@ COMMAND(cmd_su) { if ((d->player == player) && (!match || (d->last_time > match->last_time))) match = d; /* We're only entering using a password at this moment */ -#ifdef COMPILE_CONSOLE - queue_newwrite(match, (unsigned char *) T("Password: "), 13); -#else /* COMPILE_CONSOLE */ queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"), IAC, GOAHEAD), 13); -#endif /* COMPILE_CONSOLE */ if(!PromptConnection(match)) queue_newwrite(match, (unsigned char *) "\r\n", 3); @@ -5433,12 +5197,8 @@ COMMAND(cmd_su) { notify(player, T("Your HAVEN flag is set. You cannot receive pages.")); } else { /* Part 3b. Put guy in password program */ -#ifdef COMPILE_CONSOLE - queue_newwrite(match, (unsigned char *) T("Password: "), 13); -#else /* COMPILE_CONSOLE */ queue_newwrite(match, (unsigned char *) tprintf(T("Password: %c%c"), IAC, GOAHEAD), 13); -#endif /* COMPILE_CONSOLE */ if(!PromptConnection(match)) queue_newwrite(match, (unsigned char *) "\r\n", 3); @@ -5611,7 +5371,7 @@ do_reboot(dbref player, int flag) #endif #endif dump_reboot_db(); -#if !defined(COMPILE_CONSOLE) && defined(INFO_SLAVE) +#ifdef INFO_SLAVE kill_info_slave(); #endif /* Replacement for local_shutdown */ -- 2.30.2