#ifndef __FO_THREAD__
#define __FO_THREAD__

#define FALSE false
#define TRUE true

#define HANDLE_TYPE_EVENT	0x00000001
#define HANDLE_TYPE_MUTEX	0x00000002
#define HANDLE_TYPE_THREAD	0x00000004
#define HANDLE_TYPE_SEMAPHORE	0x00000008

#define INFINITE		0xFFFFFFFF

#define STATUS_WAIT_0			((DWORD   )0x00000000L)    
#define STATUS_ABANDONED_WAIT_0		((DWORD   )0x00000080L)    
#define STATUS_TIMEOUT			((DWORD   )0x00000102L)    
#define WAIT_OBJECT_0			((STATUS_WAIT_0 ) + 0 )
#define WAIT_ABANDONED			((STATUS_ABANDONED_WAIT_0 ) + 0 )
#define WAIT_ABANDONED_0		((STATUS_ABANDONED_WAIT_0 ) + 0 )
#define WAIT_TIMEOUT			STATUS_TIMEOUT

typedef unsigned char UCHAR;
typedef short unsigned int WORD;
typedef unsigned long int DWORD;
typedef DWORD * LPDWORD;
typedef void VOID;
typedef VOID * LPVOID;
typedef bool BOOL;
typedef char * LPCSTR;


typedef void *	(*LPTHREAD_START_ROUTINE)(void *);

typedef struct {
	unsigned long handle_type;
	unsigned long handle_value;
	unsigned long aux_value;
	unsigned long flags;
	unsigned long reserved;
} handle_t;

typedef handle_t * FOHANDLE;
typedef FOHANDLE * LPFOHANDLE;

typedef struct {
	DWORD nLength;
	LPVOID lpSecurityDescriptor;
	BOOL bInheritHandle;
} SECURITY_ATTRIBUTES;

typedef SECURITY_ATTRIBUTES * LPSECURITY_ATTRIBUTES;

FOHANDLE FoCreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes , DWORD dwStackSize , LPTHREAD_START_ROUTINE lpStartAddress , LPVOID lpParameters , DWORD dwCreationFlags , LPDWORD lpThreadId );
BOOL FoCloseHandle( FOHANDLE hObject );

FOHANDLE FoCreateEvent( LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName );
DWORD FoWaitForSingleObject( FOHANDLE hHandle , DWORD dwMilliseconds );
BOOL FoSetEvent( FOHANDLE hEvent );
BOOL FoResetEvent( FOHANDLE hEvent );
FOHANDLE FoCreateMutex( LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCSTR lpName );
BOOL FoReleaseMutex( FOHANDLE hMutex );

#endif
