Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!claris!outpost.UUCP!peirce From: peirce@outpost.UUCP (Michael Peirce) Newsgroups: comp.sys.mac.programmer Subject: Re: Current zone lookup in AppleTalk Message-ID: <0B010004.govchs@outpost.UUCP> Date: 25 Jan 91 19:00:07 GMT Reply-To: peirce@outpost.UUCP Organization: Peirce Software Lines: 77 X-Mailer: uAccess - Mac Release: 1.0.3 In article <8bbwt1S00UzxI5T=ch@andrew.cmu.edu>, vd09+@andrew.cmu.edu (Vincent M. Del Vecchio) writes: > > Does anyone know how to get the name of the zone you are in using AppleTalk? If you're running Phase II (check for an AppleTalk version >= 52 using SysEnvirons or Gestalt) it's easy: use the GetMyZone call. It returns the zone name, if there is one. Another call, GetAppleTalkInfo, also returns the zone name; it also returns lots of other interesting information. See tech note 250 for more information. Here's the text from the tech note that applies, including Pascal & C example code: __________________________________________________________________________ GetMyZone Parameter Block --> 26 csCode word ; always xCall (246) --> 28 xppSubCode word ; always zipGetMyZone (7) --> 34 zipBuffPtr pointer ; pointer to buffer (must be 33 bytes) --> 42 ziplnfoField 70 bytes ; first word must be set ; to zero on every call GetMyZone returns the nodeUs AppleTalk zone name. This is the zone in which all of the nodeUs network visible entities are registered. ZipBuffPtr points to a buffer that must be 33 bytes in length. If noBridgeErr is returned by the call, there is no internet, and the zone name is effectively an asterisk (*). The 70-byte zipInfoField must always be allocated at the end of the parameter block. Result codes noErr No Error (0) noBridgeErr No router is available (-93) ReqFailed SendRequest failed; (-1096) retry count exceeded Following are short examples of using GetMyZone. Pascal procedure getMyZonePhs2; var xpb:xCallParam; resultCode :OSErr; myZoneNameBuffer:Ptr; begin myZoneNameBuffer := NewPtr(33); xpb.ioCRefNum := xppRefNum; xpb.csCode := xCall; xpb.xppSubCode := zipGetMyZone; xpb.zipBuffPtr := myZoneNameBuffer; xpb.zipInfoField[1] := 0; { ALWAYS 0 } xpb.zipInfoField[2] := 0; { ALWAYS 0 } resultCode := PBControl(@xpb, false); end; C getMyZonePhs2() { xCallParam xpb; OSErr resultCode; Ptr myZoneNameBuffer; myZoneNameBuffer := NewPtr(33); xpb.ioCRefNum = xppRefNum; xpb.csCode = xCall; xpb.xppSubCode = zipGetMyZone; xpb.zipBuffPtr = (Ptr) myZoneNameBuffer; xpb.zipInfoField[0] = 0; /* ALWAYS 0 */ xpb.zipInfoField[1] = 0; /* ALWAYS 0 */ resultCode = PBControl(&xpb, false); } -- michael -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE