-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcjson_x86.inc
304 lines (237 loc) · 13.1 KB
/
cjson_x86.inc
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
;
; Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.
;
; https://github.com/DaveGamble/cJSON
;
; cjson.inc converted from cJSON.h 1.7.12 for masm by fearless 2019
;
; https://github.com/mrfearless/libraries/tree/master/cJSON
include msvcrt.inc
includelib msvcrt.lib
includelib msvcrt14.lib
; cJSON project version
CJSON_VERSION_MAJOR EQU 1
CJSON_VERSION_MINOR EQU 7
CJSON_VERSION_PATCH EQU 12
; cJSON Types:
cJSON_Invalid EQU 0; (0)
cJSON_False EQU 1; (1 << 0)
cJSON_True EQU 2; (1 << 1)
cJSON_NULL EQU 4; (1 << 2)
cJSON_Number EQU 8; (1 << 3)
cJSON_String EQU 16; (1 << 4)
cJSON_Array EQU 32; (1 << 5)
cJSON_Object EQU 64; (1 << 6)
cJSON_Raw EQU 128; (1 << 7) - raw json
cJSON_IsReference EQU 256
cJSON_StringIsConst EQU 512
; The cJSON structure:
cJSON STRUCT
next DWORD ?
prev DWORD ?
child DWORD ?
itemtype DWORD ?
valuestring DWORD ?
valueint DWORD ?
valuedouble QWORD ?
itemstring DWORD ?
cJSON ENDS
cJSON_Hooks STRUCT
malloc_fn DWORD ?
free_fn DWORD ?
cJSON_Hooks ENDS
cJSON_bool TYPEDEF DWORD
CJSON_NESTING_LIMIT EQU 1000
cJSON_Version PROTO
cJSON_InitHooks PROTO :DWORD ; (cJSON_Hooks* hooks);
cJSON_Parse PROTO :DWORD ; (const char *value);
cJSON_ParseWithOpts PROTO :DWORD, :DWORD, :DWORD ; (const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
cJSON_Print PROTO :DWORD ; (const cJSON *item);
cJSON_PrintUnformatted PROTO :DWORD ; (const cJSON *item);
cJSON_PrintBuffered PROTO :DWORD, :DWORD, :DWORD ; (const cJSON *item, int prebuffer, cJSON_bool fmt);
cJSON_PrintPreallocated PROTO :DWORD, :DWORD, :DWORD, :DWORD ; (cJSON *item, char *buffer, const int length, const cJSON_bool format);
cJSON_Delete PROTO :DWORD ; (cJSON *c);
cJSON_GetArraySize PROTO :DWORD ; (const cJSON *array);
cJSON_GetArrayItem PROTO :DWORD, :DWORD ; (const cJSON *array, int index);
cJSON_GetObjectItem PROTO :DWORD, :DWORD ; (const cJSON * const object, const char * const string);
cJSON_GetObjectItemCaseSensitive PROTO :DWORD, :DWORD ; (const cJSON * const object, const char * const string);
cJSON_HasObjectItem PROTO :DWORD, :DWORD ; (const cJSON *object, const char *string);
cJSON_GetErrorPtr PROTO
cJSON_GetStringValue PROTO :DWORD ; (cJSON *item);
; These functions check the type of an item
cJSON_IsInvalid PROTO :DWORD ; (const cJSON * const item);
cJSON_IsFalse PROTO :DWORD ; (const cJSON * const item);
cJSON_IsTrue PROTO :DWORD ; (const cJSON * const item);
cJSON_IsBool PROTO :DWORD ; (const cJSON * const item);
cJSON_IsNull PROTO :DWORD ; (const cJSON * const item);
cJSON_IsNumber PROTO :DWORD ; (const cJSON * const item);
cJSON_IsString PROTO :DWORD ; (const cJSON * const item);
cJSON_IsArray PROTO :DWORD ; (const cJSON * const item);
cJSON_IsObject PROTO :DWORD ; (const cJSON * const item);
cJSON_IsRaw PROTO :DWORD ; (const cJSON * const item);
; These calls create a cJSON item of the appropriate type.
cJSON_CreateNull PROTO
cJSON_CreateTrue PROTO
cJSON_CreateFalse PROTO
cJSON_CreateBool PROTO :DWORD ; (cJSON_bool boolean);
cJSON_CreateNumber PROTO :QWORD ; (double num);
cJSON_CreateString PROTO :DWORD ; (const char *string);
; raw json
cJSON_CreateRaw PROTO :DWORD ; (const char *raw);
cJSON_CreateArray PROTO
cJSON_CreateObject PROTO
; Create a string where valuestring references a string so it will not be freed by cJSON_Delete
cJSON_CreateStringReference PROTO :DWORD ; (const char *string);
; Create an object/arrray that only references it's elements so they will not be freed by cJSON_Delete
cJSON_CreateObjectReference PROTO :DWORD ; (const cJSON *child);
cJSON_CreateArrayReference PROTO :DWORD ; (const cJSON *child);
; These utilities create an Array of count items.
cJSON_CreateIntArray PROTO :DWORD, :DWORD ; (const int *numbers, int count);
cJSON_CreateFloatArray PROTO :DWORD, :DWORD ; (const float *numbers, int count);
cJSON_CreateDoubleArray PROTO :DWORD, :DWORD ; (const double *numbers, int count);
cJSON_CreateStringArray PROTO :DWORD, :DWORD ; (const char **strings, int count);
; Append item to the specified array/object.
cJSON_AddItemToArray PROTO :DWORD, :DWORD ; (cJSON *array, cJSON *item);
cJSON_AddItemToObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
; Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the; cJSON object.
; WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst); is zero before writing to `item->string`
cJSON_AddItemToObjectCS PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
; Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON.
cJSON_AddItemReferenceToArray PROTO :DWORD, :DWORD ; (cJSON *array, cJSON *item);
cJSON_AddItemReferenceToObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object, const char *string, cJSON *item);
; Remove/Detatch items from Arrays/Objects.
cJSON_DetachItemViaPointer PROTO :DWORD, :DWORD ; (cJSON *parent, cJSON * const item);
cJSON_DetachItemFromArray PROTO :DWORD, :DWORD ; (cJSON *array, int which);
cJSON_DeleteItemFromArray PROTO :DWORD, :DWORD ; (cJSON *array, int which);
cJSON_DetachItemFromObject PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
cJSON_DetachItemFromObjectCaseSensitive PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
cJSON_DeleteItemFromObject PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
cJSON_DeleteItemFromObjectCaseSensitive PROTO :DWORD, :DWORD ; (cJSON *object, const char *string);
; Update array items.
cJSON_InsertItemInArray PROTO :DWORD, :DWORD, :DWORD ; (cJSON *array, int which, cJSON *newitem); Shifts pre-existing items to the right.
cJSON_ReplaceItemViaPointer PROTO :DWORD, :DWORD, :DWORD ; (cJSON * const parent, cJSON * const item, cJSON * replacement);
cJSON_ReplaceItemInArray PROTO :DWORD, :DWORD, :DWORD ; (cJSON *array, int which, cJSON *newitem);
cJSON_ReplaceItemInObject PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object,const char *string,cJSON *newitem);
cJSON_ReplaceItemInObjectCaseSensitive PROTO :DWORD, :DWORD, :DWORD ; (cJSON *object,const char *string,cJSON *newitem);
cJSON_Duplicate PROTO :DWORD, :DWORD ; (const cJSON *item, cJSON_bool recurse);
cJSON_Compare PROTO :DWORD, :DWORD, :DWORD ; (const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
cJSON_Minify PROTO :DWORD ; (char *json);
; Helper functions for creating and adding items to an object at the same time.
; They return the added item or NULL on failure. */
cJSON_AddNullToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
cJSON_AddTrueToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
cJSON_AddFalseToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
cJSON_AddBoolToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const cJSON_bool boolean);
cJSON_AddNumberToObject PROTO :DWORD,:DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const double number);
cJSON_AddStringToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const char * const string);
cJSON_AddRawToObject PROTO :DWORD,:DWORD,:DWORD ; (cJSON * const object, const char * const name, const char * const raw);
cJSON_AddObjectToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
cJSON_AddArrayToObject PROTO :DWORD,:DWORD ; (cJSON * const object, const char * const name);
cJSON_SetNumberHelper PROTO :DWORD,:DWORD,:DWORD ; (cJSON *object, double number);
cJSON_malloc PROTO :DWORD ; (size_t size);
cJSON_free PROTO :DWORD ; (void *object);
cJSON_AddObjectToArray PROTO :DWORD
cJSON_AddArrayToArray PROTO :DWORD
cJSON_AddNullToArray PROTO :DWORD
cJSON_AddTrueToArray PROTO :DWORD
cJSON_AddFalseToArray PROTO :DWORD
cJSON_AddBoolToArray PROTO :DWORD, :DWORD
cJSON_AddNumberToArray PROTO :DWORD, :DWORD
cJSON_AddStringToArray PROTO :DWORD, :DWORD
cJSON_AddRawToArray PROTO :DWORD, :DWORD
; .CODE
; ; Add To Array
; cJSON_AddObjectToArray PROC hJSON:DWORD
; LOCAL hJSONObject:DWORD
; Invoke cJSON_CreateObject
; mov hJSONObject, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObject
; mov eax, hJSONObject
; ret
; cJSON_AddObjectToArray ENDP
; cJSON_AddArrayToArray PROC hJSON:DWORD
; LOCAL hJSONObjectArray:DWORD
; Invoke cJSON_CreateArray
; mov hJSONObjectArray, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectArray
; mov eax, hJSONObjectArray
; ret
; cJSON_AddArrayToArray ENDP
; cJSON_AddNullToArray PROC hJSON:DWORD
; LOCAL hJSONObjectNull:DWORD
; Invoke cJSON_CreateNull
; mov hJSONObjectNull, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectNull
; mov eax, hJSONObjectNull
; ret
; cJSON_AddNullToArray ENDP
; cJSON_AddTrueToArray PROC hJSON:DWORD
; LOCAL hJSONObjectTrue:DWORD
; Invoke cJSON_CreateTrue
; mov hJSONObjectTrue, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectTrue
; mov eax, hJSONObjectTrue
; ret
; cJSON_AddTrueToArray ENDP
; cJSON_AddFalseToArray PROC hJSON:DWORD
; LOCAL hJSONObjectFalse:DWORD
; Invoke cJSON_CreateFalse
; mov hJSONObjectFalse, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectFalse
; mov eax, hJSONObjectFalse
; ret
; cJSON_AddFalseToArray ENDP
; cJSON_AddBoolToArray PROC hJSON:DWORD, dwBoolValue:DWORD
; LOCAL hJSONObjectBool:DWORD
; Invoke cJSON_CreateBool, dwBoolValue
; mov hJSONObjectBool, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectBool
; mov eax, hJSONObjectBool
; ret
; cJSON_AddBoolToArray ENDP
; cJSON_AddNumberToArray PROC hJSON:DWORD, dwNumberValue:DWORD
; LOCAL hJSONObjectNumber:DWORD
; LOCAL qwNumberValue:QWORD
; mov eax, dwNumberValue
; mov dword ptr [qwNumberValue+0], eax
; mov dword ptr [qwNumberValue+4], eax
; Invoke cJSON_CreateNumber, qwNumberValue
; mov hJSONObjectNumber, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectNumber
; mov eax, hJSONObjectNumber
; ret
; cJSON_AddNumberToArray ENDP
; cJSON_AddStringToArray PROC hJSON:DWORD, lpszString:DWORD
; LOCAL hJSONObjectString:DWORD
; Invoke cJSON_CreateString, lpszString
; mov hJSONObjectString, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectString
; mov eax, hJSONObjectString
; ret
; cJSON_AddStringToArray ENDP
; cJSON_AddRawToArray PROC hJSON:DWORD, lpszRawJson:DWORD
; LOCAL hJSONObjectRaw:DWORD
; Invoke cJSON_CreateRaw, lpszRawJson
; mov hJSONObjectRaw, eax
; Invoke cJSON_AddItemToArray, hJSON, hJSONObjectRaw
; mov eax, hJSONObjectRaw
; ret
; cJSON_AddRawToArray ENDP