📄 fserver.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*
File: FServer.C
Contains: Contains Glue code for the PC to call the Mac
file server.
Written by: Scott Coleman
Copyright: (c) 1996 Connectix Corporation
Change History (most recent first):
*/
#pragma check_stack( off )
#pragma warning ( disable : 4035 ) // No return value warning
#pragma warning ( disable : 4704 ) // can't optimize inline asm warning
#include <windows.h>
#include "FServer.h"
#include "VCEFsd.h"
// WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
extern ServerPB* gpServerPB; // Kinda hacky, but the virtual addr passed into these
// functions are mapoped to this physical addr.
// This will only work under CE!!!
//WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
// ------------------------------------------------------------
// Global data
// ------------------------------------------------------------
UInt32 kMaxReadWriteSize = kDefMaxReadWriteSize ; // see ServerGetMaxIOSize()
// ------------------------------------------------------------
// Private Equates
// ------------------------------------------------------------
// Most server functions are called by loading a ptr to a
// ServerPB into DS:BX and executing a specific ISA Extension
// instruction. This macro contains the inline asm to do this.
UInt16 CallFunction(unsigned __int32 inCode, ServerPB *inPB)
{
unsigned __int32 Result;
WaitForSingleObject(g_FolderShareMutex, INFINITE);
v_FolderShareDevice->ServerPB = (unsigned __int32)gpServerPB;
v_FolderShareDevice->Code = inCode; // this executes the function
// Poll until the function call returns
while (v_FolderShareDevice->IOPending) {
v_FolderShareDevice->Code = kServerPollCompletion;
}
// Capture the result of the call before releasing the mutex
Result = v_FolderShareDevice->Result;
ReleaseMutex(g_FolderShareMutex);
inPB->fResult = (UInt16)Result;
return (UInt16)Result;
}
#define MakeFunction(inCode) \
{ return CallFunction(inCode, inPB);}
// ------------------------------------------------------------
// Server Glue Functions
// ------------------------------------------------------------
/* ------------------------------------------------------------
ServerGetDriveConfig [Macintosh]
Gets the config info for a specific drive
Parameters:
In: inPB - Ptr to a Server Parameter block
->fVRefNum - Which drive to get config info on
0 - kMaxDrives-1
Out: inPB - Info returned in the parameter block
->fResult - Error code
->fVRefNum - The drive's vRefNum
->fParentID - the dirID of the root
------------------------------------------------------------ */
UInt16 ServerGetDriveConfig( ServerPB * inPB )
MakeFunction ( kServerGetDriveConfig )
/* ------------------------------------------------------------
ServerCreate [Macintosh]
Creates a file (or opens and truncates and existing file)
and returns information on the new file.
NOTE: For long file name support, set fDosName[0] = 0 and
the long file name in fName
Parameters:
In: inPB - Ptr to a Server Parameter block
->fFlags - 0 = DOS Names, 1 = LFN
->fVRefNum - The volume ref num
->fParentID - Directory ID
->u.fXXX.fName - the file name
Out: inPB - Info returned in the parameter block
->fResult - Error code
------------------------------------------------------------ */
UInt16 ServerCreate( ServerPB * inPB )
MakeFunction ( kServerCreate )
/* ------------------------------------------------------------
ServerOpen [Macintosh]
Opens an existing file in the mode specified by fOpenMode
and returns information about the open file.
Parameters:
In: inPB - Ptr to a Server Parameter block
->fFlags - 0 = DOS Names, 1 = LFN
->fVRefNum - The volume ref num
->fParentID - Directory ID
->u.fXXX.fName - the file name
->fOpenMode - Open mode attributes (read only...)
Out: inPB - Info returned in the parameter block
->fResult - Error code
->fHandle - Handle to the file
------------------------------------------------------------ */
UInt16 ServerOpen( ServerPB * inPB )
MakeFunction ( kServerOpen )
/* ------------------------------------------------------------
ServerRead [Macintosh]
Reads data from an already open file.
NOTE: The ->fDTAPtr is loaded into ES:DI so that the Mac
can get the segment base.
NOTE: For 32 bit driver, ->fDTAPtr is loaded in ES:EDI.
Parameters:
In: inPB - Ptr to a Server Parameter block
->fHandle - Handle to the file
->fSize - # of bytes to read
->fPosition - starting position to read from
->fDTAPtr - Disk Transfer Address (PC read buffer)
Out: inPB - Info returned in the parameter block
->fResult - Error code
->fSize - # of bytes actually Read
------------------------------------------------------------ */
UInt16 ServerRead( ServerPB * inPB )
MakeFunction ( kServerRead )
/* ------------------------------------------------------------
ServerWrite [Macintosh]
Writes data to a open file.
NOTE: The ->fDTAPtr is loaded into ES:DI so that the Mac
can get the segment base.
NOTE: For 32 bit driver, ->fDTAPtr is loaded in ES:EDI.
Parameters:
In: inPB - Ptr to a Server Parameter block
->fHandle - Handle to the file
->fSize - # of bytes to write
->fPosition - starting position to write to
->fDTAPtr - Disk Transfer Address (PC write buffer)
Out: inPB - Info returned in the parameter block
->fResult - Error code
->fSize - # of bytes actually written
------------------------------------------------------------ */
UInt16 ServerWrite( ServerPB * inPB )
MakeFunction ( kServerWrite )
/* ------------------------------------------------------------
ServerSetEOF [Macintosh]
Sets the End of File mark for a file.
Parameters:
In: inPB - Ptr to a Server Parameter block
->fHandle - Handle to the file
->fPosition - The new EOF mark
Out: inPB - Info returned in the parameter block
->fResult - Error code
------------------------------------------------------------ */
UInt16 ServerSetEOF( ServerPB * inPB )
MakeFunction ( kServerSetEOF )
/* ------------------------------------------------------------
ServerClose [Macintosh]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -