#ifndef CLIB_SOCKET_PROTOS_H
#define CLIB_SOCKET_PROTOS_H \
       "$Id: socket_protos.h,v 4.3 1994/10/04 17:09:14 jraja Exp $"
/*
 *	Prototypes of AmiTCP/IP bsdsocket.library
 *
 *	Copyright © 1994 AmiTCP/IP Group,
 *			 Network Solutions Development, Inc.
 *			 All rights reserved.
 */

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef  UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

#ifndef SYS_TYPES_H
#include <sys/types.h>
#endif

#ifndef SYS_TIME_H
#include <sys/time.h>
#endif

#ifndef SYS_SOCKET_H
#include <sys/socket.h>
#endif

#ifndef NETINET_IN_H
#include <netinet/in.h>
#endif

#ifndef STDARG_H
#include <stdarg.h>
#endif

#ifndef AMITCP_NEW_NAMES
#define STDSOCKAPI
#define Socket socket
#define Bind bind
#define Listen listen
#define Accept accept
#define Connect connect
#define Send send
#define SendTo sendto
#define SendMsg sendmsg
#define Recv recv
#define RecvFrom recvfrom
#define RecvMsg recvmsg
#define ShutDown shutdown
#define SetSockOpt setsockopt
#define GetSockOpt getsockopt
#define GetSockName getsockname
#define GetPeerName getpeername
#define Inet_Addr inet_addr
#define Inet_Network inet_network
#define GetHostByName gethostbyname
#define GetHostByAddr gethostbyaddr
#define GetNetByName getnetbyname
#define GetNetByAddr getnetbyaddr
#define GetServByName getservbyname
#define GetServByPort getservbyport
#define GetProtoByName getprotobyname
#define GetProtoByNumber getprotobynumber
#define GetDTableSize getdtablesize
#define GetHostName gethostname
#define GetHostId gethostid
#define SyslogA vsyslog
#define Syslog syslog
#endif

int Socket(int domain, int type, int protocol);
int Bind(int s, const struct sockaddr *name, int namelen);
int Listen(int s, int backlog);
int Accept(int s, struct sockaddr *addr, int *addrlen);
int Connect(int s, const struct sockaddr *name, int namelen);
int Send(int s, const void *msg, int len, int flags);
int SendTo(int s, const void *msg, int len, int flags,
		  const struct sockaddr *to, int tolen);
int SendMsg(int s, const struct msghdr * msg, int flags);
int Recv(int s, void *buf, int len, int flags);    /* V3 */
int RecvFrom(int s, void *buf, int len, int flags,
		    struct sockaddr *from, int *fromlen);
int RecvMsg(int s, struct msghdr * msg, int flags);  /* V3 */
int Shutdown(int s, int how);
int SetSockOpt(int s, int level, int optname,
		     const void *optval, int optlen);
int GetSockOpt(int s, int level, int optname,
		     void *optval, int *optlen);
int GetSockName(int s, struct sockaddr *name, int *namelen);
int GetPeerName(int s, struct sockaddr *name, int *namelen);

int WaitSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exeptfds,
		struct timeval *timeout, ULONG *maskp);
#ifdef OLD
int Dup2Socket(int fd1, int fd2);                   /* V2 */
int IoctlSocket(int d, ULONG request, char *argp);
int CloseSocket(int d);
#endif

void SetSocketSignals(ULONG SGINTR, ULONG SGIO, ULONG SGURG);
void SetErrnoPtr(void *errno_p, int size);
LONG SocketBaseTagList(struct TagItem *tagList);        /* V3 */

LONG SocketBaseTags(LONG,...);                          /* V3 */

int GetSocketEvents(ULONG *eventmaskp);                /* V4 */

int Errno(void);

int ObtainSocket(LONG id, int domain, int type, int protocol);
int ReleaseSocket(int fd, LONG id);
int ReleaseCopyOfSocket(int fd, LONG id);

/* Arpa/inet functions */
ULONG Inet_Addr(const char *);
ULONG Inet_Network(const char *);
char *Inet_NtoA(ULONG s_addr);
ULONG Inet_MakeAddr(u_long net, u_long lna);
ULONG Inet_LnaOf(LONG s_addr);
ULONG Inet_NetOf(LONG s_addr);

/* NetDB functions */
struct hostent	*GetHostByName(char *name);
struct hostent	*GetHostByAddr(const char *addr, int len, int type);
struct netent	*GetNetByName(const char *name);
struct netent	*GetNetByAddr(long net, int type);
struct servent	*GetServByName(const char *name, const char *proto);
struct servent	*GetServByPort(int port, const char *proto);
struct protoent *GetProtoByName(const char *name);
struct protoent *GetProtoByNumber(int proto);

/* Syslog functions */
void SyslogA(int pri, const char *fmt, va_list);
void Syslog(int pri, const char *fmt, ...);

#ifdef STDSOCKAPI
#undef STDSOCKAPI
#undef Socket
#undef Bind
#undef Listen
#undef Accept
#undef Connect
#undef Send
#undef SendTo
#undef SendMsg
#undef Recv
#undef RecvFrom
#undef RecvMsg
#undef Shutdown
#undef SetSockOpt
#undef GetSockOpt
#undef GetSockName
#undef GetPeerName
#undef Inet_Addr
#undef Inet_Network
#undef GetHostByName
#undef GetHostByAddr
#undef GetNetByName
#undef GetNetByAddr
#undef GetServByName
#undef GetServByPort
#undef GetProtoByName
#undef GetProtoByNumber
#undef GetDTableSize
#undef GetHostName
#undef GetHostId
#undef SyslogA
#undef Syslog
#endif

#endif /* !CLIB_SOCKET_PROTOS_H */
