[comp.sys.mac.programmer] Current zone lookup in AppleTalk

vd09+@andrew.cmu.edu (Vincent M. Del Vecchio) (01/25/91)

Does anyone know how to get the name of the zone you are in using AppleTalk?


-Vincent Del Vecchio
vd09@andrew.cmu.edu
#include "stdsig.h"

ian@umiami.ir.miami.edu (01/26/91)

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.

I believe that there is a varible (THIS-NET) that stores the zone-Network 
number that you are currently in...and in Inside AppleTalk they talk about the
GetMyZone comamnd during the ZIP discussion...but I'm not sure if it's an 
actual toolbox routine or not....
Hope this helps some....
-- 
Scruffy
Ian Sullivan
*******************************************************************************
**                             %   "Would that love were such a thing        **
**ian@umiami.ir.miami.edu      %    that one could hold, see or touch        **
**                             %    and perhaps squash the life out of"      **
**UUU    UMUMMM     MMMMMM     %    -Anonymous                               **
**UUU    UMU MMM   MMM MMM     %                                             **
**uUU    UMU  MMM MMM  MMM     %   "Life's been good to me so far..." -J.W.  **
**UUUUUUUUMUof MMMMM   MMM     %   "Give it a while." -Me.                   **
*******************************************************************************

peirce@outpost.UUCP (Michael Peirce) (01/26/91)

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