115 |
cycrow |
1 |
/*
|
|
|
2 |
libx2bc.h
|
|
|
3 |
|
|
|
4 |
Main header for x2bc library
|
|
|
5 |
|
|
|
6 |
Author: doubleshadow, based on work of CheckerTwo
|
|
|
7 |
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
#ifndef LIB_X2_BC_INCLUDED
|
|
|
11 |
#define LIB_X2_BC_INCLUDED
|
|
|
12 |
|
|
|
13 |
#define X2BC_EXPORT
|
|
|
14 |
#define X2BCAPI __stdcall
|
|
|
15 |
|
|
|
16 |
// input file type (for BOD compilation)
|
|
|
17 |
#define X2BC_BOD_CUT 1
|
|
|
18 |
#define X2BC_BOD_BOB 2
|
|
|
19 |
|
|
|
20 |
// options (for SetOption)
|
|
|
21 |
#define X2BC_O_XTRA_PNT_INFO 1
|
|
|
22 |
#define X2BC_O_RAW_MODE 3
|
|
|
23 |
#define X2BC_O_WRITE_X3_DATA 4
|
|
|
24 |
|
|
|
25 |
// Error severity
|
|
|
26 |
#define X2BC_SEV_SUCCESS 0
|
|
|
27 |
#define X2BC_SEV_ERROR 1
|
|
|
28 |
#define X2BC_SEV_WARNING 2
|
|
|
29 |
|
|
|
30 |
// Error facilities
|
|
|
31 |
#define X2BC_FACILITY_SETTINGS 1
|
|
|
32 |
#define X2BC_FACILITY_BOBLOADER 2
|
|
|
33 |
#define X2BC_FACILITY_STATLOADER 3
|
|
|
34 |
#define X2BC_FACILITY_COMPILER 4
|
|
|
35 |
#define X2BC_FACILITY_DLL 5
|
|
|
36 |
|
|
|
37 |
// Error codes
|
|
|
38 |
#define X2BC_E_OK 0
|
|
|
39 |
#define X2BC_E_Error 1
|
|
|
40 |
#define X2BC_E_BadConstantDeclaration 2
|
|
|
41 |
#define X2BC_E_BadFormatDeclaration 3
|
|
|
42 |
#define X2BC_E_SectionEmpty 4
|
|
|
43 |
#define X2BC_E_LineIgnored 5
|
|
|
44 |
#define X2BC_E_ConstantAlwaysZero 6
|
|
|
45 |
|
|
|
46 |
#define X2BC_E_BadHeader 7
|
|
|
47 |
#define X2BC_E_BadEndHeader 8
|
|
|
48 |
#define X2BC_E_MoreData 9
|
|
|
49 |
#define X2BC_E_NotEnoughData 10
|
|
|
50 |
#define X2BC_E_ChildrenCountIncorrect 11
|
|
|
51 |
#define X2BC_E_NoStatFormat 12
|
|
|
52 |
#define X2BC_E_FormatUserWarning 13
|
|
|
53 |
#define X2BC_E_UnkPointFlags 14
|
|
|
54 |
#define X2BC_E_PointNotFound 15
|
|
|
55 |
#define X2BC_E_BadVersion 16
|
|
|
56 |
|
|
|
57 |
#define X2BC_E_FileCannotOpen 17
|
|
|
58 |
#define X2BC_E_BadFlags 18
|
|
|
59 |
|
|
|
60 |
#define X2BC_SEVERITY(code) (code >> 24)
|
|
|
61 |
#define X2BC_FACILITY(code) ((code >> 16) & 0xff)
|
|
|
62 |
|
|
|
63 |
#define X2BC_FAILED(code) ((X2BC_SEVERITY(code) & X2BC_SEV_ERROR) > 0)
|
|
|
64 |
#define X2BC_WARNING(code) ((X2BC_SEVERITY(code) & X2BC_SEV_WARNING) > 0)
|
|
|
65 |
#define X2BC_SUCCEEDED(code) ((X2BC_SEVERITY(code) & X2BC_SEV_SUCCESS ) == 0)
|
|
|
66 |
|
|
|
67 |
struct X2BC_ERROR
|
|
|
68 |
{
|
|
|
69 |
int code;
|
|
|
70 |
int line;
|
|
|
71 |
int col;
|
|
|
72 |
char text[255];
|
|
|
73 |
};
|
|
|
74 |
|
|
|
75 |
#ifdef __cplusplus
|
|
|
76 |
extern "C" {
|
|
|
77 |
#endif
|
|
|
78 |
|
|
|
79 |
/************************************************
|
|
|
80 |
* X2BC_LoadSettings
|
|
|
81 |
*
|
|
|
82 |
* Loads ini file with settings
|
|
|
83 |
*
|
|
|
84 |
* in: pszINIFileName - ini file to load
|
|
|
85 |
* ret: zero on failure, nonzero otherwise
|
|
|
86 |
************************************************/
|
|
|
87 |
X2BC_EXPORT int X2BCAPI X2BC_LoadSettings(const char *pszINIFileName);
|
|
|
88 |
|
|
|
89 |
/************************************************
|
|
|
90 |
* X2BC_BOB2BOD
|
|
|
91 |
*
|
|
|
92 |
* Converts binary BOB file to text BOD file
|
|
|
93 |
*
|
|
|
94 |
* in: pszFileName - input bob file, pszOutFileName - output bod file
|
|
|
95 |
* ret: zero on failure, nonzero otherwise
|
|
|
96 |
************************************************/
|
|
|
97 |
X2BC_EXPORT int X2BCAPI X2BC_BOB2BOD(const char *pszFileName,
|
|
|
98 |
const char *pszOutFileName);
|
|
|
99 |
|
|
|
100 |
/************************************************
|
|
|
101 |
* X2BC_BOD2BOB
|
|
|
102 |
*
|
|
|
103 |
* Converts text BOD file to binary BOB file
|
|
|
104 |
*
|
|
|
105 |
* in: pszBuffer - buffer containning the bod data. It must be zero terminated!,
|
|
|
106 |
* nSize size of buffer (excluding the terminating zero), pszOutFileName -
|
|
|
107 |
* output bob file, nBODType - type of input data (X2BC_BOD_CUT,
|
|
|
108 |
* X2BC_BOD_BOB)
|
|
|
109 |
* ret: zero on failure, nonzero otherwise
|
|
|
110 |
************************************************/
|
|
|
111 |
X2BC_EXPORT int X2BCAPI X2BC_BOD2BOB(char *pszBuffer, int nSize,
|
|
|
112 |
const char *pszOutFileName, int nBODType);
|
|
|
113 |
|
|
|
114 |
/************************************************
|
|
|
115 |
* X2BC_GetError
|
|
|
116 |
*
|
|
|
117 |
* retrieves error from the error stack
|
|
|
118 |
*
|
|
|
119 |
* in: pointer to error structure
|
|
|
120 |
* ret: zero if no error was retrieved, non zero otherwise
|
|
|
121 |
************************************************/
|
|
|
122 |
X2BC_EXPORT int X2BCAPI X2BC_GetError(X2BC_ERROR *pError);
|
|
|
123 |
|
|
|
124 |
/************************************************
|
|
|
125 |
* X2BC_SetOption
|
|
|
126 |
*
|
|
|
127 |
* set option for compiler/decompiler
|
|
|
128 |
*
|
|
|
129 |
* in: nOption - what to set (use X2BC_O_* settings)
|
|
|
130 |
* ret: zero if no error was retrieved, non zero otherwise
|
|
|
131 |
************************************************/
|
|
|
132 |
X2BC_EXPORT int X2BCAPI X2BC_SetOption(int nOption, const char *pszValue);
|
|
|
133 |
|
|
|
134 |
/************************************************
|
|
|
135 |
* X2BC_GetVersion
|
|
|
136 |
*
|
|
|
137 |
* returns library version
|
|
|
138 |
*
|
|
|
139 |
* in: nBuffLen - length of in buffer
|
|
|
140 |
* out: pszBuffer - pointer to buffer to recieve the version string
|
|
|
141 |
* ret: number of copied bytes
|
|
|
142 |
************************************************/
|
|
|
143 |
X2BC_EXPORT int X2BCAPI X2BC_GetVersion(char *pszBuffer, int nBuffLen);
|
|
|
144 |
|
|
|
145 |
#ifdef __cplusplus
|
|
|
146 |
}
|
|
|
147 |
#endif
|
|
|
148 |
|
|
|
149 |
#endif // !defined(LIB_X2_BC_INCLUDED)
|