[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PGetAppleTalkInfo



> Date: Thu, 7 Apr 1994 17:10:56 -0600 (MDT)
> From: Shannon V Spires <svspire@somnet.sandia.gov>
> Subject: How do you call pgetappletalkinfo?
>
> Ok guys and gals, I'm at the end of my rope here.
> I'm trying to create a globally-unique symbol name;
> global across a network of Macs running MCL. Sort
> of a global-gensym, if you will. One way to do this
> is to just concatenating a local gensym onto some unique
> identifier for my local Macintosh. The problem is
> getting that unique identifier for my local Mac. The
> way I'm trying to do this is to get the Appletalk
> address of this machine, which is always unique. So
> I'm trying to call pgetappletalkinfo to get the
> Appletalk address of this machine. Here's the code:
>
> ; This deftrap definition is from the Appletalk.lisp
> ;   interfaces file (it's Not in ROM).
> (deftrap _pgetappletalkinfo ((thepbptr (:pointer :mppparamblock)) (async
> :boolean))
>    (:no-trap :signed-integer)
>    (:no-trap #x0))
>
> ; Here's my code:
> (defun get-my-appletalk-address ()
>   "Returns my appletalk address."
>   (let ((address nil))
>     (rlet ((pb :MPPParamBlock
>                :version 1
>                :laLength 6
>                :linkAddr (%null-ptr)
>                :zoneName (%null-ptr)))
>       (#_PGetAppleTalkInfo pb nil)
>       (setq address (pref pb MPPParamBlock.ourAddr))
>       address)))
>
> But when I try to eval the definition, I get this error:
> > Error: value 0 is not of the expected type SEQUENCE.
> > While executing: EXPAND-TRAP
> > Type Command-. to abort.
>
> We haven't even gotten to the point of actually calling
> the function. If I ever do get there, what goes in the
> csCode field of the MPPParamBlock? IM says "PGetAppleTalkInfo"
> and then refuses to define what this constant is.
>
> Any clues anybody?
> TIA,
> Shannon
> svspire@sandia.gov
 
Shannon,
 
I couldn't get PGetAppleTalkInfo to work, but there may be another way:  Use
the value returned from #'machine-instance (which will be either the Mac name
or the User name) in combination with the zone name.  You can use the following
function to pull the zone name:
 
(defun get-my-zone ()
  (let ((zone-name "")
        (result nil))
    (%stack-block ((zone-buffer 33))
      (rlet ((xpb :XPPParamBlock
                  :ioCompletion (%null-ptr)
                  :ioResult 0
                  :ioRefNum #$xppRefNum
                  :xppRetry 3
                  :xppTimeOut 4
                  :csCode #$xCall
                  :xppSubCode #$zipGetMyZone
                  :zipBuffPtr zone-buffer))
        (%put-byte zone-buffer 0)
        (rarset xpb 0 :XPPParamBlock.zipInfoField 0)
        (rarset xpb 0 :XPPParamBlock.zipInfoField 1)
        (#_GetMyZone xpb #$false)
        ; GetMyZone seems to be async no matter what, so loop
        (loop while (= (pref xpb :XPPParamBlock.ioResult) 1))
        (setf result (pref xpb :XPPParamBlock.ioResult))
        (cond ((= result #$noErr)
               (setf zone-name (%get-string zone-buffer)))
              ((= result #$noBridgeErr)
               (setf zone-name "*"))
              (t
               (setf zone-name "Uknown Zone")))))
    zone-name))
 
Hope this helps!
 
Dan