home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 14078 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  2.0 KB

  1. Path: sparky!uunet!mcsun!sunic!isgate!krafla!rson
  2. From: rson@rhi.hi.is (Reynir Hugason)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Local Zone Name
  5. Message-ID: <5221@krafla.rhi.hi.is>
  6. Date: 17 Aug 92 07:51:13 GMT
  7. References: <D2150035.ao15oc@outpost.SF-Bay.org>
  8. Sender: usenet@rhi.hi.is
  9. Lines: 78
  10.  
  11. Here is a generic example of getting the local zone name. It should
  12. work under any system.
  13.  
  14. Boolean GetZIPAddr(AddrBlock *ZIPAddr)
  15. {
  16.     short theNode;
  17.  
  18.     if (GetNodeAddress(&theNode, &ZIPAddr->aNet) != noErr)
  19.         return false;
  20.     if ((ZIPAddr->aNode = GetBridgeAddress()) == 0)
  21.         return false;
  22.     ZIPAddr->aSocket = 6;
  23.     return true;
  24. }
  25.  
  26. void GetTheZone1(char *theZone)
  27. {
  28.     BDSElement        theBDS;
  29.     ATPParamBlock    theATPPB;
  30.     Str255            theBuffer;
  31.     AddrBlock        theZIPAddr;
  32.  
  33.     theZone[0] = 0;
  34.     if (!GetZIPAddr(&theZIPAddr))
  35.         return;
  36.     theBDS.buffSize = sizeof(Str255);
  37.     theBDS.buffPtr = &theBuffer;
  38.     theATPPB.ATPnumOfBuffs = 1;
  39.     theATPPB.ATPatpFlags = 0;
  40.     theATPPB.ATPreqLength = 0;
  41.     theATPPB.ATPreqPointer = NULL;
  42.     theATPPB.ATPbdsPointer = (Ptr)&theBDS;
  43.     theATPPB.ATPaddrBlock = theZIPAddr;
  44.     theATPPB.ATPtimeOutVal = 2;
  45.     theATPPB.ATPretryCount = 2;
  46.     theATPPB.ATPuserData = 0x07000000;
  47.     if (PSendRequest(&theATPPB, false) == noErr) {
  48.         BlockMove(theBuffer, theZone, theBuffer[0] + 1);
  49.     }
  50. }
  51.  
  52. void GetTheZone2(char *theZone)
  53. {
  54.     XCallParam        theXPBPB;
  55.     short            xppDriverRefNum;
  56.     Str255            theBuffer;
  57.  
  58.     theZone[0] = 0;
  59.     if (OpenDriver("\p.XPP", &xppDriverRefNum) != noErr)
  60.         return;
  61.     theXPBPB.zipInfoField[0] = 0;
  62.     theXPBPB.zipInfoField[1] = 0;
  63.     theXPBPB.zipLastFlag = 0;
  64.  
  65.     theXPBPB.ioRefNum = xppDriverRefNum;
  66.     theXPBPB.csCode = xCall;
  67.     theXPBPB.xppSubCode = zipGetMyZone;
  68.     theXPBPB.xppTimeout = 10;
  69.     theXPBPB.xppRetry = 2;
  70.     theXPBPB.zipBuffPtr = (Ptr)theBuffer;
  71.     if (PBControl((ParmBlkPtr)&theXPBPB, false) == noErr) {
  72.         BlockMove(theBuffer, theZone, theBuffer[0] + 1);
  73.     }
  74. }
  75.  
  76. void GetTheZone(char *theZone)
  77. {
  78.     SysEnvRec theMac;
  79.  
  80.     theZone[0] = 0;
  81.     if (SysEnvirons(1, &theMac) != noErr)
  82.         return;
  83.     if (theMac.atDrvrVersNum >= 53) {
  84.         GetTheZone2(theZone);
  85.     } else {
  86.         GetTheZone1(theZone);
  87.     }
  88. }
  89.