More small changes for GNO and ORCA/C compatibility.

In particular, address a couple instances where GNO's sockets implementation doesn't comply with modern standards.
Also, add a few missing prototypes so we can use ORCA/C prototype-checking lint functionality.
This commit is contained in:
Stephen Heumann 2015-05-31 17:57:31 -05:00
parent 9bab5c3dec
commit de9fad8d67
6 changed files with 36 additions and 11 deletions

View File

@ -1,12 +1,12 @@
.INCLUDE: Makefile.common
# This should be the ltermcap from GNO 2.0.4. The one from 2.0.6 is broken
# (links to unimplemented functions), so don't use it.
# /usr/lib/libtermcap.204 should be the ltermcap from GNO 2.0.4. The one
# from 2.0.6 is broken (links to unimplemented functions), so don't use it.
# The 2.0.4 version is in the "lib.shk" file within
# ftp://ftp.gno.org/pub/apple2/gs.specific/gno/base/v204/gnodisk1.sdk
LIBS = -l/usr/lib/libtermcap.204
LIBS = -l/usr/lib/libtermcap.204 -l/usr/lib/libnetdb
CFLAGS = -i
CFLAGS = -i -w
$(OBJS): $(HEADERS)
%.o: %.c

View File

@ -50,6 +50,9 @@
#ifdef __GNO__
typedef int socklen_t;
typedef unsigned short in_port_t;
/* GNO calls actually expect an older form of "struct sockaddr",
* different from the "struct sockaddr" defined in the headers. */
# define sockaddr __SOCKADDR
#endif
/********************************************************************/

9
sys/cdefs.h Normal file
View File

@ -0,0 +1,9 @@
/* We use this as a hack to define stuff in every file, since they all
* #include <sys/cdefs.h> first. When compiling with occ, this file will
* be included in preference to the system header of the same name. */
#ifdef __GNO__
# define __unused
#endif
#include "/usr/include/sys/cdefs.h"

View File

@ -432,8 +432,7 @@ send_docmd(char *name)
}
static int
send_dontcmd(name)
char *name;
send_dontcmd(char *name)
{
return(send_tncmd(send_dont, "dont", name));
}
@ -1386,7 +1385,7 @@ shell(int argc, char **argv __unused)
_exit(1);
}
default:
(void)wait((int *)0); /* Wait for the shell to complete */
(void)wait(NULL); /* Wait for the shell to complete */
if (TerminalWindowSize(&newrows, &newcols) && connected &&
(err_ || ((oldrows != newrows) || (oldcols != newcols)))) {
@ -2101,7 +2100,12 @@ static const char *
sockaddr_ntop(struct sockaddr *sa)
{
void *addr;
#if !defined(__GNO__) || defined(INET6)
static char addrbuf[INET6_ADDRSTRLEN];
#else
/* Since we don't have IPv6, the IPv4 size is sufficient. */
static char addrbuf[16];
#endif
switch (sa->sa_family) {
case AF_INET:
@ -2341,7 +2345,12 @@ tn(int argc, char **argv)
int gni_err = 1;
if (doaddrlookup)
gni_err = getnameinfo(res->ai_addr, res->ai_addr->sa_len,
gni_err = getnameinfo(res->ai_addr,
#ifndef __GNO__
res->ai_addr->sa_len,
#else
sizeof(struct sockaddr),
#endif
_hostname, sizeof(_hostname) - 1, NULL, 0,
NI_NAMEREQD);
if (gni_err != 0)
@ -2690,7 +2699,7 @@ command(int top, const char *tbuf, int cnt)
* Help command.
*/
static int
help(int argc, char *argv[])
help(int argc, char **argv)
{
Command *c;

View File

@ -44,6 +44,10 @@ static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#ifdef __GNO__
#include "libtelnet/getaddrinfo.h"
/* GNO doesn't have struct sockaddr_storage; just use "struct sockaddr"
* (which is really struct osockaddr). */
#define sockaddr_storage sockaddr
#define ss_family sa_family
#endif
#include <err.h>
@ -418,7 +422,7 @@ main(int argc, char *argv[])
} /* end of main */
void
usage()
usage(void)
{
fprintf(stderr, "usage: telnetd");
#ifdef AUTHENTICATION

View File

@ -68,7 +68,7 @@ static const char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
*/
void
ttloop()
ttloop(void)
{
DIAG(TD_REPORT, output_data("td: ttloop\r\n"));