Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / base / net.h
blob5ad8155b7f3683e152399e7e9659b5f6704fad21
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * net.h: system specific networking definitions
17 * Rob McCool
21 #ifndef NET_H
22 #define NET_H
24 #include "systems.h"
26 #include "file.h" /* for client file descriptors */
28 #include "pblock.h" /* for client data block */
31 /* This should be a user-given parameter later */
32 #define NET_BUFFERSIZE 8192
33 /* So should this. */
34 #define NET_READ_TIMEOUT 120
35 #define NET_WRITE_TIMEOUT 300
37 #define SSL_HANDSHAKE_TIMEOUT 300
39 #if defined(NET_SOCKETS) || defined(NET_SSL)
41 #ifdef NET_WINSOCK
42 #include <winsock.h>
43 #else /* XP_UNIX */
44 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <netinet/in.h> /* sockaddr and in_addr */
47 #include <arpa/inet.h> /* inet_ntoa */
48 #include <netdb.h> /* hostent stuff */
49 #endif /* NET_WINSOCK */
51 #ifdef NET_SSL
52 #include "minissl.h"
53 #endif
56 /* -------------------------------- Global -------------------------------- */
58 extern int net_enabledns;
61 /* ------------------------------ Data types ------------------------------ */
64 #ifdef NET_WINSOCK
65 typedef SOCKET SYS_NETFD;
66 #else /* XP_UNIX */
67 typedef int SYS_NETFD;
68 #endif /* NET_WINSOCK */
70 #define SYS_NET_ERRORFD -1
73 /* -------------------------------- Macros -------------------------------- */
76 /* These may be different for non-UNIX systems. */
79 #ifndef NET_SSL
80 #define net_socket socket
81 #define net_setsockopt setsockopt
82 #define net_getsockopt getsockopt
83 #define net_listen listen
84 #define net_select select
85 #define net_getpeername getpeername
87 #ifndef NET_WINSOCK
88 #define net_close(sd) close(sd)
89 #define net_bind bind
90 #else /* NET_WINSOCK */
91 #define net_close(sd) closesocket(sd)
92 #define system_netbind bind
93 int net_bind(SYS_NETFD s, const struct sockaddr *name, int namelen);
94 #endif /* NET_WINSOCK */
96 #ifdef DAEMON_NEEDS_SEMAPHORE
97 #define net_accept net_semaccept
98 #else /* ! DAEMON_NEEDS_SEMAPHORE */
99 #define net_accept accept
100 #endif /* DAEMON_NEEDS_SEMAPHORE */
102 #else /* NET_SSL */
103 #define net_close(sd) SSL_Close(sd)
104 #define net_socket SSL_Socket
105 #define net_setsockopt SSL_SetSockOpt
106 #define net_getsockopt SSL_GetSockOpt
108 #ifdef XP_UNIX
109 #define net_bind SSL_Bind
110 #else /* WIN32 */
111 #define system_netbind SSL_Bind
112 int net_bind(SYS_NETFD s, const struct sockaddr *name, int namelen);
113 #endif /* XP_UNIX */
115 #define net_listen SSL_Listen
116 #define net_select select /* !!! */
117 #define net_getpeername SSL_GetPeerName
118 #define net_accept SSL_Accept
119 #endif /* ! NET_SSL */
122 /* Users should never call the system_net* functions. */
123 #ifdef NET_SSL
124 #define system_netread(sd, buf, sz) SSL_Read(sd, buf, sz)
125 #define system_netwrite SSL_Write
126 #else /* ! NET_SSL */
128 #if !defined(NET_WINSOCK)
129 #define system_netread(sd, buf, sz) read(sd, buf, sz)
130 #define system_netwrite write
131 #else /* NET_WINSOCK */
132 #define system_netread(sd, buf, sz) recv(sd, buf, sz, 0)
133 #define system_netwrite(sd, buf, sz) send(sd, buf, sz, 0)
134 #endif /* ! NET_WINSOCK */
136 #endif /* NET_SSL */
138 int net_read(SYS_NETFD sd, char *buf, int sz, int timeout);
139 int net_write(SYS_NETFD sd, char *buf, int sz);
141 #ifdef DAEMON_NEEDS_SEMAPHORE
142 int net_semaccept_init(int port);
143 int net_semaccept(int s, struct sockaddr *addr, int *addrlen);
144 void net_semaccept_terminate();
145 #endif
148 /* ------------------------------ Prototypes ------------------------------ */
152 * net_find_fqdn looks through the given hostent structure trying to find
153 * a FQDN for the host. If it finds none, it returns NULL. Otherwise, it
154 * returns a newly allocated copy of that string.
157 char *net_find_fqdn(struct hostent *p);
160 * net_ip2host transforms the given textual IP number into a FQDN. If it
161 * can't find a FQDN, it will return what it can get. Otherwise, NULL.
163 * verify is whether or not the function should verify the hostname it
164 * gets. This takes an extra query but is safer for use in access control.
167 char *net_ip2host(char *ip, int verify);
170 * net_sendmail sends mail to the specified recipient with the given subject
171 * and message. Currently uses external programs.
174 int net_sendmail(char *to, char *subject, char *msg);
176 #endif
177 #endif