Subversion Repositories WoWGM

Rev

Rev 18 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 tristanc 1
#ifndef  _STPL_H_
2
#define  _STPL_H_
3
 
9 tristanc 4
#ifdef	_WIN32
5
#define NOCOMM
6
#define NOSOUND
7
#include <Windows.h>
8
#endif//_WIN32
3 tristanc 9
 
9 tristanc 10
 
11
/****************************************************************************
12
*
13
*	TYPE DEFINITIONS
14
*
15
***/
16
 
17
typedef char i8;
18
typedef char int8;
19
typedef short i16;
20
typedef short int16;
21
typedef int BOOL;
22
typedef int i32;
23
typedef int int32;
24
typedef unsigned char u8;
25
typedef unsigned char uchar;
26
typedef unsigned char uint8;
27
typedef unsigned short u16;
28
typedef unsigned short ushort;
29
typedef unsigned short uint16;
30
typedef unsigned int u32;
31
typedef unsigned int uint;
32
typedef unsigned int uint32;
33
typedef unsigned long ulong;
34
typedef unsigned long DWORD;
35
typedef void* LPVOID;
36
typedef void* HANDLE;
37
 
38
 
39
/****************************************************************************
40
*
41
*	SSTR FUNCTIONS
42
*
43
***/
44
 
45
extern char const* SStrChr(char const* string, char ch);
46
extern char* SStrChr(char* string, char ch);
47
extern char const* SStrChrR(char const* string, char ch);
48
extern char* SStrChrR(char* string, char ch);
49
extern DWORD SStrCopy(char* dest, char const* source, DWORD destsize);
50
extern int SStrCmp(char const* string1, char const* string2, DWORD maxchars);
27 tristanc 51
extern int SStrCmpI(char const* string1, char const* string2, DWORD maxchars = 0xFFFFFFFF);
9 tristanc 52
extern DWORD SStrLen(char const* string);
53
extern DWORD SStrLen(unsigned short const* string);
3 tristanc 54
extern void SStrLower(char* string);
18 tristanc 55
extern int SStrToInt(char const* string);
3 tristanc 56
extern void SStrUpper(char* string);
9 tristanc 57
 
58
 
59
/****************************************************************************
60
*
61
*	SSYNCOBJECT CLASS
62
*
63
***/
64
 
65
class SSyncObject
66
{
67
 
68
public:
69
 
70
	SSyncObject();
71
	~SSyncObject();
72
 
73
	void Close();
74
	BOOL Valid();
75
	DWORD Wait(DWORD timeoutMs);
76
 
77
	HANDLE m_opaqueData;
78
 
79
};
80
 
81
 
82
/****************************************************************************
83
*
84
*	STORM THREADING
85
*
86
***/
87
 
88
#ifdef	_WIN32
89
typedef DWORD(WINAPI THREADCALLBACK)(LPVOID);
90
#else
91
typedef LPVOID(THREADCALLBACK)(LPVOID);
92
#endif//_WIN32
93
 
94
extern HANDLE SCreateThread(THREADCALLBACK*	lpStartAddress,
95
							LPVOID			lpParameter,
96
							DWORD*			lpThreadId,
97
							char*			threadName);
98
 
99
/****************************************************************************
100
*
101
*	STHREAD CLASS
102
*
103
***/
104
 
105
class SThread : public SSyncObject
106
{
107
 
108
public:
109
 
110
	SThread();
111
	~SThread();
112
 
113
	static BOOL Create(THREADCALLBACK*	lpStartAddress,
114
					   LPVOID			param,
115
					   SThread&			thread,
116
					   char*			threadName) {
117
		thread.m_opaqueData = SCreateThread(lpStartAddress, param, 0, threadName);
118
		return thread.m_opaqueData != 0;
119
	}
120
 
121
};
10 tristanc 122
 
123
#endif /*_STPL_H*/