Files
reactos/reactos/lib/kernel32/synch/event.c
T
Casper Hornstrup 5a7413d3b7 2003-07-10 Casper S. Hornstrup <[email protected]>
* lib/kernel32/debug/break.c: Add @implemented and @unimplemented
	to APIs.
	* lib/kernel32/debug/debugger.c: Ditto.
	* lib/kernel32/debug/output.c: Ditto.
	* lib/kernel32/except/except.c: Ditto.
	* lib/kernel32/file/backup.c: Ditto.
	* lib/kernel32/file/cnotify.c: Ditto.
	* lib/kernel32/file/copy.c: Ditto.
	* lib/kernel32/file/create.c: Ditto.
	* lib/kernel32/file/curdir.c: Ditto.
	* lib/kernel32/file/delete.c: Ditto.
	* lib/kernel32/file/deviceio.c: Ditto.
	* lib/kernel32/file/dir.c: Ditto.
	* lib/kernel32/file/dosdev.c: Ditto.
	* lib/kernel32/file/file.c: Ditto.
	* lib/kernel32/file/find.c: Ditto.
	* lib/kernel32/file/iocompl.c: Ditto.
	* lib/kernel32/file/lfile.c: Ditto.
	* lib/kernel32/file/lock.c: Ditto.
	* lib/kernel32/file/mailslot.c: Ditto.
	* lib/kernel32/file/move.c: Ditto.
	* lib/kernel32/file/npipe.c: Ditto.
	* lib/kernel32/file/pipe.c: Ditto.
	* lib/kernel32/file/rw.c: Ditto.
	* lib/kernel32/file/tape.c: Ditto.
	* lib/kernel32/file/volume.c: Ditto.
	* lib/kernel32/mem/global.c: Ditto.
	* lib/kernel32/mem/heap.c: Ditto.
	* lib/kernel32/mem/isbad.c: Ditto.
	* lib/kernel32/mem/local.c: Ditto.
	* lib/kernel32/mem/procmem.c: Ditto.
	* lib/kernel32/mem/section.c: Ditto.
	* lib/kernel32/mem/virtual.c: Ditto.
	* lib/kernel32/misc/atom.c: Ditto.
	* lib/kernel32/misc/comm.c: Ditto.
	* lib/kernel32/misc/computername.c: Ditto.
	* lib/kernel32/misc/console.c: Ditto.
	* lib/kernel32/misc/env.c: Ditto.
	* lib/kernel32/misc/error.c: Ditto.
	* lib/kernel32/misc/errormsg.c: Ditto.
	* lib/kernel32/misc/handle.c: Ditto.
	* lib/kernel32/misc/ldr.c: Ditto.
	* lib/kernel32/misc/mbchars.c: Ditto.
	* lib/kernel32/misc/muldiv.c: Ditto.
	* lib/kernel32/misc/perfcnt.c: Ditto.
	* lib/kernel32/misc/profile.c: Ditto.
	* lib/kernel32/misc/res.c: Ditto.
	* lib/kernel32/misc/stubs.c: Ditto.
	* lib/kernel32/misc/sysinfo.c: Ditto.
	* lib/kernel32/misc/time.c: Ditto.
	* lib/kernel32/misc/toolhelp.c: Ditto.
	* lib/kernel32/process/cmdline.c: Ditto.
	* lib/kernel32/process/create.c: Ditto.
	* lib/kernel32/process/proc.c: Ditto.
	* lib/kernel32/process/session.c: Ditto.
	* lib/kernel32/string/lstring.c: Ditto.
	* lib/kernel32/synch/critical.c: Ditto.
	* lib/kernel32/synch/event.c: Ditto.
	* lib/kernel32/synch/intrlck.c: Ditto.
	* lib/kernel32/synch/mutex.c: Ditto.
	* lib/kernel32/synch/sem.c: Ditto.
	* lib/kernel32/synch/timer.c: Ditto.
	* lib/kernel32/synch/wait.c: Ditto.
	* lib/kernel32/thread/fiber.c: Ditto.
	* lib/kernel32/thread/fls.c: Ditto.
	* lib/kernel32/thread/thread.c: Ditto.
	* lib/kernel32/thread/tls.c: Ditto.

svn path=/trunk/; revision=5045
2003-07-10 18:50:51 +00:00

248 lines
4.6 KiB
C

/* $Id: event.c,v 1.14 2003/07/10 18:50:51 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/synch/event.c
* PURPOSE: Local string functions
* PROGRAMMER: Ariadne ( [email protected])
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES *****************************************************************/
#include <k32.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
HANDLE STDCALL
CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
WINBOOL bManualReset,
WINBOOL bInitialState,
LPCSTR lpName)
{
UNICODE_STRING EventNameU;
ANSI_STRING EventName;
HANDLE EventHandle;
RtlInitUnicodeString (&EventNameU, NULL);
if (lpName)
{
RtlInitAnsiString(&EventName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&EventNameU,
&EventName,
TRUE);
}
EventHandle = CreateEventW(lpEventAttributes,
bManualReset,
bInitialState,
EventNameU.Buffer);
if (lpName)
{
RtlFreeUnicodeString(&EventNameU);
}
return EventHandle;
}
/*
* @implemented
*/
HANDLE STDCALL
CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes,
WINBOOL bManualReset,
WINBOOL bInitialState,
LPCWSTR lpName)
{
NTSTATUS Status;
HANDLE hEvent;
UNICODE_STRING EventNameString;
POBJECT_ATTRIBUTES PtrObjectAttributes;
OBJECT_ATTRIBUTES ObjectAttributes;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = NULL;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (lpName != NULL)
{
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName);
ObjectAttributes.ObjectName = &EventNameString;
}
Status = NtCreateEvent(&hEvent,
STANDARD_RIGHTS_ALL|EVENT_READ_ACCESS|EVENT_WRITE_ACCESS,
&ObjectAttributes,
bManualReset,
bInitialState);
DPRINT( "Called\n" );
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
return hEvent;
}
/*
* @implemented
*/
HANDLE STDCALL
OpenEventA(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
LPCSTR lpName)
{
UNICODE_STRING EventNameU;
ANSI_STRING EventName;
HANDLE EventHandle;
RtlInitUnicodeString(&EventNameU,
NULL);
if (lpName)
{
RtlInitAnsiString(&EventName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&EventNameU,
&EventName,
TRUE);
}
EventHandle = OpenEventW(dwDesiredAccess,
bInheritHandle,
EventNameU.Buffer);
if (lpName)
{
RtlFreeUnicodeString(&EventNameU);
}
return EventHandle;
}
/*
* @implemented
*/
HANDLE STDCALL
OpenEventW(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
LPCWSTR lpName)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING EventNameString;
NTSTATUS Status;
HANDLE hEvent = NULL;
if (lpName == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &EventNameString;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenEvent(&hEvent,
dwDesiredAccess,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
return hEvent;
}
/*
* @implemented
*/
WINBOOL STDCALL
PulseEvent(HANDLE hEvent)
{
ULONG Count;
NTSTATUS Status;
Status = NtPulseEvent(hEvent,
&Count);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus (Status);
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
WINBOOL STDCALL
ResetEvent(HANDLE hEvent)
{
NTSTATUS Status;
ULONG Count;
Status = NtResetEvent(hEvent,
&Count);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
}
/*
* @implemented
*/
WINBOOL STDCALL
SetEvent(HANDLE hEvent)
{
NTSTATUS Status;
ULONG Count;
Status = NtSetEvent(hEvent,
&Count);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
}
/* EOF */