home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!isgate!krafla!rson
- From: rson@rhi.hi.is (Reynir Hugason)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Local Zone Name
- Message-ID: <5221@krafla.rhi.hi.is>
- Date: 17 Aug 92 07:51:13 GMT
- References: <D2150035.ao15oc@outpost.SF-Bay.org>
- Sender: usenet@rhi.hi.is
- Lines: 78
-
- Here is a generic example of getting the local zone name. It should
- work under any system.
-
- Boolean GetZIPAddr(AddrBlock *ZIPAddr)
- {
- short theNode;
-
- if (GetNodeAddress(&theNode, &ZIPAddr->aNet) != noErr)
- return false;
- if ((ZIPAddr->aNode = GetBridgeAddress()) == 0)
- return false;
- ZIPAddr->aSocket = 6;
- return true;
- }
-
- void GetTheZone1(char *theZone)
- {
- BDSElement theBDS;
- ATPParamBlock theATPPB;
- Str255 theBuffer;
- AddrBlock theZIPAddr;
-
- theZone[0] = 0;
- if (!GetZIPAddr(&theZIPAddr))
- return;
- theBDS.buffSize = sizeof(Str255);
- theBDS.buffPtr = &theBuffer;
- theATPPB.ATPnumOfBuffs = 1;
- theATPPB.ATPatpFlags = 0;
- theATPPB.ATPreqLength = 0;
- theATPPB.ATPreqPointer = NULL;
- theATPPB.ATPbdsPointer = (Ptr)&theBDS;
- theATPPB.ATPaddrBlock = theZIPAddr;
- theATPPB.ATPtimeOutVal = 2;
- theATPPB.ATPretryCount = 2;
- theATPPB.ATPuserData = 0x07000000;
- if (PSendRequest(&theATPPB, false) == noErr) {
- BlockMove(theBuffer, theZone, theBuffer[0] + 1);
- }
- }
-
- void GetTheZone2(char *theZone)
- {
- XCallParam theXPBPB;
- short xppDriverRefNum;
- Str255 theBuffer;
-
- theZone[0] = 0;
- if (OpenDriver("\p.XPP", &xppDriverRefNum) != noErr)
- return;
- theXPBPB.zipInfoField[0] = 0;
- theXPBPB.zipInfoField[1] = 0;
- theXPBPB.zipLastFlag = 0;
-
- theXPBPB.ioRefNum = xppDriverRefNum;
- theXPBPB.csCode = xCall;
- theXPBPB.xppSubCode = zipGetMyZone;
- theXPBPB.xppTimeout = 10;
- theXPBPB.xppRetry = 2;
- theXPBPB.zipBuffPtr = (Ptr)theBuffer;
- if (PBControl((ParmBlkPtr)&theXPBPB, false) == noErr) {
- BlockMove(theBuffer, theZone, theBuffer[0] + 1);
- }
- }
-
- void GetTheZone(char *theZone)
- {
- SysEnvRec theMac;
-
- theZone[0] = 0;
- if (SysEnvirons(1, &theMac) != noErr)
- return;
- if (theMac.atDrvrVersNum >= 53) {
- GetTheZone2(theZone);
- } else {
- GetTheZone1(theZone);
- }
- }
-