-
Notifications
You must be signed in to change notification settings - Fork 25
/
globals.h
201 lines (166 loc) · 4.26 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#ifndef GLOBALS_H
#define GLOBALS_H
#ifdef __linux__
#include <wintypes.h>
#endif
#include <string>
#include <cstring>
//#define UNICODE
#ifdef UNICODE
#ifndef _UNICODE
#define _UNICODE
#endif
#endif
#ifdef _UNICODE
#ifndef UNICODE
#define UNICODE
#endif
#endif
#if defined (UNICODE) && defined (_WIN32)
typedef std::wstring string_type;
typedef std::wifstream ifstream_type;
typedef std::wofstream ofstream_type;
typedef std::wfstream fstream_type;
typedef wchar_t char_type;
#define _CONV(x) L ##x
static FILE*(*type_fopen)(const char_type*, const char_type*) = _wfopen;
static size_t(*type_length)(const char_type*) = wcslen;
static char_type*(*type_copy)(char_type*, const char_type*) = wcscpy;
static int(*type_compare)(const char_type*, const char_type*) = wcscmp;
static long(*type_to_int)(const char_type*, char_type**, int) = wcstol;
static char_type*(*type_cat)(char_type*, const char_type*) = wcscat;
static errno_t(*type_path_split)(const char_type*, char_type*, size_t, char_type*, size_t, char_type*, size_t, char_type*, size_t) = _wsplitpath_s;
#else
typedef std::string string_type;
typedef std::ifstream ifstream_type;
typedef std::ofstream ofstream_type;
typedef std::fstream fstream_type;
typedef char char_type;
#define _CONV(x) x
static FILE*(*type_fopen)(const char_type*, const char_type*) = fopen;
static size_t(*type_length)(const char_type*) = strlen;
static char_type*(*type_copy)(char_type*, const char_type*) = strcpy;
static int(*type_compare)(const char_type*, const char_type*) = strcmp;
static long(*type_to_int)(const char_type*, char_type**, int) = strtol;
static char_type*(*type_cat)(char_type*, const char_type*) = strcat;
#if defined(_WIN32)
static errno_t(*type_path_split)(const char_type*, char_type*, size_t, char_type*, size_t, char_type*, size_t, char_type*, size_t) = _splitpath_s;
#endif
#endif
#pragma warning(disable:4005)
#define WINSCARDDATA __declspec(dllexport)
#pragma warning(default:4005)
#if defined(_WIN32)
#define STDCALL __stdcall
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#ifdef WINSCARDAPI
#define SCard WINSCARDAPI
#else
#define SCard
#endif
#ifdef __linux__
typedef wchar_t WCHAR;
typedef wchar_t* LPWSTR;
typedef const wchar_t* LPCWSTR;
typedef unsigned char boolean;
#define GetLastError() errno
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef STDCALL
#define STDCALL
#endif
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#endif
#ifndef HIGHBYTE
#define HIGHBYTE(x) x >> 8
#endif
#ifndef LOWBYTE
#define LOWBYTE(x) x & 0xFF
#endif
#define FILETIME_TO_SECOND 10000000
#define MAX_INI_VALUE_CHAR 1000
#define MAX_INI_VALUE_CHAR_LARGE 1000000
#define FLAG_OS_WIN9X 1
#define FLAG_OS_WINNT 2
//#define _NO_AVAIL_CARD
#ifndef CARDAPDU_DEFINED
#define CARDAPDU_DEFINED
typedef struct _CARDAPDU {
unsigned char cla;
unsigned char ins;
unsigned char p1;
unsigned char p2;
unsigned char lc;
unsigned char le;
unsigned char DataIn[256];
unsigned char DataOut[256];
unsigned short sw;
_CARDAPDU(void) {
clear();
}
void clear() {
sw = cla = ins = p1 = p2 = lc = le = (BYTE) 0;
memset(DataIn, 0, 256);
memset(DataOut, 0, 256);
}
} CARDAPDU;
#endif
#if defined(_WIN32)
typedef struct _INT_DATA_BLOB {
int* pData;
DWORD dwMaxLen;
DWORD dwActLen;
_INT_DATA_BLOB(void) {
pData = NULL;
dwMaxLen = 0;
dwActLen = 0;
}
} INT_DATA_BLOB;
typedef struct _INT64_DATA_BLOB {
__int64* pData;
DWORD dwMaxLen;
DWORD dwActLen;
_INT64_DATA_BLOB(void) {
pData = NULL;
dwMaxLen = 0;
dwActLen = 0;
}
} INT64_DATA_BLOB;
typedef struct _BYTE_DATA_BLOB {
BYTE* pData;
DWORD dwMaxLen;
DWORD dwActLen;
_BYTE_DATA_BLOB(void) {
pData = NULL;
dwMaxLen = 0;
dwActLen = 0;
}
} BYTE_DATA_BLOB;
typedef struct _FLOAT_DATA_BLOB {
float* pData;
DWORD dwMaxLen;
DWORD dwActLen;
_FLOAT_DATA_BLOB(void) {
pData = NULL;
dwMaxLen = 0;
dwActLen = 0;
}
} FLOAT_DATA_BLOB;
#endif
#define SLOT_ANY_AVAILABLE -1
#endif