-
Notifications
You must be signed in to change notification settings - Fork 259
/
declare.h
299 lines (245 loc) · 8.71 KB
/
declare.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// Copyright (c) 2014-2017 Coin Sciences Ltd
// MultiChain code distributed under the GPLv3 license, see COPYING file.
#ifndef MULTICHAIN_DECLARE_H
#define MULTICHAIN_DECLARE_H
#include "utils/define.h"
#define MC_DCT_TERM_BUFFER_SIZE 25165824
/* Classes */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mc_MapStringIndex
{
void *mapObject;
mc_MapStringIndex()
{
mapObject=NULL;
Init();
}
~mc_MapStringIndex()
{
Destroy();
}
void Init();
void Add(const char* key,int value);
void Add(const unsigned char* key,int size,int value);
void Remove(const char* key,int size);
int Get(const char* key);
int Get(const unsigned char* key,int size);
void Set(const unsigned char* key,int size,int value);
void Destroy();
void Clear();
} mc_MapStringIndex;
typedef struct mc_MapStringString
{
void *mapObject;
mc_MapStringString()
{
Init();
}
~mc_MapStringString()
{
Destroy();
}
void Init();
void Add(const char* key,const char* value);
const char * Get(const char* key);
void Destroy();
int GetCount();
} mc_MapStringString;
typedef struct mc_Buffer
{
mc_Buffer()
{
Zero();
}
~mc_Buffer()
{
Destroy();
}
mc_MapStringIndex *m_lpIndex;
unsigned char *m_lpData;
int m_AllocSize;
int m_Size;
int m_KeySize;
int m_RowSize;
int m_Count;
uint32_t m_Mode;
void Zero();
int Destroy();
int Initialize(int KeySize,int TotalSize,uint32_t Mode);
int Clear();
int Realloc(int Rows);
int Add(const void *lpKey,const void *lpValue);
int Add(const void *lpKeyValue);
int Seek(void *lpKey);
unsigned char *GetRow(int RowID);
int PutRow(int RowID,const void *lpKey,const void *lpValue);
int UpdateRow(int RowID,const void *lpKey,const void *lpValue);
int GetCount();
int SetCount(int count);
int Sort();
void CopyFrom(mc_Buffer *source);
} mc_Buffer;
typedef struct mc_List
{
mc_List()
{
Zero();
}
~mc_List()
{
Destroy();
}
unsigned char *m_lpData;
int m_AllocSize;
int m_Size;
int m_Pos;
int m_ItemSize;
void Zero();
int Destroy();
void Clear();
int Put(unsigned char *ptr, int size);
unsigned char *First();
unsigned char *Next();
} mc_List;
typedef struct mc_SHA256
{
void *m_HashObject;
void Init();
void Destroy();
void Reset();
void Write(const void *lpData,int size);
void GetHash(unsigned char *hash);
void DoubleHash(const void *lpData,int size,void *hash);
mc_SHA256()
{
Init();
}
~mc_SHA256()
{
Destroy();
}
} mc_SHA256;
struct mc_TerminalInput
{
char m_Prompt[64];
char m_Data[MC_DCT_TERM_BUFFER_SIZE];
char m_Line[MC_DCT_TERM_BUFFER_SIZE];
char m_Cache[MC_DCT_TERM_BUFFER_SIZE];
int m_Offsets[100];
int m_HistoryLines;
int m_BufferSize;
int m_ThisLine;
int m_FirstLine;
int m_LoadedLine;
int m_TerminalCols;
int m_TerminalRows;
char *GetLine();
int SetPrompt(const char *prompt);
int Prompt();
void AddLine();
int LoadLine(int line);
void SaveLine();
void MoveBack(int offset);
int TerminalCols();
int IsAlphaNumeric(char c);
int LoadDataFromLog(const char *fileName);
mc_TerminalInput()
{
int i;
strcpy(m_Prompt,"");
m_HistoryLines=100;
m_BufferSize=MC_DCT_TERM_BUFFER_SIZE;
m_ThisLine=0;
m_FirstLine=0;
m_LoadedLine=0;
memset(m_Line,0,m_BufferSize);
memset(m_Data,0,m_BufferSize);
for(i=0;i<m_HistoryLines;i++)
{
m_Offsets[i]=-1;
}
m_TerminalCols=0;
}
};
/* Functions */
int mc_AllocSize(int items,int chunk_size,int item_size);
void *mc_New(int Size);
void mc_Delete(void *ptr);
void mc_PutLE(void *dest,void *src,int dest_size);
int64_t mc_GetLE(void *src,int size);
uint32_t mc_SwapBytes32(uint32_t src);
int mc_BackupFile(const char *network_name,const char *filename, const char *extension,int options);
int mc_RecoverFile(const char *network_name,const char *filename, const char *extension,int options);
FILE *mc_OpenFile(const char *network_name,const char *filename, const char *extension,const char *mode, int options);
void mc_CloseFile(FILE *fHan);
int mc_RemoveFile(const char *network_name,const char *filename, const char *extension,int options);
size_t mc_ReadFileToBuffer(FILE *fHan,char **lpptr);
void mc_print(const char *message);
int mc_ReadGeneralConfigFile(mc_MapStringString *mapConfig,const char *network_name,const char *file_name,const char *extension);
int mc_ReadParamArgs(mc_MapStringString *mapConfig,int argc, char* argv[],const char *prefix);
int mc_HexToBin(void *dest,const void *src,int len);
int mc_BinToHex(void *dest,const void *src,int len);
void mc_MemoryDump(const void *ptr,int from,int len);
void mc_MemoryDumpChar(const void *ptr,int from,int len);
void mc_Dump(const char * message,const void *ptr,int size);
void mc_MemoryDumpCharSize(const void *ptr,int from,int len,int row_size);
void mc_MemoryDumpCharSizeToFile(FILE *fHan,const void *ptr, int from, int len,int row_size);
void mc_DumpSize(const char * message,const void *ptr,int size,int row_size);
void mc_RandomSeed(unsigned int seed);
double mc_RandomDouble();
unsigned int mc_RandomInRange(unsigned int min,unsigned int max);
unsigned int mc_TimeNowAsUInt();
double mc_TimeNowAsDouble();
int mc_GetFullFileName(const char *network_name,const char *filename, const char *extension,int options,char *buf);
int64_t mc_GetVarInt(const unsigned char *buf,int max_size,int64_t default_value,int* shift);
int mc_PutVarInt(unsigned char *buf,int max_size,int64_t value);
int mc_BuildDescription(int build, char *desc);
void mc_GetCompoundHash160(void *result,const void *hash1,const void *hash2);
int mc_SetIPv4ServerAddress(const char* host);
int mc_FindIPv4ServerAddress(uint32_t *all_ips,int max_ips);
int mc_GenerateConfFiles(const char *network_name);
void mc_CreateDir(const char *dir_name);
void mc_RemoveDataDir(const char *network_name);
void mc_RemoveDir(const char *network_name,const char *dir_name);
int mc_GetDataDirArg(char *buf);
void mc_UnsetDataDirArg();
void mc_SetDataDirArg(char *buf);
void mc_ExpandDataDirParam();
void mc_CheckDataDirInConfFile();
void mc_AdjustStartAndCount(int *count,int *start,int size);
void* custom_get_blockchain_default(const char *param,int* size,void *param_in);
int mc_TestScenario(char* scenario_file);
int mc_StringToArg(char *src,char *dest);
int mc_SaveCliCommandToLog(const char *fileName, int argc, char* argv[]);
void mc_StringLowerCase(char *buf,uint32_t len);
int mc_StringCompareCaseInsensitive(const char *str1,const char *str2,int len);
uint32_t mc_GetParamFromDetailsScript(const unsigned char *ptr,uint32_t total,uint32_t offset,uint32_t* param_value_start,size_t *bytes);
uint32_t mc_GetParamFromDetailsScriptErr(const unsigned char *ptr,uint32_t total,uint32_t offset,uint32_t* param_value_start,size_t *bytes, int *err);
uint32_t mc_FindSpecialParamInDetailsScript(const unsigned char *ptr,uint32_t total,uint32_t param,size_t *bytes);
uint32_t mc_FindNamedParamInDetailsScript(const unsigned char *ptr,uint32_t total,const char *param,size_t *bytes);
const unsigned char *mc_ParseOpDropOpReturnScript(const unsigned char *src,int size,int *op_drop_offset,int *op_drop_size,int op_drop_count,int *op_return_offset,int *op_return_size);
const unsigned char *mc_ExtractAddressFromInputScript(const unsigned char *src,int size,int *op_addr_offset,int *op_addr_size,int* is_redeem_script,int* sighash_type,int check_last);
void mc_LogString(FILE *fHan, const char* message);
const char *mc_Version();
const char *mc_FullVersion();
void __US_Sleep (int dwMilliseconds);
int __US_Fork(char *lpCommandLine,int WinState,int *lpChildPID);
int __US_BecomeDaemon();
void __US_Dummy();
void* __US_SemCreate();
void __US_SemWait(void* sem);
void __US_SemPost(void* sem);
void __US_SemDestroy(void* sem);
uint64_t __US_ThreadID();
const char* __US_UserHomeDir();
char * __US_FullPath(const char* path, char *full_path, int len);
void __US_FlushFile(int FileHan);
void __US_FlushFileWithMode(int FileHan,uint32_t use_data_sync);
int __US_DeleteFile(const char *file_name);
void sprintf_hex(char *hex,const unsigned char *bin,int size);
#ifdef __cplusplus
}
#endif
#endif /* MULTICHAIN_DECLARE_H */