summaryrefslogtreecommitdiffstats
path: root/Mac/GUSI-mods/into-include
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-08-18 14:52:38 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-08-18 14:52:38 (GMT)
commit1d6a6ea1a819a645a3a8841205b10cf33eb04493 (patch)
tree464997cdd49781964e5928be1a5d99311b24c3ec /Mac/GUSI-mods/into-include
parentb0195ec9c136300bcd65d89bfdf287a98af6c7de (diff)
downloadcpython-1d6a6ea1a819a645a3a8841205b10cf33eb04493.zip
cpython-1d6a6ea1a819a645a3a8841205b10cf33eb04493.tar.gz
cpython-1d6a6ea1a819a645a3a8841205b10cf33eb04493.tar.bz2
Putting Python-specific GUSI modifications under CVS.
Diffstat (limited to 'Mac/GUSI-mods/into-include')
-rw-r--r--Mac/GUSI-mods/into-include/GUSI.h366
-rw-r--r--Mac/GUSI-mods/into-include/GUSI_P.h471
2 files changed, 837 insertions, 0 deletions
diff --git a/Mac/GUSI-mods/into-include/GUSI.h b/Mac/GUSI-mods/into-include/GUSI.h
new file mode 100644
index 0000000..07ce429
--- /dev/null
+++ b/Mac/GUSI-mods/into-include/GUSI.h
@@ -0,0 +1,366 @@
+/*********************************************************************
+Project : GUSI - Grand Unified Socket Interface
+File : GUSI.h - Socket calls
+Author : Matthias Neeracher
+Language : MPW C/C++
+
+$Log$
+Revision 1.1 1998/08/18 14:52:33 jack
+Putting Python-specific GUSI modifications under CVS.
+
+Revision 1.2 1994/12/31 01:45:54 neeri
+Fix alignment.
+
+Revision 1.1 1994/02/25 02:56:49 neeri
+Initial revision
+
+Revision 0.15 1993/06/27 00:00:00 neeri
+f?truncate
+
+Revision 0.14 1993/06/20 00:00:00 neeri
+Changed sa_constr_ppc
+
+Revision 0.13 1993/02/14 00:00:00 neeri
+AF_PAP
+
+Revision 0.12 1992/12/08 00:00:00 neeri
+getcwd()
+
+Revision 0.11 1992/11/15 00:00:00 neeri
+remove netdb.h definitions
+
+Revision 0.10 1992/09/26 00:00:00 neeri
+Separate dirent and stat
+
+Revision 0.9 1992/09/12 00:00:00 neeri
+Hostname stuff
+
+Revision 0.8 1992/09/07 00:00:00 neeri
+readlink()
+
+Revision 0.7 1992/08/03 00:00:00 neeri
+sa_constr_ppc
+
+Revision 0.6 1992/07/21 00:00:00 neeri
+sockaddr_atlk_sym
+
+Revision 0.5 1992/06/26 00:00:00 neeri
+choose()
+
+Revision 0.4 1992/05/18 00:00:00 neeri
+PPC stuff
+
+Revision 0.3 1992/04/27 00:00:00 neeri
+getsockopt()
+
+Revision 0.2 1992/04/19 00:00:00 neeri
+C++ compatibility
+
+Revision 0.1 1992/04/17 00:00:00 neeri
+bzero()
+
+*********************************************************************/
+
+#ifndef _GUSI_
+#define _GUSI_
+
+#include <sys/types.h>
+
+/* Feel free to increase FD_SETSIZE as needed */
+#define GUSI_MAX_FD FD_SETSIZE
+
+#include <sys/cdefs.h>
+#include <compat.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <Types.h>
+#include <Events.h>
+#include <Files.h>
+#include <AppleTalk.h>
+#include <CTBUtilities.h>
+#include <Packages.h>
+#include <PPCToolBox.h>
+#include <StandardFile.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <machine/endian.h>
+
+typedef enum spin_msg {
+ SP_MISC, /* some weird thing, usually just return immediately if you get this */
+ SP_SELECT, /* in a select call */
+ SP_NAME, /* getting a host by name */
+ SP_ADDR, /* getting a host by address */
+ SP_STREAM_READ, /* Stream read call */
+ SP_STREAM_WRITE, /* Stream write call */
+ SP_DGRAM_READ, /* Datagram read call */
+ SP_DGRAM_WRITE, /* Datagram write call */
+ SP_SLEEP, /* sleeping, passes ticks left to sleep */
+ SP_AUTO_SPIN /* Autospin, passes argument to SpinCursor */
+} spin_msg;
+
+typedef int (*GUSISpinFn)(spin_msg msg, long param);
+typedef void (*GUSIEvtHandler)(EventRecord * ev);
+typedef GUSIEvtHandler GUSIEvtTable[24];
+
+/*
+ * Address families, defined in sys/socket.h
+ *
+
+#define AF_UNSPEC 0 // unspecified
+#define AF_UNIX 1 // local to host (pipes, portals)
+#define AF_INET 2 // internetwork: UDP, TCP, etc.
+#define AF_CTB 3 // Apple Comm Toolbox (not yet supported)
+#define AF_FILE 4 // Normal File I/O (used internally)
+#define AF_PPC 5 // PPC Toolbox
+#define AF_PAP 6 // Printer Access Protocol (client only)
+#define AF_APPLETALK 16 // Apple Talk
+
+*/
+
+#define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */
+
+/*
+ * Some Implementations of GUSI require you to call GUSISetup for the
+ * socket families you'd like to have defined. It's a good idea to call
+ * this for *all* implementations.
+ *
+ * GUSIDefaultSetup() will include all socket families.
+ *
+ * Never call any of the GUSIwithXXX routines directly.
+ */
+
+__BEGIN_DECLS
+void GUSIwithAppleTalkSockets();
+void GUSIwithInternetSockets();
+void GUSIwithPAPSockets();
+void GUSIwithPPCSockets();
+void GUSIwithUnixSockets();
+void GUSIwithSIOUXSockets();
+void GUSIwithMPWSockets();
+
+void GUSISetup(void (*socketfamily)());
+void GUSIDefaultSetup();
+void GUSILoadConfiguration(Handle);
+__END_DECLS
+/*
+ * Types, defined in sys/socket.h
+ *
+
+#define SOCK_STREAM 1 // stream socket
+#define SOCK_DGRAM 2 // datagram socket
+
+*/
+
+/*
+ * Defined in sys/un.h
+ *
+
+struct sockaddr_un {
+ short sun_family;
+ char sun_path[108];
+};
+
+*/
+
+#ifndef PRAGMA_ALIGN_SUPPORTED
+#error Apple had some fun with the conditional macros again
+#endif
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=mac68k
+#endif
+
+struct sockaddr_atlk {
+ short family;
+ AddrBlock addr;
+};
+
+struct sockaddr_atlk_sym {
+ short family;
+ EntityName name;
+};
+
+struct sockaddr_ppc {
+ short family;
+ LocationNameRec location;
+ PPCPortRec port;
+};
+
+/* Definitions for choose() */
+
+#define CHOOSE_DEFAULT 1 /* Use *name as default name */
+#define CHOOSE_NEW 2 /* Choose new entity name, not existing one */
+#define CHOOSE_DIR 4 /* Choose a directory name, not a file */
+
+typedef struct {
+ short numTypes;
+ SFTypeList types;
+} sa_constr_file;
+
+typedef struct {
+ short numTypes;
+ NLType types;
+} sa_constr_atlk;
+
+/* Definitions for sa_constr_ppc */
+
+#define PPC_CON_NEWSTYLE 0x8000 /* Required */
+#define PPC_CON_MATCH_NAME 0x0001 /* Match name */
+#define PPC_CON_MATCH_TYPE 0x0002 /* Match port type */
+#define PPC_CON_MATCH_NBP 0x0004 /* Match NBP type */
+
+typedef struct {
+ short flags;
+ Str32 nbpType;
+ PPCPortRec match;
+} sa_constr_ppc;
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=reset
+#endif
+
+__BEGIN_DECLS
+/*
+ * IO/Socket stuff, defined elsewhere (unistd.h, sys/socket.h
+ *
+
+int socket(int domain, int type, short protocol);
+int bind(int s, void *name, int namelen);
+int connect(int s, void *addr, int addrlen);
+int listen(int s, int qlen);
+int accept(int s, void *addr, int *addrlen);
+int close(int s);
+int read(int s, char *buffer, unsigned buflen);
+int readv(int s, struct iovec *iov, int count);
+int recv(int s, void *buffer, int buflen, int flags);
+int recvfrom(int s, void *buffer, int buflen, int flags, void *from, int *fromlen);
+int recvmsg(int s,struct msghdr *msg,int flags);
+int write(int s, const char *buffer, unsigned buflen);
+int writev(int s, struct iovec *iov, int count);
+int send(int s, void *buffer, int buflen, int flags);
+int sendto (int s, void *buffer, int buflen, int flags, void *to, int tolen);
+int sendmsg(int s,struct msghdr *msg,int flags);
+int select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+int getdtablesize(void);
+int getsockname(int s, void *name, int *namelen);
+int getpeername(int s, struct sockaddr *name, int *namelen);
+int shutdown(int s, int how);
+int fcntl(int s, unsigned int cmd, int arg);
+int dup(int s);
+int dup2(int s, int s1);
+int ioctl(int d, unsigned int request, long *argp);
+int getsockopt(int s, int level, int optname, char *optval, int * optlen);
+int setsockopt(int s, int level, int optname, char *optval, int optlen);
+int isatty(int);
+int remove(const char *filename);
+int rename(const char *oldname, const char *newname);
+int creat(const char*);
+int faccess(char*, unsigned int, long*);
+long lseek(int, long, int);
+int open(const char*, int);
+int unlink(char*);
+int symlink(char* linkto, char* linkname);
+int readlink(char* path, char* buf, int bufsiz);
+int truncate(char *path, long length);
+int ftruncate(int fd, long length);
+int chdir(char * path);
+int mkdir(char * path);
+int rmdir(char * path);
+char * getcwd(char * buf, int size);
+*/
+
+/*
+ * Defined in stdio.h
+ */
+
+#ifdef __MWERKS__
+void fsetfileinfo (char *filename, unsigned long newcreator, unsigned long newtype);
+#endif
+
+void fgetfileinfo (char *filename, unsigned long * creator, unsigned long * type);
+
+#ifdef __MWERKS__
+FILE *fdopen(int fd, const char *mode);
+int fwalk(int (*func)(FILE * stream));
+#endif
+
+int choose(
+ int domain,
+ int type,
+ char * prompt,
+ void * constraint,
+ int flags,
+ void * name,
+ int * namelen);
+
+/*
+ * Hostname routines, defined in netdb.h
+ *
+
+struct hostent * gethostbyname(char *name);
+struct hostent * gethostbyaddr(struct in_addr *addrP, int, int);
+int gethostname(char *machname, long buflen);
+struct servent * getservbyname (char * name, char * proto);
+struct protoent * getprotobyname(char * name);
+
+*/
+
+char * inet_ntoa(struct in_addr inaddr);
+struct in_addr inet_addr(char *address);
+
+/*
+ * GUSI supports a number of hooks. Every one of them has a different prototype, but needs
+ * to be passed as a GUSIHook
+ */
+
+typedef enum {
+ GUSI_SpinHook, /* A GUSISpinFn, to be called when a call blocks */
+ GUSI_ExecHook, /* Boolean (*hook)(const GUSIFileRef & ref), decides if file is executable */
+ GUSI_FTypeHook,/* Boolean (*hook)(const FSSpec & spec) sets a default file type */
+ GUSI_SpeedHook /* A long integer, to be added to the cursor spin variable */
+} GUSIHookCode;
+
+typedef void (*GUSIHook)(void);
+void GUSISetHook(GUSIHookCode code, GUSIHook hook);
+GUSIHook GUSIGetHook(GUSIHookCode code);
+
+/*
+ * What to do when a routine blocks
+ */
+
+/* Defined for compatibility */
+#define GUSISetSpin(routine) GUSISetHook(GUSI_SpinHook, (GUSIHook)routine)
+#define GUSIGetSpin() (GUSISpinFn) GUSIGetHook(GUSI_SpinHook)
+
+int GUSISetEvents(GUSIEvtTable table);
+GUSIEvtHandler * GUSIGetEvents(void);
+
+extern GUSIEvtHandler GUSISIOWEvents[];
+
+#define SIGPIPE 13
+#define SIGALRM 14
+
+/*
+ * BSD memory routines, defined in compat.h
+ *
+
+#define index(a, b) strchr(a, b)
+#define rindex(a, b) strrchr(a, b)
+#define bzero(from, len) memset(from, 0, len)
+#define bcopy(from, to, len) memcpy(to, from, len)
+#define bcmp(s1, s2, len) memcmp(s1, s2, len)
+#define bfill(from, len, x) memset(from, x, len)
+
+ */
+
+__END_DECLS
+
+#endif /* !_GUSI_ */
diff --git a/Mac/GUSI-mods/into-include/GUSI_P.h b/Mac/GUSI-mods/into-include/GUSI_P.h
new file mode 100644
index 0000000..1bc5523
--- /dev/null
+++ b/Mac/GUSI-mods/into-include/GUSI_P.h
@@ -0,0 +1,471 @@
+/*********************************************************************
+Project : GUSI - Grand Unified Socket Interface
+File : GUSI_P.h - Private stuff
+Author : Matthias Neeracher
+Language : MPW C/C++
+
+$Log$
+Revision 1.1 1998/08/18 14:52:33 jack
+Putting Python-specific GUSI modifications under CVS.
+
+Revision 1.3 1994/12/31 01:30:26 neeri
+Reorganize filename dispatching.
+
+Revision 1.2 1994/08/10 00:41:05 neeri
+Sanitized for universal headers.
+
+Revision 1.1 1994/02/25 02:57:01 neeri
+Initial revision
+
+Revision 0.22 1993/07/17 00:00:00 neeri
+GUSIRingBuffer::proc -> defproc
+
+Revision 0.21 1993/07/17 00:00:00 neeri
+GUSIO_MAX_DOMAIN -> AF_MAX
+
+Revision 0.20 1993/06/27 00:00:00 neeri
+Socket::{pre,post}_select
+
+Revision 0.19 1993/06/27 00:00:00 neeri
+Socket::ftruncate
+
+Revision 0.18 1993/02/09 00:00:00 neeri
+Socket::lurking, Socket::lurkdescr
+
+Revision 0.17 1993/01/31 00:00:00 neeri
+GUSIConfiguration::daemon
+
+Revision 0.16 1993/01/17 00:00:00 neeri
+Destructors for Socketdomain
+
+Revision 0.15 1993/01/17 00:00:00 neeri
+SAFESPIN
+
+Revision 0.14 1993/01/03 00:00:00 neeri
+GUSIConfig
+
+Revision 0.13 1992/09/24 00:00:00 neeri
+Include GUSIRsrc_P.h
+
+Revision 0.12 1992/09/13 00:00:00 neeri
+SPINVOID didn't return
+
+Revision 0.11 1992/08/30 00:00:00 neeri
+AppleTalkIdentity()
+
+Revision 0.10 1992/08/03 00:00:00 neeri
+RingBuffer
+
+Revision 0.9 1992/07/30 00:00:00 neeri
+Initializer Features
+
+Revision 0.8 1992/07/26 00:00:00 neeri
+UnixSockets.choose()
+
+Revision 0.7 1992/07/13 00:00:00 neeri
+Make AppleTalkSockets global
+
+Revision 0.6 1992/06/27 00:00:00 neeri
+choose(), hasNewSF
+
+Revision 0.5 1992/06/07 00:00:00 neeri
+Feature
+
+Revision 0.4 1992/05/21 00:00:00 neeri
+Implemented select()
+
+Revision 0.3 1992/04/19 00:00:00 neeri
+C++ rewrite
+
+Revision 0.2 1992/04/18 00:00:00 neeri
+changed read/write/send/recv dispatchers
+
+Revision 0.1 1992/04/18 00:00:00 neeri
+ppc Domain
+
+*********************************************************************/
+
+#ifndef __GUSI_P__
+#define __GUSI_P__
+
+#define __useAppleExts__
+
+#include <GUSI.h>
+#include <GUSIRsrc_P.h>
+#include <TFileSpec.h>
+
+
+#include <sys/errno.h>
+#include <sys/uio.h>
+#include <sys/socket.h>
+
+extern "C" {
+
+#include <stdio.h>
+#include <string.h>
+
+int GUSI_error(int err);
+void * GUSI_error_nil(int err);
+}
+
+#include <Memory.h>
+#include <Gestalt.h>
+#include <Traps.h>
+#include <AppleEvents.h>
+#include <Processes.h>
+#include <MixedMode.h>
+
+#if MSLGUSI
+using namespace std;
+#endif
+
+#if GENERATING68K
+#pragma segment GUSI
+#endif
+
+#define GUSI_MAX_DOMAIN AF_MAX
+#define DEFAULT_BUFFER_SIZE 4096
+
+/*
+ * In use and shutdown status.
+ */
+#define SOCK_STATUS_USED 0x1 /* Used socket table entry */
+#define SOCK_STATUS_NOREAD 0x2 /* No more reading allowed from socket */
+#define SOCK_STATUS_NOWRITE 0x4 /* No more writing allowed to socket */
+
+/*
+ * Socket connection states.
+ */
+#define SOCK_STATE_NO_STREAM 0 /* Socket doesn't have a MacTCP stream yet */
+#define SOCK_STATE_UNCONNECTED 1 /* Socket is unconnected. */
+#define SOCK_STATE_LISTENING 2 /* Socket is listening for connection. */
+#define SOCK_STATE_LIS_CON 3 /* Socket is in transition from listen to connected. */
+#define SOCK_STATE_CONNECTING 4 /* Socket is initiating a connection. */
+#define SOCK_STATE_CONNECTED 5 /* Socket is connected. */
+#define SOCK_STATE_CLOSING 6 /* Socket is closing */
+#define SOCK_STATE_LIS_CLOSE 7 /* Socket closed while listening */
+
+#define min(a,b) ( (a) < (b) ? (a) : (b))
+#define max(a,b) ( (a) > (b) ? (a) : (b))
+
+extern GUSISpinFn GUSISpin;
+extern "C" int GUSIDefaultSpin(spin_msg, long);
+extern int GUSICheckAlarm();
+
+#define GUSI_INTERRUPT(mesg,param) (GUSICheckAlarm() || (GUSISpin && (*GUSISpin)(mesg,param)))
+
+/* SPIN returns a -1 on user cancel for fn returning integers */
+#define SPIN(cond,mesg,param) \
+ do { \
+ if (GUSI_INTERRUPT(mesg,param)) \
+ return GUSI_error(EINTR); \
+ } while(cond)
+
+/* SPINP returns a NULL on user cancel, for fn returning pointers */
+#define SPINP(cond,mesg,param) \
+ do { \
+ if (GUSI_INTERRUPT(mesg,param)) { \
+ GUSI_error(EINTR); \
+ return NULL; \
+ } \
+ } while(cond)
+
+/* SPINVOID just returns on user cancel, for fn returning void */
+#define SPINVOID(cond,mesg,param) \
+ do { \
+ if (GUSI_INTERRUPT(mesg,param)) { \
+ GUSI_error(EINTR); \
+ return; \
+ } \
+ } while(cond)
+
+/* SAFESPIN doesn't return, you have to check errno */
+#define SAFESPIN(cond,mesg,param) \
+ do { \
+ if (GUSI_INTERRUPT(mesg,param)) { \
+ GUSI_error(EINTR); \
+ break; \
+ } else \
+ errno = 0; \
+ } while(cond)
+
+//
+// Library functions are never allowed to clear errno, so we have to save
+//
+class ErrnoSaver {
+public:
+ ErrnoSaver() { fSavedErrno = ::errno; ::errno = 0; }
+ ~ErrnoSaver() { if (!::errno) ::errno = fSavedErrno; }
+private:
+ int fSavedErrno;
+};
+
+#define SAVE_AND_CLEAR_ERRNO ErrnoSaver saveErrno
+
+class SocketTable;
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=mac68k
+#endif
+
+class Socket {
+ friend class SocketTable;
+
+ short refCount;
+protected:
+ Socket();
+public:
+ virtual int bind(void * name, int namelen);
+ virtual int connect(void * address, int addrlen);
+ virtual int listen(int qlen);
+ virtual Socket * accept(void * address, int * addrlen);
+ virtual int read(void * buffer, int buflen);
+ virtual int write(void * buffer, int buflen);
+ virtual int recvfrom(void * buffer, int buflen, int flags, void * from, int * fromlen);
+ virtual int sendto(void * buffer, int buflen, int flags, void * to, int tolen);
+ virtual int getsockname(void * name, int * namelen);
+ virtual int getpeername(void * name, int * namelen);
+ virtual int getsockopt(int level, int optname, void *optval, int * optlen);
+ virtual int setsockopt(int level, int optname, void *optval, int optlen);
+ virtual int fcntl(unsigned int cmd, int arg);
+ virtual int ioctl(unsigned int request, void *argp);
+ virtual int fstat(struct stat * buf);
+ virtual long lseek(long offset, int whence);
+ virtual int ftruncate(long offset);
+ virtual int isatty();
+ virtual int shutdown(int how);
+ virtual void pre_select(Boolean wantRead, Boolean wantWrite, Boolean wantExcept);
+ virtual int select(Boolean * canRead, Boolean * canWrite, Boolean * exception);
+ virtual void post_select(Boolean wantRead, Boolean wantWrite, Boolean wantExcept);
+ virtual ~Socket();
+
+ void operator++() { ++refCount; }
+ void operator--() { if (!--refCount) delete this; }
+};
+
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=reset
+#endif
+
+class SocketDomain {
+ static SocketDomain * domains[GUSI_MAX_DOMAIN];
+ static ProcessSerialNumber process;
+protected:
+ SocketDomain(int domain);
+ virtual ~SocketDomain();
+public:
+ inline static SocketDomain * Domain(int domain);
+ static void Ready();
+
+ // Optionally override the following
+
+ virtual Socket * socket(int type, short protocol);
+
+ // Optionally override the following
+
+ virtual int socketpair(int type, short protocol, Socket * sockets[]);
+
+ // Optionally define the following
+
+ virtual int choose(
+ int type,
+ char * prompt,
+ void * constraint,
+ int flags,
+ void * name,
+ int * namelen);
+
+ // Never override the following
+
+ void DontStrip();
+};
+
+class SocketTable {
+ Socket * sockets[GUSI_MAX_FD];
+ Boolean needsConsole;
+public:
+ SocketTable();
+ ~SocketTable();
+
+ void InitConsole();
+ int Install(Socket * sock, int start = 0);
+ int Remove(int fd);
+ Socket * operator[](int fd);
+};
+
+struct GUSISuffix {
+ char suffix[4];
+ OSType suffType;
+ OSType suffCreator;
+};
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=mac68k
+#endif
+
+//
+// I learned the hard way not to rely on bit field alignments
+//
+
+struct GUSIConfigRsrc {
+ OSType defaultType;
+ OSType defaultCreator;
+
+ char autoSpin;
+ unsigned char flags;
+
+ OSType version;
+ short numSuffices;
+ GUSISuffix suffices[1];
+};
+
+#if PRAGMA_ALIGN_SUPPORTED
+#pragma options align=reset
+#endif
+
+struct GUSIConfiguration {
+ OSType defaultType;
+ OSType defaultCreator;
+
+ char autoSpin;
+
+ Boolean noChdir; // Set current directory without chdir()
+ Boolean accurStat; // Return # of subdirectories + 2 in st_nlink
+ Boolean hasConsole; // Do we have our own console ?
+ Boolean noAutoInitGraf; // Never automatically do InitGraf
+ Boolean sharedOpen; // Open files with shared permissions
+ Boolean sigPipe; // raise SIGPIPE on write to closed socket
+ Boolean noAppleEvents; // Don't solicit AppleEvents for MPW tools
+ Boolean delayConsole; // Do not open console until needed
+
+ OSType version;
+ short numSuffices;
+ GUSISuffix * suffices;
+
+ GUSIConfiguration();
+ void GUSILoadConfiguration(Handle config);
+
+ void SetDefaultFType(const TFileSpec & name) const;
+ void DoAutoSpin() const;
+ void AutoInitGraf() const { if (!noAutoInitGraf) DoAutoInitGraf(); }
+ void DoAutoInitGraf() const;
+ Boolean DelayConsole() const;
+private:
+ static Boolean firstTime;
+ static short we;
+};
+
+extern GUSIConfiguration GUSIConfig;
+extern SocketTable Sockets;
+
+typedef pascal OSErr (*OSErrInitializer)();
+typedef pascal void (*voidInitializer)();
+
+class Feature {
+ Boolean good;
+public:
+ Feature(unsigned short trapNum, TrapType tTyp);
+ Feature(OSType type, long value);
+ Feature(OSType type, long mask, long value);
+ Feature(const Feature & precondition, OSErrInitializer init);
+ Feature(OSErrInitializer init);
+ Feature(const Feature & precondition, voidInitializer init);
+ Feature(voidInitializer init);
+ Feature(const Feature & cond1, const Feature & cond2);
+
+ operator void*() const { return (void *) good; }
+};
+
+extern Feature hasMakeFSSpec;
+extern Feature hasAlias;
+extern Feature hasNewSF;
+extern Feature hasProcessMgr;
+extern Feature hasCRM;
+extern Feature hasCTB;
+extern Feature hasStdNBP;
+extern Feature hasCM;
+extern Feature hasFT;
+extern Feature hasTM;
+extern Feature hasPPC;
+extern Feature hasRevisedTimeMgr;
+
+class ScattGath {
+ Handle scratch;
+protected:
+ void * buf;
+ int len;
+ int count;
+ const struct iovec * io;
+
+ ScattGath(const struct iovec *iov, int cnt);
+ virtual ~ScattGath();
+public:
+ void * buffer() { return buf; }
+ int buflen() { return len; }
+ int length(int l) { return len = l; }
+ operator void *() { return buf; }
+};
+
+class Scatterer : public ScattGath {
+public:
+ Scatterer(const struct iovec *iov, int count);
+ virtual ~Scatterer();
+};
+
+class Gatherer : public ScattGath {
+public:
+ Gatherer(const struct iovec *iov, int count);
+ virtual ~Gatherer();
+};
+
+typedef pascal void (*Deferred)(void *);
+
+class RingBuffer {
+ // Valid bytes are between consume and produce
+ // Free bytes are between produce and consume
+ // bytes between endbuf-spare and endbuf are neither
+ Ptr buffer;
+ Ptr endbuf;
+ Ptr consume;
+ Ptr produce;
+ u_short free;
+ u_short valid;
+ u_short spare;
+ Boolean lock;
+ Deferred defproc;
+ void * arg;
+
+public:
+ RingBuffer(u_short bufsiz);
+ ~RingBuffer();
+
+ Ptr Producer(long & len); // Find continuous memory for producer
+ Ptr Consumer(long & len); // Find continuous memory for consumer
+ void Validate(long len); // Validate this, unallocate rest
+ void Invalidate(long len);
+ void Produce(Ptr from, long & len);// Allocate, copy & validate
+ void Consume(Ptr to, long & len); // Copy & invalidate
+
+ long Free() { return free; }
+ long Valid() { return valid; }
+
+ void Defer() { lock = true; }
+ void Undefer() { lock = false; if (defproc) defproc(arg);}
+ Boolean Locked() { return lock; }
+ void Later(Deferred def, void * ar){ defproc = def; arg = ar; }
+
+ operator void *() { return buffer; }
+};
+
+Boolean GUSIInterrupt();
+
+Boolean CopyIconFamily(short srcResFile, short srcID, short dstResFile, short dstID);
+
+pascal OSErr PPCInit_P();
+
+OSErr AppleTalkIdentity(short & net, short & node);
+
+void CopyC2PStr(const char * cstr, StringPtr pstr);
+
+#endif