~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/src/md/mac/macsocket.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
#ifndef macksocket_h___
39
 
#define macksocket_h___
40
 
 
41
 
// macsock.h
42
 
// Interface visible to xp code
43
 
// C socket type definitions and routines
44
 
// from sys/socket.h
45
 
#include <Files.h>
46
 
#include <OpenTptInternet.h>    // All the internet typedefs
47
 
#include <utime.h>                              // For timeval
48
 
/*
49
 
 * sleep and delay conflict with the same in unistd.h from Metrowerks.  OT
50
 
 * defines them as 
51
 
 *
52
 
 *    extern pascal void                OTDelay(UInt32 seconds);
53
 
 *    extern pascal void                OTIdle(void);
54
 
 *
55
 
 *    #define sleep(x)  OTDelay(x)
56
 
 *    #define delay(x)  OTDelay(x)
57
 
 */
58
 
 
59
 
#undef sleep
60
 
#undef delay
61
 
 
62
 
#pragma once
63
 
 
64
 
#include "prio.h"
65
 
 
66
 
struct sockaddr {
67
 
        unsigned char   sa_len;                 /* total length */
68
 
        unsigned char   sa_family;              /* address family */
69
 
        char    sa_data[14];            /* actually longer; address value */
70
 
};
71
 
 
72
 
// from netinet/in.h
73
 
struct in_addr {
74
 
        unsigned long s_addr;
75
 
};
76
 
 
77
 
struct sockaddr_in {
78
 
        unsigned char   sin_len;
79
 
        unsigned char   sin_family;             // AF_INET
80
 
        unsigned short  sin_port;
81
 
        struct  in_addr sin_addr;
82
 
        char            sin_zero[8];
83
 
};
84
 
 
85
 
struct  hostent {
86
 
        char    *h_name;        /* official name of host */
87
 
        char    **h_aliases;    /* alias list */
88
 
        int     h_addrtype;     /* host address type */
89
 
        int     h_length;       /* length of address */
90
 
        char    **h_addr_list;  /* list of addresses from name server */
91
 
#define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
92
 
};
93
 
 
94
 
// Necessary network defines, found by grepping unix headers when XP code would not compile
95
 
#define FIONBIO 1
96
 
#define SOCK_STREAM 1
97
 
#define SOCK_DGRAM              2
98
 
#define IPPROTO_TCP     INET_TCP                // Default TCP protocol
99
 
#define IPPROTO_UDP             INET_UDP                // Default UDP protocol
100
 
#define INADDR_ANY              kOTAnyInetAddress
101
 
#define SOL_SOCKET              XTI_GENERIC             // Any type of socket
102
 
#define SO_REUSEADDR    IP_REUSEADDR
103
 
#define SO_BROADCAST    IP_BROADCAST
104
 
#define MSG_PEEK                0x2                             // Just look at a message waiting, don�t actually read it.
105
 
 
106
 
typedef unsigned long u_long;
107
 
 
108
 
/* ldap.h has its own definition of fd_set */
109
 
/* select support */
110
 
#if !defined(FD_SET)
111
 
#define NBBY    8
112
 
typedef long    fd_mask;
113
 
#define NFDBITS (sizeof(fd_mask) * NBBY)        /* bits per mask */
114
 
 
115
 
#ifndef howmany
116
 
#define howmany(x, y)   (((x)+((y)-1))/(y))
117
 
#endif
118
 
#define FD_SETSIZE 64
119
 
typedef struct fd_set{
120
 
    fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
121
 
} fd_set;
122
 
 
123
 
#define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
124
 
#define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
125
 
#define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
126
 
#define FD_ZERO(p)      memset (p, 0, sizeof(*(p)))
127
 
#endif /* !FD_SET */
128
 
 
129
 
 
130
 
#ifdef __cplusplus
131
 
extern "C" {
132
 
#endif
133
 
 
134
 
extern unsigned long inet_addr(const char *cp);
135
 
extern char *inet_ntoa(struct in_addr in);
136
 
 
137
 
inline unsigned long htonl(unsigned long hostlong) {return hostlong;}
138
 
inline unsigned long ntohl(unsigned long netlong) {return netlong;}
139
 
inline unsigned short ntohs(unsigned short netshort) {return netshort;}
140
 
inline unsigned short htons(unsigned short hostshort) {return hostshort;}
141
 
 
142
 
 
143
 
// UNIX look-alike routines
144
 
// They make sure that the arguments passed in are valid, and then
145
 
//
146
 
extern struct hostent *macsock_gethostbyaddr(const void *addr, int addrlen, int type);
147
 
 
148
 
extern int macsock_socket(int domain, int type, int protocol);
149
 
extern int macsock_ioctl(int sID, unsigned int request, void *value);
150
 
extern int macsock_connect(int sID, struct sockaddr *name, int namelen);
151
 
extern int macsock_write(int sID, const void *buffer, unsigned buflen);
152
 
extern int macsock_read(int sID, void *buf, unsigned nbyte);
153
 
extern int macsock_close(int sID);
154
 
 
155
 
extern int macsock_accept(int sID, struct sockaddr *addr, int *addrlen);
156
 
extern int macsock_bind(int sID, const struct sockaddr *name, int namelen);
157
 
extern int macsock_listen(int sID, int backlog);
158
 
 
159
 
extern int macsock_shutdown(int sID, int how);
160
 
extern int macsock_getpeername(int sID, struct sockaddr *name, int *namelen);
161
 
extern int macsock_getsockname(int sID, struct sockaddr *name, int *namelen);
162
 
extern int macsock_getsockopt(int sID, int level, int optname, void *optval,int *optlen);
163
 
extern int macsock_setsockopt(int sID, int level, int optname, const void *optval,int optlen);
164
 
extern int macsock_socketavailable(int sID, size_t *bytesAvailable);
165
 
extern int macsock_dup(int sID);
166
 
 
167
 
extern int macsock_send(int sID, const void *msg, int len, int flags);
168
 
extern int macsock_sendto(int sID, const void *msg, int len, int flags, struct sockaddr *toAddr, int toLen);
169
 
extern int macsock_recvfrom(int sID, void *buf, int len, int flags, struct sockaddr *from, int *fromLen);
170
 
extern int macsock_recv(int sID, void *buf, int len, int flags);
171
 
 
172
 
extern int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
173
 
 
174
 
 
175
 
#define macsock_gethostbyaddr PR_GetHostByAddr
176
 
#define macsock_socket PR_Socket
177
 
#define macsock_connect PR_Connect
178
 
#define macsock_write PR_Write
179
 
#define macsock_read PR_Read
180
 
#define macsock_close PR_Close
181
 
#define macsock_accept PR_Accept
182
 
#define macsock_bind PR_Bind
183
 
#define macsock_listen PR_Listen
184
 
#define macsock_shutdown PR_Shutdown
185
 
#define macsock_getpeername PR_GetPeerName
186
 
#define macsock_getsockname PR_GetSockName
187
 
#define macsock_socketavailable PR_SocketAvailable
188
 
#define macsock_send PR_Send
189
 
#define macsock_sendto PR_SendTo
190
 
#define macsock_recvfrom PR_RecvFrom
191
 
#define macsock_recv PR_Recv
192
 
 
193
 
#ifdef __cplusplus
194
 
}
195
 
#endif
196
 
//extern int errno;
197
 
 
198
 
/*
199
 
macsock_sendmsg
200
 
macsock_readv
201
 
macsock_writev
202
 
*/
203
 
 
204
 
/* New definitions that are not defined in macsock.h in macsock library */
205
 
struct  protoent {
206
 
    char        *p_name;                /* official protocol name */
207
 
    char        **p_aliases;    /* alias list */
208
 
    int         p_proto;                /* protocol # */
209
 
};
210
 
 
211
 
extern struct protoent *getprotobyname(const char * name);
212
 
extern struct protoent *getprotobynumber(int number);
213
 
 
214
 
extern int gethostname (char *name, int namelen);
215
 
extern struct hostent *gethostbyname(const char * name);
216
 
extern struct hostent *gethostbyaddr(const void *addr, int addrlen, int type);
217
 
 
218
 
#define INADDR_LOOPBACK 0x7F000001
219
 
 
220
 
#define SO_KEEPALIVE    TCP_KEEPALIVE
221
 
#define SO_RCVBUF               XTI_RCVBUF
222
 
#define SO_SNDBUF               XTI_SNDBUF
223
 
#define SO_LINGER       XTI_LINGER          /* linger on close if data present */
224
 
 
225
 
#define IPPROTO_IP              INET_IP
226
 
 
227
 
/* Get/Set sock opt until fixed in NSPR 2.0 */
228
 
struct  linger {
229
 
        int     l_onoff;                /* option on/off */
230
 
        int     l_linger;               /* linger time */
231
 
};
232
 
 
233
 
struct ip_mreq {
234
 
        struct in_addr  imr_multiaddr;  /* IP multicast address of group */
235
 
        struct in_addr  imr_interface;  /* local IP address of interface */
236
 
};
237
 
 
238
 
#endif /* macksocket_h___ */