From 132aaa829361d3f884fdcfe512f3d43785054a36 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Tue, 12 Jul 2005 13:35:58 +0000 Subject: [PATCH] - The socket/usergroup API function and data type definitions that used to be defined in have been moved into a separate header file which, for backwards compatibility, can be include from within if the preprocessor symbol __USE_CLIB2_NETLIB is defined early on. Eventually, should be removed from the general header files and become a local library build header file altogether. Note that in this case you would have to build your own software using common TCP/IP SDK header files. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15011 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 14 +- library/GNUmakefile.os4 | 6 +- library/changes | 9 ++ library/include/sys/clib2_net.h | 230 ++++++++++++++++++++++++++++++++ library/include/unistd.h | 175 +----------------------- library/smakefile | 4 +- 6 files changed, 258 insertions(+), 180 deletions(-) create mode 100644 library/include/sys/clib2_net.h diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 62642fd..a9c9ef2 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.65 2005-07-03 10:36:46 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.66 2005-07-12 13:35:52 obarthel Exp $ # # :ts=8 # @@ -110,15 +110,17 @@ WARNINGS = \ # -Wconversion -Wshadow INCLUDES = -Iinclude -I. -Inetinclude -#OPTIONS = -fno-builtin -fno-common -DDEBUG - OPTIONS = -fno-builtin -fno-common -DNDEBUG -#OPTIONS = -fno-builtin -fno-common -D__MEM_DEBUG -#OPTIONS = -fno-builtin -fno-common -DDEBUG -D__MEM_DEBUG -DNO_INLINE_STDARG +#OPTIONS = -fno-builtin -fno-common -D__USE_CLIB2_NETLIB -DDEBUG + OPTIONS = -fno-builtin -fno-common -D__USE_CLIB2_NETLIB -DNDEBUG +#OPTIONS = -fno-builtin -fno-common -D__USE_CLIB2_NETLIB -D__MEM_DEBUG +#OPTIONS = -fno-builtin -fno-common -D__USE_CLIB2_NETLIB -DDEBUG -D__MEM_DEBUG -DNO_INLINE_STDARG OPTIMIZE = -O -fomit-frame-pointer -fstrength-reduce -finline-functions #OPTIMIZE = -O2 -fomit-frame-pointer #DEBUG = -g -CFLAGS = $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(CODE_FLAGS) $(CODE_TYPE) $(INCLUDES) +CFLAGS = \ + $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) \ + $(CODE_FLAGS) $(CODE_TYPE) $(INCLUDES) ############################################################################## diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index 2cbc126..0b6362a 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.72 2005-07-03 10:36:46 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.73 2005-07-12 13:35:52 obarthel Exp $ # # :ts=8 # @@ -122,8 +122,8 @@ WARNINGS = \ # -Wconversion -Wshadow INCLUDES = -Iinclude -I. -I$(SDK_INCLUDE) -#OPTIONS = -D__THREAD_SAFE -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99 - OPTIONS = -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99 +#OPTIONS = -D__THREAD_SAFE -D__USE_CLIB2_NETLIB -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99 + OPTIONS = -D__USE_CLIB2_NETLIB -DNDEBUG -DUSE_64_BIT_INTS -D__USE_INLINE__ -Wa,-mregnames -fno-common -std=gnu99 OPTIMIZE = -O3 #DEBUG = -ggdb diff --git a/library/changes b/library/changes index 655e51a..4457660 100644 --- a/library/changes +++ b/library/changes @@ -56,6 +56,15 @@ - Retrofitted thread-safety into the termios code. +- The socket/usergroup API function and data type definitions that used to + be defined in have been moved into a separate header file + which, for backwards compatibility, can be include + from within if the preprocessor symbol __USE_CLIB2_NETLIB + is defined early on. Eventually, should be removed + from the general header files and become a local library build header + file altogether. Note that in this case you would have to build your + own software using common TCP/IP SDK header files. + c.lib 1.193 (4.6.2005) diff --git a/library/include/sys/clib2_net.h b/library/include/sys/clib2_net.h new file mode 100644 index 0000000..e66cb1b --- /dev/null +++ b/library/include/sys/clib2_net.h @@ -0,0 +1,230 @@ +/* + * $Id: clib2_net.h,v 1.1 2005-07-12 13:35:58 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_CLIB2_NET_H +#define _SYS_CLIB2_NET_H + +/****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************/ + +/* The following is not part of the ISO 'C' (1994) standard. */ + +/****************************************************************************/ + +/* + * The following may have been predefined by local TCP/IP header files. We + * don't want to be any trouble... + */ + +#if !defined(FD_SET) && !defined(__NO_NET_API) + +/****************************************************************************/ + +#ifndef _UNISTD_H +#include +#endif /* _UNISTD_H */ + +#ifndef _STRING_H +#include +#endif /* _STRING_H */ + +#ifndef _STDLIB_H +#include +#endif /* _STDLIB_H */ + +#ifndef _SYS_TIME_H +#include +#endif /* _SYS_TIME_H */ + +#ifndef _SYS_TYPES_H +#include +#endif /* _SYS_TYPES_H */ + +/****************************************************************************/ + +/* + * select() uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields. + * + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef struct fd_set +{ + unsigned long bits[(FD_SETSIZE + 31) / 32]; +} fd_set; + +#define FD_SET(n,p) ((void)((p)->bits[((unsigned long)n) >> 5] |= (1UL << (((unsigned long)n) & 31)))) +#define FD_CLR(n,p) ((void)((p)->bits[((unsigned long)n) >> 5] &= ~(1UL << (((unsigned long)n) & 31)))) +#define FD_ISSET(n,p) (((p)->bits[((unsigned long)n) >> 5] & (1UL << (((unsigned long)n) & 31))) != 0) +#define FD_COPY(f,t) ((void)memmove(t,f,sizeof(*(f)))) +#define FD_ZERO(p) ((void)memset(p,0,sizeof(*(p)))) + +/****************************************************************************/ + +/* Forward declarations for below... */ +struct hostent; +struct netent; +struct protoent; +struct servent; +struct passwd; +struct msghdr; +struct sockaddr; + +/****************************************************************************/ + +/* + * You might want to have included in place of + * this local definition. + */ +#if defined(__USE_NETINET_IN_H) + +#include + +#else + +/* + * These two symbols are typically defined by , which also + * happens to define 'struct in_addr'. We don't want to redefine it. + */ +#if !defined(_NETINET_IN_H) && !defined(IPPROTO_IP) + +/* Internet address (a structure for historical reasons) */ +struct in_addr +{ + unsigned long s_addr; +}; + +#endif /* !_NETINET_IN_H && !IPPROTO_IP */ + +#endif /* __USE_NETINET_IN_H */ + +/****************************************************************************/ + +/* Error codes set by the name<->address resolution functions. */ +extern int h_errno; + +/****************************************************************************/ + +typedef unsigned long socklen_t; + +/****************************************************************************/ + +extern int accept(int sockfd,struct sockaddr *cliaddr,socklen_t *addrlen); +extern int bind(int sockfd,struct sockaddr *name,int namelen); +extern int connect(int sockfd,struct sockaddr *name,socklen_t namelen); +extern struct hostent * gethostbyaddr(const char *addr, socklen_t len, int type); +extern struct hostent * gethostbyname(const char *name); +extern int gethostname(const char *name, int namelen); +extern struct netent * getnetbyname(const char *name); +extern int getpeername(int sockfd,struct sockaddr *name,socklen_t *namelen); +extern int getsockname(int sockfd,struct sockaddr *name,socklen_t *namelen); +extern int getsockopt(int sockfd,int level,int optname,void *optval,socklen_t *optlen); +extern unsigned long inet_addr(const char *addr); +extern char * inet_ntoa(struct in_addr in); +extern int ioctl(int fd,unsigned long request, ... /* char *arg */); +extern int listen(int sockfd,int backlog); +extern int recv(int fd,void *buff,size_t nbytes,int flags); +extern int recvfrom(int sockfd,void *buff,int len,int flags,struct sockaddr *from,socklen_t *fromlen); +extern int recvmsg(int socket,struct msghdr *msg,int flags); +extern int select(int num_fds,fd_set *read_fds,fd_set *write_fds,fd_set *except_fds,struct timeval *timeout); +extern int send(int fd,const void *buff,size_t nbytes,int flags); +extern int sendmsg(int socket,struct msghdr *msg,int flags); +extern int sendto(int sockfd,const void *buff,int len,int flags,struct sockaddr *to,socklen_t tolen); +extern int setsockopt(int sockfd,int level,int optname,const void *optval,socklen_t optlen); +extern int shutdown(int socket, int how); +extern int socket(int domain,int type,int protocol); +extern long gethostid(void); +extern struct netent * getnetbyaddr(long net,int type); +extern struct servent * getservbyname(const char *name, const char *proto); +extern struct servent * getservbyport(int port, const char *proto); +extern struct protoent * getprotobyname(const char *name); +extern struct protoent * getprotobynumber(int proto); +extern int inet_aton(const char *cp, struct in_addr *addr); +extern unsigned long inet_lnaof(struct in_addr in); +extern struct in_addr inet_makeaddr(int net,int host); +extern unsigned long inet_netof(struct in_addr in); +extern unsigned long inet_network(const char *cp); +extern const char * hstrerror(int error_number); + +/****************************************************************************/ + +extern char *crypt(const char *key, const char *salt); +extern gid_t getegid(void); +extern uid_t geteuid(void); +extern gid_t getgid(void); +extern struct group *getgrgid(gid_t gid); +extern struct group *getgrnam(const char *name); +extern int getgroups(int ngroups, gid_t *groups); +extern char *getpass(const char *prompt); +extern struct passwd *getpwnam(const char *name); +extern struct passwd *getpwuid(uid_t uid); +extern uid_t getuid(void); +extern int initgroups(const char *name, gid_t basegroup); +extern int setegid(gid_t g); +extern int seteuid(uid_t u); +extern int setgid(gid_t id); +extern int setgroups(int ngroups, const gid_t *groups); +extern int setregid(gid_t real, gid_t eff); +extern int setreuid(uid_t real, uid_t eff); +extern long setsid(void); +extern int setuid(uid_t id); +extern void endgrent(void); +extern void endpwent(void); +extern struct group *getgrent(void); +extern struct passwd *getpwent(void); +extern void setgrent(void); +extern void setpwent(void); + +/****************************************************************************/ + +#endif /* !FD_SET && !__NO_NET_API */ + +/****************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/****************************************************************************/ + +#endif /* _SYS_CLIB2_NET_H */ diff --git a/library/include/unistd.h b/library/include/unistd.h index 9ec4fbb..c94a22a 100644 --- a/library/include/unistd.h +++ b/library/include/unistd.h @@ -1,5 +1,5 @@ /* - * $Id: unistd.h,v 1.12 2005-06-18 07:23:17 obarthel Exp $ + * $Id: unistd.h,v 1.13 2005-07-12 13:35:58 obarthel Exp $ * * :ts=4 * @@ -118,174 +118,11 @@ extern char * __getcwd(char * buffer,size_t buffer_size,const char *file,int lin /****************************************************************************/ -/* - * The following may have been predefined by local TCP/IP header files. We - * don't want to be any trouble... - */ - -#if !defined(FD_SET) && !defined(__NO_NET_API) - -/****************************************************************************/ - -#ifndef _STRING_H -#include -#endif /* _STRING_H */ - -#ifndef _STDLIB_H -#include -#endif /* _STDLIB_H */ - -#ifndef _SYS_TIME_H -#include -#endif /* _SYS_TIME_H */ - -#ifndef _SYS_TYPES_H -#include -#endif /* _SYS_TYPES_H */ - -/****************************************************************************/ - -/* - * select() uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields. - * - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. - */ -#ifndef FD_SETSIZE -#define FD_SETSIZE 256 -#endif - -typedef struct fd_set -{ - unsigned long bits[(FD_SETSIZE + 31) / 32]; -} fd_set; - -#define FD_SET(n,p) ((void)((p)->bits[((unsigned long)n) >> 5] |= (1UL << (((unsigned long)n) & 31)))) -#define FD_CLR(n,p) ((void)((p)->bits[((unsigned long)n) >> 5] &= ~(1UL << (((unsigned long)n) & 31)))) -#define FD_ISSET(n,p) (((p)->bits[((unsigned long)n) >> 5] & (1UL << (((unsigned long)n) & 31))) != 0) -#define FD_COPY(f,t) ((void)memmove(t,f,sizeof(*(f)))) -#define FD_ZERO(p) ((void)memset(p,0,sizeof(*(p)))) - -/****************************************************************************/ - -/* Forward declarations for below... */ -struct hostent; -struct netent; -struct protoent; -struct servent; -struct passwd; -struct msghdr; -struct sockaddr; - -/****************************************************************************/ - -/* - * You might want to have included in place of - * this local definition. - */ -#if defined(__USE_NETINET_IN_H) - -#include - -#else - -/* - * These two symbols are typically defined by , which also - * happens to define 'struct in_addr'. We don't want to redefine it. - */ -#if !defined(_NETINET_IN_H) && !defined(IPPROTO_IP) - -/* Internet address (a structure for historical reasons) */ -struct in_addr -{ - unsigned long s_addr; -}; - -#endif /* !_NETINET_IN_H && !IPPROTO_IP */ - -#endif /* __USE_NETINET_IN_H */ - -/****************************************************************************/ - -/* Error codes set by the name<->address resolution functions. */ -extern int h_errno; - -/****************************************************************************/ - -typedef unsigned long socklen_t; - -/****************************************************************************/ - -extern int accept(int sockfd,struct sockaddr *cliaddr,socklen_t *addrlen); -extern int bind(int sockfd,struct sockaddr *name,int namelen); -extern int connect(int sockfd,struct sockaddr *name,socklen_t namelen); -extern struct hostent * gethostbyaddr(const char *addr, socklen_t len, int type); -extern struct hostent * gethostbyname(const char *name); -extern int gethostname(const char *name, int namelen); -extern struct netent * getnetbyname(const char *name); -extern int getpeername(int sockfd,struct sockaddr *name,socklen_t *namelen); -extern int getsockname(int sockfd,struct sockaddr *name,socklen_t *namelen); -extern int getsockopt(int sockfd,int level,int optname,void *optval,socklen_t *optlen); -extern unsigned long inet_addr(const char *addr); -extern char * inet_ntoa(struct in_addr in); -extern int ioctl(int fd,unsigned long request, ... /* char *arg */); -extern int listen(int sockfd,int backlog); -extern int recv(int fd,void *buff,size_t nbytes,int flags); -extern int recvfrom(int sockfd,void *buff,int len,int flags,struct sockaddr *from,socklen_t *fromlen); -extern int recvmsg(int socket,struct msghdr *msg,int flags); -extern int select(int num_fds,fd_set *read_fds,fd_set *write_fds,fd_set *except_fds,struct timeval *timeout); -extern int send(int fd,const void *buff,size_t nbytes,int flags); -extern int sendmsg(int socket,struct msghdr *msg,int flags); -extern int sendto(int sockfd,const void *buff,int len,int flags,struct sockaddr *to,socklen_t tolen); -extern int setsockopt(int sockfd,int level,int optname,const void *optval,socklen_t optlen); -extern int shutdown(int socket, int how); -extern int socket(int domain,int type,int protocol); -extern long gethostid(void); -extern struct netent * getnetbyaddr(long net,int type); -extern struct servent * getservbyname(const char *name, const char *proto); -extern struct servent * getservbyport(int port, const char *proto); -extern struct protoent * getprotobyname(const char *name); -extern struct protoent * getprotobynumber(int proto); -extern int inet_aton(const char *cp, struct in_addr *addr); -extern unsigned long inet_lnaof(struct in_addr in); -extern struct in_addr inet_makeaddr(int net,int host); -extern unsigned long inet_netof(struct in_addr in); -extern unsigned long inet_network(const char *cp); -extern const char * hstrerror(int error_number); - -/****************************************************************************/ - -extern char *crypt(const char *key, const char *salt); -extern gid_t getegid(void); -extern uid_t geteuid(void); -extern gid_t getgid(void); -extern struct group *getgrgid(gid_t gid); -extern struct group *getgrnam(const char *name); -extern int getgroups(int ngroups, gid_t *groups); -extern char *getpass(const char *prompt); -extern struct passwd *getpwnam(const char *name); -extern struct passwd *getpwuid(uid_t uid); -extern uid_t getuid(void); -extern int initgroups(const char *name, gid_t basegroup); -extern int setegid(gid_t g); -extern int seteuid(uid_t u); -extern int setgid(gid_t id); -extern int setgroups(int ngroups, const gid_t *groups); -extern int setregid(gid_t real, gid_t eff); -extern int setreuid(uid_t real, uid_t eff); -extern long setsid(void); -extern int setuid(uid_t id); -extern void endgrent(void); -extern void endpwent(void); -extern struct group *getgrent(void); -extern struct passwd *getpwent(void); -extern void setgrent(void); -extern void setpwent(void); - -/****************************************************************************/ - -#endif /* !FD_SET && !__NO_NET_API */ +/* If desired, also include the networking API, as integrated into + the clib2 libnet.a library. */ +#if defined(__USE_CLIB2_NETLIB) && !defined(_SYS_CLIB2_NET_H) +#include +#endif /* __USE_CLIB2_NETLIB && !_SYS_CLIB2_NET_H */ /****************************************************************************/ diff --git a/library/smakefile b/library/smakefile index 70ed86d..619ef56 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.48 2005-07-03 10:36:47 obarthel Exp $ +# $Id: smakefile,v 1.49 2005-07-12 13:35:53 obarthel Exp $ # # :ts=8 # @@ -36,7 +36,7 @@ INCLUDE_DIR = V:include CPU = cpu=060 MATH = define=IEEE_FLOATING_POINT_SUPPORT math=IEEE SUPPORT = define=UNIX_PATH_SEMANTICS define=SOCKET_SUPPORT define=USERGROUP_SUPPORT \ - define=__C_MACROS__ define=__THREAD_SAFE + define=__C_MACROS__ define=__THREAD_SAFE define=__USE_CLIB2_NETLIB ##############################################################################