From 581990e767bea28f51ad9e6e370a92c3802a0932 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 31 May 2015 10:13:17 -0500 Subject: [PATCH] Misc. small changes for GNO and ORCA/C compatibility --- Makefile | 2 +- telnet/commands.c | 19 +++++++++++++++---- telnet/main.c | 2 +- telnet/telnet.c | 2 +- telnet/types.h | 4 ++++ telnet/utilities.c | 9 +++++++-- telnetd/defs.h | 6 ++++++ telnetd/ext.h | 2 +- telnetd/sys_term.c | 4 +++- telnetd/telnetd.c | 4 ++-- 10 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3c7c864..672e293 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ TELNETD_OBJS = $(TELNETD_SRCS:.c=.o) OBJS = $(LIBTELNET_OBJS) $(TELNET_OBJS) $(TELNETD_OBJS) INCLUDES = -I libtelnet -I . -TELNET_DEFINES = -DTERMCAP -DKLUDGELINEMODE -DENV_HACK -DOPIE +TELNET_DEFINES = -DTERMCAP -DKLUDGELINEMODE -DENV_HACK TELNETD_DEFINES = -DDIAGNOSTICS -DOLD_ENVIRON -DENV_HACK -DSTREAMSPTY DEFINES = $(TELNET_DEFINES) $(TELNETD_DEFINES) LIBS = -ltermcap diff --git a/telnet/commands.c b/telnet/commands.c index bd353be..19460a9 100644 --- a/telnet/commands.c +++ b/telnet/commands.c @@ -40,7 +40,9 @@ static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #include -#include +#ifndef __GNO__ +# include +#endif #include #include #include @@ -77,7 +79,9 @@ static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #include #include -#include +#ifdef INET6 +# include +#endif #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 @@ -1345,7 +1349,7 @@ suspend(void) } static int -shell(int argc, char *argv[] __unused) +shell(int argc, char **argv __unused) { long oldrows, oldcols, newrows, newcols, err_; @@ -2100,9 +2104,11 @@ sockaddr_ntop(struct sockaddr *sa) case AF_INET: addr = &((struct sockaddr_in *)sa)->sin_addr; break; +#ifndef __GNO__ case AF_UNIX: addr = &((struct sockaddr_un *)sa)->sun_path; break; +#endif #ifdef INET6 case AF_INET6: addr = &((struct sockaddr_in6 *)sa)->sin6_addr; @@ -2169,7 +2175,7 @@ switch_af(struct addrinfo **aip) #endif int -tn(int argc, char *argv[]) +tn(int argc, char **argv) { char *srp = 0; int proto, opt; @@ -2256,6 +2262,7 @@ tn(int argc, char *argv[]) src_res0 = src_res; } if (hostp[0] == '/') { +#ifndef __GNO__ struct sockaddr_un su; if (strlen(hostp) >= sizeof(su.sun_path)) { @@ -2279,6 +2286,10 @@ tn(int argc, char *argv[]) goto fail; } goto af_unix; +#else + fprintf(stderr, "UNIX domain sockets are not supported on GNO\n"); + goto fail; +#endif } else if (hostp[0] == '@' || hostp[0] == '!') { if ( #ifdef INET6 diff --git a/telnet/main.c b/telnet/main.c index 9a324ed..33f0727 100644 --- a/telnet/main.c +++ b/telnet/main.c @@ -346,7 +346,7 @@ main(int argc, char *argv[]) autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1; argc -= optind; - argv += optind; + argv = argv + optind; if (argc) { char *args[9], **argp = args; diff --git a/telnet/telnet.c b/telnet/telnet.c index 4584997..e786c90 100644 --- a/telnet/telnet.c +++ b/telnet/telnet.c @@ -47,7 +47,6 @@ static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; */ #include -#include #include #include #include @@ -62,6 +61,7 @@ static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; #include "general.h" #ifdef USE_TERMIO +# include # include #else # include diff --git a/telnet/types.h b/telnet/types.h index 4db5292..ddb62cb 100644 --- a/telnet/types.h +++ b/telnet/types.h @@ -46,3 +46,7 @@ struct termspeeds { }; extern struct termspeeds termspeeds[]; + +#ifdef __GNO__ +typedef unsigned long uint32_t; +#endif diff --git a/telnet/utilities.c b/telnet/utilities.c index 3727517..56f8d0f 100644 --- a/telnet/utilities.c +++ b/telnet/utilities.c @@ -185,8 +185,13 @@ printoption(const char *direction, int cmd, int option) fprintf(NetTrace, "%s IAC %d", direction, option); } else { const char *fmt; - fmt = (cmd == WILL) ? "WILL" : (cmd == WONT) ? "WONT" : - (cmd == DO) ? "DO" : (cmd == DONT) ? "DONT" : 0; + switch (cmd) { + case WILL: fmt = "WILL"; break; + case WONT: fmt = "WONT"; break; + case DO: fmt = "DO"; break; + case DONT: fmt = "DONT"; break; + default: fmt = 0; break; + } if (fmt) { fprintf(NetTrace, "%s %s ", direction, fmt); if (TELOPT_OK(option)) diff --git a/telnetd/defs.h b/telnetd/defs.h index 537b602..82145f7 100644 --- a/telnetd/defs.h +++ b/telnetd/defs.h @@ -55,12 +55,18 @@ #endif #include +#ifndef SHUT_RDWR +# define SHUT_RDWR 2 +#endif #include #include #include #include #include #ifndef FILIO_H +# if !defined(USE_TERMIO) +# define USE_OLD_TTY +# endif #include #else #include diff --git a/telnetd/ext.h b/telnetd/ext.h index 25db496..97308e8 100644 --- a/telnetd/ext.h +++ b/telnetd/ext.h @@ -174,7 +174,7 @@ extern void willoption(int), wontoption(int); -int output_data(const char *, ...) __printflike(1, 2); +int output_data(const char *, ...) /*__printflike(1, 2)*/; void output_datalen(const char *, int); void startslave(char *, int, char *); diff --git a/telnetd/sys_term.c b/telnetd/sys_term.c index 0c6010a..15b6b39 100644 --- a/telnetd/sys_term.c +++ b/telnetd/sys_term.c @@ -40,7 +40,9 @@ static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #include -#include +#ifdef USE_TERMIO +# include +#endif #include #include "telnetd.h" diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c index 3393d3d..88056de 100644 --- a/telnetd/telnetd.c +++ b/telnetd/telnetd.c @@ -322,7 +322,7 @@ main(int argc, char *argv[]) } argc -= optind; - argv += optind; + argv = argv + optind; if (debug) { int s, ns, foo, error; @@ -1174,7 +1174,7 @@ telnet(int f, int p, char *host) } /* end of telnet */ #ifndef TCSIG -# ifdef TIOCSIG +# if defined(TIOCSIG) && !defined(__GNO__) # define TCSIG TIOCSIG # endif #endif