| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef _COMMON_H__ |
| 23 |
#define _COMMON_H__ |
| 24 |
|
| 25 |
#ifdef _MSC_VER |
| 26 |
#pragma warning(disable: 4995) |
| 27 |
#pragma warning(disable: 4996) |
| 28 |
#endif |
| 29 |
|
| 30 |
#ifdef _WIN32 |
| 31 |
#include <windows.h> |
| 32 |
#endif |
| 33 |
|
| 34 |
#include <ctype.h> |
| 35 |
#include <string.h> |
| 36 |
|
| 37 |
|
| 38 |
typedef unsigned char u8; |
| 39 |
typedef unsigned short u16; |
| 40 |
typedef unsigned int u32; |
| 41 |
typedef unsigned __int64 u64; |
| 42 |
typedef signed char s8; |
| 43 |
typedef signed short s16; |
| 44 |
typedef signed int s32; |
| 45 |
typedef __int64 s64; |
| 46 |
|
| 47 |
static char *trim(char *s) |
| 48 |
{ |
| 49 |
char *ptr = NULL; |
| 50 |
if (!s) return NULL; |
| 51 |
if (!*s) return s; |
| 52 |
|
| 53 |
for (ptr = s + strlen(s) - 1; (ptr >= s) && isspace(*ptr); ptr--); |
| 54 |
ptr[1] = '\0'; |
| 55 |
return s; |
| 56 |
} |
| 57 |
|
| 58 |
#ifdef _WIN32 |
| 59 |
char __forceinline *error() |
| 60 |
{ |
| 61 |
LPVOID lpMsgBuf = NULL; |
| 62 |
|
| 63 |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 64 |
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 512, NULL); |
| 65 |
|
| 66 |
return strdup((char*)lpMsgBuf); |
| 67 |
} |
| 68 |
#endif |
| 69 |
|
| 70 |
#endif |