nf0i+@andrew.cmu.edu (Norman William Franke, III) (01/18/90)
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? Thanks, Norman Franke nf0i+@andrew.cmu.edu
mm3d+@andrew.cmu.edu (Matt McNally) (01/18/90)
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? After perusing the DTS sample code, and chapter 8 (Zone Information Protocol) in Inside AppleTalk it seems that the only real differnece between looking for *your* zone and looking for *all* the zones is the constant you pack into the userData field of the ATP Param Block. Below I've included a source fragment that I hope highlights the main differences between requesting all of the 'available' zones, or the current (ie. '*') zone. If you have any questions, or I've gone awry in a major way, feel free to send me EMail. Also, if anyone would like the complete sources let me know and I'll forward them on. ----- kGZNCall = $07000000; {GetMyZone indicator} kGZLCall = $08000000; {GetZoneList indicator} ...set up ATP Param Block... dIndex := 1; If AllZones Then dATPPBptr^.userData := kGZLCall+dIndex {indicate GetZoneInfo request} Else dATPPBptr^.userData := kGZNCall; ...make ATP Request and Extract Zone or Zones from BDS elements... ------------------------------------------------------------------------- Matt M. McNally - 'Macintosh II Initiative' Research Programmer/Dugan Carnegie Mellon, H&SS Dean's Office, Pittsburgh 15213 mm3d@andrew.cmu.edu | Baker Hall 369B, (412) 268-6990 -------------------------------------------------------------------------
rmh@apple.com (Rick Holzgrafe) (01/19/90)
In article <sZhJIpi00WBL03UUlC@andrew.cmu.edu> 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."