Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!apple.com!rmh From: rmh@apple.com (Rick Holzgrafe) Newsgroups: comp.sys.mac.programmer Subject: Re: zones Message-ID: <6249@internal.Apple.COM> Date: 18 Jan 90 18:58:14 GMT References: Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 71 In article nf0i+@andrew.cmu.edu (Norman William Franke, III) writes: > I found out how to read the zones from some sample code from Apple, but > how does one determine what zone one is in? I thought it was the first > zone returned, but it just "broke". Does anyone know how to do this? Yes. The Inside Mac documentation is sketchy and the MPW include files are incomplete, but it can be done and here's how: GetMyZone (char buf[578]) { OSErr err; short atpRefNum, mppRefNum; short myNode, myNet; SendReqparms atp; BDSElement bds; err = OpenDriver ("\P.MPP", &mppRefNum); if (err != noErr) /* oops */ GetNodeAddress (&myNode, &myNet); err = OpenDriver ("\P.ATP", &atpRefNum); if (err != noErr) /* oops */ bds.buffSize = sizeof (buf); bds.buffPtr = buf; atp.ioCompletion = NULL; atp.ioRefNum = atpRefNum; atp.csCode = 255; // sendRequest atp.userData = 0x07000000;// GetMyZone atp.atpFlags = 0; atp.addrBlock.aNet = myNet; atp.addrBlock.aSocket = 6; // GetBridgeAddress is new, if not imp. use low-mem global // ABusVars.sysABridge // If bridge == 0 or net == 0, no bridge and no zones! atp.addrBlock.aNode = GetBridgeAddress (); atp.reqLength = 0; atp.reqPointer = (Ptr)0; atp.bdsPointer = (Ptr)&bds; atp.filler = 1;// NumOfBuffs -- honest! atp.timeOutVal = 1; atp.retryCount = 3; atp.atpFlags = 0; atp.retryCount = 3; PBControl ((ParmBlkPtr)&atp, false); err = atp.ioResult; if (err != noErr) /* oops */ if (buf[0] > 32) // "Can't happen", it says here buf[0] = 32; /* buf now contains the name of your zone! */ } The above won't compile as is (you'll need error handling at least), and I may have screwed something up by excerpting this from a larger routine, but it *does* come from a working routine. It's in MPW 3.0 C. Hope it helps. ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 67-B | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."