From: larimer@zeus.cdc.com (Mark D. Larimer)
Newsgroups: comp.sys.mac.programmer
Subject: Re: Help: mounting appleshare volumes
Date: 27 Sep 92 06:24:08 GMT
Organization: Control Data Systems, Inc.
X-UserAgent: Nuntius v1.1.1d7
X-XXDate: Sun, 27 Sep 92 07:23:42 GMT

Let me rephrase that...

{-------------------------------------------------------------------}
  Function Pack (s1,s2,s3,s4,s5,s6 : Str255) : packedType; FORWARD;
{-------------------------------------------------------------------}

{ The guts of the proc that mounts a server in either }
{   System 7 or System 6 with AppleShare 3.0 rdev.    }
Procedure MountIt;
  
  var  err         : OSErr;
       errStr      : Str255;
       myBuffer    : AFPVolMountInfo;
       myParamBlock: ParamBlockRec;

    begin
      with myBuffer do begin
        media:='afpm'; { type of volume; four-character code; afpm =
AppleShareMediaType  }
        flags:=0; { reserved; must be set to 0  }
        nbpInterval:=8; { Name-Binding Protocol (NBP) retry interval  }
        nbpCount:=3; { NBP retry count  }
        uamType:=2; { user authentication method; 2 = kPassword = 8-byte
password }
        zoneNameOffset:=24; { offset from start of record to zone name  }
        serverNameOffset:=57; { offset to server name  }
        volNameOffset:=89; { offset to volume name   }
        userNameOffset:=117; { offset to user name  }
        userPassWordOffset:=149; { offset to user password  }
        volPassWordOffset:=158; { offset to volume password  }
        
        {                                                             
user       volume  }
        {              zone name   server        volume     username   pw
        pw      }
        afpData:=Pack('ZONE NAME','Cool Server','Volume
I','username','password','password');
        length:=sizeof(myBuffer);  { length of mounting information  }
      end;
      
      myParamBlock.ioCompletion:=nil; { proc pointer to execute upon
completion  }
      myParamBlock.ioBuffer:=@myBuffer; { pointer to mounting information
 record  }

      err:=PBVolumeMount(@myParamBlock);  { mount the volume  }
      if err<>0 then begin
        NumToString(err,errStr);
        ParamText('Error during PBVolumeMount',errStr,'','');
        itemHit:=Alert(idAlert,nil);
      end
      else
        serverVRefNum:=myParamBlock.ioVRefNum;  { if successful, vol ref
num returned  }
    end;

{----------------------------------------------------------------------
------}

  { Lay the mounting information into the buffer at the proper offset
locations }
  Function Pack(s1,s2,s3,s4,s5,s6:Str255):packedType;
  
  var  i,j   : integer;
       Data  : packedType;
      
    begin
      j:=2;
      Data[1]:=chr(length(s1));
      for i:=1 to length(s1) do begin
        Data[j]:=s1[i];
        j:=j+1;
      end;
      
      j:=35;
      Data[34]:=chr(length(s2));
      for i:=1 to length(s2) do begin
        Data[j]:=s2[i];
        j:=j+1;
      end;
      
      j:=67;
      Data[66]:=chr(length(s3));
      for i:=1 to length(s3) do begin
        Data[j]:=s3[i];
        j:=j+1;
      end;
      
      j:=95;
      Data[94]:=chr(length(s4));
      for i:=1 to length(s4) do begin
        Data[j]:=s4[i];
        j:=j+1;
      end;
      
      j:=127;
      Data[126]:=chr(length(s5));
      for i:=1 to length(s5) do begin
        Data[j]:=s5[i];
        j:=j+1;
      end;
      
      j:=136;
      Data[135]:=chr(length(s6));
      for i:=1 to length(s6) do begin
        Data[j]:=s6[i];
        j:=j+1;
      end;
      
    Pack:=Data;
  end;

{--------------------------------------------------------------}