Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d6a6ea

Browse files
committed
Putting Python-specific GUSI modifications under CVS.
1 parent b0195ec commit 1d6a6ea

6 files changed

Lines changed: 3264 additions & 0 deletions

File tree

Mac/GUSI-mods/into-include/GUSI.h

Lines changed: 366 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,366 @@
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+
$Log$
8+
Revision 1.1 1998/08/18 14:52:33 jack
9+
Putting Python-specific GUSI modifications under CVS.
10+
11+
Revision 1.2 1994/12/31 01:45:54 neeri
12+
Fix alignment.
13+
14+
Revision 1.1 1994/02/25 02:56:49 neeri
15+
Initial revision
16+
17+
Revision 0.15 1993/06/27 00:00:00 neeri
18+
f?truncate
19+
20+
Revision 0.14 1993/06/20 00:00:00 neeri
21+
Changed sa_constr_ppc
22+
23+
Revision 0.13 1993/02/14 00:00:00 neeri
24+
AF_PAP
25+
26+
Revision 0.12 1992/12/08 00:00:00 neeri
27+
getcwd()
28+
29+
Revision 0.11 1992/11/15 00:00:00 neeri
30+
remove netdb.h definitions
31+
32+
Revision 0.10 1992/09/26 00:00:00 neeri
33+
Separate dirent and stat
34+
35+
Revision 0.9 1992/09/12 00:00:00 neeri
36+
Hostname stuff
37+
38+
Revision 0.8 1992/09/07 00:00:00 neeri
39+
readlink()
40+
41+
Revision 0.7 1992/08/03 00:00:00 neeri
42+
sa_constr_ppc
43+
44+
Revision 0.6 1992/07/21 00:00:00 neeri
45+
sockaddr_atlk_sym
46+
47+
Revision 0.5 1992/06/26 00:00:00 neeri
48+
choose()
49+
50+
Revision 0.4 1992/05/18 00:00:00 neeri
51+
PPC stuff
52+
53+
Revision 0.3 1992/04/27 00:00:00 neeri
54+
getsockopt()
55+
56+
Revision 0.2 1992/04/19 00:00:00 neeri
57+
C++ compatibility
58+
59+
Revision 0.1 1992/04/17 00:00:00 neeri
60+
bzero()
61+
62+
*********************************************************************/
63+
64+
#ifndef _GUSI_
65+
#define _GUSI_
66+
67+
#include <sys/types.h>
68+
69+
/* Feel free to increase FD_SETSIZE as needed */
70+
#define GUSI_MAX_FD FD_SETSIZE
71+
72+
#include <sys/cdefs.h>
73+
#include <compat.h>
74+
#include <sys/ioctl.h>
75+
#include <sys/fcntl.h>
76+
#include <sys/stat.h>
77+
#include <dirent.h>
78+
#include <Types.h>
79+
#include <Events.h>
80+
#include <Files.h>
81+
#include <AppleTalk.h>
82+
#include <CTBUtilities.h>
83+
#include <Packages.h>
84+
#include <PPCToolBox.h>
85+
#include <StandardFile.h>
86+
#include <stdio.h>
87+
#include <sys/time.h>
88+
#include <sys/socket.h>
89+
#include <string.h>
90+
#include <netinet/in.h>
91+
#include <netdb.h>
92+
#include <sys/un.h>
93+
#include <unistd.h>
94+
#include <machine/endian.h>
95+
96+
typedef enum spin_msg {
97+
SP_MISC, /* some weird thing, usually just return immediately if you get this */
98+
SP_SELECT, /* in a select call */
99+
SP_NAME, /* getting a host by name */
100+
SP_ADDR, /* getting a host by address */
101+
SP_STREAM_READ, /* Stream read call */
102+
SP_STREAM_WRITE, /* Stream write call */
103+
SP_DGRAM_READ, /* Datagram read call */
104+
SP_DGRAM_WRITE, /* Datagram write call */
105+
SP_SLEEP, /* sleeping, passes ticks left to sleep */
106+
SP_AUTO_SPIN /* Autospin, passes argument to SpinCursor */
107+
} spin_msg;
108+
109+
typedef int (*GUSISpinFn)(spin_msg msg, long param);
110+
typedef void (*GUSIEvtHandler)(EventRecord * ev);
111+
typedef GUSIEvtHandler GUSIEvtTable[24];
112+
113+
/*
114+
* Address families, defined in sys/socket.h
115+
*
116+
117+
#define AF_UNSPEC 0 // unspecified
118+
#define AF_UNIX 1 // local to host (pipes, portals)
119+
#define AF_INET 2 // internetwork: UDP, TCP, etc.
120+
#define AF_CTB 3 // Apple Comm Toolbox (not yet supported)
121+
#define AF_FILE 4 // Normal File I/O (used internally)
122+
#define AF_PPC 5 // PPC Toolbox
123+
#define AF_PAP 6 // Printer Access Protocol (client only)
124+
#define AF_APPLETALK 16 // Apple Talk
125+
126+
*/
127+
128+
#define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */
129+
130+
/*
131+
* Some Implementations of GUSI require you to call GUSISetup for the
132+
* socket families you'd like to have defined. It's a good idea to call
133+
* this for *all* implementations.
134+
*
135+
* GUSIDefaultSetup() will include all socket families.
136+
*
137+
* Never call any of the GUSIwithXXX routines directly.
138+
*/
139+
140+
__BEGIN_DECLS
141+
void GUSIwithAppleTalkSockets();
142+
void GUSIwithInternetSockets();
143+
void GUSIwithPAPSockets();
144+
void GUSIwithPPCSockets();
145+
void GUSIwithUnixSockets();
146+
void GUSIwithSIOUXSockets();
147+
void GUSIwithMPWSockets();
148+
149+
void GUSISetup(void (*socketfamily)());
150+
void GUSIDefaultSetup();
151+
void GUSILoadConfiguration(Handle);
152+
__END_DECLS
153+
/*
154+
* Types, defined in sys/socket.h
155+
*
156+
157+
#define SOCK_STREAM 1 // stream socket
158+
#define SOCK_DGRAM 2 // datagram socket
159+
160+
*/
161+
162+
/*
163+
* Defined in sys/un.h
164+
*
165+
166+
struct sockaddr_un {
167+
short sun_family;
168+
char sun_path[108];
169+
};
170+
171+
*/
172+
173+
#ifndef PRAGMA_ALIGN_SUPPORTED
174+
#error Apple had some fun with the conditional macros again
175+
#endif
176+
177+
#if PRAGMA_ALIGN_SUPPORTED
178+
#pragma options align=mac68k
179+
#endif
180+
181+
struct sockaddr_atlk {
182+
short family;
183+
AddrBlock addr;
184+
};
185+
186+
struct sockaddr_atlk_sym {
187+
short family;
188+
EntityName name;
189+
};
190+
191+
struct sockaddr_ppc {
192+
short family;
193+
LocationNameRec location;
194+
PPCPortRec port;
195+
};
196+
197+
/* Definitions for choose() */
198+
199+
#define CHOOSE_DEFAULT 1 /* Use *name as default name */
200+
#define CHOOSE_NEW 2 /* Choose new entity name, not existing one */
201+
#define CHOOSE_DIR 4 /* Choose a directory name, not a file */
202+
203+
typedef struct {
204+
short numTypes;
205+
SFTypeList types;
206+
} sa_constr_file;
207+
208+
typedef struct {
209+
short numTypes;
210+
NLType types;
211+
} sa_constr_atlk;
212+
213+
/* Definitions for sa_constr_ppc */
214+
215+
#define PPC_CON_NEWSTYLE 0x8000 /* Required */
216+
#define PPC_CON_MATCH_NAME 0x0001 /* Match name */
217+
#define PPC_CON_MATCH_TYPE 0x0002 /* Match port type */
218+
#define PPC_CON_MATCH_NBP 0x0004 /* Match NBP type */
219+
220+
typedef struct {
221+
short flags;
222+
Str32 nbpType;
223+
PPCPortRec match;
224+
} sa_constr_ppc;
225+
226+
#if PRAGMA_ALIGN_SUPPORTED
227+
#pragma options align=reset
228+
#endif
229+
230+
__BEGIN_DECLS
231+
/*
232+
* IO/Socket stuff, defined elsewhere (unistd.h, sys/socket.h
233+
*
234+
235+
int socket(int domain, int type, short protocol);
236+
int bind(int s, void *name, int namelen);
237+
int connect(int s, void *addr, int addrlen);
238+
int listen(int s, int qlen);
239+
int accept(int s, void *addr, int *addrlen);
240+
int close(int s);
241+
int read(int s, char *buffer, unsigned buflen);
242+
int readv(int s, struct iovec *iov, int count);
243+
int recv(int s, void *buffer, int buflen, int flags);
244+
int recvfrom(int s, void *buffer, int buflen, int flags, void *from, int *fromlen);
245+
int recvmsg(int s,struct msghdr *msg,int flags);
246+
int write(int s, const char *buffer, unsigned buflen);
247+
int writev(int s, struct iovec *iov, int count);
248+
int send(int s, void *buffer, int buflen, int flags);
249+
int sendto (int s, void *buffer, int buflen, int flags, void *to, int tolen);
250+
int sendmsg(int s,struct msghdr *msg,int flags);
251+
int select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
252+
int getdtablesize(void);
253+
int getsockname(int s, void *name, int *namelen);
254+
int getpeername(int s, struct sockaddr *name, int *namelen);
255+
int shutdown(int s, int how);
256+
int fcntl(int s, unsigned int cmd, int arg);
257+
int dup(int s);
258+
int dup2(int s, int s1);
259+
int ioctl(int d, unsigned int request, long *argp);
260+
int getsockopt(int s, int level, int optname, char *optval, int * optlen);
261+
int setsockopt(int s, int level, int optname, char *optval, int optlen);
262+
int isatty(int);
263+
int remove(const char *filename);
264+
int rename(const char *oldname, const char *newname);
265+
int creat(const char*);
266+
int faccess(char*, unsigned int, long*);
267+
long lseek(int, long, int);
268+
int open(const char*, int);
269+
int unlink(char*);
270+
int symlink(char* linkto, char* linkname);
271+
int readlink(char* path, char* buf, int bufsiz);
272+
int truncate(char *path, long length);
273+
int ftruncate(int fd, long length);
274+
int chdir(char * path);
275+
int mkdir(char * path);
276+
int rmdir(char * path);
277+
char * getcwd(char * buf, int size);
278+
*/
279+
280+
/*
281+
* Defined in stdio.h
282+
*/
283+
284+
#ifdef __MWERKS__
285+
void fsetfileinfo (char *filename, unsigned long newcreator, unsigned long newtype);
286+
#endif
287+
288+
void fgetfileinfo (char *filename, unsigned long * creator, unsigned long * type);
289+
290+
#ifdef __MWERKS__
291+
FILE *fdopen(int fd, const char *mode);
292+
int fwalk(int (*func)(FILE * stream));
293+
#endif
294+
295+
int choose(
296+
int domain,
297+
int type,
298+
char * prompt,
299+
void * constraint,
300+
int flags,
301+
void * name,
302+
int * namelen);
303+
304+
/*
305+
* Hostname routines, defined in netdb.h
306+
*
307+
308+
struct hostent * gethostbyname(char *name);
309+
struct hostent * gethostbyaddr(struct in_addr *addrP, int, int);
310+
int gethostname(char *machname, long buflen);
311+
struct servent * getservbyname (char * name, char * proto);
312+
struct protoent * getprotobyname(char * name);
313+
314+
*/
315+
316+
char * inet_ntoa(struct in_addr inaddr);
317+
struct in_addr inet_addr(char *address);
318+
319+
/*
320+
* GUSI supports a number of hooks. Every one of them has a different prototype, but needs
321+
* to be passed as a GUSIHook
322+
*/
323+
324+
typedef enum {
325+
GUSI_SpinHook, /* A GUSISpinFn, to be called when a call blocks */
326+
GUSI_ExecHook, /* Boolean (*hook)(const GUSIFileRef & ref), decides if file is executable */
327+
GUSI_FTypeHook,/* Boolean (*hook)(const FSSpec & spec) sets a default file type */
328+
GUSI_SpeedHook /* A long integer, to be added to the cursor spin variable */
329+
} GUSIHookCode;
330+
331+
typedef void (*GUSIHook)(void);
332+
void GUSISetHook(GUSIHookCode code, GUSIHook hook);
333+
GUSIHook GUSIGetHook(GUSIHookCode code);
334+
335+
/*
336+
* What to do when a routine blocks
337+
*/
338+
339+
/* Defined for compatibility */
340+
#define GUSISetSpin(routine) GUSISetHook(GUSI_SpinHook, (GUSIHook)routine)
341+
#define GUSIGetSpin() (GUSISpinFn) GUSIGetHook(GUSI_SpinHook)
342+
343+
int GUSISetEvents(GUSIEvtTable table);
344+
GUSIEvtHandler * GUSIGetEvents(void);
345+
346+
extern GUSIEvtHandler GUSISIOWEvents[];
347+
348+
#define SIGPIPE 13
349+
#define SIGALRM 14
350+
351+
/*
352+
* BSD memory routines, defined in compat.h
353+
*
354+
355+
#define index(a, b) strchr(a, b)
356+
#define rindex(a, b) strrchr(a, b)
357+
#define bzero(from, len) memset(from, 0, len)
358+
#define bcopy(from, to, len) memcpy(to, from, len)
359+
#define bcmp(s1, s2, len) memcmp(s1, s2, len)
360+
#define bfill(from, len, x) memset(from, x, len)
361+
362+
*/
363+
364+
__END_DECLS
365+
366+
#endif /* !_GUSI_ */

0 commit comments

Comments
 (0)