]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | /********************************************************************* |
2 | Project : GUSI - Grand Unified Socket Interface | |
3 | File : GUSI.h - Socket calls | |
4 | Author : Matthias Neeracher | |
5 | Language : MPW C/C++ | |
6 | *********************************************************************/ | |
7 | ||
8 | #ifndef _GUSI_ | |
9 | #define _GUSI_ | |
10 | ||
11 | #ifdef __MWERKS__ | |
12 | #ifndef macintosh | |
13 | #define macintosh 1 | |
14 | #endif | |
15 | #endif | |
16 | ||
17 | #ifdef macintosh | |
18 | #include <errno.h> | |
19 | #else | |
20 | #ifndef KERNEL | |
21 | extern int errno; /* global error number */ | |
22 | #endif | |
23 | #endif | |
24 | ||
25 | #define __P(protos) protos /* full-blown ANSI C */ | |
26 | ||
27 | #define EPERM 1 /* Operation not permitted */ | |
28 | /* MSL defines ENOMEM, EACCES, ENOENT, ENOSYS. We give in. */ | |
29 | #ifndef ENOENT | |
30 | #define ENOENT 2 /* No such file or directory */ | |
31 | #endif | |
32 | #define ESRCH 3 /* No such process */ | |
33 | #define EINTR 4 /* Interrupted system call */ | |
34 | #define EIO 5 /* Input/output error */ | |
35 | #define ENXIO 6 /* Device not configured */ | |
36 | #define E2BIG 7 /* Argument list too long */ | |
37 | #define ENOEXEC 8 /* Exec format error */ | |
38 | #define EBADF 9 /* Bad file descriptor */ | |
39 | #define ECHILD 10 /* No child processes */ | |
40 | #define EDEADLK 11 /* Resource deadlock avoided */ | |
41 | /* 11 was EAGAIN */ | |
42 | #ifndef ENOMEM | |
43 | #define ENOMEM 12 /* Cannot allocate memory */ | |
44 | #define EACCES 13 /* Permission denied */ | |
45 | #endif | |
46 | #define EFAULT 14 /* Bad address */ | |
47 | #ifndef _POSIX_SOURCE | |
48 | #define ENOTBLK 15 /* Block device required */ | |
49 | #define EBUSY 16 /* Device busy */ | |
50 | #endif | |
51 | #define EEXIST 17 /* File exists */ | |
52 | #define EXDEV 18 /* Cross-device link */ | |
53 | #define ENODEV 19 /* Operation not supported by device */ | |
54 | #define ENOTDIR 20 /* Not a directory */ | |
55 | #define EISDIR 21 /* Is a directory */ | |
56 | #define EINVAL 22 /* Invalid argument */ | |
57 | #define ENFILE 23 /* Too many open files in system */ | |
58 | #define EMFILE 24 /* Too many open files */ | |
59 | #define ENOTTY 25 /* Inappropriate ioctl for device */ | |
60 | #ifndef _POSIX_SOURCE | |
61 | #define ETXTBSY 26 /* Text file busy */ | |
62 | #endif | |
63 | #define EFBIG 27 /* File too large */ | |
64 | #define ENOSPC 28 /* No space left on device */ | |
65 | #define ESPIPE 29 /* Illegal seek */ | |
66 | #define EROFS 30 /* Read-only file system */ | |
67 | #define EMLINK 31 /* Too many links */ | |
68 | #define EPIPE 32 /* Broken pipe */ | |
69 | ||
70 | #ifndef __MWERKS__ | |
71 | /* math software */ | |
72 | #define EDOM 33 /* Numerical argument out of domain */ | |
73 | #define ERANGE 34 /* Result too large */ | |
74 | #endif | |
75 | ||
76 | /* non-blocking and interrupt i/o */ | |
77 | #if defined(macintosh) | |
78 | #ifndef EAGAIN | |
79 | #define EAGAIN 11 | |
80 | #endif | |
81 | #else | |
82 | #define EAGAIN 35 /* Resource temporarily unavailable */ | |
83 | #endif | |
84 | #define EWOULDBLOCK EAGAIN /* Operation would block */ | |
85 | #ifndef _POSIX_SOURCE | |
86 | /* Did I tell that MSL also occupies errnos 33-40? We give in. */ | |
87 | #if ENOMEM==37 | |
88 | #define EINPROGRESS 136 /* Operation now in progress */ | |
89 | #define EALREADY 137 /* Operation already in progress */ | |
90 | ||
91 | /* ipc/network software -- argument errors */ | |
92 | #define ENOTSOCK 138 /* Socket operation on non-socket */ | |
93 | #define EDESTADDRREQ 139 /* Destination address required */ | |
94 | #define EMSGSIZE 140 /* Message too long */ | |
95 | #else | |
96 | #define EINPROGRESS 36 /* Operation now in progress */ | |
97 | #define EALREADY 37 /* Operation already in progress */ | |
98 | ||
99 | /* ipc/network software -- argument errors */ | |
100 | #define ENOTSOCK 38 /* Socket operation on non-socket */ | |
101 | #define EDESTADDRREQ 39 /* Destination address required */ | |
102 | #define EMSGSIZE 40 /* Message too long */ | |
103 | #endif | |
104 | #define EPROTOTYPE 41 /* Protocol wrong type for socket */ | |
105 | #define ENOPROTOOPT 42 /* Protocol not available */ | |
106 | #define EPROTONOSUPPORT 43 /* Protocol not supported */ | |
107 | #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ | |
108 | #define EOPNOTSUPP 45 /* Operation not supported on socket */ | |
109 | #define EPFNOSUPPORT 46 /* Protocol family not supported */ | |
110 | #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ | |
111 | #define EADDRINUSE 48 /* Address already in use */ | |
112 | #define EADDRNOTAVAIL 49 /* Can't assign requested address */ | |
113 | ||
114 | /* ipc/network software -- operational errors */ | |
115 | #define ENETDOWN 50 /* Network is down */ | |
116 | #define ENETUNREACH 51 /* Network is unreachable */ | |
117 | #define ENETRESET 52 /* Network dropped connection on reset */ | |
118 | #define ECONNABORTED 53 /* Software caused connection abort */ | |
119 | #define ECONNRESET 54 /* Connection reset by peer */ | |
120 | #define ENOBUFS 55 /* No buffer space available */ | |
121 | #define EISCONN 56 /* Socket is already connected */ | |
122 | #define ENOTCONN 57 /* Socket is not connected */ | |
123 | #define ESHUTDOWN 58 /* Can't send after socket shutdown */ | |
124 | #define ETOOMANYREFS 59 /* Too many references: can't splice */ | |
125 | #define ETIMEDOUT 60 /* Connection timed out */ | |
126 | #define ECONNREFUSED 61 /* Connection refused */ | |
127 | ||
128 | #define ELOOP 62 /* Too many levels of symbolic links */ | |
129 | #endif /* _POSIX_SOURCE */ | |
130 | #define ENAMETOOLONG 63 /* File name too long */ | |
131 | ||
132 | /* should be rearranged */ | |
133 | #ifndef _POSIX_SOURCE | |
134 | #define EHOSTDOWN 64 /* Host is down */ | |
135 | #define EHOSTUNREACH 65 /* No route to host */ | |
136 | #endif /* _POSIX_SOURCE */ | |
137 | #define ENOTEMPTY 66 /* Directory not empty */ | |
138 | ||
139 | /* quotas & mush */ | |
140 | #ifndef _POSIX_SOURCE | |
141 | #define EPROCLIM 67 /* Too many processes */ | |
142 | #define EUSERS 68 /* Too many users */ | |
143 | #define EDQUOT 69 /* Disc quota exceeded */ | |
144 | ||
145 | /* Network File System */ | |
146 | #define ESTALE 70 /* Stale NFS file handle */ | |
147 | #define EREMOTE 71 /* Too many levels of remote in path */ | |
148 | #define EBADRPC 72 /* RPC struct is bad */ | |
149 | #define ERPCMISMATCH 73 /* RPC version wrong */ | |
150 | #define EPROGUNAVAIL 74 /* RPC prog. not avail */ | |
151 | #define EPROGMISMATCH 75 /* Program version wrong */ | |
152 | #define EPROCUNAVAIL 76 /* Bad procedure for program */ | |
153 | #endif /* _POSIX_SOURCE */ | |
154 | ||
155 | #define ENOLCK 77 /* No locks available */ | |
156 | ||
157 | #ifndef ENOSYS | |
158 | #define ENOSYS 78 /* Function not implemented */ | |
159 | #endif | |
160 | ||
161 | #define EFTYPE 79 /* Inappropriate file type or format */ | |
162 | ||
163 | #ifdef KERNEL | |
164 | /* pseudo-errors returned inside kernel to modify return to process */ | |
165 | #define ERESTART -1 /* restart syscall */ | |
166 | #define EJUSTRETURN -2 /* don't modify regs, just return */ | |
167 | #endif | |
168 | ||
169 | #define NBBY 8 /* number of bits in a byte */ | |
170 | ||
171 | /* | |
172 | * Select uses bit masks of file descriptors in longs. These macros | |
173 | * manipulate such bit fields (the filesystem macros use chars). | |
174 | * FD_SETSIZE may be defined by the user, but the default here should | |
175 | * be enough for most uses. | |
176 | */ | |
177 | #ifndef FD_SETSIZE | |
178 | #ifdef macintosh | |
179 | #define FD_SETSIZE 64 | |
180 | #else | |
181 | #define FD_SETSIZE 256 | |
182 | #endif | |
183 | #endif | |
184 | ||
185 | typedef long fd_mask; | |
186 | #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ | |
187 | ||
188 | #ifndef howmany | |
189 | #define howmany(x, y) (((x)+((y)-1))/(y)) | |
190 | #endif | |
191 | ||
192 | typedef struct fd_set { | |
193 | fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; | |
194 | } fd_set; | |
195 | ||
196 | #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) | |
197 | #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) | |
198 | #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) | |
199 | #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) | |
200 | ||
201 | // #include <sys/types.h> | |
202 | typedef unsigned char u_char; | |
203 | typedef unsigned short u_short; | |
204 | typedef unsigned int u_int; | |
205 | typedef unsigned long u_long; | |
206 | typedef unsigned short ushort; /* Sys V compatibility */ | |
207 | ||
208 | typedef char * caddr_t; /* core address */ | |
209 | typedef long daddr_t; /* disk address */ | |
210 | typedef short dev_t; /* device number */ | |
211 | typedef u_long ino_t; /* inode number */ | |
212 | typedef long off_t; /* file offset (should be a quad) */ | |
213 | typedef u_short nlink_t; /* link count */ | |
214 | typedef long swblk_t; /* swap offset */ | |
215 | typedef long segsz_t; /* segment size */ | |
216 | typedef u_short uid_t; /* user id */ | |
217 | typedef u_short gid_t; /* group id */ | |
218 | typedef short pid_t; /* process id */ | |
219 | typedef u_short mode_t; /* permissions */ | |
220 | typedef u_long fixpt_t; /* fixed point number */ | |
221 | ||
222 | ||
223 | // Feel free to increase FD_SETSIZE as needed | |
224 | #define GUSI_MAX_FD FD_SETSIZE | |
225 | ||
226 | //#include <sys/cdefs.h> | |
227 | ||
228 | #ifndef macintosh | |
229 | #ifdef __MWERKS__ | |
230 | #define macintosh 1 | |
231 | #endif | |
232 | #endif | |
233 | ||
234 | #if defined(__cplusplus) | |
235 | #define __BEGIN_DECLS extern "C" { | |
236 | #define __END_DECLS } | |
237 | #else | |
238 | #define __BEGIN_DECLS | |
239 | #define __END_DECLS | |
240 | #endif | |
241 | ||
242 | //#include <compat.h> | |
243 | //#include <sys/ioctl.h> | |
244 | #define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ | |
245 | #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) | |
246 | #define IOCBASECMD(x) ((x) & ~IOCPARM_MASK) | |
247 | #define IOCGROUP(x) (((x) >> 8) & 0xff) | |
248 | ||
249 | #define IOCPARM_MAX NBPG /* max size of ioctl, mult. of NBPG */ | |
250 | #define IOC_VOID 0x20000000 /* no parameters */ | |
251 | #define IOC_OUT 0x40000000 /* copy out parameters */ | |
252 | #define IOC_IN 0x80000000 /* copy in parameters */ | |
253 | #define IOC_INOUT (IOC_IN|IOC_OUT) | |
254 | #define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */ | |
255 | ||
256 | #define _IOC(inout,group,num,len) \ | |
257 | (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) | |
258 | #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) | |
259 | #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) | |
260 | #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) | |
261 | /* this should be _IORW, but stdio got there first */ | |
262 | #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) | |
263 | ||
264 | #define FIOCLEX _IO('f', 1) /* set close on exec on fd */ | |
265 | #define FIONCLEX _IO('f', 2) /* remove close on exec */ | |
266 | #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ | |
267 | #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ | |
268 | #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ | |
269 | #define FIOSETOWN _IOW('f', 124, int) /* set owner */ | |
270 | #define FIOGETOWN _IOR('f', 123, int) /* get owner */ | |
271 | ||
272 | __BEGIN_DECLS | |
273 | #ifdef macintosh | |
274 | int ioctl(int fildes, unsigned int cmd, unsigned long *arg); | |
275 | #else | |
276 | int ioctl __P((int, unsigned long, ...)); | |
277 | #endif | |
278 | __END_DECLS | |
279 | ||
280 | //#include <sys/fcntl.h> | |
281 | //#include <sys/stat.h> | |
282 | //#include <dirent.h> | |
283 | //#include <Types.h> | |
284 | //#include <Events.h> | |
285 | //#include <Files.h> | |
286 | //#include <AppleTalk.h> | |
287 | //#include <CTBUtilities.h> | |
288 | //#include <Packages.h> | |
289 | //#include <PPCToolBox.h> | |
290 | //#include <StandardFile.h> | |
291 | //#include <stdio.h> | |
292 | //#include <sys/time.h> | |
293 | ||
294 | ||
295 | /* | |
296 | * Definitions for byte order, according to byte significance from low | |
297 | * address to high. | |
298 | */ | |
299 | #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ | |
300 | #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ | |
301 | #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ | |
302 | ||
303 | #define BYTE_ORDER BIG_ENDIAN | |
304 | ||
305 | __BEGIN_DECLS | |
306 | unsigned long htonl (unsigned long); | |
307 | unsigned short htons (unsigned short); | |
308 | unsigned long ntohl (unsigned long); | |
309 | unsigned short ntohs (unsigned short); | |
310 | __END_DECLS | |
311 | ||
312 | /* | |
313 | * Macros for network/external number representation conversion. | |
314 | */ | |
315 | #if BYTE_ORDER == BIG_ENDIAN && !defined(lint) | |
316 | #define ntohl(x) (x) | |
317 | #define ntohs(x) (x) | |
318 | #define htonl(x) (x) | |
319 | #define htons(x) (x) | |
320 | ||
321 | #define NTOHL(x) (x) | |
322 | #define NTOHS(x) (x) | |
323 | #define HTONL(x) (x) | |
324 | #define HTONS(x) (x) | |
325 | ||
326 | #else | |
327 | ||
328 | #define NTOHL(x) (x) = ntohl((u_long)x) | |
329 | #define NTOHS(x) (x) = ntohs((u_short)x) | |
330 | #define HTONL(x) (x) = htonl((u_long)x) | |
331 | #define HTONS(x) (x) = htons((u_short)x) | |
332 | #endif | |
333 | ||
334 | ||
335 | ||
336 | /* | |
337 | * Constants and structures defined by the internet system, | |
338 | * Per RFC 790, September 1981. | |
339 | */ | |
340 | ||
341 | /* | |
342 | * Protocols | |
343 | */ | |
344 | #define IPPROTO_IP 0 /* dummy for IP */ | |
345 | #define IPPROTO_ICMP 1 /* control message protocol */ | |
346 | #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ | |
347 | #define IPPROTO_TCP 6 /* tcp */ | |
348 | #define IPPROTO_EGP 8 /* exterior gateway protocol */ | |
349 | #define IPPROTO_PUP 12 /* pup */ | |
350 | #define IPPROTO_UDP 17 /* user datagram protocol */ | |
351 | #define IPPROTO_IDP 22 /* xns idp */ | |
352 | #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ | |
353 | #define IPPROTO_EON 80 /* ISO cnlp */ | |
354 | ||
355 | #define IPPROTO_RAW 255 /* raw IP packet */ | |
356 | #define IPPROTO_MAX 256 | |
357 | ||
358 | ||
359 | /* | |
360 | * Local port number conventions: | |
361 | * Ports < IPPORT_RESERVED are reserved for | |
362 | * privileged processes (e.g. root). | |
363 | * Ports > IPPORT_USERRESERVED are reserved | |
364 | * for servers, not necessarily privileged. | |
365 | */ | |
366 | #define IPPORT_RESERVED 1024 | |
367 | #define IPPORT_USERRESERVED 5000 | |
368 | ||
369 | /* | |
370 | * Internet address (a structure for historical reasons) | |
371 | */ | |
372 | struct in_addr { | |
373 | u_long s_addr; | |
374 | }; | |
375 | ||
376 | /* | |
377 | * Definitions of bits in internet address integers. | |
378 | * On subnets, the decomposition of addresses to host and net parts | |
379 | * is done according to subnet mask, not the masks here. | |
380 | */ | |
381 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) | |
382 | #define IN_CLASSA_NET 0xff000000 | |
383 | #define IN_CLASSA_NSHIFT 24 | |
384 | #define IN_CLASSA_HOST 0x00ffffff | |
385 | #define IN_CLASSA_MAX 128 | |
386 | ||
387 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) | |
388 | #define IN_CLASSB_NET 0xffff0000 | |
389 | #define IN_CLASSB_NSHIFT 16 | |
390 | #define IN_CLASSB_HOST 0x0000ffff | |
391 | #define IN_CLASSB_MAX 65536 | |
392 | ||
393 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) | |
394 | #define IN_CLASSC_NET 0xffffff00 | |
395 | #define IN_CLASSC_NSHIFT 8 | |
396 | #define IN_CLASSC_HOST 0x000000ff | |
397 | ||
398 | #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) | |
399 | #define IN_MULTICAST(i) IN_CLASSD(i) | |
400 | ||
401 | #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) | |
402 | #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) | |
403 | ||
404 | #define INADDR_ANY (u_long)0x00000000 | |
405 | #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ | |
406 | #ifndef KERNEL | |
407 | #define INADDR_NONE 0xffffffff /* -1 return */ | |
408 | #endif | |
409 | ||
410 | #define IN_LOOPBACKNET 127 /* official! */ | |
411 | ||
412 | /* | |
413 | * Socket address, internet style. | |
414 | */ | |
415 | struct sockaddr_in { | |
416 | u_char sin_len; | |
417 | u_char sin_family; | |
418 | u_short sin_port; | |
419 | struct in_addr sin_addr; | |
420 | char sin_zero[8]; | |
421 | }; | |
422 | ||
423 | /* | |
424 | * Structure used to describe IP options. | |
425 | * Used to store options internally, to pass them to a process, | |
426 | * or to restore options retrieved earlier. | |
427 | * The ip_dst is used for the first-hop gateway when using a source route | |
428 | * (this gets put into the header proper). | |
429 | */ | |
430 | #ifdef __MWERKS__ | |
431 | #pragma cplusplus off | |
432 | #endif | |
433 | struct ip_opts { | |
434 | struct in_addr ip_dst; /* first hop, 0 w/o src rt */ | |
435 | char ip_opts[40]; /* actually variable in size */ | |
436 | }; | |
437 | #ifdef __MWERKS__ | |
438 | #pragma cplusplus reset | |
439 | #endif | |
440 | ||
441 | /* | |
442 | * Options for use with [gs]etsockopt at the IP level. | |
443 | * First word of comment is data type; bool is stored in int. | |
444 | */ | |
445 | #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP per-packet options */ | |
446 | #define IP_HDRINCL 2 /* int; header is included with data (raw) */ | |
447 | #define IP_TOS 3 /* int; IP type of service and precedence */ | |
448 | #define IP_TTL 4 /* int; IP time to live */ | |
449 | #define IP_RECVOPTS 5 /* bool; receive all IP options w/datagram */ | |
450 | #define IP_RECVRETOPTS 6 /* bool; receive IP options for response */ | |
451 | #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/datagram */ | |
452 | #define IP_RETOPTS 8 /* ip_opts; set/get IP per-packet options */ | |
453 | ||
454 | /* | |
455 | * Structure returned by gettimeofday(2) system call, | |
456 | * and used in other calls. | |
457 | */ | |
458 | struct timeval { | |
459 | long tv_sec; /* seconds */ | |
460 | long tv_usec; /* and microseconds */ | |
461 | }; | |
462 | ||
463 | struct timezone { | |
464 | int tz_minuteswest; /* minutes west of Greenwich */ | |
465 | int tz_dsttime; /* type of dst correction */ | |
466 | }; | |
467 | #define DST_NONE 0 /* not on dst */ | |
468 | #define DST_USA 1 /* USA style dst */ | |
469 | #define DST_AUST 2 /* Australian style dst */ | |
470 | #define DST_WET 3 /* Western European dst */ | |
471 | #define DST_MET 4 /* Middle European dst */ | |
472 | #define DST_EET 5 /* Eastern European dst */ | |
473 | #define DST_CAN 6 /* Canada */ | |
474 | //#include <sys/socket.h> | |
475 | ||
476 | /* | |
477 | * Definitions related to sockets: types, address families, options. | |
478 | */ | |
479 | ||
480 | /* | |
481 | * Types | |
482 | */ | |
483 | #define SOCK_STREAM 1 /* stream socket */ | |
484 | #define SOCK_DGRAM 2 /* datagram socket */ | |
485 | #define SOCK_RAW 3 /* raw-protocol interface */ | |
486 | #define SOCK_RDM 4 /* reliably-delivered message */ | |
487 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */ | |
488 | ||
489 | /* | |
490 | * Option flags per-socket. | |
491 | */ | |
492 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */ | |
493 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ | |
494 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */ | |
495 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */ | |
496 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */ | |
497 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ | |
498 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ | |
499 | #define SO_LINGER 0x0080 /* linger on close if data present */ | |
500 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ | |
501 | ||
502 | /* | |
503 | * Additional options, not kept in so_options. | |
504 | */ | |
505 | #define SO_SNDBUF 0x1001 /* send buffer size */ | |
506 | #define SO_RCVBUF 0x1002 /* receive buffer size */ | |
507 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */ | |
508 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ | |
509 | #define SO_SNDTIMEO 0x1005 /* send timeout */ | |
510 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ | |
511 | #define SO_ERROR 0x1007 /* get error status and clear */ | |
512 | #define SO_TYPE 0x1008 /* get socket type */ | |
513 | ||
514 | /* | |
515 | * Structure used for manipulating linger option. | |
516 | */ | |
517 | struct linger { | |
518 | int l_onoff; /* option on/off */ | |
519 | int l_linger; /* linger time */ | |
520 | }; | |
521 | ||
522 | /* | |
523 | * Level number for (get/set)sockopt() to apply to socket itself. | |
524 | */ | |
525 | #define SOL_SOCKET 0xffff /* options for socket level */ | |
526 | ||
527 | /* | |
528 | * Address families. | |
529 | */ | |
530 | #ifdef macintosh | |
531 | #define AF_UNSPEC 0 /* unspecified */ | |
532 | #define AF_UNIX 1 /* local to host (pipes, portals) */ | |
533 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ | |
534 | #define AF_CTB 3 /* Apple Comm Toolbox (not yet supported) */ | |
535 | #define AF_FILE 4 /* Normal File I/O (used internally) */ | |
536 | #define AF_PPC 5 /* PPC Toolbox */ | |
537 | #define AF_PAP 6 /* Printer Access Protocol (client only) */ | |
538 | #define AF_APPLETALK 16 /* Apple Talk */ | |
539 | ||
540 | #define AF_MAX 20 | |
541 | #else | |
542 | #define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */ | |
543 | #define AF_UNSPEC 0 /* unspecified */ | |
544 | #define AF_UNIX 1 /* local to host (pipes, portals) */ | |
545 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ | |
546 | #define AF_IMPLINK 3 /* arpanet imp addresses */ | |
547 | #define AF_PUP 4 /* pup protocols: e.g. BSP */ | |
548 | #define AF_CHAOS 5 /* mit CHAOS protocols */ | |
549 | #define AF_NS 6 /* XEROX NS protocols */ | |
550 | #define AF_ISO 7 /* ISO protocols */ | |
551 | #define AF_OSI AF_ISO | |
552 | #define AF_ECMA 8 /* european computer manufacturers */ | |
553 | #define AF_DATAKIT 9 /* datakit protocols */ | |
554 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ | |
555 | #define AF_SNA 11 /* IBM SNA */ | |
556 | #define AF_DECnet 12 /* DECnet */ | |
557 | #define AF_DLI 13 /* DEC Direct data link interface */ | |
558 | #define AF_LAT 14 /* LAT */ | |
559 | #define AF_HYLINK 15 /* NSC Hyperchannel */ | |
560 | #define AF_APPLETALK16 /* Apple Talk */ | |
561 | #define AF_ROUTE 17 /* Internal Routing Protocol */ | |
562 | #define AF_LINK 18 /* Link layer interface */ | |
563 | #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ | |
564 | ||
565 | #define AF_MAX 20 | |
566 | #endif | |
567 | ||
568 | /* | |
569 | * Structure used by kernel to store most | |
570 | * addresses. | |
571 | */ | |
572 | #if defined(powerc) || defined (__powerc) | |
573 | #pragma options align=mac68k | |
574 | #endif | |
575 | struct sockaddr { | |
576 | u_char sa_len; /* total length */ | |
577 | u_char sa_family; /* address family */ | |
578 | char sa_data[14]; /* actually longer; address value */ | |
579 | }; | |
580 | #if defined(powerc) || defined (__powerc) | |
581 | #pragma options align=reset | |
582 | #endif | |
583 | ||
584 | /* | |
585 | * Structure used by kernel to pass protocol | |
586 | * information in raw sockets. | |
587 | */ | |
588 | struct sockproto { | |
589 | u_short sp_family; /* address family */ | |
590 | u_short sp_protocol; /* protocol */ | |
591 | }; | |
592 | ||
593 | /* | |
594 | * Protocol families, same as address families for now. | |
595 | */ | |
596 | #ifdef macintosh | |
597 | #define PF_UNSPEC AF_UNSPEC /* unspecified */ | |
598 | #define PF_UNIX AF_UNIX /* local to host (pipes, portals) */ | |
599 | #define PF_INET AF_INET /* internetwork: UDP, TCP, etc. */ | |
600 | #define PF_CTB AF_CTB /* Apple Comm Toolbox (not yet supported) */ | |
601 | #define PF_FILE AF_FILE /* Normal File I/O (used internally) */ | |
602 | #define PF_PPC AF_PPC /* PPC Toolbox */ | |
603 | #define PF_PAP AF_PAP /* Printer Access Protocol (client only) */ | |
604 | #define PF_APPLETALK AF_APPLETALK /* Apple Talk */ | |
605 | #else | |
606 | #define PF_UNSPEC AF_UNSPEC | |
607 | #define PF_UNIX AF_UNIX | |
608 | #define PF_INET AF_INET | |
609 | #define PF_IMPLINK AF_IMPLINK | |
610 | #define PF_PUP AF_PUP | |
611 | #define PF_CHAOS AF_CHAOS | |
612 | #define PF_NS AF_NS | |
613 | #define PF_ISO AF_ISO | |
614 | #define PF_OSI AF_ISO | |
615 | #define PF_ECMA AF_ECMA | |
616 | #define PF_DATAKIT AF_DATAKIT | |
617 | #define PF_CCITT AF_CCITT | |
618 | #define PF_SNA AF_SNA | |
619 | #define PF_DECnet AF_DECnet | |
620 | #define PF_DLI AF_DLI | |
621 | #define PF_LAT AF_LAT | |
622 | #define PF_HYLINK AF_HYLINK | |
623 | #define PF_APPLETALK AF_APPLETALK | |
624 | #define PF_ROUTE AF_ROUTE | |
625 | #define PF_LINK AF_LINK | |
626 | #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ | |
627 | #endif | |
628 | ||
629 | #define PF_MAX AF_MAX | |
630 | ||
631 | /* | |
632 | * Maximum queue length specifiable by listen. | |
633 | */ | |
634 | #define SOMAXCONN 5 | |
635 | ||
636 | /* | |
637 | * Message header for recvmsg and sendmsg calls. | |
638 | * Used value-result for recvmsg, value only for sendmsg. | |
639 | */ | |
640 | struct msghdr { | |
641 | caddr_t msg_name; /* optional address */ | |
642 | u_int msg_namelen; /* size of address */ | |
643 | struct iovec *msg_iov; /* scatter/gather array */ | |
644 | u_int msg_iovlen; /* # elements in msg_iov */ | |
645 | caddr_t msg_control; /* ancillary data, see below */ | |
646 | u_int msg_controllen; /* ancillary data buffer len */ | |
647 | int msg_flags; /* flags on received message */ | |
648 | }; | |
649 | ||
650 | #define MSG_OOB 0x1 /* process out-of-band data */ | |
651 | #define MSG_PEEK 0x2 /* peek at incoming message */ | |
652 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */ | |
653 | #define MSG_EOR 0x8 /* data completes record */ | |
654 | #define MSG_TRUNC 0x10 /* data discarded before delivery */ | |
655 | #define MSG_CTRUNC 0x20 /* control data lost before delivery */ | |
656 | #define MSG_WAITALL 0x40 /* wait for full request or error */ | |
657 | ||
658 | /* | |
659 | * Header for ancillary data objects in msg_control buffer. | |
660 | * Used for additional information with/about a datagram | |
661 | * not expressible by flags. The format is a sequence | |
662 | * of message elements headed by cmsghdr structures. | |
663 | */ | |
664 | struct cmsghdr { | |
665 | u_int cmsg_len; /* data byte count, including hdr */ | |
666 | int cmsg_level; /* originating protocol */ | |
667 | int cmsg_type; /* protocol-specific type */ | |
668 | /* followed by u_char cmsg_data[]; */ | |
669 | }; | |
670 | ||
671 | /* given pointer to struct adatahdr, return pointer to data */ | |
672 | #define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1)) | |
673 | ||
674 | /* given pointer to struct adatahdr, return pointer to next adatahdr */ | |
675 | #define CMSG_NXTHDR(mhdr, cmsg) \ | |
676 | (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \ | |
677 | (mhdr)->msg_control + (mhdr)->msg_controllen) ? \ | |
678 | (struct cmsghdr *)NULL : \ | |
679 | (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len))) | |
680 | ||
681 | #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) | |
682 | ||
683 | /* "Socket"-level control message types: */ | |
684 | #define SCM_RIGHTS 0x01 /* access rights (array of int) */ | |
685 | ||
686 | /* | |
687 | * 4.3 compat sockaddr, move to compat file later | |
688 | */ | |
689 | struct osockaddr { | |
690 | u_short sa_family; /* address family */ | |
691 | char sa_data[14]; /* up to 14 bytes of direct address */ | |
692 | }; | |
693 | ||
694 | /* | |
695 | * 4.3-compat message header (move to compat file later). | |
696 | */ | |
697 | struct omsghdr { | |
698 | caddr_t msg_name; /* optional address */ | |
699 | int msg_namelen; /* size of address */ | |
700 | struct iovec *msg_iov; /* scatter/gather array */ | |
701 | int msg_iovlen; /* # elements in msg_iov */ | |
702 | caddr_t msg_accrights; /* access rights sent/received */ | |
703 | int msg_accrightslen; | |
704 | }; | |
705 | ||
706 | //#include <string.h> | |
707 | //#include <netinet/in.h> | |
708 | //#include <netdb.h> | |
709 | //#include <sys/un.h> | |
710 | //#include <unistd.h> | |
711 | //#include <machine/endian.h> | |
712 | // | |
713 | ||
714 | typedef enum spin_msg { | |
715 | SP_MISC, /* some weird thing, usually just return immediately if you get this */ | |
716 | SP_SELECT, /* in a select call */ | |
717 | SP_NAME, /* getting a host by name */ | |
718 | SP_ADDR, /* getting a host by address */ | |
719 | SP_STREAM_READ, /* Stream read call */ | |
720 | SP_STREAM_WRITE, /* Stream write call */ | |
721 | SP_DGRAM_READ, /* Datagram read call */ | |
722 | SP_DGRAM_WRITE, /* Datagram write call */ | |
723 | SP_SLEEP, /* sleeping, passes ticks left to sleep */ | |
724 | SP_AUTO_SPIN /* Autospin, passes argument to SpinCursor */ | |
725 | } spin_msg; | |
726 | ||
727 | typedef int (*GUSISpinFn)(spin_msg msg, long param); | |
728 | typedef void (*GUSIEvtHandler)(EventRecord * ev); | |
729 | typedef GUSIEvtHandler GUSIEvtTable[24]; | |
730 | ||
731 | /* | |
732 | * Address families, defined in sys/socket.h | |
733 | * | |
734 | ||
735 | #define AF_UNSPEC 0 // unspecified | |
736 | #define AF_UNIX 1 // local to host (pipes, portals) | |
737 | #define AF_INET 2 // internetwork: UDP, TCP, etc. | |
738 | #define AF_CTB 3 // Apple Comm Toolbox (not yet supported) | |
739 | #define AF_FILE 4 // Normal File I/O (used internally) | |
740 | #define AF_PPC 5 // PPC Toolbox | |
741 | #define AF_PAP 6 // Printer Access Protocol (client only) | |
742 | #define AF_APPLETALK 16 // Apple Talk | |
743 | ||
744 | */ | |
745 | ||
746 | #define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */ | |
747 | ||
748 | /* | |
749 | * Some Implementations of GUSI require you to call GUSISetup for the | |
750 | * socket families you'd like to have defined. It's a good idea to call | |
751 | * this for *all* implementations. | |
752 | * | |
753 | * GUSIDefaultSetup() will include all socket families. | |
754 | * | |
755 | * Never call any of the GUSIwithXXX routines directly. | |
756 | */ | |
757 | ||
758 | __BEGIN_DECLS | |
759 | void GUSIwithAppleTalkSockets(); | |
760 | void GUSIwithInternetSockets(); | |
761 | void GUSIwithPAPSockets(); | |
762 | void GUSIwithPPCSockets(); | |
763 | void GUSIwithUnixSockets(); | |
764 | void GUSIwithSIOUXSockets(); | |
765 | void GUSIwithMPWSockets(); | |
766 | ||
767 | void GUSISetup(void (*socketfamily)()); | |
768 | void GUSIDefaultSetup(); | |
769 | __END_DECLS | |
770 | /* | |
771 | * Types, defined in sys/socket.h | |
772 | * | |
773 | ||
774 | #define SOCK_STREAM 1 // stream socket | |
775 | #define SOCK_DGRAM 2 // datagram socket | |
776 | ||
777 | */ | |
778 | ||
779 | /* | |
780 | * Defined in sys/un.h | |
781 | * | |
782 | ||
783 | struct sockaddr_un { | |
784 | short sun_family; | |
785 | char sun_path[108]; | |
786 | }; | |
787 | ||
788 | */ | |
789 | ||
790 | #ifndef PRAGMA_ALIGN_SUPPORTED | |
791 | #error Apple had some fun with the conditional macros again | |
792 | #endif | |
793 | ||
794 | #if PRAGMA_ALIGN_SUPPORTED | |
795 | #pragma options align=mac68k | |
796 | #endif | |
797 | ||
798 | /* | |
799 | struct sockaddr_atlk { | |
800 | short family; | |
801 | AddrBlock addr; | |
802 | }; | |
803 | ||
804 | struct sockaddr_atlk_sym { | |
805 | short family; | |
806 | EntityName name; | |
807 | }; | |
808 | ||
809 | struct sockaddr_ppc { | |
810 | short family; | |
811 | LocationNameRec location; | |
812 | PPCPortRec port; | |
813 | }; | |
814 | ||
815 | // Definitions for choose() | |
816 | ||
817 | #define CHOOSE_DEFAULT 1 | |
818 | #define CHOOSE_NEW 2 | |
819 | #define CHOOSE_DIR 4 | |
820 | ||
821 | typedef struct { | |
822 | short numTypes; | |
823 | SFTypeList types; | |
824 | } sa_constr_file; | |
825 | ||
826 | typedef struct { | |
827 | short numTypes; | |
828 | NLType types; | |
829 | } sa_constr_atlk; | |
830 | ||
831 | ||
832 | // Definitions for sa_constr_ppc | |
833 | ||
834 | #define PPC_CON_NEWSTYLE 0x8000 | |
835 | #define PPC_CON_MATCH_NAME 0x0001 | |
836 | #define PPC_CON_MATCH_TYPE 0x0002 | |
837 | #define PPC_CON_MATCH_NBP 0x0004 | |
838 | ||
839 | typedef struct { | |
840 | short flags; | |
841 | Str32 nbpType; | |
842 | PPCPortRec match; | |
843 | } sa_constr_ppc; | |
844 | ||
845 | */ | |
846 | ||
847 | #if PRAGMA_ALIGN_SUPPORTED | |
848 | #pragma options align=reset | |
849 | #endif | |
850 | ||
851 | __BEGIN_DECLS | |
852 | /* | |
853 | * IO/Socket stuff, defined elsewhere (unistd.h, sys/socket.h | |
854 | * | |
855 | */ | |
856 | int socket(int domain, int type, short protocol); | |
857 | int bind(int s, void *name, int namelen); | |
858 | int connect(int s, void *addr, int addrlen); | |
859 | int listen(int s, int qlen); | |
860 | int accept(int s, void *addr, int *addrlen); | |
861 | int close(int s); | |
862 | int read(int s, char *buffer, unsigned buflen); | |
863 | int readv(int s, struct iovec *iov, int count); | |
864 | int recv(int s, void *buffer, int buflen, int flags); | |
865 | int recvfrom(int s, void *buffer, int buflen, int flags, void *from, int *fromlen); | |
866 | int recvmsg(int s,struct msghdr *msg,int flags); | |
867 | int write(int s, const char *buffer, unsigned buflen); | |
868 | int writev(int s, struct iovec *iov, int count); | |
869 | int send(int s, void *buffer, int buflen, int flags); | |
870 | int sendto (int s, void *buffer, int buflen, int flags, void *to, int tolen); | |
871 | int sendmsg(int s,struct msghdr *msg,int flags); | |
872 | int select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); | |
873 | int getdtablesize(void); | |
874 | int getsockname(int s, void *name, int *namelen); | |
875 | int getpeername(int s, struct sockaddr *name, int *namelen); | |
876 | int shutdown(int s, int how); | |
877 | int fcntl(int s, unsigned int cmd, int arg); | |
878 | int dup(int s); | |
879 | int dup2(int s, int s1); | |
880 | //int ioctl(int d, unsigned int request, long *argp); | |
881 | int getsockopt(int s, int level, int optname, char *optval, int * optlen); | |
882 | int setsockopt(int s, int level, int optname, char *optval, int optlen); | |
883 | int isatty(int); | |
884 | int remove(const char *filename); | |
885 | int rename(const char *oldname, const char *newname); | |
886 | int creat(const char*); | |
887 | int faccess(char*, unsigned int, long*); | |
888 | long lseek(int, long, int); | |
889 | int open(const char*, int); | |
890 | int unlink(char*); | |
891 | int symlink(char* linkto, char* linkname); | |
892 | int readlink(char* path, char* buf, int bufsiz); | |
893 | int truncate(char *path, long length); | |
894 | int ftruncate(int fd, long length); | |
895 | int chdir(char * path); | |
896 | int mkdir(char * path); | |
897 | int rmdir(char * path); | |
898 | char * getcwd(char * buf, int size); | |
899 | ||
900 | ||
901 | /* | |
902 | * Defined in stdio.h | |
903 | */ | |
904 | ||
905 | #ifdef __MWERKS__ | |
906 | void fsetfileinfo (char *filename, unsigned long newcreator, unsigned long newtype); | |
907 | #endif | |
908 | ||
909 | void fgetfileinfo (char *filename, unsigned long * creator, unsigned long * type); | |
910 | ||
911 | #ifdef __MWERKS__ | |
912 | FILE *fdopen(int fd, const char *mode); | |
913 | int fwalk(int (*func)(FILE * stream)); | |
914 | #endif | |
915 | ||
916 | int choose( | |
917 | int domain, | |
918 | int type, | |
919 | char * prompt, | |
920 | void * constraint, | |
921 | int flags, | |
922 | void * name, | |
923 | int * namelen); | |
924 | ||
925 | /* | |
926 | * Hostname routines, defined in netdb.h | |
927 | * | |
928 | */ | |
929 | ||
930 | /* | |
931 | * Structures returned by network data base library. All addresses are | |
932 | * supplied in host order, and returned in network order (suitable for | |
933 | * use in system calls). | |
934 | */ | |
935 | struct hostent { | |
936 | char *h_name; /* official name of host */ | |
937 | char **h_aliases; /* alias list */ | |
938 | int h_addrtype; /* host address type */ | |
939 | int h_length; /* length of address */ | |
940 | char **h_addr_list; /* list of addresses from name server */ | |
941 | #define h_addr h_addr_list[0] /* address, for backward compatiblity */ | |
942 | }; | |
943 | ||
944 | /* | |
945 | * Assumption here is that a network number | |
946 | * fits in 32 bits -- probably a poor one. | |
947 | */ | |
948 | struct netent { | |
949 | char *n_name; /* official name of net */ | |
950 | char **n_aliases; /* alias list */ | |
951 | int n_addrtype; /* net address type */ | |
952 | unsigned long n_net; /* network # */ | |
953 | }; | |
954 | ||
955 | struct servent { | |
956 | char *s_name; /* official service name */ | |
957 | char **s_aliases; /* alias list */ | |
958 | int s_port; /* port # */ | |
959 | char *s_proto; /* protocol to use */ | |
960 | }; | |
961 | ||
962 | struct protoent { | |
963 | char *p_name; /* official protocol name */ | |
964 | char **p_aliases; /* alias list */ | |
965 | int p_proto; /* protocol # */ | |
966 | }; | |
967 | ||
968 | /* | |
969 | * Error return codes from gethostbyname() and gethostbyaddr() | |
970 | * (left in extern int h_errno). | |
971 | */ | |
972 | ||
973 | #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ | |
974 | #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ | |
975 | #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ | |
976 | #define NO_DATA 4 /* Valid name, no data record of requested type */ | |
977 | #define NO_ADDRESS NO_DATA /* no address, look for MX record */ | |
978 | ||
979 | int gethostname(char *machname, long buflen); | |
980 | ||
981 | void endhostent __P((void)); | |
982 | void endnetent __P((void)); | |
983 | void endprotoent __P((void)); | |
984 | void endservent __P((void)); | |
985 | struct hostent *gethostbyaddr __P((const char *, int, int)); | |
986 | struct hostent *gethostbyname __P((const char *)); | |
987 | struct hostent *gethostent __P((void)); | |
988 | struct netent *getnetbyaddr __P((long, int)); /* u_long? */ | |
989 | struct netent *getnetbyname __P((const char *)); | |
990 | struct netent *getnetent __P((void)); | |
991 | struct protoent *getprotobyname __P((const char *)); | |
992 | struct protoent *getprotobynumber __P((int)); | |
993 | struct protoent *getprotoent __P((void)); | |
994 | struct servent *getservbyname __P((const char *, const char *)); | |
995 | struct servent *getservbyport __P((int, const char *)); | |
996 | struct servent *getservent __P((void)); | |
997 | void herror __P((const char *)); | |
998 | void sethostent __P((int)); | |
999 | /* void sethostfile __P((const char *)); */ | |
1000 | void setnetent __P((int)); | |
1001 | void setprotoent __P((int)); | |
1002 | void setservent __P((int)); | |
1003 | ||
1004 | ||
1005 | char * inet_ntoa(struct in_addr inaddr); | |
1006 | struct in_addr inet_addr(const char *address); | |
1007 | ||
1008 | /* | |
1009 | * GUSI supports a number of hooks. Every one of them has a different prototype, but needs | |
1010 | * to be passed as a GUSIHook | |
1011 | */ | |
1012 | ||
1013 | typedef enum { | |
1014 | GUSI_SpinHook, /* A GUSISpinFn, to be called when a call blocks */ | |
1015 | GUSI_ExecHook, /* Boolean (*hook)(const GUSIFileRef & ref), decides if file is executable */ | |
1016 | GUSI_FTypeHook,/* Boolean (*hook)(const FSSpec & spec) sets a default file type */ | |
1017 | GUSI_SpeedHook /* A long integer, to be added to the cursor spin variable */ | |
1018 | } GUSIHookCode; | |
1019 | ||
1020 | typedef void (*GUSIHook)(void); | |
1021 | void GUSISetHook(GUSIHookCode code, GUSIHook hook); | |
1022 | GUSIHook GUSIGetHook(GUSIHookCode code); | |
1023 | ||
1024 | /* | |
1025 | * What to do when a routine blocks | |
1026 | */ | |
1027 | ||
1028 | /* Defined for compatibility */ | |
1029 | #define GUSISetSpin(routine) GUSISetHook(GUSI_SpinHook, (GUSIHook)routine) | |
1030 | #define GUSIGetSpin() (GUSISpinFn) GUSIGetHook(GUSI_SpinHook) | |
1031 | ||
1032 | int GUSISetEvents(GUSIEvtTable table); | |
1033 | GUSIEvtHandler * GUSIGetEvents(void); | |
1034 | ||
1035 | extern GUSIEvtHandler GUSISIOWEvents[]; | |
1036 | ||
1037 | #define SIGPIPE 13 | |
1038 | #define SIGALRM 14 | |
1039 | ||
1040 | /* | |
1041 | * BSD memory routines, defined in compat.h | |
1042 | * | |
1043 | */ | |
1044 | #define index(a, b) strchr(a, b) | |
1045 | #define rindex(a, b) strrchr(a, b) | |
1046 | #define bzero(from, len) memset(from, 0, len) | |
1047 | #define bcopy(from, to, len) memcpy(to, from, len) | |
1048 | #define bcmp(s1, s2, len) memcmp(s1, s2, len) | |
1049 | #define bfill(from, len, x) memset(from, x, len) | |
1050 | ||
1051 | ||
1052 | __END_DECLS | |
1053 | ||
1054 | typedef struct wxSockInternal | |
1055 | { | |
1056 | long nothing ; | |
1057 | } ; | |
1058 | ||
1059 | #endif /* !_GUSI_ */ |