Commit 6ebbe3c9 authored by Alexandre Julliard's avatar Alexandre Julliard

Cleaned up and removed some no longer used code.

parent 881708cc
......@@ -29,14 +29,10 @@ const K32OBJ_OPS CHANGE_Ops =
typedef struct
{
K32OBJ header;
LPSTR lpPathName;
BOOL32 bWatchSubtree;
DWORD dwNotifyFilter;
THREAD_QUEUE wait_queue;
BOOL32 notify;
} CHANGE_OBJECT;
/****************************************************************************
......@@ -67,13 +63,11 @@ HANDLE32 WINAPI FindFirstChangeNotification32A( LPCSTR lpPathName,
CHANGE_OBJECT *change;
struct create_change_notification_request req;
struct create_change_notification_reply reply;
int len;
req.subtree = bWatchSubtree;
req.filter = dwNotifyFilter;
CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) );
......@@ -89,8 +83,6 @@ HANDLE32 WINAPI FindFirstChangeNotification32A( LPCSTR lpPathName,
change->lpPathName = HEAP_strdupA( SystemHeap, 0, lpPathName );
change->bWatchSubtree = bWatchSubtree;
change->dwNotifyFilter = dwNotifyFilter;
change->wait_queue = NULL;
change->notify = FALSE;
return HANDLE_Alloc( PROCESS_Current(), &change->header,
......
......@@ -652,10 +652,7 @@ HFILE32 DOSFS_OpenDevice( const char *name, int unixmode )
!strcmp(DOSFS_Devices[i].name,"HPSCAN"))
{
int fd = open( "/dev/null", unixmode );
if ((handle = FILE_Alloc( &file, fd )) == INVALID_HANDLE_VALUE32)
return HFILE_ERROR32;
file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
return handle;
return FILE_Alloc( &file, fd, DOSFS_Devices[i].name );
}
FIXME(dosfs,"device open %s not supported (yet)\n",DOSFS_Devices[i].name);
return HFILE_ERROR32;
......
......@@ -10,7 +10,6 @@
#include <time.h>
#include "windows.h"
#include "k32obj.h"
#include "thread.h"
#define MAX_PATHNAME_LEN 1024
......@@ -21,7 +20,6 @@ typedef struct
int mode;
char *unix_name;
DWORD type; /* Type for win32 apps */
THREAD_QUEUE wait_queue;
} FILE_OBJECT;
/* Definition of a full DOS file name */
......@@ -62,9 +60,8 @@ typedef struct
extern FILE_OBJECT *FILE_GetFile( HFILE32 handle, DWORD access,
int *server_handle );
extern void FILE_ReleaseFile( FILE_OBJECT *file );
extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle );
extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle, const char *unix_name );
extern void FILE_SetDosError(void);
extern int FILE_GetUnixHandle( HFILE32 hFile, DWORD access );
extern HFILE32 FILE_DupUnixHandle( int fd );
extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE32 FILE_Dup( HFILE32 hFile );
......@@ -72,7 +69,7 @@ extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode);
extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
extern LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low,
DWORD offset_high, DWORD offset_low,
int prot, int flags );
......
......@@ -28,7 +28,7 @@
/***********************************************************************
* CLIENT_ProtocolError
*/
void CLIENT_ProtocolError( const char *err, ... )
static void CLIENT_ProtocolError( const char *err, ... )
{
THDB *thdb = THREAD_Current();
va_list args;
......@@ -216,6 +216,26 @@ unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
/***********************************************************************
* CLIENT_WaitSimpleReply
*
* Wait for a simple fixed-length reply from the server.
*/
unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd )
{
struct iovec vec[2];
unsigned int ret;
int got;
vec[1].iov_base = reply;
vec[1].iov_len = len;
ret = CLIENT_WaitReply_v( &got, passed_fd, vec, 2 );
if (got != len)
CLIENT_ProtocolError( "WaitSimpleReply: len %d != %d\n", len, got );
return ret;
}
/***********************************************************************
* CLIENT_NewThread
*
* Send a new thread request.
......@@ -224,7 +244,7 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
{
struct new_thread_request request;
struct new_thread_reply reply;
int len, fd[2];
int fd[2];
extern BOOL32 THREAD_InitDone;
extern void server_init( int fd );
extern void select_loop(void);
......@@ -273,16 +293,13 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
request.pid = thdb->process->server_pid;
CLIENT_SendRequest( REQ_NEW_THREAD, fd[1], 1, &request, sizeof(request) );
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) goto error;
if (len < sizeof(reply)) goto error;
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) goto error;
thdb->server_tid = reply.tid;
thdb->process->server_pid = reply.pid;
if (thdb->socket != -1) close( thdb->socket );
thdb->socket = fd[0];
thdb->seq = 0; /* reset the sequence number for the new fd */
/* we don't need the handles for now */
if (thandle) *thandle = reply.thandle;
else if (reply.thandle != -1) CLIENT_CloseHandle( reply.thandle );
if (phandle) *phandle = reply.phandle;
......@@ -359,45 +376,12 @@ int CLIENT_DuplicateHandle( int src_process, int src_handle, int dst_process, in
req.options = options;
CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.handle;
}
/***********************************************************************
* CLIENT_GetProcessInfo
*
* Send a get process info request. Return 0 if OK.
*/
int CLIENT_GetProcessInfo( int handle, struct get_process_info_reply *reply )
{
int len, err;
CLIENT_SendRequest( REQ_GET_PROCESS_INFO, -1, 1, &handle, sizeof(handle) );
err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
CHECK_LEN( len, sizeof(*reply) );
return err;
}
/***********************************************************************
* CLIENT_GetThreadInfo
*
* Send a get thread info request. Return 0 if OK.
*/
int CLIENT_GetThreadInfo( int handle, struct get_thread_info_reply *reply )
{
int len, err;
CLIENT_SendRequest( REQ_GET_THREAD_INFO, -1, 1, &handle, sizeof(handle) );
err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
CHECK_LEN( len, sizeof(*reply) );
return err;
}
/***********************************************************************
* CLIENT_OpenProcess
*
* Open a handle to a process.
......@@ -406,15 +390,13 @@ int CLIENT_OpenProcess( void *pid, DWORD access, BOOL32 inherit )
{
struct open_process_request req;
struct open_process_reply reply;
int len;
req.pid = pid;
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_PROCESS, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.handle;
}
......@@ -435,7 +417,6 @@ int CLIENT_Select( int count, int *handles, int flags, int timeout )
CLIENT_SendRequest( REQ_SELECT, -1, 2,
&req, sizeof(req),
handles, count * sizeof(int) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.signaled;
}
......@@ -20,13 +20,6 @@ typedef struct
K32OBJ header;
} EVENT;
static void EVENT_Destroy( K32OBJ *obj );
const K32OBJ_OPS EVENT_Ops =
{
EVENT_Destroy /* destroy */
};
/***********************************************************************
* CreateEvent32A (KERNEL32.156)
......@@ -45,8 +38,7 @@ HANDLE32 WINAPI CreateEvent32A( SECURITY_ATTRIBUTES *sa, BOOL32 manual_reset,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_EVENT, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
......@@ -96,8 +88,7 @@ HANDLE32 WINAPI OpenEvent32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
......@@ -173,20 +164,6 @@ BOOL32 WINAPI ResetEvent( HANDLE32 handle )
/***********************************************************************
* EVENT_Destroy
*/
static void EVENT_Destroy( K32OBJ *obj )
{
EVENT *event = (EVENT *)obj;
assert( obj->type == K32OBJ_EVENT );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, event );
}
/***********************************************************************
* NOTE: The Win95 VWin32_Event routines given below are really low-level
* routines implemented directly by VWin32. The user-mode libraries
* implement Win32 synchronisation routines on top of these low-level
......
......@@ -21,23 +21,25 @@ extern const K32OBJ_OPS DEVICE_Ops;
extern const K32OBJ_OPS CONSOLE_Ops;
extern const K32OBJ_OPS SNAPSHOT_Ops;
/* The following are fully implemented in the server and could be removed */
extern const K32OBJ_OPS SEMAPHORE_Ops;
extern const K32OBJ_OPS EVENT_Ops;
extern const K32OBJ_OPS MUTEX_Ops;
extern const K32OBJ_OPS PIPE_Ops;
static const K32OBJ_OPS K32OBJ_NullOps =
{
NULL /* destroy */
};
static void K32OBJ_Destroy( K32OBJ *obj );
static const K32OBJ_OPS K32OBJ_DefaultOps =
{
K32OBJ_Destroy /* destroy */
};
const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] =
{
NULL,
&SEMAPHORE_Ops, /* K32OBJ_SEMAPHORE */
&EVENT_Ops, /* K32OBJ_EVENT */
&MUTEX_Ops, /* K32OBJ_MUTEX */
&K32OBJ_DefaultOps, /* K32OBJ_SEMAPHORE */
&K32OBJ_DefaultOps, /* K32OBJ_EVENT */
&K32OBJ_DefaultOps, /* K32OBJ_MUTEX */
&K32OBJ_NullOps, /* K32OBJ_CRITICAL_SECTION */
&PROCESS_Ops, /* K32OBJ_PROCESS */
&THREAD_Ops, /* K32OBJ_THREAD */
......@@ -48,7 +50,7 @@ const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] =
&MEM_MAPPED_FILE_Ops, /* K32OBJ_MEM_MAPPED_FILE */
&K32OBJ_NullOps, /* K32OBJ_SERIAL */
&DEVICE_Ops, /* K32OBJ_DEVICE_IOCTL */
&PIPE_Ops, /* K32OBJ_PIPE */
&K32OBJ_DefaultOps, /* K32OBJ_PIPE */
&K32OBJ_NullOps, /* K32OBJ_MAILSLOT */
&K32OBJ_NullOps, /* K32OBJ_TOOLHELP_SNAPSHOT */
&K32OBJ_NullOps /* K32OBJ_SOCKET */
......@@ -113,6 +115,18 @@ void K32OBJ_DecCount( K32OBJ *ptr )
/***********************************************************************
* K32OBJ_Destroy
*
* Generic destroy functions for objects that don't need any special treatment.
*/
static void K32OBJ_Destroy( K32OBJ *obj )
{
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, obj );
}
/***********************************************************************
* K32OBJ_IsValid
*
* Check if a pointer is a valid kernel object
......
......@@ -19,13 +19,6 @@ typedef struct _MUTEX
K32OBJ header;
} MUTEX;
static void MUTEX_Destroy( K32OBJ *obj );
const K32OBJ_OPS MUTEX_Ops =
{
MUTEX_Destroy /* destroy */
};
/***********************************************************************
* CreateMutex32A (KERNEL32.166)
......@@ -43,8 +36,7 @@ HANDLE32 WINAPI CreateMutex32A( SECURITY_ATTRIBUTES *sa, BOOL32 owner,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_MUTEX, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
......@@ -86,8 +78,7 @@ HANDLE32 WINAPI OpenMutex32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
......@@ -130,15 +121,3 @@ BOOL32 WINAPI ReleaseMutex( HANDLE32 handle )
CLIENT_SendRequest( REQ_RELEASE_MUTEX, -1, 1, &req, sizeof(req) );
return !CLIENT_WaitReply( NULL, NULL, 0 );
}
/***********************************************************************
* MUTEX_Destroy
*/
static void MUTEX_Destroy( K32OBJ *obj )
{
MUTEX *mutex = (MUTEX *)obj;
assert( obj->type == K32OBJ_MUTEX );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, mutex );
}
......@@ -19,13 +19,6 @@ typedef struct _PIPE
K32OBJ header;
} PIPE;
static void PIPE_Destroy( K32OBJ *obj );
const K32OBJ_OPS PIPE_Ops =
{
PIPE_Destroy /* destroy */
};
/***********************************************************************
* CreatePipe (KERNEL32.170)
......@@ -71,16 +64,3 @@ BOOL32 WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
SYSTEM_UNLOCK();
return TRUE;
}
/***********************************************************************
* PIPE_Destroy
*/
static void PIPE_Destroy( K32OBJ *obj )
{
PIPE *pipe = (PIPE *)obj;
assert( obj->type == K32OBJ_PIPE );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, pipe );
}
......@@ -19,13 +19,6 @@ typedef struct
K32OBJ header;
} SEMAPHORE;
static void SEMAPHORE_Destroy( K32OBJ *obj );
const K32OBJ_OPS SEMAPHORE_Ops =
{
SEMAPHORE_Destroy /* destroy */
};
/***********************************************************************
* CreateSemaphore32A (KERNEL32.174)
......@@ -52,8 +45,7 @@ HANDLE32 WINAPI CreateSemaphore32A( SECURITY_ATTRIBUTES *sa, LONG initial,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_SEMAPHORE, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
......@@ -95,8 +87,7 @@ HANDLE32 WINAPI OpenSemaphore32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
CHECK_LEN( len, sizeof(reply) );
CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
......@@ -133,7 +124,6 @@ BOOL32 WINAPI ReleaseSemaphore( HANDLE32 handle, LONG count, LONG *previous )
{
struct release_semaphore_request req;
struct release_semaphore_reply reply;
int len;
if (count < 0)
{
......@@ -145,21 +135,7 @@ BOOL32 WINAPI ReleaseSemaphore( HANDLE32 handle, LONG count, LONG *previous )
if (req.handle == -1) return FALSE;
req.count = (unsigned int)count;
CLIENT_SendRequest( REQ_RELEASE_SEMAPHORE, -1, 1, &req, sizeof(req) );
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) return FALSE;
CHECK_LEN( len, sizeof(reply) );
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
if (previous) *previous = reply.prev_count;
return TRUE;
}
/***********************************************************************
* SEMAPHORE_Destroy
*/
static void SEMAPHORE_Destroy( K32OBJ *obj )
{
SEMAPHORE *sem = (SEMAPHORE *)obj;
assert( obj->type == K32OBJ_SEMAPHORE );
/* There cannot be any thread on the list since the ref count is 0 */
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, sem );
}
......@@ -60,7 +60,6 @@ typedef struct _CONSOLE {
LPSTR title; /* title of console */
INPUT_RECORD *irs; /* buffered input records */
int nrofirs;/* nr of buffered input records */
THREAD_QUEUE wait_queue;
} CONSOLE;
static void CONSOLE_Destroy( K32OBJ *obj );
......@@ -644,7 +643,6 @@ BOOL32 WINAPI AllocConsole(VOID)
{
struct create_console_request req;
struct create_console_reply reply;
int len;
PDB32 *pdb = PROCESS_Current();
CONSOLE *console;
HANDLE32 hIn, hOut, hErr;
......@@ -674,7 +672,6 @@ BOOL32 WINAPI AllocConsole(VOID)
console->pid = -1;
console->title = NULL;
console->nrofirs = 0;
console->wait_queue = NULL;
console->irs = HeapAlloc(GetProcessHeap(),0,1);;
console->mode = ENABLE_PROCESSED_INPUT
| ENABLE_LINE_INPUT
......@@ -685,13 +682,12 @@ BOOL32 WINAPI AllocConsole(VOID)
console->hread = console->hwrite = -1;
CLIENT_SendRequest( REQ_CREATE_CONSOLE, -1, 1, &req, sizeof(req) );
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ) != ERROR_SUCCESS)
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ) != ERROR_SUCCESS)
{
K32OBJ_DecCount(&console->header);
SYSTEM_UNLOCK();
return FALSE;
}
CHECK_LEN( len, sizeof(reply) );
console->hread = reply.handle_read;
console->hwrite = reply.handle_write;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment