summaryrefslogtreecommitdiff
path: root/NetWare/nw5sck.h
blob: b32493f36cf2d4570c19d59a0457a7baaee25718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

/*
 * Copyright © 2001 Novell, Inc. All Rights Reserved.
 *
 * You may distribute under the terms of either the GNU General Public
 * License or the Artistic License, as specified in the README file.
 *
 */

/*
 * FILENAME     :  nw5sck.h
 * DESCRIPTION  :  Socket related functions.
 * Author       :  SGP
 * Date         :  January 2001.
 * Date Modified:  June 26th 2001.
 *
 */



#ifndef  _INC_NW_SOCKET
#define  _INC_NW_SOCKET


#include <sys/socket.h>
#ifdef __cplusplus
extern "C" {
#endif

typedef u_int           SOCKET;

struct nwsockent local_context;

# undef gethostbyname
# undef gethostbyaddr

# undef endhostent
# undef endnetent
# undef endprotoent
# undef endservent
# undef gethostent
# undef getprotoent
# undef getnetbyaddr
# undef getnetbyname
# undef gethostbyaddr
# undef getprotobyname
# undef getservbyname
# undef getservbyport
# undef getservent
# undef sethostent
# undef setnetent
# undef setprotoent
# undef setservent

# define gethostbyname(name)   NetDBgethostbyname(&local_context,name)
# define gethostbyaddr(a,l,t)  NetDBgethostbyaddr(&local_context,a,l,t)

# define endhostent()          NetDBendhostent(&local_context)
# define endnetent()           NWendnetent(&local_context)
# define endprotoent()         NWendprotoent(&local_context)
# define endservent()          NWendservent(&local_context)
# define gethostent()          NetDBgethostent(&local_context,NULL)
# define getprotoent()         NWgetprotoent(&local_context)
# define gethostbyaddr(a,l,t)  NetDBgethostbyaddr(&local_context,a,l,t)
# define getnetbyaddr(net,typ) NWgetnetbyaddr(&local_context,net,typ)
# define getnetbyname(name)    NWgetnetbyname(&local_context,name)
# define getprotobyname(name)  NWgetprotobyname(&local_context,name)
# define getservbyname(n,p)    NWgetservbyname(&local_context,n,p)
# define getservbyport(n,p)    NWgetservbyport(&local_context,n,p)
# define getservent()          NWgetservent(&local_context)
# define sethostent()          NWsethostent(&local_context, stayopen)
# define setnetent()           NWsetnetent(&local_context, stayopen)
# define setprotoent()         NWsetprotoent(&local_context, stayopen)
# define setservent()          NWsetservent(&local_context, stayopen)

u_long nw_htonl(u_long hostlong);
u_short nw_htons(u_short hostshort);
u_long nw_ntohl(u_long netlong);
u_short nw_ntohs(u_short netshort);

SOCKET nw_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
int nw_bind(SOCKET s, const struct sockaddr *addr, int addrlen);
int nw_connect(SOCKET s, const struct sockaddr *addr, int addrlen);

struct hostent * nw_gethostbyname(const char * name);
struct hostent * nw_gethostbyaddr(const char *addr, int len, int type);
int nw_gethostname(char *name, int len);
struct netent * nw_getnetbyaddr(long net, int type);
struct netent *nw_getnetbyname(char *name);
int nw_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen);
struct protoent * nw_getprotobyname(const char *name);
struct protoent * nw_getprotobynumber(int num);
struct servent * nw_getservbyname(const char *name, const char *proto);
struct servent * nw_getservbyport(int port, const char *proto);
struct servent * nw_getservent(void);
void nw_sethostent(int stayopen);
void nw_setnetent(int stayopen);
void nw_setprotoent(int stayopen);
void nw_setservent(int stayopen);
int nw_setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen);

int nw_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen);
int nw_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen);

unsigned long nw_inet_addr(const char *cp);

void nw_endhostent();
void nw_endnetent();
void nw_endprotoent();
void nw_endservent();
struct hostent *nw_gethostent();
struct netent *nw_getnetent();
struct protoent * nw_getprotoent();

SOCKET nw_socket(int af, int type, int protocol);
int nw_listen(SOCKET s, int backlog);
int nw_send(SOCKET s, const char *buf, int len, int flags);
int nw_recv(SOCKET s, char *buf, int len, int flags);
int nw_sendto(SOCKET s, const char *buf, int len, int flags,const struct sockaddr *to, int tolen);
int nw_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen);
int nw_select(int nfds, fd_set* rd, fd_set* wr, fd_set* ex, const struct timeval* timeout);
int nw_shutdown(SOCKET s, int how);
#ifdef __cplusplus
}
#endif


#endif	// _INC_NW_SOCKET