AppleShare File Server 3.0 Control_____________________________________________________________________________CHAPTER 1-SERVER CONTROL CALLS_________
VAR ServerError: Integer;VAR SecondsLeft: LongInt): OSErr;VARscPB: SCParamBlockRec;BEGINscPB.pollServerPB.scCode := SCPollServer;{ Macintosh File Shar
VAR VolListModDate: LongInt):OSErr;VARscPB: SCParamBlockRec;BEGINscPB.statusPB.scCode := SCGetServerStatus;scPB.statusPB.scNamePtr := NamePtr;MySCGetS
scPB: SCParamBlockRec;BEGINscPB.startPB.scCode := SCStartServer;scPB.startPB.scStartSelect := kCurInstalled;scPB.startPB.scEventSelect := kFinderExtn;
MySCCancelShutDown := SyncServerDispatch(@scPB);END;SCSleepServerThe following function calls SCSleepServer to temporarily shut down the fileserver (&
Obtaining status information about users, volumes, and shared itemsThis section describes the server control calls that you use to obtaininformation a
NamePtr^ := '';ENDELSEBEGINscPB.standardPB.scNamePtr := NamePtr;END;scPB.standardPB.scIndex := Index;MySCGetExpFldr := SyncServerDispatch(@s
END;SERVER CONTROL CALLSThe following procedure creates a list of shared volumes and folders. Beforeusing this procedure, you must initialize gMaxVolu
END;ENDELSE IF err <> fnfErr THEN{ fnfErr only means there is nothing at this }{ Index position }BEGIN{ handle any unexpected errors }END;END;EN
UNRecID := scPB.userInfoPB.scUNRecID;UserID := scPB.userInfoPB.scUserID;LoginTime := scPB.userInfoPB.scLoginTime;LastUseTime := scPB.userInfoPB.scLast
{ handle any unexpected errors }END;UNTIL err <> noErr;END;SCGetUserMountInfoThe following function calls SCGetUserMountInfo to get information
AppleShare File Server 3.0 software componentsThe AppleShare File Server 3.0 is composed of a number of files. The FileServer Extension provides the a
procedure, you mustinitialize gMaxVolumes and gMaxExpFolders with the values returned bythe SCGetGetupInfo control call.PROCEDURE GetAllUserMountInfo
a file server.Note Although Macintosh File Sharing implements SCDisconnect, there is noway to use this call with Macintosh File Sharing because Macin
ArrayCount := 1; { one user }NumMinutes := 10;Flags := UNRFSendMsgMask; { send a message }Message := 'Goodbye.';err := MySCDisconnect(@UNRe
scPB.disconnectPB.scFlags := Flags;scPB.disconnectPB.scMessagePtr := MessagePtr;MySCDisconnectVolUsers := SyncServerDispatch(@scPB);END;The following
This section describes the server control call that lets you send messages tousers.SCSendMessageThe following function calls SCSendMessage to send a m
DiscArrayPtr: LongIntPtr;ArrayCount: Integer;Flags: Integer;Message: tLoginMsg;BEGIN{ allocate an array large enough to get all users }DiscArrayPtr :=
Flags := UNRFSendMsgMask; { send a message }Message := 'Moof!';err := MySCSendMessage(DiscArrayPtr, ArrayCount,Flags, @Message);IF err = noE
VARscPB: SCParamBlockRec;BEGINscPB.standardPB.scNamePtr := NamePtr;scPB.standardPB.scVRefNum := VRefNum;scPB.standardPB.scCode := SCSetCopyProtect;scP
Note This call is not supported by Macintosh File Sharing.FUNCTION mySCInstallServerEventProc(theSEHandler: ProcPtr): OSErr;VARscPB: SCParamBlockRec;
scPB: SCParamBlockRec;BEGINscPB.serverEventPB.scCode := SCGetServerEventProc;MySCGetServerEventProc := SyncServerDispatch(@scPB);theSEQHdrPtr := QHdrP
The AppleShare Installer initially installs the AppleShare File Serverapplication in the System Folder, but the file can reside anywhere on theserver
to see if the handler is interested in the event that just happened. If itis, the server calls the handler, passing pointers to the tSEQEntry recordan
been satisfied, you can use server events in conjunction with server controlcalls to respond to the condition. For example, you can shut the server do
qLink: QElemPtr;qType: Integer;theSERec: ServerEventRecord;END;{ Extend the tSEQEntry with a few items we need access }{ to within the server event ha
BEGINscPB.serverEventPB.scSEQEntryPtr := theSEHandler;scPB.serverEventPB.scCode := SCInstallServerEventProc;mySCInstallServerEventProc := SyncServerDi
(theSEQPtr: ExtendedSEQEntryPtr;theSERecPtr: ServerEventRecordPtr);VARtheSERecQElemPtr: SERecQElemPtr;BEGINWITH theSEQPtr^ DOBEGINIF freeQ.qHead <&
{ and enqueue my server event record into }{ the usedQ. }Enqueue(QElemPtr(theSERecQElemPtr), @usedQ);{ Wake up our process so it can handle the server
{ clear all SEwhichAFPFlags, }theSEQEntry.SEwhichAFPFlag[0] := 0;theSEQEntry.SEwhichAFPFlag[1] := 0;{ and clear all SEwhichSCFlags. }theSEQEntry.SEwhi
InitSEQEntry := TRUE; { Everything is OK. }ENDELSEInitSEQEntry := FALSE; { No memory. }IF GetCurrentProcess(ourPSN) <> noErr THEN; { Get our pro
{ bits first. }PROCEDURE SetSEFlags;BEGINWITH gExtendedSEQEntry.theSEQEntry DOBEGIN{ If the bCSEHAFPInDoRequest or }{ bCSEHAFPInSendResponse bits in
END;{ ProcessServerEvents should be called every time through }{ the event loop to see if there are any server event }{ records to process. If there
The File Sharing Extension contains no user interface of its own. The userinterface is provided by the Network Extension, which allows users to starta
END;{ Your application calls InstallServerEventHandler to }{ install the server event handler. Change the }{ InitSEQEntry function where indicated to
{ Your application calls RemoveServerEventHandler to }{ remove the server event handler and dispose of the }{ memory allocated by InitSEQEntry (which
of the parameter block, and lists the possible result codes. The calls arepresented in alphabetical order.SCCancelShutDownSCCancelShutDown cancels the
Result Codes noErr 0 No error.paramErr -50 The server is not running.SCClrCopyProtect may also return errors returned by t
Result Codes noErr 0 No error.AlreadyShuttingDown -1 The server is alreadyshutting down.AlreadyDisconnecting
scMessagePtr Longword input value: A pointer to a Str199containing the message sent to theworkstations.Result Codes noErr 0
negative, then an empty Pascal string ('') isreturned.scVRefNum Word result value: Returns the referencenumber
Fields ioResult Word result value: Result code.scSEQEntryPtr Longword result pointer: Returns a pointer to an operating sys
bJBSEnabled Set if Apple II boot service is enabled.All other bits are reserved.scNumSessions Word result value: The number of currently o
volumes supported by the server.Note This value is not returned under Macintosh File Sharing. (The maximumnumber of volumes supported under Macintosh
File Manager The Macintosh File Manager normally handles local requests forfile access. When Macintosh File Sharing is turned on, however, the FileSh
scCode Word input value: The server control code; always SCGetUserMountInfo ($0014).scFilesOpen Word result value: Returns the total nu
Fields ioResult Word result value: Result code.scNamePtr Longword result pointer: Points to a Str31where the user name will
scSEQEntryPtr Longword input pointer: Points to the tSEQEntryserver event object to be installed in the serverevent handler queue.scCode
SCPSJustDisabled Server was just disabled and there was no startuperror.SCPSDisabledwErr Server is disabled and there is an "SE" error ins
SESysTooOldErr The System file is too old for AppleShare FileServer 3.0.SEInsuffAppMemErr There was not enough memory for the file server tostart
SCSendMessageSCSendMessage sends a server message to every user whose user name record ID(UNRecID) is contained in the array pointed to by scDiscArray
!! WARNING Macintosh File Sharing does not return a valid value forscServerVersion if the server is not running. !!Parameter (uses versionPB vari
Fields ioResult Word result value: Result code.scNamePtr Longword input pointer: Points to the filename.scVRefNum Word input value: The
scSetupPtr is NIL, or SetupInfoRec contains a value that is outof range.SCShutDownSCShutDown shuts down the file
range, or an unknown bit isset in scFlags.SCSleepServerSCSleepServer shuts down the file server temporarily. This call has the sameparameters as SCShu
Some of the server control call descriptions are accompanied by a secondsegment of sample code that shows a particular use of that call. Each ofthese
SCStartServerSCStartServer starts the file server.!! IMPORTANT The AppleShare File Server 3.0 is normally started by theAppleShare File Server appli
Note This call is not supported by Macintosh File Sharing.Parameter (uses standardPB variant of SCParamBlockRec)Block 16
The SCDisconnect call does not send disconnect attention messages underMacintosh File Sharing.SCGetExpFldrWith Macintosh File Sharing, your program sh
Macintosh File Sharing does not return a valid value for SCServerVersion ifthe server is not running.SCSetSetupInfoThe SCSetSetupInfo call does not us
SCGetExpFldr = 6;SCGetSetupInfo = 7;SCSetSetupInfo = 8;SCSendMessage = 9;SCGetServerStatus = 10;SCIn
{ and 7.0.1}{ $0031 = File Server Extension, version 3.0}{ $0032 = File Sharing Extension, version 7.0.2}{some random constants for SCStart
{ SCPollServer in scServerError}SENoUGFileOpenErr = 1; {The Users & Groups Data }{ File could not be opened}SENoRealVolsErr = 2; {Ther
{ File Server Extension or }{ File Sharing Extension }{ could not be found}SESysTooOldErr = 13; {The System File is too old }{ for AppleShare (
{ and AppleShare 3.0}SIMaxLogins: Integer; {1..11 for File }{ Sharing; 1..121 }{ for AppleShare 3.0}SISrvrUsageLimit: Integer; {10 to 1
scStartSelect: Integer;scEventSelect: Integer;reserved4: ARRAY[1..4] OF LongInt;END;disconnectParam =RECORDscDiscArrayPtr: LongIntPtr;scArrayCount
Determining if server control calls are availableBefore using any of the other control calls, use the TrapAvailable call tomake sure that the server d
scLogins: Integer;scCode: Integer;scIndex: Integer;scDirID: LongInt;END;setupParam =RECORDscSetupPtr: SetupInfoRecPtr;scMaxVolumes:
reserved3: Integer;scCode: Integer;END;versionParam =RECORDscExtNamePtr: StringPtr;reserved2: Integer;reserved3: Integer;scC
reserved3: Integer;scCode: Integer;scFilesOpen: Integer;scWriteableFiles: Integer;scUNRecID: LongInt;scMounted: Bo
Server control routineFUNCTION SyncServerDispatch (pb: SCParamBlockPtr): OSErr;Server event interface fileThe ServerEventINTF file contains all of the
{ to detect server starts and wakeups}bCSEHShare = 5;{An HFS Share trap has just been completed}bCSEHUnShare = 6;{An HFS UnShare
bCSEHSessionTimedOut = 15;{A workstation's session timed out}bCSEHSrvrClosedSession = 16;{The server has closed a workstation's session}{W
TYPEServerEventRecordPtr = ^ServerEventRecord;ServerEventRecord =RECORDtheEventNumber: LongInt;{the server event that's occuring; see the }{ SE
{ bCSEHAFPInSendResponse: the first }{ BufferMax bytes of the AFP packet }{ if theEventNumber = bCSEHServerControlCall: }{ the first BufferMax b
theUNSUserID: LongInt;{the UserID of the user that made the call}theUserName: Str31;{the name of the user that made the call}{Note: If theEve
SEwhichSCFlag: LongInt;{specifies which Server Control calls will cause }{ the Server Event Handler to be called}END;Application-defined routinePROCE
END;The following segment of code gets the server version information and storesit in global variables for later use. (Global variables and their data
MaxVolumes := scPB.setupPB.scMaxVolumes;MaxExpFolders := scPB.setupPB.scMaxExpFolders;CurMaxSessions := scPB.setupPB.scCurMaxSessions;END;END;END;The
Comments to this Manuals