Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
BigEasy/BigEasyPPC.h
/* |
File: BigEasyPPC.h |
Contains: xxx put contents here xxx |
Written by: xxx put writers here xxx |
Copyright: © 1992 by Apple Computer, Inc., all rights reserved. |
Change History (most recent first): |
<1> 1/20/92 dvb first checked in |
*/ |
/* file: BigEasyPPC.h |
* |
* Started Mid 1991, more or less. |
* |
* A set of routines to quickly |
* access some simple uses of PPC. |
* |
*/ |
#ifndef _BigEasyPPC_ |
#define _BigEasyPPC_ |
/*-------------------------- |
Inclusions |
--------------------------*/ |
#include <PPCToolbox.h> |
/*-------------------------- |
Types |
--------------------------*/ |
#define kEasyPPCWritePacketCount 20 /* maximum number of packets waiting to be sent */ |
#define kEasyPPCClientCount 10 /* most number of connections to one port */ |
/* |
* Each client connected to an Easy Port |
* has one of these records, stored in an |
* array in a handle. |
*/ |
typedef struct |
{ |
Boolean used; /* is this client structure available? */ |
Boolean waitingToConnect; /* Ready to accept a connection? */ |
Boolean waitingToReadLength; |
Boolean waitingToReadData; |
Str32 userName; |
PPCPortRec portName; /* port of who we're connected to */ |
LocationNameRec locationName; /* location of who we're connected to */ |
long sessRefNum; |
long waitingDataSize; /* If a message is about to arrive, how big? */ |
PPCInformPBRec ipbr; |
PPCReadPBRec rpbr; |
long tinyBuffer; /* So we don't to 0-length reads for length */ |
} EasyPPCClient; |
typedef struct |
{ |
Boolean used; |
PPCWritePBRec wpbr; |
void *buffer; /* if non-zero, then BigEasy owns it, and should dispose it */ |
} EasyPPCWritePB; |
typedef struct |
{ |
long portRefNum; /* this port's refNum */ |
long type; /* this port's type */ |
long serverType; /* type of server to connect to; must be different for password use */ |
Str32 userName; /* this computer's user name */ |
unsigned short fairSeed; /* to rotate among what we check first */ |
unsigned short fairClient; /* to rotate amongst the clients */ |
long connected; /* Count of how many we're connected to */ |
EasyPPCClient client[kEasyPPCClientCount]; /* An array of clients */ |
unsigned short fairWrite; /* to rotate amongst the outgoing messages */ |
long waitingToWrite; /* Count of outstanding messages */ |
EasyPPCWritePB wpbr[kEasyPPCWritePacketCount]; /* An array of outgoing msgs */ |
} EasyPPCSessionRecord; |
typedef EasyPPCSessionRecord *EasyPPCSession; |
typedef enum |
{ |
easyPPCSessionMessageWaiting = 2, /* param is length of message */ |
easyPPCSessionMessageRead, /* we read our message, param is 'more' boolean */ |
easyPPCSessionMessageWritten, /* our message sent, no param */ |
easyPPCSessionJustConnected, /* our letConnect was taken, no param */ |
easyPPCSessionIdle, /* nothing doing */ |
easyPPCSessionOtherPortGone, /* someone left us */ |
easyPPCSessionTooManyConnections /* can't connect if too many! */ |
}; |
typedef struct |
{ |
short operation; /* member of enum above */ |
short error; /* error, if any */ |
long sessRefNum; /* which session this pertains to */ |
long packetType; /* on a read or write, the packet type */ |
long length; /* on a message-waiting, the length waiting */ |
void *buffer; /* buffer location, on a message-written */ |
} EasyPPCPollResult; |
/*-------------------------- |
Prototypes |
--------------------------*/ |
EasyPPCSession NewEasyPPCSession(StringPtr name,OSType type); |
void DisposeEasyPPCSession(EasyPPCSession es); |
OSErr ConnectEasyPPCSession(EasyPPCSession es, |
LocationNameRec *locationName,PortInfoRec *pir,long *sessRefNum); |
OSErr DisconnectEasyPPCSession(EasyPPCSession es,long sessRefNum); |
OSErr LetConnectEasyPPCSession(EasyPPCSession es); |
OSErr WriteEasyPPCSession(EasyPPCSession es,long sessRefNum, |
long packetType,void *buffer,long length,Boolean easyManage); |
OSErr ReadEasyPPCSession(EasyPPCSession es,long sessRefNum,void *buffer,long length); |
void PollEasyPPCSession(EasyPPCSession es,EasyPPCPollResult *pollResult); |
OSErr BrowseAndConnectEasyPPCSession(EasyPPCSession es, |
StringPtr prompt, StringPtr applListLabel,long *sessRefNum, |
LocationNameRec *location,PortInfoRec *portInfo); |
void FindNamesEasyPPCSession(EasyPPCSession es,long sessRefNum, |
StringPtr zoneName,StringPtr macName,StringPtr portName); |
void SetServerTypeEasyPPCSession(EasyPPCSession es,OSType serverType); |
#endif _BigEasyPPC_ |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-03-19