Debian Codegraph @

tools/cheatsConverter/src/common.h

raw symbols SCIP
1 /* Cheats converter
2
3 Copyright 2009 DeSmuME team
4
5 This file is part of DeSmuME
6
7 DeSmuME is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 DeSmuME is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with DeSmuME; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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