libsheepy
libsheepyObject.c
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2023 Remy Noulin
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #include "../libsheepyObject.h"
24 #if (!defined(__OpenBSD__))
25 // pthread.h is already included in tpool.h for pthread_mutex_t in OpenBSD with GCC 4.9.4
26 #include "pthread.h"
27 #endif
28 #if (!(__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__))
29 //register_printf_specifier
30 #include "printf.h"
31 #endif
32 #if (!(__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __HAIKU__))
33 // sysinfo
34 #include "sys/sysinfo.h"
35 #endif
36 
37 #define internal static
38 
39 #include <sys/stat.h>
40 #include <ctype.h>
41 #include <unistd.h>
42 #include <stdio.h>
43 #include <dirent.h>
44 #include <stdarg.h>
45 #if (!(__OpenBSD__ || __HAIKU__))
46 #include <wordexp.h>
47 #endif
48 #include <stdbool.h>
49 #include <string.h>
50 #include <stdlib.h>
51 #include <libgen.h>
52 #include <stdint.h>
53 
54 #if (!defined(__OpenBSD__))
55 #endif
56 #if (!(__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__))
57 #endif
58 #if (!(__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __HAIKU__))
59 #endif
60 #if (__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun__ || __HAIKU__)
61 smallDictt *shSysinfo(void);
62 smallDictt *shSysinfo(void);
63 #endif
64 void cleanUpBaseTerminateG(baset **val);
65 void cleanUpBaseFreeG(baset **val);
66 void cleanUpBaseFinishG(baset **val);
67 void cleanUpBaseSmashG(baset **val);
68 baset *duplicateBaseG(baset *self);
69 void freeManyOF(void *paramType, ...);
70 void terminateManyOF(void *paramType, ...);
71 void smashManyOF(void *paramType, ...);
72 void finishManyOF(void *paramType, ...);
79 int systemNFreeJOF(smallJsont *command, int line, const char *thisFunc, const char *thisFileName);
80 int systemNFreeOF(smallStringt *command, int line, const char *thisFunc, const char *thisFileName);
81 #if (!(__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__))
82 int print_m(FILE *stream, const struct printf_info *info, const void *const *args);
83 int print_m_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtypes, int* size);
84 #endif
85 void putsOF(baset* object);
86 void putsUndefinedGF(undefinedt* object);
87 void putsBoolGF(bool object);
88 void putsBoolPGF(bool* object);
89 void putsDoubleGF(double object);
90 void putsDoublePGF(double* object);
91 void putsIntGF(int64_t object);
92 void putsIntPGF(int64_t* object);
93 void putsInt32GF(int32_t object);
94 void putsInt32PGF(int32_t* object);
95 void putsUintGF(uint64_t object);
96 void putsUintPGF(uint64_t* object);
97 void putsUint32GF(uint32_t object);
98 void putsUint32PGF(uint32_t* object);
99 void putsSGF(const char* object);
100 void putsListSGF(char** object);
101 void putsListCSGF(const char** object);
102 void putsDictGF(smallDictt* object);
103 void putsJsonGF(smallJsont* object);
104 void putsArrayGF(smallArrayt* object);
105 void putsSmallBoolGF(smallBoolt* object);
106 void putsSmallBytesGF(smallBytest* object);
107 void putsSmallDoubleGF(smallDoublet* object);
108 void putsSmallIntGF(smallIntt* object);
109 void putsSmallStringGF(smallStringt* object);
110 void putsVoidGF(void* object);
112 char *toStringOF(baset* object);
113 char *toStringUndefinedGF(undefinedt* object);
114 char *toStringBoolGF(bool object);
115 char *toStringBoolPGF(bool* object);
116 char *toStringFloatGF(float object);
117 char *toStringFloatPGF(float* object);
118 char *toStringDoubleGF(double object);
119 char *toStringDoublePGF(double* object);
120 char *toStringIntGF(int64_t object);
121 char *toStringIntPGF(int64_t* object);
122 char *toStringInt32GF(int32_t object);
123 char *toStringInt32PGF(int32_t* object);
124 char *toStringInt16GF(int16_t object);
125 char *toStringInt16PGF(int16_t* object);
126 char *toStringUintGF(uint64_t object);
127 char *toStringUintPGF(uint64_t* object);
128 char *toStringUint32GF(uint32_t object);
129 char *toStringUint32PGF(uint32_t* object);
130 char *toStringUint16GF(uint16_t object);
131 char *toStringUint16PGF(uint16_t* object);
132 char *toStringUint8GF(uint8_t object);
133 char *toStringUint8PGF(uint8_t* object);
134 char *toStringCharGF(char object);
135 char *toStringSGF(const char* object);
136 char *toStringListSGF(char** object);
137 char *toStringListCSGF(const char** object);
138 char *toStringDictGF(smallDictt* object);
139 char *toStringArrayGF(smallArrayt* object);
140 char *toStringSmallBoolGF(smallBoolt* object);
141 char *toStringSmallBytesGF(smallBytest* object);
142 char *toStringSmallDoubleGF(smallDoublet* object);
143 char *toStringSmallIntGF(smallIntt* object);
144 char *toStringSmallStringGF(smallStringt* object);
145 char *toStringVoidGF(void* object);
147 char *toStringSmallJsonGF(smallJsont* object);
148 char *otos(void *basetObj);
149 smallStringt *formatO(const char *fmt, ...);
150 int execO(const char *cmd, smallArrayt *out, smallArrayt *err UNUSED);
153 smallArrayt* walkDirO(const char* dirPath);
156 internal void walkADir(const char *dirPath, smallArrayt *list);
157 smallArrayt* walkDirDirO(const char* dirPath);
160 internal void walkADirDir(const char *dirPath, smallArrayt *list);
161 smallArrayt *readDirO(const char *dirPath);
164 smallArrayt *readDirDirO(const char *dirPath);
167 smallArrayt *walkDirAllO(const char* dirPath);
170 internal void walkADirAll(const char *dirPath, smallArrayt *list);
171 smallArrayt *readDirAllO(const char *dirPath);
174 time_t getModificationTimeJO(smallJsont *path);
175 time_t getModificationTimeO(smallStringt *path);
176 int setModificationTimeJO(smallJsont *path, time_t mtime);
177 int setModificationTimeO(smallStringt *path, time_t mtime);
178 bool equalModificationTimesJO(smallJsont *path1, smallJsont *path2);
179 bool equalModificationTimesSJO(const char *path1, smallJsont *path2);
180 bool equalModificationTimesJOS(smallJsont *path1, const char *path2);
184 bool equalModificationTimesSO(const char *path1, smallStringt *path2);
185 bool equalModificationTimesOS(smallStringt *path1, const char *path2);
186 smallJsont *timeToJO(const time_t t);
187 smallStringt *timeToSO(const time_t t);
191 #if (__OpenBSD__ || __HAIKU__)
193 #else
195 #endif
198 smallJsont *getCwdJO(void);
199 smallStringt *getCwdO(void);
200 int chDirJO(smallJsont *path);
201 int chDirO(smallStringt *path);
202 bool isDirJO(smallJsont *path);
203 bool isDirO(smallStringt *path);
204 bool isLinkJO(smallJsont *path);
205 bool isLinkO(smallStringt *path);
206 bool fileExistsJO(smallJsont *filePath);
207 bool fileExistsO(smallStringt *filePath);
208 bool fileChmodJO(smallJsont *filePath, mode_t mode);
209 bool fileChmodO(smallStringt *filePath, mode_t mode);
210 ssize_t fileSizeJO(smallJsont *filePath);
211 ssize_t fileSizeO(smallStringt *filePath);
212 void *readFileToNewG(void *none UNUSED, const char *filePath);
213 void *readStreamToNewG(void *none UNUSED, FILE *fp);
214 char *readFileToG(char **string, const char *filePath);
215 char *readStreamToG(char **string, FILE *fp);
216 void readTextSmallJsonNotSupported(char ***self UNUSED, smallJsont *path UNUSED);
217 void readTextSmallStringNotSupported(char ***self UNUSED, smallStringt *path UNUSED);
218 void readToFileSmallJsonNotSupported(void *self UNUSED, smallJsont *path UNUSED);
219 void readToFileSmallStringNotSupported(void *self UNUSED, smallStringt *path UNUSED);
220 int writeFileFromG(const char *string, const char *filePath);
221 int writeStreamFromG(const char *string, FILE *fp);
222 int writeTextSmallJsonNotSupported(char **self UNUSED, smallJsont *path UNUSED);
223 int writeTextSmallStringNotSupported(char **self UNUSED, smallStringt *path UNUSED);
224 int writeTextCCSmallJsonNotSupported(const char **self UNUSED, smallJsont *path UNUSED);
225 int writeTextCCSmallStringNotSupported(const char **self UNUSED, smallStringt *path UNUSED);
226 char **readTextSG(char ***list, const char *filePath);
227 char **readTextStreamG(char ***list, FILE *fp);
228 bool writeTextSG(char **list, const char *filePath);
229 bool writeTextStreamG(char **list, FILE *fp);
230 bool writeTextCG(const char **list, const char *filePath);
231 bool writeTextStreamCG(const char **list, FILE *fp);
232 bool appendFileSG(const char *string, const char *filePath);
233 bool appendTextSG(char **list, const char *filePath);
234 bool appendTextCG(const char **list, const char *filePath);
236 int mkdirParentsO(smallStringt* path);
237 int rmAllSmallJsonO(smallJsont* path);
238 int rmAllO(smallStringt* path);
239 int copyO(smallStringt* src, smallStringt* dst);
240 int copySSmallJsonO(const char* src, smallJsont* dst);
241 int copySO(const char* src, smallStringt* dst);
242 int copySmallJsonOS(smallJsont* src, const char* dst);
244 int copySmallJsonO(smallJsont* src, smallStringt* dst);
245 int copyOS(smallStringt* src, const char* dst);
246 int copyOSmallJson(smallStringt* src, smallJsont* dst);
249 int renameSmallJsonOS(smallJsont* src, const char* dst);
250 int renameO(smallStringt* src, smallStringt* dst);
252 int renameSSmallJsonO(const char* src, smallJsont* dst);
253 int renameSO(const char* src, smallStringt* dst);
254 int renameOS(smallStringt* src, const char* dst);
255 int moveSmallJsonO(smallJsont* src, smallStringt* dst);
257 int moveSmallJsonOS(smallJsont* src, const char* dst);
258 int moveO(smallStringt* src, smallStringt* dst);
259 int moveOSmallJson(smallStringt* src, smallJsont* dst);
260 int moveSSmallJsonO(const char* src, smallJsont* dst);
261 int moveSO(const char* src, smallStringt* dst);
262 int moveOS(smallStringt* src, const char* dst);
263 smallJsont *randomSmallJsonO(uint64_t length);
264 smallStringt *randomSO(uint64_t length);
265 smallJsont *randomAlphaNumSmallJsonO(uint64_t length);
266 smallStringt *randomAlphaNumSO(uint64_t length);
268 smallStringt *readO(void);
270 smallStringt *readLineO(FILE *fp);
271 char *intToSG(char *retType UNUSED, int64_t n);
272 char *doubleToSG(char *retType UNUSED, double n);
273 char **iListUniqG(char ***list, int dum UNUSED);
274 char **iicListUniqG(char ***list, int dum UNUSED);
275 char **listFromArrayG(char **retType UNUSED, char **array, size_t size);
276 char **listFromCArrayG(char **retType UNUSED, const char **array, size_t size);
277 char getSG(const char *string, int retType UNUSED, int64_t index);
278 char *listGetG(char **list, int retType UNUSED, int64_t index);
279 char *listGetCG(const char **list, int retType UNUSED, int64_t index);
280 char *iListGetG(char **list, int retType UNUSED, int64_t index);
281 const char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
282 char *listPopG(char ***list, int retType UNUSED);
283 char *listDequeueG(char ***list, int retType UNUSED);
284 char **listDupCG(const char **list);
285 bool listEqCG(char **list1, const char **list2);
286 bool listEqC1G(const char **list1, char **list2);
287 bool listEqCCG(const char **list1, const char **list2);
288 bool icListEqCG(char **list1, const char **list2);
289 bool icListEqC1G(const char **list1, char **list2);
290 bool icListEqCCG(const char **list1, const char **list2);
291 size_t listLengthCG(const char **list);
292 ssize_t listIndexOfCG(const char **list, const char *string);
293 ssize_t listIndexOfCharCG(const char **list, char c);
294 ssize_t icListIndexOfCG(const char **list, const char *string);
295 ssize_t icListIndexOfCharCG(const char **list, char c);
296 bool listHasCharCG(const char **list, char c);
297 bool listHasCG(const char **list, const char *string);
298 bool icListHasCG(const char **list, const char *string);
299 bool icListHasCharCG(const char **list, char c);
300 char *joinCG(const char **list, const char* delim);
301 char *joinCharCG(const char **list, char delim);
302 char **listAddCG(char **list1, const char **list2);
303 int listPrintCG(const char **list);
304 bool eqCharChar(char c, char value);
305 bool equalChaOG(char c, baset* value);
306 bool equalChaBoolG(char c UNUSED, bool value UNUSED);
307 bool equalChaDoubleG(char c, double value);
308 bool equalChaInt64G(char c, int64_t value);
309 bool equalChaInt32G(char c, int32_t value);
310 bool equalChaUint32G(char c, uint32_t value);
311 bool equalChaUint64G(char c, uint64_t value);
314 bool equalChaSmallIntG(char c, smallIntt* value);
315 bool equalChaSmallJsonG(char c, smallJsont* value);
317 bool equalCharOG(const char *s, baset* value);
318 bool equalCharBoolG(const char *s, bool value);
319 bool equalCharDoubleG(const char *s, double value);
320 bool equalCharInt64G(const char *s, int64_t value);
321 bool equalCharInt32G(const char *s, int32_t value);
322 bool equalCharUint32G(const char *s, uint32_t value);
323 bool equalCharUint64G(const char *s, uint64_t value);
324 bool equalCharSmallBoolG(const char *s, smallBoolt* value);
325 bool equalCharSmallBytesG(const char *s, smallBytest* value);
326 bool equalCharSmallDoubleG(const char *s, smallDoublet* value);
327 bool equalCharSmallIntG(const char *s, smallIntt* value);
328 bool equalCharPSmallJsonG(const char *s, smallJsont* value);
329 bool equalCharPSmallStringG(const char *s, smallStringt* value);
330 bool equalArrayOG(char ** p1, baset* p2);
331 bool equalCArrayOG(const char ** p1, baset* p2);
332 bool equalArraySmallJsonG(char ** p1, smallJsont* p2);
333 bool equalArraySmallArrayG(char ** p1, smallArrayt* p2);
334 bool equalCArraySmallJsonG(const char ** p1, smallJsont* p2);
335 bool equalCArraySmallArrayG(const char ** p1, smallArrayt* p2);
336 bool equalOCharG(baset* p1, const char * p2);
337 bool equalOChaG(baset* p1, char p2);
338 bool equalOArrayG(baset* p1, char ** p2);
339 bool equalOCArrayG(baset* p1, const char ** p2);
340 bool equalOOG(baset* p1, baset* p2);
341 bool equalOBoolG(baset* p1, bool p2);
342 bool equalODoubleG(baset* p1, double p2);
343 bool equalOInt64G(baset* p1, int64_t p2);
344 bool equalOInt32G(baset* p1, int32_t p2);
345 bool equalOUint32G(baset* p1, uint32_t p2);
346 bool equalOUint64G(baset* p1, uint64_t p2);
347 bool equalOSmallArrayG(baset* p1, smallArrayt* p2);
348 bool equalOSmallBoolG(baset* p1, smallBoolt* p2);
349 bool equalOSmallBytesG(baset* p1, smallBytest* p2);
350 bool equalOSmallDoubleG(baset* p1, smallDoublet* p2);
351 bool equalOSmallDictG(baset* p1, smallDictt* p2);
352 bool equalOSmallIntG(baset* p1, smallIntt* p2);
353 bool equalOSmallJsonG(baset* p1, smallJsont* p2);
354 bool equalOSmallStringG(baset* p1, smallStringt* p2);
355 bool equalBoolChaG(bool p1 UNUSED, char p2 UNUSED);
356 bool equalBoolCharG(bool p1, const char * p2);
357 bool equalBoolOG(bool p1, baset* p2);
358 bool equalBoolFG(bool p1, bool p2);
359 bool equalBoolDoubleG(bool p1, double p2);
360 bool equalBoolInt64G(bool p1, int64_t p2);
361 bool equalBoolInt32G(bool p1, int32_t p2);
362 bool equalBoolUint32G(bool p1, uint32_t p2);
363 bool equalBoolUint64G(bool p1, uint64_t p2);
364 bool equalBoolSmallBoolG(bool p1, smallBoolt* p2);
365 bool equalBoolSmallBytesG(bool p1, smallBytest* p2);
366 bool equalBoolSmallDoubleG(bool p1, smallDoublet* p2);
367 bool equalBoolSmallIntG(bool p1, smallIntt* p2);
368 bool equalBoolSmallJsonG(bool p1, smallJsont* p2);
369 bool equalBoolSmallStringG(bool p1, smallStringt* p2);
370 bool equalDoubleChaG(double p1, char p2);
371 bool equalDoubleCharG(double p1, const char * p2);
372 bool equalDoubleBaseG(double p1, baset* p2);
373 bool equalDoubleBoolG(double p1, bool p2);
374 bool equalDoubleFG(double p1, double p2);
375 bool equalDoubleInt64G(double p1, int64_t p2);
376 bool equalDoubleInt32G(double p1, int32_t p2);
377 bool equalDoubleUint32G(double p1, uint32_t p2);
378 bool equalDoubleUint64G(double p1, uint64_t p2);
379 bool equalDoubleSmallBoolG(double p1, smallBoolt* p2);
380 bool equalDoubleSmallBytesG(double p1, smallBytest* p2);
381 bool equalDoubleSmallDoubleG(double p1, smallDoublet* p2);
382 bool equalDoubleSmallIntG(double p1, smallIntt* p2);
383 bool equalDoubleSmallJsonG(double p1, smallJsont* p2);
384 bool equalDoubleSmallStringG(double p1, smallStringt* p2);
385 bool equalInt64ChaG(int64_t p1, char p2);
386 bool equalInt64CharG(int64_t p1, const char * p2);
387 bool equalInt64BaseG(int64_t p1, baset* p2);
388 bool equalInt64BoolG(int64_t p1, bool p2);
389 bool equalInt64DoubleG(int64_t p1, double p2);
390 bool equalInt64FG(int64_t p1, int64_t p2);
391 bool equalInt64Int32G(int64_t p1, int32_t p2);
392 bool equalInt64Uint32G(int64_t p1, uint32_t p2);
393 bool equalInt64Uint64G(int64_t p1, uint64_t p2);
394 bool equalInt64SmallBoolG(int64_t p1, smallBoolt* p2);
395 bool equalInt64SmallBytesG(int64_t p1, smallBytest* p2);
396 bool equalInt64SmallDoubleG(int64_t p1, smallDoublet* p2);
397 bool equalInt64SmallIntG(int64_t p1, smallIntt* p2);
398 bool equalInt64SmallJsonG(int64_t p1, smallJsont* p2);
399 bool equalInt64SmallStringG(int64_t p1, smallStringt* p2);
400 bool equalInt32ChaG(int32_t p1, char p2);
401 bool equalInt32CharG(int32_t p1, const char * p2);
402 bool equalInt32BaseG(int32_t p1, baset* p2);
403 bool equalInt32BoolG(int32_t p1, bool p2);
404 bool equalInt32DoubleG(int32_t p1, double p2);
405 bool equalInt32Int64G(int32_t p1, int64_t p2);
406 bool equalInt32FG(int32_t p1, int32_t p2);
407 bool equalInt32Uint32G(int32_t p1, uint32_t p2);
408 bool equalInt32Uint64G(int32_t p1, uint64_t p2);
409 bool equalInt32SmallBoolG(int32_t p1, smallBoolt* p2);
410 bool equalInt32SmallBytesG(int32_t p1, smallBytest* p2);
411 bool equalInt32SmallDoubleG(int32_t p1, smallDoublet* p2);
412 bool equalInt32SmallIntG(int32_t p1, smallIntt* p2);
413 bool equalInt32SmallJsonG(int32_t p1, smallJsont* p2);
414 bool equalInt32SmallStringG(int32_t p1, smallStringt* p2);
415 bool equalUint32ChaG(uint32_t p1, char p2);
416 bool equalUint32CharG(uint32_t p1, const char * p2);
417 bool equalUint32BaseG(uint32_t p1, baset* p2);
418 bool equalUint32BoolG(uint32_t p1, bool p2);
419 bool equalUint32DoubleG(uint32_t p1, double p2);
420 bool equalUint32Int64G(uint32_t p1, int64_t p2);
421 bool equalUint32Int32G(uint32_t p1, int32_t p2);
422 bool equalUint32FG(uint32_t p1, uint32_t p2);
423 bool equalUint32Uint64G(uint32_t p1, uint64_t p2);
424 bool equalUint32SmallBoolG(uint32_t p1, smallBoolt* p2);
425 bool equalUint32SmallBytesG(uint32_t p1, smallBytest* p2);
426 bool equalUint32SmallDoubleG(uint32_t p1, smallDoublet* p2);
427 bool equalUint32SmallIntG(uint32_t p1, smallIntt* p2);
428 bool equalUint32SmallJsonG(uint32_t p1, smallJsont* p2);
429 bool equalUint32SmallStringG(uint32_t p1, smallStringt* p2);
430 bool equalUint64ChaG(uint64_t p1, char p2);
431 bool equalUint64CharG(uint64_t p1, const char * p2);
432 bool equalUint64BaseG(uint64_t p1, baset* p2);
433 bool equalUint64BoolG(uint64_t p1, bool p2);
434 bool equalUint64DoubleG(uint64_t p1, double p2);
435 bool equalUint64Int64G(uint64_t p1, int64_t p2);
436 bool equalUint64Int32G(uint64_t p1, int32_t p2);
437 bool equalUint64Uint32G(uint64_t p1, uint32_t p2);
438 bool equalUint64FG(uint64_t p1, uint64_t p2);
439 bool equalUint64SmallBoolG(uint64_t p1, smallBoolt* p2);
440 bool equalUint64SmallBytesG(uint64_t p1, smallBytest* p2);
441 bool equalUint64SmallDoubleG(uint64_t p1, smallDoublet* p2);
442 bool equalUint64SmallIntG(uint64_t p1, smallIntt* p2);
443 bool equalUint64SmallJsonG(uint64_t p1, smallJsont* p2);
444 bool equalUint64SmallStringG(uint64_t p1, smallStringt* p2);
445 bool notEqualCharG(char c UNUSED, void *value UNUSED);
446 bool notEqualOCharG(void *a UNUSED, char c UNUSED);
447 bool notEqualOG(void *a UNUSED, void *b UNUSED);
448 bool notEqualCCOG(const char *a UNUSED, void *b UNUSED);
449 bool notEqualBoolOG(bool p1 UNUSED, void *p2 UNUSED);
450 bool notEqualDoubleOG(double p1 UNUSED, void *p2 UNUSED);
451 bool notEqualInt64OG(int64_t p1 UNUSED, void *p2 UNUSED);
452 bool notEqualInt32OG(int32_t p1 UNUSED, void *p2 UNUSED);
453 bool notEqualUint32OG(uint32_t p1 UNUSED, void *p2 UNUSED);
454 bool notEqualUint64OG(uint64_t p1 UNUSED, void *p2 UNUSED);
455 bool notEqualOBoolG(void *p1 UNUSED, bool p2 UNUSED);
456 bool notEqualDoubleG(void *p1 UNUSED, double p2 UNUSED);
457 bool notEqualOInt64G(void *p1 UNUSED, int64_t p2 UNUSED);
458 bool notEqualOInt32G(void *p1 UNUSED, int32_t p2 UNUSED);
459 bool notEqualOUint32G(void *p1 UNUSED, uint32_t p2 UNUSED);
460 bool notEqualOUint64G(void *p1 UNUSED, uint64_t p2 UNUSED);
461 bool icEqCharChar(char c, char value);
462 bool icEqualChaOG(char c, baset* value);
465 bool icEqualCharOG(const char *s, baset* value);
466 bool icEqualCharPSmallJsonG(const char *s, smallJsont* value);
467 bool icEqualCharPSmallStringG(const char *s, smallStringt* value);
468 bool icEqualArrayOG(char ** p1, baset* p2);
469 bool icEqualCArrayOG(const char ** p1, baset* p2);
470 bool icEqualArraySmallJsonG(char ** p1, smallJsont* p2);
471 bool icEqualCArraySmallJsonG(const char ** p1, smallJsont* p2);
472 bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2);
473 bool icEqualCArraySmallArrayG(const char ** p1, smallArrayt* p2);
474 bool icEqualOCharG(baset* p1, const char * p2);
475 bool icEqualOChaG(baset* p1, char p2);
476 bool icEqualOArrayG(baset* p1, char ** p2);
477 bool icEqualOCArrayG(baset* p1, const char ** p2);
478 bool icEqualOOG(baset* p1, baset* p2);
479 bool icEqualOSmallArrayG(baset* p1, smallArrayt* p2);
480 bool icEqualOSmallDictG(baset* p1, smallDictt* p2);
481 bool icEqualOSmallJsonG(baset* p1, smallJsont* p2);
483 void freeBasetInContainer(void *baseo);
486 int cpuCount(void);
489 void finalizeLibsheepyAtExit(void);
490 #if (__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__)
491 void initLibsheepyObject(void);
492 void initLibsheepyObject(void);
493 #endif
494 
503 #if (__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun__ || __HAIKU__)
504 smallDictt *shSysinfo(void) {
505 
506  // TODO macos
507  // https://stackoverflow.com/questions/12523704/mac-os-x-equivalent-header-file-for-sysinfo-h-in-linux
508  //
510  if (!r) {
511  return(NULL);
512  }
513 
514  setIntO(r, "uptime", 0);
515  setIntO(r, "loads", 0);
516  setIntO(r, "totalram", 0);
517  setIntO(r, "freeram", 0);
518  setIntO(r, "sharedram", 0);
519  setIntO(r, "bufferram", 0);
520  setIntO(r, "totalswap", 0);
521  setIntO(r, "freeswap", 0);
522  setIntO(r, "procs", 0);
523  return(r);
524 }
525 #else // #if (__APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun__ || __HAIKU__)
527 
529  if (!r) {
530  return(NULL);
531  }
532 
533  struct sysinfo info;
534 
535  if (sysinfo(&info) == -1) {
536  pFuncError
537  terminateO(r);
538  return(NULL);
539  }
540 
541  setIntO(r, "uptime", info.uptime);
542  setIntO(r, "loads", (int64_t)info.loads[0]);
543  setIntO(r, "totalram", (int64_t)info.totalram);
544  setIntO(r, "freeram", (int64_t)info.freeram);
545  setIntO(r, "sharedram", (int64_t)info.sharedram);
546  setIntO(r, "bufferram", (int64_t)info.bufferram);
547  setIntO(r, "totalswap", (int64_t)info.totalswap);
548  setIntO(r, "freeswap", (int64_t)info.freeswap);
549  setIntO(r, "procs", info.procs);
550  return(r);
551 }
552 #endif
553 // #if __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun__ || __HAIKU__
554 
556 
557  terminateO(*val);
558 }
559 
560 void cleanUpBaseFreeG(baset **val) {
561 
562  freeO(*val);
563 }
564 
566 
567  finishO(*val);
568 }
569 
571 
572  smashO(*val);
573 }
574 
576 
577  return(self->f->duplicate(self));
578 }
579 
580 void freeManyOF(void *paramType, ...) {
581  va_list pl;
582 
583  freeO((baset*)paramType);
584 
585  // add arguments to a list
586  va_start(pl, paramType);
587  paramType = va_arg(pl, baset *);
588  while (paramType) {
589  freeO((baset*)paramType);
590  paramType = va_arg(pl, baset *);
591  }
592  va_end(pl);
593 }
594 
595 void terminateManyOF(void *paramType, ...) {
596  va_list pl;
597  baset *obj = NULL;
598 
599  obj = (baset*)paramType;
600  terminateO(obj);
601 
602  // add arguments to a list
603  va_start(pl, paramType);
604  paramType = va_arg(pl, baset *);
605  while (paramType) {
606  obj = (baset*)paramType;
607  terminateO(obj);
608  paramType = va_arg(pl, baset *);
609  }
610  va_end(pl);
611 }
612 
613 void smashManyOF(void *paramType, ...) {
614  va_list pl;
615  baset *obj = NULL;
616 
617  obj = (baset*)paramType;
618  smashO(obj);
619 
620  // add arguments to a list
621  va_start(pl, paramType);
622  paramType = va_arg(pl, baset *);
623  while (paramType) {
624  obj = (baset*)paramType;
625  smashO(obj);
626  paramType = va_arg(pl, baset *);
627  }
628  va_end(pl);
629 }
630 
631 void finishManyOF(void *paramType, ...) {
632  va_list pl;
633  baset *obj = NULL;
634 
635  obj = (baset*)paramType;
636  finishO(obj);
637 
638  // add arguments to a list
639  va_start(pl, paramType);
640  paramType = va_arg(pl, baset *);
641  while (paramType) {
642  obj = (baset*)paramType;
643  finishO(obj);
644  paramType = va_arg(pl, baset *);
645  }
646  va_end(pl);
647 }
648 
650 
652  if (!r) {
653  return(NULL);
654  }
656  return(r);
657 }
658 
660 
661  return(allocSmallString(getProgPath()));
662 }
663 
665 
667  if (!r) {
668  return(NULL);
669  }
671  return(r);
672 }
673 
675 
677 }
678 
680 
681  if (!command) {
682  return(-1);
683  }
684 
685  const char *type = getTopTypeO(command);
686 
687  if (!eqS(type,"string")) {
688  return(-1);
689  }
690 
691  return(system(getTopSO(command)));
692 }
693 
695 
696  if (!command) {
697  return(-1);
698  }
699 
700  return(system(ssGet(command)));
701 }
702 
703 int systemNFreeJOF(smallJsont *command, int line, const char *thisFunc, const char *thisFileName) {
704  int r;
705 
706  if (!command) {
707  return(-1);
708  }
709 
710  const char *type = getTopTypeO(command);
711 
712  if (!eqS(type,"string")) {
713  return(-1);
714  }
715 
716  char *cmd = getTopSO(command);;
717 
718  r = system(cmd);
719  if (r) {
720  printf("\nSystem Error at %d, %s, %s. The command was: \"%s\"\n", line, thisFunc, thisFileName, cmd);
721  printf("\n");
722  }
723  terminateO(command);
724  return(r);
725 }
726 
727 int systemNFreeOF(smallStringt *command, int line, const char *thisFunc, const char *thisFileName) {
728  int r;
729 
730  if (!command) {
731  return(-1);
732  }
733 
734  char *cmd = ssGet(command);;
735 
736  r = system(cmd);
737  if (r) {
738  printf("\nSystem Error at %d, %s, %s. The command was: \"%s\"\n", line, thisFunc, thisFileName, cmd);
739  printf("\n");
740  }
741  terminateO(command);
742  return(r);
743 }
744 
745 #if (!(__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__))
746 
749 int print_m(FILE *stream, const struct printf_info *info, const void *const *args) {
750  const baset *o = NULL;
751  char *b = NULL;
752  int len;
753 
754  o = *((baset*const*) args[0]);
755  // warning OK: toString discards const qualifier -Wdiscarded-qualifiers
756  _Pragma ("GCC diagnostic push")
757  _Pragma ("GCC diagnostic ignored \"-Wdiscarded-qualifiers\"") {
758  //#pragma GCC diagnostic push
759  //bug in cg_c - #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
760  b = toStringO(o);
761  _Pragma ("GCC diagnostic pop")
762  //#pragma GCC diagnostic pop
763 
764  /* Pad to the minimum field width and print to the stream. */
765  //len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
766  sheepyRGBFP;
767  free(b);
768  return(len);
769 }
770  }
771 
775 int print_m_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtypes, int* size) {
776 
777  if (n > 0) {
778  argtypes[0] = PA_POINTER;
779  size[0] = sizeof(baset*);
780  }
781  return(1);
782 }
783 
784 #endif
785 // #if __APPLE__ || __FreeBSD_ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
786 
787 void putsOF(baset* object) {
788  char *s = NULL;
789 
790  if (!object) {
791  return;
792  }
793  s = toStringO(object);
794  puts(s);
795  free(s);
796 }
797 
799  char *s = NULL;
800 
801  if (!object) {
802  return;
803  }
804  s = toStringO((baset *)object);
805  puts(s);
806  free(s);
807 }
808 
809 void putsBoolGF(bool object) {
810 
811  if (object) {
812  puts("true");
813  }
814  else {
815  puts("false");
816 }
817  }
818 
819 void putsBoolPGF(bool* object) {
820 
821  if (!object) {
822  return;
823  }
824  if (*object) {
825  puts("true");
826  }
827  else {
828  puts("false");
829 }
830  }
831 
832 void putsDoubleGF(double object) {
833  char *s = NULL;
834 
835  isError(s, malloc(256*sizeof(char))) {
836  return;
837  }
838  snprintf(s,256, "%e", object);
839  puts(s);
840  free(s);
841 }
842 
843 void putsDoublePGF(double* object) {
844  char *s = NULL;
845 
846  if (!object) {
847  return;
848  }
849  isError(s, malloc(256*sizeof(char))) {
850  return;
851  }
852  snprintf(s,256, "%e", *object);
853  puts(s);
854  free(s);
855 }
856 
857 void putsIntGF(int64_t object) {
858  char *s = NULL;
859 
860  s = intToS(object);
861  if (s) {
862  puts(s);
863  }
864  free(s);
865 }
866 
867 void putsIntPGF(int64_t* object) {
868  char *s = NULL;
869 
870  if (!object) {
871  return;
872  }
873  s = intToS(*object);
874  if (s) {
875  puts(s);
876  }
877  free(s);
878 }
879 
880 void putsInt32GF(int32_t object) {
881  char *s = NULL;
882 
883  s = intToS(object);
884  if (s) {
885  puts(s);
886  }
887  free(s);
888 }
889 
890 void putsInt32PGF(int32_t* object) {
891  char *s = NULL;
892 
893  if (!object) {
894  return;
895  }
896  s = intToS(*object);
897  if (s) {
898  puts(s);
899  }
900  free(s);
901 }
902 
903 void putsUintGF(uint64_t object) {
904  char *s = NULL;
905 
906  // TODO create uintToS
907  s = intToS((int64_t)object);
908  if (s) {
909  puts(s);
910  }
911  free(s);
912 }
913 
914 void putsUintPGF(uint64_t* object) {
915  char *s = NULL;
916 
917  if (!object) {
918  return;
919  }
920  // TODO create uintToS
921  s = intToS((int64_t)*object);
922  if (s) {
923  puts(s);
924  }
925  free(s);
926 }
927 
928 void putsUint32GF(uint32_t object) {
929  char *s = NULL;
930 
931  s = intToS(object);
932  if (s) {
933  puts(s);
934  }
935  free(s);
936 }
937 
938 void putsUint32PGF(uint32_t* object) {
939  char *s = NULL;
940 
941  if (!object) {
942  return;
943  }
944  s = intToS(*object);
945  if (s) {
946  puts(s);
947  }
948  free(s);
949 }
950 
951 void putsSGF(const char* object) {
952 
953  if (!object) {
954  return;
955  }
956  puts(object);
957 }
958 
959 void putsListSGF(char** object) {
960 
961  pError0(listPrintS(object));
962 }
963 
964 void putsListCSGF(const char** object) {
965 
966  pError0(listPrintCS(object));
967 }
968 
969 void putsDictGF(smallDictt* object) {
970  char *s = NULL;
971 
972  if (!object) {
973  return;
974  }
975  s = toStringO((baset *)object);
976  if (s) {
977  puts(s);
978  }
979  free(s);
980 }
981 
982 void putsJsonGF(smallJsont* object) {
983  char *s = NULL;
984 
985  if (!object) {
986  return;
987  }
988  s = toStringO((baset *)object);
989  if (s) {
990  puts(s);
991  }
992  free(s);
993 }
994 
995 void putsArrayGF(smallArrayt* object) {
996  char *s = NULL;
997 
998  if (!object) {
999  return;
1000  }
1001  s = toStringO((baset *)object);
1002  if (s) {
1003  puts(s);
1004  }
1005  free(s);
1006 }
1007 
1009  char *s = NULL;
1010 
1011  if (!object) {
1012  return;
1013  }
1014  s = toStringO((baset *)object);
1015  if (s) {
1016  puts(s);
1017  }
1018  free(s);
1019 }
1020 
1022  char *s = NULL;
1023 
1024  if (!object) {
1025  return;
1026  }
1027  s = toStringO((baset *)object);
1028  if (s) {
1029  puts(s);
1030  }
1031  free(s);
1032 }
1033 
1035  char *s = NULL;
1036 
1037  if (!object) {
1038  return;
1039  }
1040  s = toStringO((baset *)object);
1041  if (s) {
1042  puts(s);
1043  }
1044  free(s);
1045 }
1046 
1047 void putsSmallIntGF(smallIntt* object) {
1048  char *s = NULL;
1049 
1050  if (!object) {
1051  return;
1052  }
1053  s = toStringO((baset *)object);
1054  if (s) {
1055  puts(s);
1056  }
1057  free(s);
1058 }
1059 
1061  char *s = NULL;
1062 
1063  if (!object) {
1064  return;
1065  }
1066  s = toStringO((baset *)object);
1067  if (s) {
1068  puts(s);
1069  }
1070  free(s);
1071 }
1072 
1073 void putsVoidGF(void* object) {
1074 
1075  if (!object) {
1076  return;
1077  }
1078  puts("Unsupported putsG type or void pointer");
1079 }
1080 
1082  char *s = NULL;
1083 
1084  if (!object) {
1085  return;
1086  }
1087  s = toStringO((baset *)object);
1088  if (s) {
1089  puts(s);
1090  }
1091  free(s);
1092 }
1093 
1094 
1095 char *toStringOF(baset* object) {
1096 
1097  if (!object) {
1098  return(NULL);
1099  }
1100  return(toStringO(object));
1101 }
1102 
1104 
1105  if (!object) {
1106  return(NULL);
1107  }
1108  return(toStringO((baset *)object));
1109 }
1110 
1111 char *toStringBoolGF(bool object) {
1112 
1113  if (object) {
1114  return(strdup("true"));
1115  }
1116  else {
1117  return(strdup("false"));
1118 }
1119  }
1120 
1121 char *toStringBoolPGF(bool* object) {
1122 
1123  if (!object) {
1124  return(NULL);
1125  }
1126  if (*object) {
1127  return(strdup("true"));
1128  }
1129  else {
1130  return(strdup("false"));
1131 }
1132  }
1133 
1134 char *toStringFloatGF(float object) {
1135  char *s = NULL;
1136 
1137  isError(s, malloc(256*sizeof(char))) return(NULL);
1138  snprintf(s,256, "%f", (double)object);
1139  return(s);
1140 }
1141 
1142 char *toStringFloatPGF(float* object) {
1143  char *s = NULL;
1144 
1145  if (!object) {
1146  return(NULL);
1147  }
1148  isError(s, malloc(256*sizeof(char))) return(NULL);
1149  snprintf(s,256, "%f", (double)*object);
1150  return(s);
1151 }
1152 
1153 char *toStringDoubleGF(double object) {
1154  char *s = NULL;
1155 
1156  isError(s, malloc(256*sizeof(char))) return(NULL);
1157  snprintf(s,256, "%e", object);
1158  return(s);
1159 }
1160 
1161 char *toStringDoublePGF(double* object) {
1162  char *s = NULL;
1163 
1164  if (!object) {
1165  return(NULL);
1166  }
1167  isError(s, malloc(256*sizeof(char))) return(NULL);
1168  snprintf(s,256, "%e", *object);
1169  return(s);
1170 }
1171 
1172 char *toStringIntGF(int64_t object) {
1173 
1174  return(intToS(object));
1175 }
1176 
1177 char *toStringIntPGF(int64_t* object) {
1178 
1179  if (!object) {
1180  return(NULL);
1181  }
1182  return(intToS(*object));
1183 }
1184 
1185 char *toStringInt32GF(int32_t object) {
1186 
1187  return(intToS(object));
1188 }
1189 
1190 char *toStringInt32PGF(int32_t* object) {
1191 
1192  if (!object) {
1193  return(NULL);
1194  }
1195  return(intToS(*object));
1196 }
1197 
1198 char *toStringInt16GF(int16_t object) {
1199 
1200  return(intToS(object));
1201 }
1202 
1203 char *toStringInt16PGF(int16_t* object) {
1204 
1205  if (!object) {
1206  return(NULL);
1207  }
1208  return(intToS(*object));
1209 }
1210 
1211 char *toStringUintGF(uint64_t object) {
1212 
1213  // TODO create uintToS
1214  return(intToS((int64_t)object));
1215 }
1216 
1217 char *toStringUintPGF(uint64_t* object) {
1218 
1219  if (!object) {
1220  return(NULL);
1221  }
1222  // TODO create uintToS
1223  return(intToS((int64_t)*object));
1224 }
1225 
1226 char *toStringUint32GF(uint32_t object) {
1227 
1228  return(intToS(object));
1229 }
1230 
1231 char *toStringUint32PGF(uint32_t* object) {
1232 
1233  if (!object) {
1234  return(NULL);
1235  }
1236  return(intToS(*object));
1237 }
1238 
1239 char *toStringUint16GF(uint16_t object) {
1240 
1241  return(intToS(object));
1242 }
1243 
1244 char *toStringUint16PGF(uint16_t* object) {
1245 
1246  if (!object) {
1247  return(NULL);
1248  }
1249  return(intToS(*object));
1250 }
1251 
1252 char *toStringUint8GF(uint8_t object) {
1253 
1254  return(intToS(object));
1255 }
1256 
1257 char *toStringUint8PGF(uint8_t* object) {
1258 
1259  if (!object) {
1260  return(NULL);
1261  }
1262  return(intToS(*object));
1263 }
1264 
1265 char *toStringCharGF(char object) {
1266  char r[2];;
1267 
1268  r[0] = object;
1269  r[1] = 0;
1270 
1271  return(strdup(r));
1272 }
1273 
1274 char *toStringSGF(const char* object) {
1275 
1276  return(dupS(object));
1277 }
1278 
1279 char *toStringListSGF(char** object) {
1280 
1281  if (!object) {
1282  return(NULL);
1283  }
1284  char *s = join(object, "\",\"");
1285  if (!s) {
1286  // empty list
1287  return(strdup("[]"));
1288  }
1289  char *r = catS("[\"", s, "\"]");;
1290  free(s);
1291  return(r);
1292 }
1293 
1294 char *toStringListCSGF(const char** object) {
1295 
1296  if (!object) {
1297  return(NULL);
1298  }
1299  char *s = joinCS(object, "\",\"");
1300  if (!s) {
1301  // empty list
1302  return(strdup("[]"));
1303  }
1304  char *r = catS("[\"", s, "\"]");;
1305  free(s);
1306  return(r);
1307 }
1308 
1309 char *toStringDictGF(smallDictt* object) {
1310 
1311  if (!object) {
1312  return(NULL);
1313  }
1314  return(toStringO((baset *)object));
1315 }
1316 
1318 
1319  if (!object) {
1320  return(NULL);
1321  }
1322  return(toStringO((baset *)object));
1323 }
1324 
1326 
1327  if (!object) {
1328  return(NULL);
1329  }
1330  return(toStringO((baset *)object));
1331 }
1332 
1334 
1335  if (!object) {
1336  return(NULL);
1337  }
1338  return(toStringO((baset *)object));
1339 }
1340 
1342 
1343  if (!object) {
1344  return(NULL);
1345  }
1346  return(toStringO((baset *)object));
1347 }
1348 
1350 
1351  if (!object) {
1352  return(NULL);
1353  }
1354  return(toStringO((baset *)object));
1355 }
1356 
1358 
1359  if (!object) {
1360  return(NULL);
1361  }
1362  return(toStringO((baset *)object));
1363 }
1364 
1365 char *toStringVoidGF(void* object) {
1366 
1367  if (!object) {
1368  return(NULL);
1369  }
1370  return(strdup("Unsupported toStringG type or void pointer"));
1371 }
1372 
1374 
1375  if (!object) {
1376  return(NULL);
1377  }
1378  return(toStringO((baset *)object));
1379 }
1380 
1382 
1383  if (!object) {
1384  return(NULL);
1385  }
1386  return(toStringO((baset *)object));
1387 }
1388 
1389 char *otos(void *basetObj) {
1390 
1391  cast(baset*, obj, basetObj);
1392  return(toStringO(obj));
1393 }
1394 
1395 smallStringt *formatO(const char *fmt, ...) {
1396  char *r = NULL;
1397  va_list pl;
1398 
1399  if (!fmt) {
1400  return(NULL);
1401  }
1402  va_start(pl, fmt);
1403  if (vasprintf(&r, fmt, pl) == -1) {
1404  va_end(pl);
1405  return(NULL);
1406  }
1407  va_end(pl);
1408 
1410  free(r);
1411  if (!R) {
1412  return(NULL);
1413  }
1414  return(R);
1415 }
1416 
1417 
1418 int execO(const char *cmd, smallArrayt *out, smallArrayt *err UNUSED) {
1419  FILE* fp = NULL;
1420  char **list = NULL;
1421 
1422  // sanity checks
1423  if (!cmd) {
1424  return(0);
1425  }
1426 
1427  if (!out) {
1428  return(0);
1429  }
1430 
1431  fp = popen(cmd, "r");
1432  if (!fp) {
1433  pFuncError
1434  shEPrintfS("The command was: \"%s\"\n", cmd);
1435  return(0);//LCOV_EXCL_LINE
1436  }
1437 
1438  list = readStream(fp);
1439 
1440  pclose(fp);
1441  out->f->fromArrayNFree(out, list, 0);
1442  return(1);
1443 }
1444 
1446 
1447  if (!cmd) {
1448  return(0);
1449  }
1450 
1451  const char *type = getTopTypeO(cmd);
1452 
1453  if (!eqS(type,"string")) {
1454  return(0);
1455  }
1456 
1457  return(execO(sjGet(cmd), out, err));
1458 }
1459 
1461 
1462  if (!cmd) {
1463  return(0);
1464  }
1465  return(execO(ssGet(cmd), out, err));
1466 }
1467 
1468 smallArrayt* walkDirO(const char* dirPath) {
1469 
1470  // sanity checks
1471  if (!dirPath || isBlankS(dirPath)) {
1472  return(NULL);
1473  }
1474 
1476  if (!list) {
1477  return(NULL);
1478  }
1479  walkADir(dirPath, list);
1480 
1481  list->f->sort(list);
1482 
1483  return(list);
1484 }
1485 
1487 
1488  if (!dirPath) {
1489  return(NULL);
1490  }
1491 
1492  const char *type = getTopTypeO(dirPath);
1493 
1494  if (!eqS(type,"string")) {
1495  return(NULL);
1496  }
1497 
1498  return(walkDirO(getTopSO(dirPath)));
1499 }
1500 
1502 
1503  if (!dirPath) {
1504  return(NULL);
1505  }
1506  return(walkDirO(ssGet(dirPath)));
1507 }
1508 
1509 internal void walkADir(const char *dirPath, smallArrayt *list) {
1510  DIR *d = NULL;
1511  struct dirent *dp = NULL;
1512  char *sPath = NULL;
1513 
1514  d = opendir(dirPath);
1515  if (!d) {
1516  pFuncError
1517  shEPrintfS("The path was: \"%s\"\n", dirPath);
1518  return;
1519  }
1520 
1521  dp = readdir(d);
1522  while (dp) {
1523  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1524  dp = readdir(d);
1525  continue;
1526  }
1527 
1528  sPath = catS(dirPath, "/", dp->d_name);
1529 
1530  if (isDir(sPath)) {
1531  if (!isLink(sPath)) {
1532  walkADir(sPath, list);
1533  }
1534  }
1535  else {
1536  list->f->pushS(list, sPath);
1537  }
1538  free(sPath);
1539  dp = readdir(d);
1540  }
1541 
1542  closedir(d);
1543 }
1544 
1545 smallArrayt* walkDirDirO(const char* dirPath) {
1546 
1547  // sanity checks
1548  if (!dirPath || isBlankS(dirPath)) {
1549  return(NULL);
1550  }
1551 
1553  if (!list) {
1554  return(NULL);
1555  }
1556  walkADirDir(dirPath, list);
1557 
1558  list->f->sort(list);
1559 
1560  return(list);
1561 }
1562 
1564 
1565  if (!dirPath) {
1566  return(NULL);
1567  }
1568 
1569  const char *type = getTopTypeO(dirPath);
1570 
1571  if (!eqS(type,"string")) {
1572  return(NULL);
1573  }
1574 
1575  return(walkDirDirO(getTopSO(dirPath)));
1576 }
1577 
1579 
1580  if (!dirPath) {
1581  return(NULL);
1582  }
1583  return(walkDirDirO(ssGet(dirPath)));
1584 }
1585 
1586 internal void walkADirDir(const char *dirPath, smallArrayt *list) {
1587  DIR *d = NULL;
1588  struct dirent *dp = NULL;
1589  char *sPath = NULL;
1590 
1591  d = opendir(dirPath);
1592  if (!d) {
1593  pFuncError
1594  shEPrintfS("The path was: \"%s\"\n", dirPath);
1595  return;
1596  }
1597 
1598  dp = readdir(d);
1599  while (dp) {
1600  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1601  dp = readdir(d);
1602  continue;
1603  }
1604 
1605  sPath = catS(dirPath, "/", dp->d_name);
1606 
1607  if (isDir(sPath)) {
1608  list->f->pushS(list, sPath);
1609  if (!isLink(sPath)) {
1610  walkADirDir(sPath, list);
1611  }
1612  }
1613  free(sPath);
1614  dp = readdir(d);
1615  }
1616 
1617  closedir(d);
1618 }
1619 
1620 smallArrayt *readDirO(const char *dirPath) {
1621  DIR *d = NULL;
1622  struct dirent *dp = NULL;
1623 
1624  // sanity checks
1625  if (!dirPath || isBlankS(dirPath)) {
1626  return(NULL);
1627  }
1628 
1630  if (!list) {
1631  return(NULL);
1632  }
1633 
1634  d = opendir(dirPath);
1635  if (!d) {
1636  pFuncError
1637  shEPrintfS("The path was: \"%s\"\n", dirPath);
1638  return(list);
1639  }
1640 
1641  dp = readdir(d);
1642  while (dp) {
1643  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1644  dp = readdir(d);
1645  continue;
1646  }
1647 
1648  char *sPath = catS(dirPath, "/", dp->d_name);
1649 
1650  if (!isDir(sPath)) {
1651  list->f->pushS(list, dp->d_name);
1652  }
1653  free(sPath);
1654  dp = readdir(d);
1655  }
1656 
1657  closedir(d);
1658 
1659  list->f->sort(list);
1660 
1661  return(list);
1662 }
1663 
1665 
1666  if (!dirPath) {
1667  return(NULL);
1668  }
1669 
1670  const char *type = getTopTypeO(dirPath);
1671 
1672  if (!eqS(type,"string")) {
1673  return(NULL);
1674  }
1675 
1676  return(readDirO(getTopSO(dirPath)));
1677 }
1678 
1680 
1681  if (!dirPath) {
1682  return(NULL);
1683  }
1684  return(readDirO(ssGet(dirPath)));
1685 }
1686 
1687 smallArrayt *readDirDirO(const char *dirPath) {
1688  DIR *d = NULL;
1689  struct dirent *dp = NULL;
1690 
1691  // sanity checks
1692  if (!dirPath || isBlankS(dirPath)) {
1693  return(NULL);
1694  }
1695 
1697  if (!list) {
1698  return(NULL);
1699  }
1700 
1701  d = opendir(dirPath);
1702  if (!d) {
1703  pFuncError
1704  shEPrintfS("The path was: \"%s\"\n", dirPath);
1705  return(list);
1706  }
1707 
1708  dp = readdir(d);
1709  while (dp) {
1710  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1711  dp = readdir(d);
1712  continue;
1713  }
1714 
1715  char *sPath = catS(dirPath, "/", dp->d_name);
1716 
1717  if (isDir(sPath)) {
1718  list->f->pushS(list, dp->d_name);
1719  }
1720  free(sPath);
1721  dp = readdir(d);
1722  }
1723 
1724  closedir(d);
1725 
1726  list->f->sort(list);
1727 
1728  return(list);
1729 }
1730 
1732 
1733  if (!dirPath) {
1734  return(NULL);
1735  }
1736 
1737  const char *type = getTopTypeO(dirPath);
1738 
1739  if (!eqS(type,"string")) {
1740  return(NULL);
1741  }
1742 
1743  return(readDirDirO(getTopSO(dirPath)));
1744 }
1745 
1747 
1748  if (!dirPath) {
1749  return(NULL);
1750  }
1751  return(readDirDirO(ssGet(dirPath)));
1752 }
1753 
1754 smallArrayt *walkDirAllO(const char* dirPath) {
1755 
1756  // sanity checks
1757  if (!dirPath || isBlankS(dirPath)) {
1758  return(NULL);
1759  }
1760 
1762  if (!list) {
1763  return(NULL);
1764  }
1765  walkADirAll(dirPath, list);
1766 
1767  list->f->sort(list);
1768 
1769  return(list);
1770 }
1771 
1773 
1774  if (!dirPath) {
1775  return(NULL);
1776  }
1777 
1778  const char *type = getTopTypeO(dirPath);
1779 
1780  if (!eqS(type,"string")) {
1781  return(NULL);
1782  }
1783 
1784  return(walkDirAllO(getTopSO(dirPath)));
1785 }
1786 
1788 
1789  if (!dirPath) {
1790  return(NULL);
1791  }
1792  return(walkDirAllO(ssGet(dirPath)));
1793 }
1794 
1795 internal void walkADirAll(const char *dirPath, smallArrayt *list) {
1796  DIR *d = NULL;
1797  struct dirent *dp = NULL;
1798  char *sPath = NULL;
1799 
1800  d = opendir(dirPath);
1801  if (!d) {
1802  pFuncError
1803  shEPrintfS("The path was: \"%s\"\n", dirPath);
1804  return;
1805  }
1806 
1807  dp = readdir(d);
1808  while (dp) {
1809  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1810  dp = readdir(d);
1811  continue;
1812  }
1813 
1814  sPath = catS(dirPath, "/", dp->d_name);
1815 
1816  list->f->pushS(list, sPath);
1817 
1818  if (isDir(sPath)) {
1819  if (!isLink(sPath)) {
1820  walkADirAll(sPath, list);
1821  }
1822  }
1823  dp = readdir(d);
1824  free(sPath);
1825  }
1826 
1827  closedir(d);
1828 }
1829 
1830 smallArrayt *readDirAllO(const char *dirPath) {
1831  DIR *d = NULL;
1832  struct dirent *dp = NULL;
1833 
1834  // sanity checks
1835  if (!dirPath || isBlankS(dirPath)) {
1836  return(NULL);
1837  }
1838 
1840  if (!list) {
1841  return(NULL);
1842  }
1843 
1844  d = opendir(dirPath);
1845  if (!d) {
1846  pFuncError
1847  shEPrintfS("The path was: \"%s\"\n", dirPath);
1848  return(list);
1849  }
1850 
1851  dp = readdir(d);
1852  while (dp) {
1853  if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
1854  dp = readdir(d);
1855  continue;
1856  }
1857 
1858  char *sPath = catS(dirPath, "/", dp->d_name);
1859 
1860  list->f->pushS(list, dp->d_name);
1861  free(sPath);
1862  dp = readdir(d);
1863  }
1864 
1865  closedir(d);
1866 
1867  list->f->sort(list);
1868 
1869  return(list);
1870 }
1871 
1873 
1874  if (!dirPath) {
1875  return(NULL);
1876  }
1877 
1878  const char *type = getTopTypeO(dirPath);
1879 
1880  if (!eqS(type,"string")) {
1881  return(NULL);
1882  }
1883 
1884  return(readDirAllO(getTopSO(dirPath)));
1885 }
1886 
1888 
1889  if (!dirPath) {
1890  return(NULL);
1891  }
1892  return(readDirAllO(ssGet(dirPath)));
1893 }
1894 
1896 
1897  if (!path) {
1898  return(0);
1899  }
1900 
1901  const char *type = getTopTypeO(path);
1902 
1903  if (!eqS(type,"string")) {
1904  return(0);
1905  }
1906 
1907  return(getModificationTime(getTopSO(path))); {
1908  // bug cg_c IF
1909 }
1910  }
1911 
1913 
1914  if (!path || !path->data) {
1915  return(0);
1916  }
1917 
1918  return(getModificationTime(ssGet(path))); {
1919  // bug cg_c IF
1920 }
1921  }
1922 
1923 
1924 int setModificationTimeJO(smallJsont *path, time_t mtime) {
1925 
1926  if (!path) {
1927  return(0);
1928  }
1929 
1930  const char *type = getTopTypeO(path);
1931 
1932  if (!eqS(type,"string")) {
1933  return(0);
1934  }
1935 
1936  return(setModificationTime(getTopSO(path), mtime)); {
1937  // bug cg_c IF
1938 }
1939  }
1940 
1941 int setModificationTimeO(smallStringt *path, time_t mtime) {
1942 
1943  if (!path || !path->data) {
1944  return(0);
1945  }
1946 
1947  return(setModificationTime(ssGet(path), mtime)); {
1948  // bug cg_c IF
1949 }
1950  }
1951 
1952 
1954 
1955  if (!path1 || !path2) {
1956  return(false);
1957  }
1958 
1959  const char *type = getTopTypeO(path1);
1960 
1961  if (!eqS(type,"string")) {
1962  return(false);
1963  }
1964 
1965  type = getTopTypeO(path2);
1966 
1967  if (!eqS(type,"string")) {
1968  return(false);
1969  }
1970 
1971  return(equalModificationTimes(getTopSO(path1), getTopSO(path2))); {
1972  // bug cg_c IF
1973 }
1974  }
1975 
1976 bool equalModificationTimesSJO(const char *path1, smallJsont *path2) {
1977 
1978  if (!path1 || !path2) {
1979  return(false);
1980  }
1981 
1982  const char *type = getTopTypeO(path2);
1983 
1984  if (!eqS(type,"string")) {
1985  return(false);
1986  }
1987 
1988  return(equalModificationTimes(path1, getTopSO(path2))); {
1989  // bug cg_c IF
1990 }
1991  }
1992 
1993 bool equalModificationTimesJOS(smallJsont *path1, const char *path2) {
1994 
1995  if (!path1 || !path2) {
1996  return(false);
1997  }
1998 
1999  const char *type = getTopTypeO(path1);
2000 
2001  if (!eqS(type,"string")) {
2002  return(false);
2003  }
2004 
2005  return(equalModificationTimes(getTopSO(path1), path2)); {
2006  // bug cg_c IF
2007 }
2008  }
2009 
2011 
2012  if (!path1 || !path2 || !path2->data) {
2013  return(false);
2014  }
2015 
2016  const char *type = getTopTypeO(path1);
2017 
2018  if (!eqS(type,"string")) {
2019  return(false);
2020  }
2021 
2022  return(equalModificationTimes(getTopSO(path1), ssGet(path2))); {
2023  // bug cg_c IF
2024 }
2025  }
2026 
2028 
2029  if (!path1 || !path2 || !path1->data) {
2030  return(false);
2031  }
2032 
2033  const char *type = getTopTypeO(path2);
2034 
2035  if (!eqS(type,"string")) {
2036  return(false);
2037  }
2038 
2039  return(equalModificationTimes(ssGet(path1), getTopSO(path2))); {
2040  // bug cg_c IF
2041 }
2042  }
2043 
2045 
2046  if (!path1 || !path2 || !path1->data || !path2->data) {
2047  return(false);
2048  }
2049 
2050  time_t t1 = getModificationTimeO(path1); {
2051  time_t t2 = getModificationTimeO(path2); {
2052 
2053  if (!t1 || !t2) {
2054  return(false);
2055  }
2056  return(t1 == t2);;
2057 }
2058  }
2059  }
2060 
2061 bool equalModificationTimesSO(const char *path1, smallStringt *path2) {
2062 
2063  if (!path2) {
2064  return(false);
2065  }
2066  return(equalModificationTimes(path1, ssGet(path2))); {
2067  // cg_c bug
2068 }
2069  }
2070 
2071 bool equalModificationTimesOS(smallStringt *path1, const char *path2) {
2072 
2073  if (!path1) {
2074  return(false);
2075  }
2076  return(equalModificationTimes(ssGet(path1), path2)); {
2077  // cg_c bug
2078 }
2079  }
2080 
2081 smallJsont *timeToJO(const time_t t) {
2082 
2083  char *s = timeToS(t);
2085  if (!r) {
2086  free(s);
2087  return(NULL);
2088  }
2089  setTopStringO(r, s);
2090  free(s);
2091  return(r);
2092 }
2093 
2094 smallStringt *timeToSO(const time_t t) {
2095 
2096  char *s = timeToS(t);
2098  free(s);
2099  if (!r) {
2100  return(NULL);
2101  }
2102  return(r);
2103 }
2104 
2106 
2107  if (!path) {
2108  return(NULL);
2109  }
2110 
2111  const char *type = getTopTypeO(path);
2112 
2113  if (!eqS(type,"string")) {
2114  return(NULL);
2115  }
2116 
2118  if (!r) {
2119  return(NULL);
2120  }
2122  return(r);
2123 }
2124 
2126  char *dir = NULL;
2127  smallStringt *r = NULL;
2128 
2129  if (!path || !path->data) {
2130  return(NULL);
2131  }
2132 
2133  if (isBlankO(path)) {
2134  return(allocSmallString("./"));
2135  }
2136 
2137  dir = strdup(ssGet(path));
2138  dirname(dir);
2139 
2140  // is dirname empty?
2141  if (strEq(dir, ssGet(path))) {
2142  // set dir to pwd when dirname is empty
2143  free(dir);
2144  dir = strdup("./");
2145  }
2146  r = allocSmallString(dir);
2147  free(dir);
2148  if (!r) {
2149  return(NULL);
2150  }
2151  return(r);
2152 }
2153 
2154 
2156 
2157  // sanity checks
2158  if (!path) {
2159  return(NULL);
2160  }
2161 
2162  const char *type = getTopTypeO(path);
2163 
2164  if (!eqS(type,"string")) {
2165  return(NULL);
2166  }
2167 
2168  char *r = expandHome(getTopSO(path));
2169  freeO(path);
2170  setTopNFreeStringO(path, r);
2171  return(path);
2172 }
2173 
2174 #if (__OpenBSD__ || __HAIKU__)
2176 
2177  // sanity checks
2178  if (!path || !path->data) {
2179  return(NULL);
2180  }
2181 
2182  char *r = expandHome(ssGet(path));
2183  path->f->set(path, r);
2184  free(r);
2185  return(path);
2186 }
2187 
2188 #else
2190  wordexp_t exp_result;
2191 
2192  // sanity checks
2193  // duplicate path to be able to realloc (impossible when path is static)
2194  // expand ~/ or ~USER
2195 
2196  // sanity checks
2197  if (!path || !path->data) {
2198  return(NULL);
2199  }
2200 
2201  #if (!__TERMUX__)
2202  // expand ~/
2203  int status = wordexp(path->f->get(path), &exp_result, 0);;
2204  switch (status) {
2205  case WRDE_BADCHAR:
2206  shEPrintfS("expandHomeO error: unquoted invalid character\n");
2207  shEPrintfS("The path was: \"%s\"\n", ssGet(path));
2208  return(NULL);
2209  case WRDE_BADVAL:
2210  shEPrintfS("expandHomeO error: undefined shell variable\n");
2211  shEPrintfS("The path was: \"%s\"\n", ssGet(path));
2212  return(NULL);
2213  case WRDE_NOSPACE:
2214  shEPrintfS("expandHomeO error: out of memory\n");
2215  shEPrintfS("The path was: \"%s\"\n", ssGet(path));
2216  return(NULL);
2217  case WRDE_SYNTAX:
2218  shEPrintfS("expandHomeO error: syntax error\n");
2219  shEPrintfS("The path was: \"%s\"\n", ssGet(path));
2220  return(NULL);
2221  default:
2222  break;
2223  }
2224 
2225  path->f->set(path, exp_result.we_wordv[0]);
2226  wordfree(&exp_result);
2227  #else
2228  path->f->replace(path, "~", "/data/data/com.termux/files/home", 1);
2229  #endif
2230  return(path);
2231 }
2232 
2233 #endif
2234 // #if __OpenBSD__ || __HAIKU__
2235 
2237 
2238  if (!path) {
2239  return(NULL);
2240  }
2241 
2242  const char *type = getTopTypeO(path);
2243 
2244  if (!eqS(type,"string")) {
2245  return(NULL);
2246  }
2247 
2248  char *r = normalizePath(getTopSO(path));
2249  freeO(path);
2250  setTopNFreeStringO(path, r);
2251  return(path);
2252 }
2253 
2255 
2256  // sanity checks
2257  if (!path || !path->data) {
2258  return(NULL);
2259  }
2260 
2261  if (isEmptyO(path)) {
2262  return(path);
2263  }
2264 
2265  // list path elements
2266  char **pathL = splitSO(path, "/");
2267 
2268  // remove empty elements
2269  pErrorNULL(iListCompactS(&pathL));
2270 
2271  if (listIsEmptyS(pathL)) {
2272  listFreeS(pathL);
2273  // keep leading /
2274  path->f->set(path, "/");
2275  return(path);
2276  }
2277 
2278  // new path elements
2279  char **list = NULL;
2280 
2281  // detect leading double dots
2282  bool onlyLeadingDoubleDots = true;
2283 
2284  // add elements to list
2285  forEachCharP(pathL, level) {
2286  if (strEq(*level, "..")) {
2287  if (onlyLeadingDoubleDots) {
2288  // keep leading ..
2289  pErrorNULL(listPushS(&list, ".."));
2290  }
2291  else {
2292  // remove .. in path
2293  char *s = listPopS(&list);
2294  free(s);
2295  }
2296  }
2297  else if (!strEq(*level, ".")) {
2298  // remove . and add elements
2299  pErrorNULL(listPushS(&list, *level));
2300  // an element is pushed, so this is the end of leading double dots
2301  onlyLeadingDoubleDots = false;
2302  }
2303  }
2304 
2305  if (listLengthS(list) == 1 && strEq(list[0], "..") && path->f->getAt(path, 0) == '/') {
2306  // handle ../ .. /.. /../
2307  list[0][0] = 0;
2308  }
2309 
2310  // handle /.: add empty string
2311  if (path->f->equalS(path, "/.")) {
2312  pErrorNULL(listPushS(&list, ""));
2313  }
2314 
2315  // keep leading /
2316  if (path->f->getAt(path, 0) == '/') {
2317  if (listIsEmptyS(list)) {
2318  // .. cancelled path: /a/b/../..
2319  listFreeManyS(pathL, list);
2320  path->f->set(path, "/");
2321  return(path);
2322  }
2323  pErrorNULL(listPrependS(&list, ""));
2324  }
2325 
2326  // create new path
2327  char *r = join(list, "/");;
2328  // keep order pathL, list because list can be NULL
2329  // if it is first listFreeManyS stops early
2330  listFreeManyS(pathL, list);
2331  if (!r) {
2332  path->f->set(path, "");
2333  return(path);
2334  }
2335  path->f->setNFree(path, r);
2336  return(path);
2337 }
2338 
2339 
2341 
2342  char *s = getCwd();
2343 
2344  if (!s) {
2345  return(NULL);
2346  }
2347 
2349  if (!r) {
2350  free(s);
2351  return(NULL);
2352  }
2353  setTopNFreeStringO(r, s);
2354  return(r);
2355 }
2356 
2358  char *r = NULL;
2359 
2360  r = getcwd(NULL, 0);
2361  if (!r) {
2362  pFuncError
2363  return(NULL);
2364  }
2366  if (!s) {
2367  free(r);
2368  return(NULL);
2369  }
2370  s->f->setNFree(s, r);
2371  return(s);
2372 }
2373 
2374 int chDirJO(smallJsont *path) {
2375 
2376  if (!path) {
2377  return(0);
2378  }
2379 
2380  const char *type = getTopTypeO(path);
2381 
2382  if (!eqS(type,"string")) {
2383  return(0);
2384  }
2385 
2386  return(chDir(getTopSO(path)));
2387 }
2388 
2389 int chDirO(smallStringt *path) {
2390 
2391  if (!path) {
2392  return(0);
2393  }
2394 
2395  int r = chdir(ssGet(path));
2396  if (r) {
2397  pFuncError
2398  shEPrintfS("The path was: \"%s\"\n", ssGet(path));
2399  return(0);
2400  }
2401  return(1);
2402 }
2403 
2404 bool isDirJO(smallJsont *path) {
2405 
2406  if (!path) {
2407  return(false);
2408  }
2409 
2410  const char *type = getTopTypeO(path);
2411 
2412  if (!eqS(type,"string")) {
2413  return(false);
2414  }
2415 
2416  return(isDir(getTopSO(path)));
2417 }
2418 
2419 bool isDirO(smallStringt *path) {
2420  struct stat st;
2421 
2422  // sanity checks
2423  if (!path || isBlankO(path)) {
2424  return(false);
2425  }
2426 
2427  if (stat(ssGet(path), &st) == -1) {
2428  return(false);
2429  }
2430 
2431  if (!S_ISDIR(st.st_mode)) {
2432  return(false);
2433  }
2434  return(true);
2435 }
2436 
2437 bool isLinkJO(smallJsont *path) {
2438 
2439  if (!path) {
2440  return(false);
2441  }
2442 
2443  const char *type = getTopTypeO(path);
2444 
2445  if (!eqS(type,"string")) {
2446  return(false);
2447  }
2448 
2449  return(isLink(getTopSO(path)));
2450 }
2451 
2452 bool isLinkO(smallStringt *path) {
2453  struct stat st;
2454 
2455  // sanity checks
2456  if (!path || isBlankO(path)) {
2457  return(false);
2458  }
2459 
2460  if (lstat(ssGet(path), &st) == -1) {
2461  return(false);
2462  }
2463 
2464  if (!S_ISLNK(st.st_mode)) {
2465  return(false);
2466  }
2467  return(true);
2468 }
2469 
2470 bool fileExistsJO(smallJsont *filePath) {
2471 
2472  if (!filePath) {
2473  return(false);
2474  }
2475 
2476  const char *type = getTopTypeO(filePath);
2477 
2478  if (!eqS(type,"string")) {
2479  return(false);
2480  }
2481 
2482  return(fileExists(getTopSO(filePath)));
2483 }
2484 
2485 bool fileExistsO(smallStringt *filePath) {
2486 
2487  // sanity checks
2488  if (!filePath || filePath->f->isBlank(filePath)) {
2489  return(false);
2490  }
2491 
2492  int r = access(filePath->f->get(filePath), F_OK);
2493  //if r
2494  // perror("fileExists error");
2495  // dont print error because this is a test
2496  return(r != -1);;
2497 }
2498 
2499 bool fileChmodJO(smallJsont *filePath, mode_t mode) {
2500 
2501  if (!filePath) {
2502  return(false);
2503  }
2504 
2505  const char *type = getTopTypeO(filePath);
2506 
2507  if (!eqS(type,"string")) {
2508  return(false);
2509  }
2510 
2511  return(fileChmod(getTopSO(filePath), mode));
2512 }
2513 
2514 bool fileChmodO(smallStringt *filePath, mode_t mode) {
2515 
2516  // sanity checks
2517  if (!filePath || isBlankO(filePath)) {
2518  return(false);
2519  }
2520 
2521  int r = chmod(ssGet(filePath), mode);
2522  if (r) {
2523  pFuncError
2524  shEPrintfS("The path was: \"%s\"\n", ssGet(filePath));
2525  }
2526  return(r == 0);;
2527 }
2528 
2529 ssize_t fileSizeJO(smallJsont *filePath) {
2530 
2531  if (!filePath) {
2532  return(-1);
2533  }
2534 
2535  const char *type = getTopTypeO(filePath);
2536 
2537  if (!eqS(type,"string")) {
2538  return(-1);
2539  }
2540 
2541  return(fileSize(getTopSO(filePath)));
2542 }
2543 
2544 ssize_t fileSizeO(smallStringt *filePath) {
2545  struct stat st;
2546 
2547  // sanity checks
2548  if (!filePath || isBlankO(filePath)) {
2549  return(-1);
2550  }
2551 
2552  int r = stat(ssGet(filePath), &st);;
2553  if (r) {
2554  pFuncError
2555  shEPrintfS("The path was: \"%s\"\n", ssGet(filePath));
2556  return(-1);
2557  }
2558 
2559  // macOS returns a varying number a number above the constant below
2560  // when the file doesnt exists
2561  if ((uint64_t)(st.st_size) > 140734000000000) {
2562  return(-1);//LCOV_EXCL_LINE
2563  }
2564  return(st.st_size);
2565 }
2566 
2567 void *readFileToNewG(void *none UNUSED, const char *filePath) {
2568 
2569  return(readFileToS(filePath));
2570 }
2571 
2572 void *readStreamToNewG(void *none UNUSED, FILE *fp) {
2573 
2574  return(readStreamToS(fp));
2575 }
2576 
2577 char *readFileToG(char **string, const char *filePath) {
2578 
2579  if (!string) {
2580  return(NULL);
2581  }
2582  *string = readFileToS(filePath);
2583  return(*string);
2584 }
2585 
2586 char *readStreamToG(char **string, FILE *fp) {
2587 
2588  if (!string) {
2589  return(NULL);
2590  }
2591  *string = readStreamToS(fp);
2592  return(*string);
2593 }
2594 
2595 void readTextSmallJsonNotSupported(char ***self UNUSED, smallJsont *path UNUSED) {
2596 
2597  // TODO
2598  shPrintError;
2599  logI("readFile smallJsont path not supported");
2600 }
2601 
2602 void readTextSmallStringNotSupported(char ***self UNUSED, smallStringt *path UNUSED) {
2603 
2604  // TODO
2605  shPrintError;
2606  logI("readFile smallStringt path not supported");
2607 }
2608 
2609 void readToFileSmallJsonNotSupported(void *self UNUSED, smallJsont *path UNUSED) {
2610 
2611  // TODO
2612  shPrintError;
2613  logI("readFile smallJsont path not supported");
2614 }
2615 
2617 
2618  // TODO
2619  shPrintError;
2620  logI("readFile smallStringt path not supported");
2621 }
2622 
2623 int writeFileFromG(const char *string, const char *filePath) {
2624 
2625  return(writeFileS(filePath, string));
2626 }
2627 
2628 int writeStreamFromG(const char *string, FILE *fp) {
2629 
2630  return(writeStreamS(fp, string));
2631 }
2632 
2633 int writeTextSmallJsonNotSupported(char **self UNUSED, smallJsont *path UNUSED) {
2634 
2635  // TODO
2636  shPrintError;
2637  logI("writeFile smallJsont path not supported");
2638  return(0);
2639 }
2640 
2641 int writeTextSmallStringNotSupported(char **self UNUSED, smallStringt *path UNUSED) {
2642 
2643  // TODO
2644  shPrintError;
2645  logI("writeFile smallStringt path not supported");
2646  return(0);
2647 }
2648 
2649 int writeTextCCSmallJsonNotSupported(const char **self UNUSED, smallJsont *path UNUSED) {
2650 
2651  // TODO
2652  shPrintError;
2653  logI("writeFile smallJsont path not supported");
2654  return(0);
2655 }
2656 
2657 int writeTextCCSmallStringNotSupported(const char **self UNUSED, smallStringt *path UNUSED) {
2658 
2659  // TODO
2660  shPrintError;
2661  logI("writeFile smallStringt path not supported");
2662  return(0);
2663 }
2664 
2665 char **readTextSG(char ***list, const char *filePath) {
2666 
2667  if (!list) {
2668  return(NULL);
2669  }
2670  *list = readText(filePath);
2671  return(*list);
2672 }
2673 
2674 char **readTextStreamG(char ***list, FILE *fp) {
2675 
2676  if (!list) {
2677  return(NULL);
2678  }
2679  *list = readStream(fp);
2680  return(*list);
2681 }
2682 
2683 bool writeTextSG(char **list, const char *filePath) {
2684 
2685  return(writeText(filePath, list));
2686 }
2687 
2688 bool writeTextStreamG(char **list, FILE *fp) {
2689 
2690  return(writeStream(fp, list));
2691 }
2692 
2693 bool writeTextCG(const char **list, const char *filePath) {
2694 
2695  return(writeCText(filePath, list));
2696 }
2697 
2698 bool writeTextStreamCG(const char **list, FILE *fp) {
2699 
2700  return(writeCStream(fp, list));
2701 }
2702 
2703 bool appendFileSG(const char *string, const char *filePath) {
2704 
2705  return(appendFileS(filePath, string));
2706 }
2707 
2708 bool appendTextSG(char **list, const char *filePath) {
2709 
2710  return(appendText(filePath, list));
2711 }
2712 
2713 bool appendTextCG(const char **list, const char *filePath) {
2714 
2715  return(appendCText(filePath, list));
2716 }
2717 
2719 
2720  if (!path) {
2721  return(0);
2722  }
2723 
2724  const char *type = getTopTypeO(path);
2725 
2726  if (!eqS(type,"string")) {
2727  return(0);
2728  }
2729 
2730  return(mkdirParents(getTopSO(path)));
2731 }
2732 
2734 
2735  // sanity checks
2736  if (!path || path->f->isBlank(path)) {
2737  return(0);
2738  }
2739 
2740  return(mkdirParents(ssGet(path)));
2741 }
2742 
2744 
2745  if (!path) {
2746  return(0);
2747  }
2748 
2749  const char *type = getTopTypeO(path);
2750 
2751  if (!eqS(type,"string")) {
2752  return(0);
2753  }
2754 
2755  return(rmAll(getTopSO(path)));
2756 }
2757 
2758 int rmAllO(smallStringt* path) {
2759 
2760  // sanity checks
2761  if (!path || path->f->isBlank(path)) {
2762  return(0);
2763  }
2764 
2765  return(rmAll(ssGet(path)));
2766 }
2767 
2769 
2770  // sanity checks
2771  if (!src || !dst || src->f->isBlank(src) || dst->f->isBlank(dst)) {
2772  return(0);
2773  }
2774 
2775  return(copy(ssGet(src), ssGet(dst)));
2776 }
2777 
2778 int copySSmallJsonO(const char* src, smallJsont* dst) {
2779 
2780  if (!src || !dst || isBlankS(src)) {
2781  return(0);
2782  }
2783 
2784  if (checkObjectTypes && !isOSmallJson(dst)) {
2785  return(0);
2786  }
2787 
2788  const char *type = getTopTypeO(dst);
2789 
2790  if (!eqS(type,"string")) {
2791  return(0);
2792  }
2793 
2794  if (isBlankO(dst)) {
2795  return(0);
2796  }
2797 
2798  return(copy(src, getTopSO(dst)));
2799 }
2800 
2801 int copySO(const char* src, smallStringt* dst) {
2802 
2803  // sanity checks
2804  if (!src || !dst || isBlankS(src) || dst->f->isBlank(dst)) {
2805  return(0);
2806  }
2807 
2808  return(copy(src, ssGet(dst)));
2809 }
2810 
2811 int copySmallJsonOS(smallJsont* src, const char* dst) {
2812 
2813  if (!src || !dst || isBlankS(dst)) {
2814  return(0);
2815  }
2816 
2817  if (checkObjectTypes && !isOSmallJson(src)) {
2818  return(0);
2819  }
2820 
2821  const char *type = getTopTypeO(src);
2822 
2823  if (!eqS(type,"string")) {
2824  return(0);
2825  }
2826 
2827  if (isBlankO(src)) {
2828  return(0);
2829  }
2830 
2831  return(copy(getTopSO(src), dst));
2832 }
2833 
2835 
2836  if (!src || !dst) {
2837  return(0);
2838  }
2839 
2840  if (checkObjectTypes && !isOSmallJson(src)) {
2841  return(0);
2842  }
2843 
2844  if (checkObjectTypes && !isOSmallJson(dst)) {
2845  return(0);
2846  }
2847 
2848  const char *type = getTopTypeO(src);
2849 
2850  if (!eqS(type,"string")) {
2851  return(0);
2852  }
2853 
2854  type = getTopTypeO(dst);
2855 
2856  if (!eqS(type,"string")) {
2857  return(0);
2858  }
2859 
2860  if (isBlankO(src) || isBlankO(dst)) {
2861  return(0);
2862  }
2863 
2864  return(copy(getTopSO(src), getTopSO(dst)));
2865 }
2866 
2868 
2869  if (!src || !dst) {
2870  return(0);
2871  }
2872 
2873  if (checkObjectTypes && !isOSmallJson(src)) {
2874  return(0);
2875  }
2876 
2877  if (checkObjectTypes && !isOSmallString(dst)) {
2878  return(0);
2879  }
2880 
2881  const char *type = getTopTypeO(src);
2882 
2883  if (!eqS(type,"string")) {
2884  return(0);
2885  }
2886 
2887  if (isBlankO(src) || isBlankO(dst)) {
2888  return(0);
2889  }
2890 
2891  return(copy(getTopSO(src), ssGet(dst)));
2892 }
2893 
2894 int copyOS(smallStringt* src, const char* dst) {
2895 
2896  // sanity checks
2897  if (!src || !dst || src->f->isBlank(src) || isBlankS(dst)) {
2898  return(0);
2899  }
2900 
2901  return(copy(ssGet(src), dst));
2902 }
2903 
2905 
2906  if (!src || !dst) {
2907  return(0);
2908  }
2909 
2910  if (checkObjectTypes && !isOSmallString(src)) {
2911  return(0);
2912  }
2913 
2914  if (checkObjectTypes && !isOSmallJson(dst)) {
2915  return(0);
2916  }
2917 
2918  const char *type = getTopTypeO(dst);
2919 
2920  if (!eqS(type,"string")) {
2921  return(0);
2922  }
2923 
2924  if (isBlankO(src) || isBlankO(dst)) {
2925  return(0);
2926  }
2927 
2928  return(copy(ssGet(src), getTopSO(dst)));
2929 }
2930 
2932 
2933  if (!src || !dst) {
2934  return(0);
2935  }
2936 
2937  if (checkObjectTypes && !isOSmallJson(src)) {
2938  return(0);
2939  }
2940 
2941  if (checkObjectTypes && !isOSmallString(dst)) {
2942  return(0);
2943  }
2944 
2945  const char *type = getTopTypeO(src);
2946 
2947  if (!eqS(type,"string")) {
2948  return(0);
2949  }
2950 
2951  if (isBlankO(src) || isBlankO(dst)) {
2952  return(0);
2953  }
2954 
2955  return(shRename(getTopSO(src), ssGet(dst)));
2956 }
2957 
2959 
2960  if (!src || !dst) {
2961  return(0);
2962  }
2963 
2964  if (checkObjectTypes && !isOSmallJson(src)) {
2965  return(0);
2966  }
2967 
2968  if (checkObjectTypes && !isOSmallJson(dst)) {
2969  return(0);
2970  }
2971 
2972  const char *type = getTopTypeO(src);
2973 
2974  if (!eqS(type,"string")) {
2975  return(0);
2976  }
2977 
2978  type = getTopTypeO(dst);
2979 
2980  if (!eqS(type,"string")) {
2981  return(0);
2982  }
2983 
2984  if (isBlankO(src) || isBlankO(dst)) {
2985  return(0);
2986  }
2987 
2988  return(shRename(getTopSO(src), getTopSO(dst)));
2989 }
2990 
2991 int renameSmallJsonOS(smallJsont* src, const char* dst) {
2992 
2993  if (!src || !dst || isBlankS(dst)) {
2994  return(0);
2995  }
2996 
2997  if (checkObjectTypes && !isOSmallJson(src)) {
2998  return(0);
2999  }
3000 
3001  const char *type = getTopTypeO(src);
3002 
3003  if (!eqS(type,"string")) {
3004  return(0);
3005  }
3006 
3007  if (isBlankO(src)) {
3008  return(0);
3009  }
3010 
3011  return(shRename(getTopSO(src), dst));
3012 }
3013 
3015 
3016  // sanity checks
3017  if (!src || !dst || src->f->isBlank(src) || dst->f->isBlank(dst)) {
3018  return(0);
3019  }
3020 
3021  return(shRename(ssGet(src), ssGet(dst)));
3022 }
3023 
3025 
3026  if (!src || !dst) {
3027  return(0);
3028  }
3029 
3030  if (checkObjectTypes && !isOSmallString(src)) {
3031  return(0);
3032  }
3033 
3034  if (checkObjectTypes && !isOSmallJson(dst)) {
3035  return(0);
3036  }
3037 
3038  const char *type = getTopTypeO(dst);
3039 
3040  if (!eqS(type,"string")) {
3041  return(0);
3042  }
3043 
3044  if (isBlankO(src) || isBlankO(dst)) {
3045  return(0);
3046  }
3047 
3048  return(shRename(ssGet(src), getTopSO(dst)));
3049 }
3050 
3051 int renameSSmallJsonO(const char* src, smallJsont* dst) {
3052 
3053  if (!dst) {
3054  return(0);
3055  }
3056 
3057  if (checkObjectTypes && !isOSmallJson(dst)) {
3058  return(0);
3059  }
3060 
3061  const char *type = getTopTypeO(dst);
3062 
3063  if (!eqS(type,"string")) {
3064  return(0);
3065  }
3066 
3067  if (isBlankS(src) || isBlankO(dst)) {
3068  return(0);
3069  }
3070 
3071  return(shRename(src, sjGet(dst)));
3072 }
3073 
3074 int renameSO(const char* src, smallStringt* dst) {
3075 
3076  if (!dst) {
3077  return(0);
3078  }
3079  return(shRename(src, ssGet(dst)));
3080 }
3081 
3082 int renameOS(smallStringt* src, const char* dst) {
3083 
3084  if (!src) {
3085  return(0);
3086  }
3087  return(shRename(ssGet(src), dst));
3088 }
3089 
3091 
3092  if (!src || !dst) {
3093  return(0);
3094  }
3095 
3096  if (checkObjectTypes && !isOSmallJson(src)) {
3097  return(0);
3098  }
3099 
3100  if (checkObjectTypes && !isOSmallString(dst)) {
3101  return(0);
3102  }
3103 
3104  const char *type = getTopTypeO(src);
3105 
3106  if (!eqS(type,"string")) {
3107  return(0);
3108  }
3109 
3110  if (isBlankO(src) || isBlankO(dst)) {
3111  return(0);
3112  }
3113 
3114  return(shMove(getTopSO(src), ssGet(dst)));
3115 }
3116 
3118 
3119  if (!src || !dst) {
3120  return(0);
3121  }
3122 
3123  if (checkObjectTypes && !isOSmallJson(src)) {
3124  return(0);
3125  }
3126 
3127  if (checkObjectTypes && !isOSmallJson(dst)) {
3128  return(0);
3129  }
3130 
3131  const char *type = getTopTypeO(src);
3132 
3133  if (!eqS(type,"string")) {
3134  return(0);
3135  }
3136 
3137  type = getTopTypeO(dst);
3138 
3139  if (!eqS(type,"string")) {
3140  return(0);
3141  }
3142 
3143  if (isBlankO(src) || isBlankO(dst)) {
3144  return(0);
3145  }
3146 
3147  return(shMove(getTopSO(src), getTopSO(dst)));
3148 }
3149 
3150 int moveSmallJsonOS(smallJsont* src, const char* dst) {
3151 
3152  if (!src || !dst || isBlankS(dst)) {
3153  return(0);
3154  }
3155 
3156  if (checkObjectTypes && !isOSmallJson(src)) {
3157  return(0);
3158  }
3159 
3160  const char *type = getTopTypeO(src);
3161 
3162  if (!eqS(type,"string")) {
3163  return(0);
3164  }
3165 
3166  if (isBlankO(src)) {
3167  return(0);
3168  }
3169 
3170  return(shMove(getTopSO(src), dst));
3171 }
3172 
3174 
3175  // sanity checks
3176  if (!src || !dst || src->f->isBlank(src) || dst->f->isBlank(dst)) {
3177  return(0);
3178  }
3179 
3180  return(shMove(ssGet(src), ssGet(dst)));
3181 }
3182 
3184 
3185  if (!src || !dst) {
3186  return(0);
3187  }
3188 
3189  if (checkObjectTypes && !isOSmallString(src)) {
3190  return(0);
3191  }
3192 
3193  if (checkObjectTypes && !isOSmallJson(dst)) {
3194  return(0);
3195  }
3196 
3197  const char *type = getTopTypeO(dst);
3198 
3199  if (!eqS(type,"string")) {
3200  return(0);
3201  }
3202 
3203  if (isBlankO(src) || isBlankO(dst)) {
3204  return(0);
3205  }
3206 
3207  return(shMove(ssGet(src), getTopSO(dst)));
3208 }
3209 
3210 int moveSSmallJsonO(const char* src, smallJsont* dst) {
3211 
3212  if (!dst) {
3213  return(0);
3214  }
3215 
3216  if (checkObjectTypes && !isOSmallJson(dst)) {
3217  return(0);
3218  }
3219 
3220  const char *type = getTopTypeO(dst);
3221 
3222  if (!eqS(type,"string")) {
3223  return(0);
3224  }
3225 
3226  if (isBlankS(src) || isBlankO(dst)) {
3227  return(0);
3228  }
3229 
3230  return(shMove(src, sjGet(dst)));
3231 }
3232 
3233 int moveSO(const char* src, smallStringt* dst) {
3234 
3235  if (!dst) {
3236  return(0);
3237  }
3238  return(shMove(src, ssGet(dst)));
3239 }
3240 
3241 int moveOS(smallStringt* src, const char* dst) {
3242 
3243  if (!src) {
3244  return(0);
3245  }
3246  return(shMove(ssGet(src), dst));
3247 }
3248 
3249 smallJsont *randomSmallJsonO(uint64_t length) {
3250  char *s = NULL;
3251 
3252  s = randomS(length);
3253  if (!s) {
3254  return(NULL);
3255  }
3257  if (!r) {
3258  free(s);
3259  return(NULL);
3260  }
3261  setTopNFreeStringO(r, s);
3262  return(r);
3263 }
3264 
3265 smallStringt *randomSO(uint64_t length) {
3266  char *s = NULL;
3267 
3268  s = randomS(length);
3269  if (!s) {
3270  return(NULL);
3271  }
3273  if (!r) {
3274  free(s);
3275  return(NULL);
3276  }
3277  r->f->setNFree(r, s);
3278  return(r);
3279 }
3280 
3282  char *s = NULL;
3283 
3284  s = randomAlphaNumS(length);
3285  if (!s) {
3286  return(NULL);
3287  }
3289  if (!r) {
3290  free(s);
3291  return(NULL);
3292  }
3293  setTopNFreeStringO(r, s);
3294  return(r);
3295 }
3296 
3297 smallStringt *randomAlphaNumSO(uint64_t length) {
3298  char *s = NULL;
3299 
3300  s = randomAlphaNumS(length);
3301  if (!s) {
3302  return(NULL);
3303  }
3305  if (!r) {
3306  free(s);
3307  return(NULL);
3308  }
3309  r->f->setNFree(r, s);
3310  return(r);
3311 }
3312 
3314 
3315  char *s = readS();
3316  if (!s) {
3317  return(NULL);
3318  }
3320  if (!r) {
3321  free(s);
3322  return(NULL);
3323  }
3324  setTopNFreeStringO(r, s);
3325  return(r);
3326 }
3327 
3328 #define startMax 20
3329 
3331  size_t max = startMax;;
3332 
3333  char *s = malloc(max);
3334  if (!s) {
3335  return(NULL);
3336  }
3337 
3338  size_t i = 0;
3339  while (1) {
3340  #ifndef unitTest
3341  int c = getchar();
3342  #else
3343  int c;
3344  if (i < startMax) {
3345  c = 'a';
3346  }
3347  else {
3348  c = '\n';
3349  }
3350  #endif
3351  if (c == '\n') {
3352  s[i] = 0;
3353  break;
3354  }
3355  s[i] = (char)c;
3356  if (i == max-1) {
3357  // buffer full
3358  max += max;
3359  char *tmp = realloc(s, max);
3360  if (!tmp) {
3361  free(s);
3362  return(NULL);
3363  }
3364  s = tmp;
3365  }
3366  i++;
3367  }
3369  if (!r) {
3370  free(s);
3371  return(NULL);
3372  }
3373  r->f->setNFree(r, s);
3374  return(r);
3375 }
3376 
3378 
3379  char *s = readLine(fp);
3380  if (!s) {
3381  return(NULL);
3382  }
3384  if (!r) {
3385  free(s);
3386  return(NULL);
3387  }
3388  setTopNFreeStringO(r, s);
3389  return(r);
3390 }
3391 
3393  char *s = NULL;
3394 
3395  // sanity checks
3396  if (!fp) {
3397  return(NULL);
3398  }
3399 
3400  s = readLine(fp);
3401  if (!s) {
3402  return(NULL);
3403  }
3405  if (!r) {
3406  free(s);
3407  return(NULL);
3408  }
3409  r->f->setNFree(r, s);
3410  return(r);
3411 }
3412 
3413 char *intToSG(char *retType UNUSED, int64_t n) {
3414 
3415  return(intToS(n));
3416 }
3417 
3418 char *doubleToSG(char *retType UNUSED, double n) {
3419 
3420  return(doubleToS(n));
3421 }
3422 
3423 char **iListUniqG(char ***list, int dum UNUSED) {
3424 
3425  return(iListUniqS(list));
3426 }
3427 
3428 char **iicListUniqG(char ***list, int dum UNUSED) {
3429 
3430  return(iicListUniqS(list));
3431 }
3432 
3433 char **listFromArrayG(char **retType UNUSED, char **array, size_t size) {
3434 
3435  return(listFromArrayS(array, size));
3436 }
3437 
3438 char **listFromCArrayG(char **retType UNUSED, const char **array, size_t size) {
3439 
3440  return(listFromCArrayS(array, size));
3441 }
3442 
3443 char getSG(const char *string, int retType UNUSED, int64_t index) {
3444 
3445  return(getS(string, index));
3446 }
3447 
3448 char *listGetG(char **list, int retType UNUSED, int64_t index) {
3449 
3450  return(listGetS(list, index));
3451 }
3452 
3453 char *listGetCG(const char **list, int retType UNUSED, int64_t index) {
3454 
3455  return(listGetCS(list, index));
3456 }
3457 
3458 char *iListGetG(char **list, int retType UNUSED, int64_t index) {
3459 
3460  return(iListGetS(list, index));
3461 }
3462 
3463 const char *iListGetCG(const char **list, int retType UNUSED, int64_t index) {
3464 
3465  return(iListGetCS(list, index));
3466 }
3467 
3468 char *listPopG(char ***list, int retType UNUSED) {
3469 
3470  return(listPopS(list));
3471 }
3472 
3473 char *listDequeueG(char ***list, int retType UNUSED) {
3474 
3475  return(listDequeueS(list));
3476 }
3477 
3478 char **listDupCG(const char **list) {
3479 
3480  return(listDupCS(list));
3481 }
3482 
3483 bool listEqCG(char **list1, const char **list2) {
3484 
3485  return(listEqCS(list1, list2));
3486 }
3487 
3488 bool listEqC1G(const char **list1, char **list2) {
3489 
3490  return(listEqC1S(list1, list2));
3491 }
3492 
3493 bool listEqCCG(const char **list1, const char **list2) {
3494 
3495  return(listEqCCS(list1, list2));
3496 }
3497 
3498 bool icListEqCG(char **list1, const char **list2) {
3499 
3500  return(icListEqCS(list1, list2));
3501 }
3502 
3503 bool icListEqC1G(const char **list1, char **list2) {
3504 
3505  return(icListEqC1S(list1, list2));
3506 }
3507 
3508 bool icListEqCCG(const char **list1, const char **list2) {
3509 
3510  return(icListEqCCS(list1, list2));
3511 }
3512 
3513 size_t listLengthCG(const char **list) {
3514 
3515  return(listLengthCS(list));
3516 }
3517 
3518 ssize_t listIndexOfCG(const char **list, const char *string) {
3519 
3520  return(listIndexOfCS(list, string));
3521 }
3522 
3523 ssize_t listIndexOfCharCG(const char **list, char c) {
3524 
3525  return(listIndexOfCharCS(list, c));
3526 }
3527 
3528 ssize_t icListIndexOfCG(const char **list, const char *string) {
3529 
3530  return(icListIndexOfCS(list, string));
3531 }
3532 
3533 ssize_t icListIndexOfCharCG(const char **list, char c) {
3534 
3535  return(icListIndexOfCharCS(list, c));
3536 }
3537 
3538 bool listHasCharCG(const char **list, char c) {
3539 
3540  return(listHasCharCS(list, c));
3541 }
3542 
3543 bool listHasCG(const char **list, const char *string) {
3544 
3545  return(listHasCS(list, string));
3546 }
3547 
3548 bool icListHasCG(const char **list, const char *string) {
3549 
3550  return(icListHasCS(list, string));
3551 }
3552 
3553 bool icListHasCharCG(const char **list, char c) {
3554 
3555  return(icListHasCharCS(list, c));
3556 }
3557 
3558 char *joinCG(const char **list, const char* delim) {
3559 
3560  return(joinCS(list, delim));
3561 }
3562 
3563 char *joinCharCG(const char **list, char delim) {
3564 
3565  charToS(s, delim);
3566  return(joinCS(list, s));
3567 }
3568 
3569 char **listAddCG(char **list1, const char **list2) {
3570 
3571  return(listAddCS(list1, list2));
3572 }
3573 
3574 int listPrintCG(const char **list) {
3575 
3576  return(listPrintCS(list));
3577 }
3578 
3579 bool eqCharChar(char c, char value) {
3580 
3581  return(c == value);;
3582 }
3583 
3584 bool equalChaOG(char c, baset* value) {
3585 
3586  charToS(s, c);
3587  return(equalCharOG(s, value));
3588 }
3589 
3590 bool equalChaBoolG(char c UNUSED, bool value UNUSED) {
3591 
3592  return(false);
3593 }
3594 
3595 bool equalChaDoubleG(char c, double value) {
3596 
3597  charToS(s, c);
3598  return(equalDoubleCharG(value, s));
3599 }
3600 
3601 bool equalChaInt64G(char c, int64_t value) {
3602 
3603  charToS(s, c);
3604  return(equalInt64CharG(value, s));
3605 }
3606 
3607 bool equalChaInt32G(char c, int32_t value) {
3608 
3609  charToS(s, c);
3610  return(equalInt32CharG(value, s));
3611 }
3612 
3613 bool equalChaUint32G(char c, uint32_t value) {
3614 
3615  charToS(s, c);
3616  return(equalUint32CharG(value, s));
3617 }
3618 
3619 bool equalChaUint64G(char c, uint64_t value) {
3620 
3621  charToS(s, c);
3622  return(equalUint64CharG(value, s));
3623 }
3624 
3626 
3627  if (!value || !value->B) {
3628  return(false);
3629  }
3630 
3631  charToS(s, c);
3632 
3633  return(equalSO(value, s));
3634 }
3635 
3637 
3638  charToS(s, c);
3639 
3640  if (!value) {
3641  return(false);
3642  }
3643  return(value->f->equalChar(value, s));
3644 }
3645 
3647 
3648  charToS(s, c);
3649 
3650  if (!value) {
3651  return(false);
3652  }
3653  return(value->f->equalChar(value, s));
3654 }
3655 
3657 
3658  if (!value) {
3659  return(false);
3660  }
3661 
3662  if (checkObjectTypes && !isOSmallJson(value)) {
3663  return(0);
3664  }
3665 
3666  const char *type = getTopTypeO(value);
3667 
3668  if (!eqS(type,"string")) {
3669  return(0);
3670  }
3671 
3672  charToS(s, c);
3673  return(eqS(getTopSO(value), s));
3674 }
3675 
3677 
3678  if (!value || !value->data) {
3679  return(false);
3680  }
3681 
3682  charToS(s, c);
3683  return(equalSO(value, s));
3684 }
3685 
3686 
3687 bool equalCharOG(const char *s, baset* value) {
3688 
3689  if (!s || !value) {
3690  return(false);
3691  }
3692 
3693  char *v = toStringO(value);
3694  bool r = strEq(s, v);
3695  free(v);
3696  return(r);
3697 }
3698 
3699 bool equalCharBoolG(const char *s, bool value) {
3700 
3701  return(equalBoolCharG(value, s));
3702 }
3703 
3704 bool equalCharDoubleG(const char *s, double value) {
3705 
3706  return(equalDoubleCharG(value, s));
3707 }
3708 
3709 bool equalCharInt64G(const char *s, int64_t value) {
3710 
3711  return(equalInt64CharG(value, s));
3712 }
3713 
3714 bool equalCharInt32G(const char *s, int32_t value) {
3715 
3716  return(equalInt32CharG(value, s));
3717 }
3718 
3719 bool equalCharUint32G(const char *s, uint32_t value) {
3720 
3721  return(equalUint32CharG(value, s));
3722 }
3723 
3724 bool equalCharUint64G(const char *s, uint64_t value) {
3725 
3726  return(equalUint64CharG(value, s));
3727 }
3728 
3729 bool equalCharSmallBoolG(const char *s, smallBoolt* value) {
3730 
3731  if (!value) {
3732  return(false);
3733  }
3734  return(value->f->equalChar(value, s));
3735 }
3736 
3738 
3739  if (!value) {
3740  return(false);
3741  }
3742  return(value->f->equalS(value, s));
3743 }
3744 
3746 
3747  if (!value) {
3748  return(false);
3749  }
3750  return(value->f->equalChar(value, s));
3751 }
3752 
3753 bool equalCharSmallIntG(const char *s, smallIntt* value) {
3754 
3755  if (!value) {
3756  return(false);
3757  }
3758  return(value->f->equalChar(value, s));
3759 }
3760 
3762 
3763  if (!value) {
3764  return(false);
3765  }
3766 
3767  if (checkObjectTypes && !isOSmallJson(value)) {
3768  return(false);
3769  }
3770 
3771  const char *type = getTopTypeO(value);
3772 
3773  if (!eqS(type,"string")) {
3774  return(false);
3775  }
3776 
3777  return(eqS(getTopSO(value), s));
3778 }
3779 
3781 
3782  if (!value) {
3783  return(false);
3784  }
3785  return(equalSO(value, s));
3786 }
3787 
3788 
3789 bool equalArrayOG(char ** p1, baset* p2) {
3790 
3791  if (!p1 || !p2) {
3792  return(false);
3793  }
3794 
3795  if (!isOType(p2, "smallArray")) {
3796  return(false);
3797  }
3798 
3799  cast(smallArrayt *, arr, p2);
3800 
3801  if (!listLengthS(p1) || !lenO(arr)) {
3802  return(false);
3803  }
3804 
3805  // compare elements
3806  // TODO compare any types of element, not only strings
3807  enumerateSArray(arr->a, e, i) {
3808  if (not e) {
3809  return(false);
3810  }
3811  if (!strEq(sStringGetTiny((sStringt*)e), p1[i])) {
3812  return(false);
3813  }
3814  }
3815 
3816  return(true);
3817 }
3818 
3819 bool equalCArrayOG(const char ** p1, baset* p2) {
3820 
3821  if (!p1 || !p2) {
3822  return(false);
3823  }
3824 
3825  if (!isOType(p2, "smallArray")) {
3826  return(false);
3827  }
3828 
3829  cast(smallArrayt *, arr, p2);
3830 
3831  if (!listLengthCS(p1) || !lenO(arr)) {
3832  return(false);
3833  }
3834 
3835  // compare elements
3836  // TODO compare any types of element, not only strings
3837  enumerateSArray(arr->a, e, i) {
3838  if (not e) {
3839  return(false);
3840  }
3841  if (!strEq(sStringGetTiny((sStringt*)e), p1[i])) {
3842  return(false);
3843  }
3844  }
3845 
3846  return(true);
3847 }
3848 
3849 bool equalArraySmallJsonG(char ** p1, smallJsont* p2) {
3850 
3851  if (!p1 || !p2) {
3852  return(false);
3853  }
3854 
3855  if (checkObjectTypes && !isOSmallJson(p2)) {
3856  return(false);
3857  }
3858 
3859  const char *type = getTopTypeO(p2);
3860 
3861  if (!eqS(type,"array")) {
3862  return(false);
3863  }
3864 
3865  return(p2->f->equalArray(p2, p1));
3866 }
3867 
3868 bool equalArraySmallArrayG(char ** p1, smallArrayt* p2) {
3869 
3870  if (!p2) {
3871  return(false);
3872  }
3873 
3874  if (checkObjectTypes && !isOSmallArray(p2)) {
3875  return(false);
3876  }
3877 
3878  return(p2->f->equalArray(p2, p1));
3879 }
3880 
3881 bool equalCArraySmallJsonG(const char ** p1, smallJsont* p2) {
3882 
3883  if (!p1 || !p2) {
3884  return(false);
3885  }
3886 
3887  if (checkObjectTypes && !isOSmallJson(p2)) {
3888  return(false);
3889  }
3890 
3891  const char *type = getTopTypeO(p2);
3892 
3893  if (!eqS(type,"array")) {
3894  return(false);
3895  }
3896 
3897  return(p2->f->equalCArray(p2, p1));
3898 }
3899 
3900 bool equalCArraySmallArrayG(const char ** p1, smallArrayt* p2) {
3901 
3902  if (!p2) {
3903  return(false);
3904  }
3905 
3906  if (checkObjectTypes && !isOSmallArray(p2)) {
3907  return(false);
3908  }
3909 
3910  return(p2->f->equalCArray(p2, p1));
3911 }
3912 
3913 bool equalOCharG(baset* p1, const char * p2) {
3914 
3915  return(equalCharOG(p2, p1));
3916 }
3917 
3918 bool equalOChaG(baset* p1, char p2) {
3919 
3920  return(equalChaOG(p2, p1));
3921 }
3922 
3923 bool equalOArrayG(baset* p1, char ** p2) {
3924 
3925  return(equalArrayOG(p2, p1));
3926 }
3927 
3928 bool equalOCArrayG(baset* p1, const char ** p2) {
3929 
3930  return(equalCArrayOG(p2, p1));
3931 }
3932 
3933 bool equalOOG(baset* p1, baset* p2) {
3934 
3935  if (!p1 || !p2) {
3936  return(false);
3937  }
3938 
3939  char *s = toStringO(p1);
3940  char *S = toStringO(p2);
3941  bool r;
3942  if (strEq(s, S)) {
3943  r = true;
3944  }
3945  else {
3946  r = false;
3947  }
3948  freeManyS(s, S);
3949  return(r);
3950 }
3951 
3952 bool equalOBoolG(baset* p1, bool p2) {
3953 
3954  return(equalBoolOG(p2, p1));
3955 }
3956 
3957 bool equalODoubleG(baset* p1, double p2) {
3958 
3959  return(equalDoubleBaseG(p2, p1));
3960 }
3961 
3962 bool equalOInt64G(baset* p1, int64_t p2) {
3963 
3964  return(equalInt64BaseG(p2, p1));
3965 }
3966 
3967 bool equalOInt32G(baset* p1, int32_t p2) {
3968 
3969  return(equalInt32BaseG(p2, p1));
3970 }
3971 
3972 bool equalOUint32G(baset* p1, uint32_t p2) {
3973 
3974  return(equalUint32BaseG(p2, p1));
3975 }
3976 
3977 bool equalOUint64G(baset* p1, uint64_t p2) {
3978 
3979  return(equalUint64BaseG(p2, p1));
3980 }
3981 
3983 
3984  if (!p2) {
3985  return(false);
3986  }
3987 
3988  if (checkObjectTypes && !isOSmallArray(p2)) {
3989  return(false);
3990  }
3991 
3992  return(p2->f->equalBase(p2, p1));
3993 }
3994 
3996 
3997  if (!p2) {
3998  return(false);
3999  }
4000 
4001  if (checkObjectTypes && !isOSmallBool(p2)) {
4002  return(false);
4003  }
4004 
4005  return(p2->f->equalBase(p2, p1));
4006 }
4007 
4009 
4010  if (!p2) {
4011  return(false);
4012  }
4013 
4014  if (checkObjectTypes && !isOSmallBytes(p2)) {
4015  return(false);
4016  }
4017 
4018  return(p2->f->equalBase(p2, p1));
4019 }
4020 
4022 
4023  if (!p2) {
4024  return(false);
4025  }
4026 
4027  if (checkObjectTypes && !isOSmallDouble(p2)) {
4028  return(false);
4029  }
4030 
4031  return(p2->f->equalBase(p2, p1));
4032 }
4033 
4035 
4036  if (!p2) {
4037  return(false);
4038  }
4039 
4040  if (checkObjectTypes && !isOSmallDict(p2)) {
4041  return(false);
4042  }
4043 
4044  return(p2->f->equalBase(p2, p1));
4045 }
4046 
4048 
4049  if (!p2) {
4050  return(false);
4051  }
4052 
4053  if (checkObjectTypes && !isOSmallInt(p2)) {
4054  return(false);
4055  }
4056 
4057  return(p2->f->equalBase(p2, p1));
4058 }
4059 
4061 
4062  if (!p2) {
4063  return(false);
4064  }
4065 
4066  if (checkObjectTypes && !isOSmallJson(p2)) {
4067  return(false);
4068  }
4069 
4070  return(p2->f->equalBase(p2, p1));
4071 }
4072 
4074 
4075  if (!p1 || !p2 || !p2->data) {
4076  return(false);
4077  }
4078 
4079  if (checkObjectTypes && !isOSmallString(p2)) {
4080  return(false);
4081  }
4082 
4083  char *s = toStringO(p1);
4084 
4085  bool r = equalSO(p2, s);
4086  free(s);
4087  return(r);
4088 }
4089 
4090 bool equalBoolChaG(bool p1 UNUSED, char p2 UNUSED) {
4091 
4092  return(false);
4093 }
4094 
4095 bool equalBoolCharG(bool p1, const char * p2) {
4096 
4097  if (!p2) {
4098  return(false);
4099  }
4100 
4101  if (strEq(p2, "true") || strEq(p2, "TRUE")) {
4102  return(p1);
4103  }
4104  else if (strEq(p2, "false") || strEq(p2, "FALSE")) {
4105  return(!p1);
4106  }
4107  return(false);
4108 }
4109 
4110 bool equalBoolOG(bool p1, baset* p2) {
4111 
4112  if (!p2) {
4113  return(false);
4114  }
4115 
4116  char *s = toStringO(p2);
4117 
4118  if (strEq(s, "true") || strEq(s, "TRUE")) {
4119  free(s);
4120  return(p1);
4121  }
4122  else if (strEq(s, "false") || strEq(s, "FALSE")) {
4123  free(s);
4124  return(!p1);
4125  }
4126  free(s);
4127  return(false);
4128 }
4129 
4130 bool equalBoolFG(bool p1, bool p2) {
4131 
4132  return(p1 == p2);;
4133 }
4134 
4135 bool equalBoolDoubleG(bool p1, double p2) {
4136 
4137  return(p1 == p2);;
4138 }
4139 
4140 bool equalBoolInt64G(bool p1, int64_t p2) {
4141 
4142  return(p1 == p2);;
4143 }
4144 
4145 bool equalBoolInt32G(bool p1, int32_t p2) {
4146 
4147  return(p1 == p2);;
4148 }
4149 
4150 bool equalBoolUint32G(bool p1, uint32_t p2) {
4151 
4152  return(p1 == p2);;
4153 }
4154 
4155 bool equalBoolUint64G(bool p1, uint64_t p2) {
4156 
4157  return(p1 == p2);;
4158 }
4159 
4160 bool equalBoolSmallBoolG(bool p1, smallBoolt* p2) {
4161 
4162  if (!p2 || !p2->value) {
4163  return(false);
4164  }
4165 
4166  return(p2->value->value == p1);;
4167 }
4168 
4169 bool equalBoolSmallBytesG(bool p1, smallBytest* p2) {
4170 
4171  if (!p2 || !p2->B) {
4172  return(false);
4173  }
4174 
4175  if (equalSO(p2, "true") || equalSO(p2, "TRUE")) {
4176  return(p1);
4177  }
4178  else if (equalSO(p2, "false") || equalSO(p2, "FALSE")) {
4179  return(!p1);
4180  }
4181  return(false);
4182 }
4183 
4185 
4186  if (!p2 || !p2->value) {
4187  return(false);
4188  }
4189 
4190  return(p2->value->value == p1);;
4191 }
4192 
4193 bool equalBoolSmallIntG(bool p1, smallIntt* p2) {
4194 
4195  if (!p2 || !p2->value) {
4196  return(false);
4197  }
4198 
4199  return(p2->value->value == p1);;
4200 }
4201 
4202 bool equalBoolSmallJsonG(bool p1, smallJsont* p2) {
4203 
4204  if (!p2) {
4205  return(false);
4206  }
4207 
4208  if (checkObjectTypes && !isOSmallJson(p2)) {
4209  return(false);
4210  }
4211 
4212  return(equalBoolO(p2, p1));
4213 }
4214 
4216 
4217  if (!p2 || !p2->data) {
4218  return(false);
4219  }
4220 
4221  char *s = sStringGetTiny(p2->data);
4222  if (strEq(s, "true") || strEq(s, "TRUE")) {
4223  return(p1);
4224  }
4225  else if (strEq(s, "false") || strEq(s, "FALSE")) {
4226  return(!p1);
4227  }
4228  return(false);
4229 }
4230 
4231 bool equalDoubleChaG(double p1, char p2) {
4232 
4233  return(equalChaDoubleG(p2, p1));
4234 }
4235 
4236 bool equalDoubleCharG(double p1, const char * p2) {
4237 
4238  if (!p2) {
4239  return(false);
4240  }
4241 
4242  if (isInt(p2) || !isNumber(p2)) {
4243  return(false);
4244  }
4245 
4246  double value = parseDouble(p2);
4247 
4248  return(p1 == value);;
4249 }
4250 
4251 bool equalDoubleBaseG(double p1, baset* p2) {
4252 
4253  if (!p2) {
4254  return(false);
4255  }
4256 
4257  char *s = toStringO(p2);
4258 
4259  if (isInt(s) || !isNumber(s)) {
4260  free(s);
4261  return(false);
4262  }
4263 
4264  double value = parseDouble(s);
4265 
4266  bool r;
4267  if (p1 == value) {
4268  r = true;
4269  }
4270  else {
4271  r = false;
4272  }
4273  free(s);
4274  return(r);
4275 }
4276 
4277 bool equalDoubleBoolG(double p1, bool p2) {
4278 
4279  return(p1 == p2);;
4280 }
4281 
4282 bool equalDoubleFG(double p1, double p2) {
4283 
4284  return(p1 == p2);;
4285 }
4286 
4287 bool equalDoubleInt64G(double p1, int64_t p2) {
4288 
4289  return(p1 == p2);;
4290 }
4291 
4292 bool equalDoubleInt32G(double p1, int32_t p2) {
4293 
4294  return(p1 == p2);;
4295 }
4296 
4297 bool equalDoubleUint32G(double p1, uint32_t p2) {
4298 
4299  return(p1 == p2);;
4300 }
4301 
4302 bool equalDoubleUint64G(double p1, uint64_t p2) {
4303 
4304  return(p1 == p2);;
4305 }
4306 
4307 bool equalDoubleSmallBoolG(double p1, smallBoolt* p2) {
4308 
4309  if (!p2 || !p2->value) {
4310  return(false);
4311  }
4312 
4313  return(p2->value->value == p1);;
4314 }
4315 
4316 bool equalDoubleSmallBytesG(double p1, smallBytest* p2) {
4317 
4318  if (!p2 || !p2->B) {
4319  return(false);
4320  }
4321 
4322  char *s = sBytesGet(p2->B);
4323 
4324  bool has0 = false;
4325  rangeDown(i, p2->B->count) {
4326  if (s[i] == 0) {
4327  has0 = true;
4328  break;
4329  }
4330  }
4331 
4332  if (!has0) {
4333  return(false);
4334  }
4335 
4336  if (isInt(s) || !isNumber(s)) {
4337  return(false);
4338  }
4339 
4340  double p2Value = parseDouble(s);
4341 
4342  return(p2Value == p1);;
4343 }
4344 
4346 
4347  if (!p2 || !p2->value) {
4348  return(false);
4349  }
4350 
4351  return(p2->value->value == p1);;
4352 }
4353 
4354 bool equalDoubleSmallIntG(double p1, smallIntt* p2) {
4355 
4356  if (!p2 || !p2->value) {
4357  return(false);
4358  }
4359 
4360  return(p2->value->value == p1);;
4361 }
4362 
4363 bool equalDoubleSmallJsonG(double p1, smallJsont* p2) {
4364 
4365  if (!p2) {
4366  return(false);
4367  }
4368 
4369  if (checkObjectTypes && !isOSmallJson(p2)) {
4370  return(false);
4371  }
4372 
4373  return(equalDoubleO(p2, p1));
4374 }
4375 
4377 
4378  if (!p2 || !p2->data) {
4379  return(false);
4380  }
4381 
4382  char *s = sStringGetTiny(p2->data);
4383 
4384  if (isInt(s) || !isNumber(s)) {
4385  return(false);
4386  }
4387 
4388  double p2Value = parseDoubleO(p2);
4389 
4390  return(p2Value == p1);;
4391 }
4392 
4393 bool equalInt64ChaG(int64_t p1, char p2) {
4394 
4395  return(equalChaInt64G(p2, p1));
4396 }
4397 
4398 bool equalInt64CharG(int64_t p1, const char * p2) {
4399 
4400  if (!p2) {
4401  return(false);
4402  }
4403 
4404  if (!isInt(p2)) {
4405  return(false);
4406  }
4407 
4408  int64_t value = parseInt(p2);
4409 
4410  return(p1 == value);;
4411 }
4412 
4413 bool equalInt64BaseG(int64_t p1, baset* p2) {
4414 
4415  if (!p2) {
4416  return(false);
4417  }
4418 
4419  char *s = toStringO(p2);
4420 
4421  if (!isInt(s)) {
4422  free(s);
4423  return(false);
4424  }
4425 
4426  int64_t value = parseInt(s);
4427 
4428  bool r;
4429  if (p1 == value) {
4430  r = true;
4431  }
4432  else {
4433  r = false;
4434  }
4435  free(s);
4436  return(r);
4437 }
4438 
4439 bool equalInt64BoolG(int64_t p1, bool p2) {
4440 
4441  return(p1 == p2);;
4442 }
4443 
4444 bool equalInt64DoubleG(int64_t p1, double p2) {
4445 
4446  return(p1 == p2);;
4447 }
4448 
4449 bool equalInt64FG(int64_t p1, int64_t p2) {
4450 
4451  return(p1 == p2);;
4452 }
4453 
4454 bool equalInt64Int32G(int64_t p1, int32_t p2) {
4455 
4456  return(p1 == p2);;
4457 }
4458 
4459 bool equalInt64Uint32G(int64_t p1, uint32_t p2) {
4460 
4461  return(p1 == p2);;
4462 }
4463 
4464 bool equalInt64Uint64G(int64_t p1, uint64_t p2) {
4465 
4466  return((uint64_t)p1 == p2);;
4467 }
4468 
4469 bool equalInt64SmallBoolG(int64_t p1, smallBoolt* p2) {
4470 
4471  if (!p2 || !p2->value) {
4472  return(false);
4473  }
4474 
4475  return(p2->value->value == p1);;
4476 }
4477 
4478 bool equalInt64SmallBytesG(int64_t p1, smallBytest* p2) {
4479 
4480  if (!p2 || !p2->B) {
4481  return(false);
4482  }
4483 
4484  char *s = sBytesGet(p2->B);
4485 
4486  bool has0 = false;
4487  rangeDown(i, p2->B->count) {
4488  if (s[i] == 0) {
4489  has0 = true;
4490  break;
4491  }
4492  }
4493 
4494  if (!has0) {
4495  return(false);
4496  }
4497 
4498  if (!isInt(s)) {
4499  return(false);
4500  }
4501 
4502  int64_t p2Value = parseInt(s);
4503 
4504  return(p2Value == p1);;
4505 }
4506 
4507 bool equalInt64SmallDoubleG(int64_t p1, smallDoublet* p2) {
4508 
4509  if (!p2 || !p2->value) {
4510  return(false);
4511  }
4512 
4513  return(p2->value->value == p1);;
4514 }
4515 
4516 bool equalInt64SmallIntG(int64_t p1, smallIntt* p2) {
4517 
4518  if (!p2 || !p2->value) {
4519  return(false);
4520  }
4521 
4522  return(p2->value->value == p1);;
4523 }
4524 
4525 bool equalInt64SmallJsonG(int64_t p1, smallJsont* p2) {
4526 
4527  if (!p2) {
4528  return(false);
4529  }
4530 
4531  if (checkObjectTypes && !isOSmallJson(p2)) {
4532  return(false);
4533  }
4534 
4535  return(equalInt64O(p2, p1));
4536 }
4537 
4538 bool equalInt64SmallStringG(int64_t p1, smallStringt* p2) {
4539 
4540  if (!p2 || !p2->data) {
4541  return(false);
4542  }
4543 
4544  char *s = sStringGetTiny(p2->data);
4545 
4546  if (!isInt(s)) {
4547  return(false);
4548  }
4549 
4550  int64_t p2Value = parseIntO(p2);
4551 
4552  return(p2Value == p1);;
4553 }
4554 
4555 bool equalInt32ChaG(int32_t p1, char p2) {
4556 
4557  return(equalChaInt32G(p2, p1));
4558 }
4559 
4560 bool equalInt32CharG(int32_t p1, const char * p2) {
4561 
4562  if (!p2) {
4563  return(false);
4564  }
4565 
4566  if (!isInt(p2)) {
4567  return(false);
4568  }
4569 
4570  int32_t value = (int32_t)parseInt(p2);
4571 
4572  return(p1 == value);;
4573 }
4574 
4575 bool equalInt32BaseG(int32_t p1, baset* p2) {
4576 
4577  if (!p2) {
4578  return(false);
4579  }
4580 
4581  char *s = toStringO(p2);
4582 
4583  if (!isInt(s)) {
4584  free(s);
4585  return(false);
4586  }
4587 
4588  int32_t value = (int32_t)parseInt(s);
4589 
4590  bool r;
4591  if (p1 == value) {
4592  r = true;
4593  }
4594  else {
4595  r = false;
4596  }
4597  free(s);
4598  return(r);
4599 }
4600 
4601 bool equalInt32BoolG(int32_t p1, bool p2) {
4602 
4603  return(p1 == p2);;
4604 }
4605 
4606 bool equalInt32DoubleG(int32_t p1, double p2) {
4607 
4608  return(p1 == p2);;
4609 }
4610 
4611 bool equalInt32Int64G(int32_t p1, int64_t p2) {
4612 
4613  return(p1 == p2);;
4614 }
4615 
4616 bool equalInt32FG(int32_t p1, int32_t p2) {
4617 
4618  return(p1 == p2);;
4619 }
4620 
4621 bool equalInt32Uint32G(int32_t p1, uint32_t p2) {
4622 
4623  return((uint32_t)p1 == p2);;
4624 }
4625 
4626 bool equalInt32Uint64G(int32_t p1, uint64_t p2) {
4627 
4628  return((uint64_t)p1 == p2);;
4629 }
4630 
4631 bool equalInt32SmallBoolG(int32_t p1, smallBoolt* p2) {
4632 
4633  if (!p2 || !p2->value) {
4634  return(false);
4635  }
4636 
4637  return(p2->value->value == p1);;
4638 }
4639 
4640 bool equalInt32SmallBytesG(int32_t p1, smallBytest* p2) {
4641 
4642  if (!p2 || !p2->B) {
4643  return(false);
4644  }
4645 
4646  char *s = sBytesGet(p2->B);
4647 
4648  bool has0 = false;
4649  rangeDown(i, p2->B->count) {
4650  if (s[i] == 0) {
4651  has0 = true;
4652  break;
4653  }
4654  }
4655 
4656  if (!has0) {
4657  return(false);
4658  }
4659 
4660  if (!isInt(s)) {
4661  return(false);
4662  }
4663 
4664  int32_t p2Value = (int32_t)parseInt(s);
4665 
4666  return(p2Value == p1);;
4667 }
4668 
4669 bool equalInt32SmallDoubleG(int32_t p1, smallDoublet* p2) {
4670 
4671  if (!p2 || !p2->value) {
4672  return(false);
4673  }
4674 
4675  return(p2->value->value == p1);;
4676 }
4677 
4678 bool equalInt32SmallIntG(int32_t p1, smallIntt* p2) {
4679 
4680  if (!p2 || !p2->value) {
4681  return(false);
4682  }
4683 
4684  return(p2->value->value == p1);;
4685 }
4686 
4687 bool equalInt32SmallJsonG(int32_t p1, smallJsont* p2) {
4688 
4689  if (!p2) {
4690  return(false);
4691  }
4692 
4693  if (checkObjectTypes && !isOSmallJson(p2)) {
4694  return(false);
4695  }
4696 
4697  return(equalInt32O(p2, p1));
4698 }
4699 
4700 bool equalInt32SmallStringG(int32_t p1, smallStringt* p2) {
4701 
4702  if (!p2 || !p2->data) {
4703  return(false);
4704  }
4705 
4706  char *s = sStringGetTiny(p2->data);
4707 
4708  if (!isInt(s)) {
4709  return(false);
4710  }
4711 
4712  int32_t p2Value = (int32_t)parseIntO(p2);
4713 
4714  return(p2Value == p1);;
4715 }
4716 
4717 bool equalUint32ChaG(uint32_t p1, char p2) {
4718 
4719  return(equalChaUint32G(p2, p1));
4720 }
4721 
4722 bool equalUint32CharG(uint32_t p1, const char * p2) {
4723 
4724  if (!p2) {
4725  return(false);
4726  }
4727 
4728  if (!isInt(p2)) {
4729  return(false);
4730  }
4731 
4732  uint32_t value = (uint32_t)parseInt(p2);
4733 
4734  return(p1 == value);;
4735 }
4736 
4737 bool equalUint32BaseG(uint32_t p1, baset* p2) {
4738 
4739  if (!p2) {
4740  return(false);
4741  }
4742 
4743  char *s = toStringO(p2);
4744 
4745  if (!isInt(s)) {
4746  free(s);
4747  return(false);
4748  }
4749 
4750  uint32_t value = (uint32_t)parseInt(s);
4751 
4752  bool r;
4753  if (p1 == value) {
4754  r = true;
4755  }
4756  else {
4757  r = false;
4758  }
4759  free(s);
4760  return(r);
4761 }
4762 
4763 bool equalUint32BoolG(uint32_t p1, bool p2) {
4764 
4765  return(p1 == p2);;
4766 }
4767 
4768 bool equalUint32DoubleG(uint32_t p1, double p2) {
4769 
4770  return(p1 == p2);;
4771 }
4772 
4773 bool equalUint32Int64G(uint32_t p1, int64_t p2) {
4774 
4775  return(p1 == p2);;
4776 }
4777 
4778 bool equalUint32Int32G(uint32_t p1, int32_t p2) {
4779 
4780  return(p1 == (uint32_t)p2);;
4781 }
4782 
4783 bool equalUint32FG(uint32_t p1, uint32_t p2) {
4784 
4785  return(p1 == p2);;
4786 }
4787 
4788 bool equalUint32Uint64G(uint32_t p1, uint64_t p2) {
4789 
4790  return(p1 == p2);;
4791 }
4792 
4793 bool equalUint32SmallBoolG(uint32_t p1, smallBoolt* p2) {
4794 
4795  if (!p2 || !p2->value) {
4796  return(false);
4797  }
4798 
4799  return(p2->value->value == p1);;
4800 }
4801 
4802 bool equalUint32SmallBytesG(uint32_t p1, smallBytest* p2) {
4803 
4804  if (!p2 || !p2->B) {
4805  return(false);
4806  }
4807 
4808  char *s = sBytesGet(p2->B);
4809 
4810  bool has0 = false;
4811  rangeDown(i, p2->B->count) {
4812  if (s[i] == 0) {
4813  has0 = true;
4814  break;
4815  }
4816  }
4817 
4818  if (!has0) {
4819  return(false);
4820  }
4821 
4822  if (!isInt(s)) {
4823  return(false);
4824  }
4825 
4826  uint32_t p2Value = (uint32_t)parseInt(s);
4827 
4828  return(p2Value == p1);;
4829 }
4830 
4831 bool equalUint32SmallDoubleG(uint32_t p1, smallDoublet* p2) {
4832 
4833  if (!p2 || !p2->value) {
4834  return(false);
4835  }
4836 
4837  return(p2->value->value == p1);;
4838 }
4839 
4840 bool equalUint32SmallIntG(uint32_t p1, smallIntt* p2) {
4841 
4842  if (!p2 || !p2->value) {
4843  return(false);
4844  }
4845 
4846  return(p2->value->value == p1);;
4847 }
4848 
4849 bool equalUint32SmallJsonG(uint32_t p1, smallJsont* p2) {
4850 
4851  if (!p2) {
4852  return(false);
4853  }
4854 
4855  if (checkObjectTypes && !isOSmallJson(p2)) {
4856  return(false);
4857  }
4858 
4859  return(equalUint32O(p2, p1));
4860 }
4861 
4862 bool equalUint32SmallStringG(uint32_t p1, smallStringt* p2) {
4863 
4864  if (!p2 || !p2->data) {
4865  return(false);
4866  }
4867 
4868  char *s = sStringGetTiny(p2->data);
4869 
4870  if (!isInt(s)) {
4871  return(false);
4872  }
4873 
4874  uint32_t p2Value = (uint32_t)parseIntO(p2);
4875 
4876  return(p2Value == p1);;
4877 }
4878 
4879 bool equalUint64ChaG(uint64_t p1, char p2) {
4880 
4881  return(equalChaUint64G(p2, p1));
4882 }
4883 
4884 bool equalUint64CharG(uint64_t p1, const char * p2) {
4885 
4886  if (!p2) {
4887  return(false);
4888  }
4889 
4890  if (!isInt(p2)) {
4891  return(false);
4892  }
4893 
4894  uint64_t value = (uint64_t)parseInt(p2);
4895 
4896  return(p1 == value);;
4897 }
4898 
4899 bool equalUint64BaseG(uint64_t p1, baset* p2) {
4900 
4901  if (!p2) {
4902  return(false);
4903  }
4904 
4905  char *s = toStringO(p2);
4906 
4907  if (!isInt(s)) {
4908  free(s);
4909  return(false);
4910  }
4911 
4912  uint64_t value = (uint64_t)parseInt(s);
4913 
4914  bool r;
4915  if (p1 == value) {
4916  r = true;
4917  }
4918  else {
4919  r = false;
4920  }
4921  free(s);
4922  return(r);
4923 }
4924 
4925 bool equalUint64BoolG(uint64_t p1, bool p2) {
4926 
4927  return(p1 == p2);;
4928 }
4929 
4930 bool equalUint64DoubleG(uint64_t p1, double p2) {
4931 
4932  return(p1 == p2);;
4933 }
4934 
4935 bool equalUint64Int64G(uint64_t p1, int64_t p2) {
4936 
4937  return(p1 == (uint64_t)p2);;
4938 }
4939 
4940 bool equalUint64Int32G(uint64_t p1, int32_t p2) {
4941 
4942  return(p1 == (uint64_t)p2);;
4943 }
4944 
4945 bool equalUint64Uint32G(uint64_t p1, uint32_t p2) {
4946 
4947  return(p1 == p2);;
4948 }
4949 
4950 bool equalUint64FG(uint64_t p1, uint64_t p2) {
4951 
4952  return(p1 == p2);;
4953 }
4954 
4955 bool equalUint64SmallBoolG(uint64_t p1, smallBoolt* p2) {
4956 
4957  if (!p2 || !p2->value) {
4958  return(false);
4959  }
4960 
4961  return(p2->value->value == p1);;
4962 }
4963 
4964 bool equalUint64SmallBytesG(uint64_t p1, smallBytest* p2) {
4965 
4966  if (!p2 || !p2->B) {
4967  return(false);
4968  }
4969 
4970  char *s = sBytesGet(p2->B);
4971 
4972  bool has0 = false;
4973  rangeDown(i, p2->B->count) {
4974  if (s[i] == 0) {
4975  has0 = true;
4976  break;
4977  }
4978  }
4979 
4980  if (!has0) {
4981  return(false);
4982  }
4983 
4984  if (!isInt(s)) {
4985  return(false);
4986  }
4987 
4988  uint64_t p2Value = (uint64_t)parseInt(s);
4989 
4990  return(p2Value == p1);;
4991 }
4992 
4993 bool equalUint64SmallDoubleG(uint64_t p1, smallDoublet* p2) {
4994 
4995  if (!p2 || !p2->value) {
4996  return(false);
4997  }
4998 
4999  return(p2->value->value == p1);;
5000 }
5001 
5002 bool equalUint64SmallIntG(uint64_t p1, smallIntt* p2) {
5003 
5004  if (!p2 || !p2->value) {
5005  return(false);
5006  }
5007 
5008  return((uint64_t)p2->value->value == p1);;
5009 }
5010 
5011 bool equalUint64SmallJsonG(uint64_t p1, smallJsont* p2) {
5012 
5013  if (!p2) {
5014  return(false);
5015  }
5016 
5017  if (checkObjectTypes && !isOSmallJson(p2)) {
5018  return(false);
5019  }
5020 
5021  return(equalUint64O(p2, p1));
5022 }
5023 
5024 bool equalUint64SmallStringG(uint64_t p1, smallStringt* p2) {
5025 
5026  if (!p2 || !p2->data) {
5027  return(false);
5028  }
5029 
5030  char *s = sStringGetTiny(p2->data);
5031 
5032  if (!isInt(s)) {
5033  return(false);
5034  }
5035 
5036  uint64_t p2Value = (uint64_t)parseIntO(p2);
5037 
5038  return(p2Value == p1);;
5039 }
5040 
5041 bool notEqualCharG(char c UNUSED, void *value UNUSED) {
5042 
5043  return(false);
5044 }
5045 
5046 bool notEqualOCharG(void *a UNUSED, char c UNUSED) {
5047 
5048  return(false);
5049 }
5050 
5051 bool notEqualOG(void *a UNUSED, void *b UNUSED) {
5052 
5053  return(false);
5054 }
5055 
5056 bool notEqualCCOG(const char *a UNUSED, void *b UNUSED) {
5057 
5058  return(false);
5059 }
5060 
5061 bool notEqualBoolOG(bool p1 UNUSED, void *p2 UNUSED) {
5062 
5063  return(false);
5064 }
5065 
5066 bool notEqualDoubleOG(double p1 UNUSED, void *p2 UNUSED) {
5067 
5068  return(false);
5069 }
5070 
5071 bool notEqualInt64OG(int64_t p1 UNUSED, void *p2 UNUSED) {
5072 
5073  return(false);
5074 }
5075 
5076 bool notEqualInt32OG(int32_t p1 UNUSED, void *p2 UNUSED) {
5077 
5078  return(false);
5079 }
5080 
5081 bool notEqualUint32OG(uint32_t p1 UNUSED, void *p2 UNUSED) {
5082 
5083  return(false);
5084 }
5085 
5086 bool notEqualUint64OG(uint64_t p1 UNUSED, void *p2 UNUSED) {
5087 
5088  return(false);
5089 }
5090 
5091 bool notEqualOBoolG(void *p1 UNUSED, bool p2 UNUSED) {
5092 
5093  return(false);
5094 }
5095 
5096 bool notEqualDoubleG(void *p1 UNUSED, double p2 UNUSED) {
5097 
5098  return(false);
5099 }
5100 
5101 bool notEqualOInt64G(void *p1 UNUSED, int64_t p2 UNUSED) {
5102 
5103  return(false);
5104 }
5105 
5106 bool notEqualOInt32G(void *p1 UNUSED, int32_t p2 UNUSED) {
5107 
5108  return(false);
5109 }
5110 
5111 bool notEqualOUint32G(void *p1 UNUSED, uint32_t p2 UNUSED) {
5112 
5113  return(false);
5114 }
5115 
5116 bool notEqualOUint64G(void *p1 UNUSED, uint64_t p2 UNUSED) {
5117 
5118  return(false);
5119 }
5120 
5121 
5122 bool icEqCharChar(char c, char value) {
5123 
5124  return(tolower(c) == tolower(value));;
5125 }
5126 
5127 bool icEqualChaOG(char c, baset* value) {
5128 
5129  charToS(s, c);
5130  return(icEqualCharOG(s, value));
5131 }
5132 
5134 
5135  // sanity checks
5136  if (!value) {
5137  return(false);
5138  }
5139 
5140  if (checkObjectTypes && !isOSmallJson(value)) {
5141  return(false);
5142  }
5143 
5144  return(value->f->icEqualChar(value, c));
5145 }
5146 
5148 
5149  if (!value) {
5150  return(false);
5151  }
5152  charToS(s, c);
5153  return(icEqualSO(value, s));
5154 }
5155 
5156 
5157 bool icEqualCharOG(const char *s, baset* value) {
5158 
5159  if (!s || !value) {
5160  return(false);
5161  }
5162 
5163  char *v = toStringO(value);
5164  bool r = icEqS(s, v);
5165  free(v);
5166  return(r);
5167 }
5168 
5170 
5171  // sanity checks
5172  if (!value) {
5173  return(false);
5174  }
5175 
5176  if (checkObjectTypes && !isOSmallJson(value)) {
5177  return(false);
5178  }
5179 
5180  return(value->f->icEqualS(value, s));
5181 }
5182 
5184 
5185  if (!value) {
5186  return(false);
5187  }
5188  return(icEqualSO(value, s));
5189 }
5190 
5191 
5192 bool icEqualArrayOG(char ** p1, baset* p2) {
5193 
5194  if (!p1 || !p2) {
5195  return(false);
5196  }
5197 
5198  if (!isOType(p2, "smallArray")) {
5199  return(false);
5200  }
5201 
5202  cast(smallArrayt *, arr, p2);
5203 
5204  if (!listLengthS(p1) || !lenO(arr)) {
5205  return(false);
5206  }
5207 
5208  // compare elements
5209  // TODO compare any types of element, not only strings
5210  enumerateSArray(arr->a, e, i) {
5211  if (not e) {
5212  return(false);
5213  }
5214  if (!icEqS(sStringGetTiny((sStringt*)e), p1[i])) {
5215  return(false);
5216  }
5217  }
5218 
5219  return(true);
5220 }
5221 
5222 bool icEqualCArrayOG(const char ** p1, baset* p2) {
5223 
5224  if (!p1 || !p2) {
5225  return(false);
5226  }
5227 
5228  if (!isOType(p2, "smallArray")) {
5229  return(false);
5230  }
5231 
5232  cast(smallArrayt *, arr, p2);
5233 
5234  if (!listLengthCS(p1) || !lenO(arr)) {
5235  return(false);
5236  }
5237 
5238  // compare elements
5239  // TODO compare any types of element, not only strings
5240  enumerateSArray(arr->a, e, i) {
5241  if (not e) {
5242  return(false);
5243  }
5244  if (!icEqS(sStringGetTiny((sStringt*)e), p1[i])) {
5245  return(false);
5246  }
5247  }
5248 
5249  return(true);
5250 }
5251 
5252 bool icEqualArraySmallJsonG(char ** p1, smallJsont* p2) {
5253 
5254  // sanity checks
5255  if (!p2) {
5256  return(false);
5257  }
5258 
5259  if (checkObjectTypes && !isOSmallJson(p2)) {
5260  return(false);
5261  }
5262 
5263  const char *type = getTopTypeO(p2);
5264 
5265  if (!eqS(type,"array")) {
5266  return(false);
5267  }
5268 
5269  return(p2->f->icEqualArray(p2, p1));
5270 }
5271 
5272 bool icEqualCArraySmallJsonG(const char ** p1, smallJsont* p2) {
5273 
5274  // sanity checks
5275  if (!p2) {
5276  return(false);
5277  }
5278 
5279  if (checkObjectTypes && !isOSmallJson(p2)) {
5280  return(false);
5281  }
5282 
5283  const char *type = getTopTypeO(p2);
5284 
5285  if (!eqS(type,"array")) {
5286  return(false);
5287  }
5288 
5289  return(p2->f->icEqualCArray(p2, p1));
5290 }
5291 
5292 bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2) {
5293 
5294  if (!p2) {
5295  return(false);
5296  }
5297 
5298  if (checkObjectTypes && !isOSmallArray(p2)) {
5299  return(false);
5300  }
5301 
5302  return(p2->f->icEqualArray(p2, p1));
5303 }
5304 
5305 bool icEqualCArraySmallArrayG(const char ** p1, smallArrayt* p2) {
5306 
5307  if (!p2) {
5308  return(false);
5309  }
5310 
5311  if (checkObjectTypes && !isOSmallArray(p2)) {
5312  return(false);
5313  }
5314 
5315  return(p2->f->icEqualCArray(p2, p1));
5316 }
5317 
5318 bool icEqualOCharG(baset* p1, const char * p2) {
5319 
5320  return(icEqualCharOG(p2, p1));
5321 }
5322 
5323 bool icEqualOChaG(baset* p1, char p2) {
5324 
5325  return(icEqualChaOG(p2, p1));
5326 }
5327 
5328 bool icEqualOArrayG(baset* p1, char ** p2) {
5329 
5330  return(icEqualArrayOG(p2, p1));
5331 }
5332 
5333 bool icEqualOCArrayG(baset* p1, const char ** p2) {
5334 
5335  return(icEqualCArrayOG(p2, p1));
5336 }
5337 
5338 bool icEqualOOG(baset* p1, baset* p2) {
5339 
5340  if (!p1 || !p2) {
5341  return(false);
5342  }
5343 
5344  char *s = toStringO(p1);
5345  char *S = toStringO(p2);
5346  bool r;
5347  if (icEqS(s, S)) {
5348  r = true;
5349  }
5350  else {
5351  r = false;
5352  }
5353  freeManyS(s, S);
5354  return(r);
5355 }
5356 
5358 
5359  if (!p2) {
5360  return(false);
5361  }
5362 
5363  if (checkObjectTypes && !isOSmallArray(p2)) {
5364  return(false);
5365  }
5366 
5367  return(p2->f->icEqualBase(p2, p1));
5368 }
5369 
5371 
5372  if (!p2) {
5373  return(false);
5374  }
5375 
5376  if (checkObjectTypes && !isOSmallDict(p2)) {
5377  return(false);
5378  }
5379 
5380  return(p2->f->icEqualBase(p2, p1));
5381 }
5382 
5384 
5385  // sanity checks
5386  if (!p2) {
5387  return(false);
5388  }
5389 
5390  if (checkObjectTypes && !isOSmallJson(p2)) {
5391  return(false);
5392  }
5393 
5394  return(p2->f->icEqualBase(p2, p1));
5395 }
5396 
5398 
5399  if (!p1 || !p2 || !p2->data) {
5400  return(false);
5401  }
5402 
5403  if (checkObjectTypes && !isOSmallString(p2)) {
5404  return(false);
5405  }
5406 
5407  char *s = toStringO(p1);
5408 
5409  bool r = icEqualSO(p2, s);
5410  free(s);
5411  return(r);
5412 }
5413 
5414 
5415 
5416 // TODO format function, print objects, stderr print
5417 
5418 void freeBasetInContainer(void *baseo) {
5419 
5420  // Terminate baset object
5421  cast(baset*,o,baseo);
5422  terminateO(o);
5423 }
5424 
5425 
5427  smallt *r = NULL;
5428 
5429  if (!obj) {
5430  return(NULL);
5431  }
5432 
5433  if (isOType(obj, "undefined")) {
5434  r = (smallt *)allocSUndefined();
5435  }
5436  else if (isOType(obj, "smallArray")) {
5437  if (!((smallArrayt *)obj)->a) {
5438  ((smallArrayt *)obj)->a = allocSArray();
5439  }
5440  r = (smallt *)((smallArrayt *)obj)->a;
5441  }
5442  else if (isOType(obj, "smallDict")) {
5443  if (!((smallDictt *)obj)->d) {
5444  ((smallDictt *)obj)->d = allocSDict();
5445  }
5446  r = (smallt *)((smallDictt *)obj)->d;
5447  }
5448  else if (isOType(obj, "smallBool")) {
5449  if (!((smallBoolt *)obj)->value) {
5450  ((smallBoolt *)obj)->value = allocSBool(false);
5451  }
5452  r = (smallt *)((smallBoolt *)obj)->value;
5453  }
5454  else if (isOType(obj, "smallBytes")) {
5455  if (!((smallBytest *)obj)->B) {
5456  ((smallBytest *)obj)->B = allocSBytes();
5457  }
5458  r = (smallt *)((smallBytest *)obj)->B;
5459  }
5460  else if (isOType(obj, "smallContainer")) {
5461  if (!((smallContainert *)obj)->data) {
5462  ((smallContainert *)obj)->data = allocSContainer(NULL);
5463  }
5464  r = (smallt *)((smallContainert *)obj)->data;
5465  }
5466  else if (isOType(obj, "smallDouble")) {
5467  if (!((smallDoublet *)obj)->value) {
5468  ((smallDoublet *)obj)->value = allocSDouble(0);
5469  }
5470  r = (smallt *)((smallDoublet *)obj)->value;
5471  }
5472  else if (isOType(obj, "smallInt")) {
5473  if (!((smallIntt *)obj)->value) {
5474  ((smallIntt *)obj)->value = allocSInt(0);
5475  }
5476  r = (smallt *)((smallIntt *)obj)->value;
5477  }
5478  else if (isOType(obj, "smallString")) {
5479  if (!((smallStringt *)obj)->data) {
5480  ((smallStringt *)obj)->data = allocSStringTiny("");
5481  }
5482  r = (smallt *)((smallStringt *)obj)->data;
5483  }
5484  else {
5485  // store other baset object in sContainers
5486  sContainert *c = allocSContainer(obj);
5487  if (!c) {
5488  return(NULL);
5489  }
5490  c->dataType = SH_DT_BASET;
5492  r = (smallt *) c;
5493  }
5494 
5495  return(r);
5496 }
5497 
5498 
5500  undefinedt *u = NULL;
5501  smallBoolt *b = NULL;
5502  smallBytest *B = NULL;
5503  smallContainert *c = NULL;
5504  smallDictt *d = NULL;
5505  smallDoublet *D = NULL;
5506  smallIntt *i = NULL;
5507  smallStringt *s = NULL;
5508  smallArrayt *a = NULL;
5509  baset *r = NULL;
5510 
5511  if (!obj) {
5512  return(NULL);
5513  }
5514 
5515  switch(obj->type) {
5516  case UNDEFINED:
5518  r = (baset *)u;
5519  break;
5520  case BOOL:
5522  if (!b) {
5523  return(NULL);
5524  }
5525  b->value = (sBoolt *)obj;
5526  r = (baset *)b;
5527  break;
5528  case BYTES:
5530  if (!B) {
5531  return(NULL);
5532  }
5533  B->B = (sBytest *)obj;
5534  r = (baset *)B;
5535  break;
5536  case CONTAINER:
5537  ;cast(sContainert*, sc, obj);
5538  if (sc->dataType == SH_DT_BASET) {
5539  r = (baset *)sc->data;
5540  }
5541  else {
5543  if (!c) {
5544  return(NULL);
5545  }
5546  c->data = (sContainert *)obj;
5547  r = (baset *)c;
5548  }
5549  break;
5550  case DICT:
5552  if (!d) {
5553  return(NULL);
5554  }
5555  d->d = (sDictt *)obj;
5556  r = (baset *)d;
5557  break;
5558  case DOUBLE:
5560  if (!D) {
5561  return(NULL);
5562  }
5563  D->value = (sDoublet *)obj;
5564  r = (baset *)D;
5565  break;
5566  case INT:
5568  if (!i) {
5569  return(NULL);
5570  }
5571  i->value = (sIntt *)obj;
5572  r = (baset *)i;
5573  break;
5574  case STRING:
5576  if (!s) {
5577  return(NULL);
5578  }
5579  s->data = (sStringt *)obj;
5580  s->_len = strlen((char*)obj)-1;
5581  r = (baset *)s;
5582  break;
5583  case ARRAY:
5585  if (!a) {
5586  return(NULL);
5587  }
5588  a->a = (sArrayt *)obj;
5589  r = (baset *)a;
5590  break;
5591  default:;
5592  // return NULL
5593  }
5594  return(r);
5595 }
5596 
5597 int cpuCount(void) {
5598 
5599  return((int)sysconf(_SC_NPROCESSORS_ONLN));
5600 }
5601 
5602 dArrayT(finalizeRecycleContainersFuncst, recycleContainersFt);
5603 
5604 internal finalizeRecycleContainersFuncst finalizeRecycleContainersFuncs;
5605 
5607 
5608  dArrayAppend(&finalizeRecycleContainersFuncs, f);
5609  return(1);
5610 }
5611 
5613 
5614  // call finalizeRecycleSmall*
5615  range(i, dArrayCount(&finalizeRecycleContainersFuncs)) {
5616  dArrayAt(&finalizeRecycleContainersFuncs, i)(NULL);
5617  }
5618 }
5619 
5621 
5622  tpoolKill;
5623 
5624  dArrayFree(&finalizeRecycleContainersFuncs);
5625 
5634  finalizeSmallInt();
5636 }
5637 
5638 #if (__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__)
5639 void initLibsheepyObject(void) {
5640 
5641  dArrayInit(&finalizeRecycleContainersFuncs);
5652 
5653  int numberOfOnlineProcs = (int)sysconf(_SC_NPROCESSORS_ONLN);
5654  tpool = tpool_init(numberOfOnlineProcs);
5655 
5656  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
5657  range(i, tpoolLockCount) {
5658  tpoolLocks[i] = mutex;
5659  }
5660 
5661  // register %m type specifiers in printf for baset objects
5662  // not available in macos - register_printf_specifier('m', print_m, print_m_arginfo);
5663 
5664  // call finalizeLibsheepy when the program finishes
5666 }
5667 
5668 #else // #if (__APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__)
5670 
5671  dArrayInit(&finalizeRecycleContainersFuncs);
5682 
5683  int numberOfOnlineProcs = (int)sysconf(_SC_NPROCESSORS_ONLN);
5684  tpool = tpool_init(numberOfOnlineProcs);
5685 
5686  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
5687  range(i, tpoolLockCount) {
5688  tpoolLocks[i] = mutex;
5689  }
5690 
5691  // register %m type specifiers in printf for baset objects
5692  register_printf_specifier('m', print_m, print_m_arginfo); {
5693 
5694  // call finalizeLibsheepy when the program finishes
5696 }
5697  }
5698 
5699 #endif
5700 // #if __APPLE__ || __FreeBSD__ || __TERMUX__ || __OpenBSD__ || __DragonFly__ || MUSL_LIBC || __sun__ || __HAIKU__
5701 
5707 
5712 baset* rtBaset = NULL;
5714 bool rtBool = false;
5715 bool* rtBoolP = NULL;
5716 double rtDouble = 0;
5717 double* rtDoubleP = NULL;
5718 int64_t rtInt64_t = 0;
5719 int64_t* rtInt64_tP = NULL;
5720 int32_t rtInt32_t = 0;
5721 int32_t* rtInt32_tP = NULL;
5722 uint64_t rtUint64_t = 0;
5723 uint64_t* rtUint64_tP = NULL;
5724 uint32_t rtUint32_t = 0;
5725 uint32_t* rtUint32_tP = NULL;
5726 float rtF32 = 0;
5727 double rtF64 = 0;
5728 double* rtF64P = NULL;
5729 int64_t rtI64 = 0;
5730 int64_t* rtI64P = NULL;
5731 int32_t rtI32 = 0;
5732 int32_t* rtI32P = NULL;
5733 uint64_t rtU64 = 0;
5734 uint64_t* rtU64P = NULL;
5735 uint32_t rtU32 = 0;
5736 uint32_t* rtU32P = NULL;
5737 uint16_t rtU16 = 0;
5738 uint8_t rtU8 = 0;
5739 char* rtChar = NULL;
5748 void* rtVoid = NULL;
bool icEqualCharPSmallStringG(const char *s, smallStringt *value)
smallStringt * randomSO(uint64_t length)
char ** listAddCG(char **list1, const char **list2)
char * toStringSmallDoubleGF(smallDoublet *object)
void listFreeS(char **list)
list Free String
Definition: libsheepy.c:50780
bool equalUint64Int64G(uint64_t p1, int64_t p2)
void finalizeRecycleUndefined(void *arg UNUSED)
char ** listFromArrayG(char **retType UNUSED, char **array, size_t size)
call listFromArrayS for fromArrayG
bool icEqualOSmallDictG(baset *p1, smallDictt *p2)
char ** iListUniqS(char ***list)
Uniquify elements of list each elements are unique in the list.
Definition: libsheepy.c:54942
char * s
#define charToS(dst, c)
Definition: libsheepy.h:1862
bool equalInt32SmallBoolG(int32_t p1, smallBoolt *p2)
bool equalArrayOG(char **p1, baset *p2)
bool equalUint64SmallDoubleG(uint64_t p1, smallDoublet *p2)
bool equalModificationTimes(const char *path1, const char *path2)
compare modification times for path1 and path2
Definition: libsheepy.c:1979
void putsInt32GF(int32_t object)
bool equalOBoolG(baset *p1, bool p2)
void finalizeSmallBytes(void)
int listPrintCS(const char **list)
Definition: libsheepy.c:53852
size_t len
smallStringt * getProgPathO(void)
bool equalDoubleSmallDoubleG(double p1, smallDoublet *p2)
smallt * toSmallt(baset *obj)
convert baset object to smallt
bool equalInt64SmallDoubleG(int64_t p1, smallDoublet *p2)
char * timeToS(const time_t t)
time To String convert unix time to string (ctime is not used here because it adds at the end of th...
Definition: libsheepy.c:2048
obj f free & obj
bool eqS(const char *string1, const char *string2)
string Equal compare string1 to string2
Definition: libsheepy.c:9067
bool equalCArraySmallJsonG(const char **p1, smallJsont *p2)
bool equalInt32FG(int32_t p1, int32_t p2)
int renameOSmallJson(smallStringt *src, smallJsont *dst)
bool notEqualDoubleG(void *p1 UNUSED, double p2 UNUSED)
void * readFileToNewG(void *none UNUSED, const char *filePath)
call readFileToS (for readFileG)
bool writeCStream(FILE *fp, const char **list)
write const list to stream
Definition: libsheepy.c:54328
bool isBlankS(const char *string)
is Blank String
Definition: libsheepy.c:50246
smallJsont * readSmallJsonO(void)
read String read user input (one line) as a string
#define dArrayFree
free the internal buffers
Definition: libsheepy.h:7062
ssize_t icListIndexOfCS(const char **list, const char *string)
ignore case and return index of string in const list
Definition: libsheepy.c:55200
void cleanUpBaseSmashG(baset **val)
#define getTopSO(self)
char * toStringBoolGF(bool object)
char * toStringUndefinedGF(undefinedt *object)
void putsArrayGF(smallArrayt *object)
void putsListCSGF(const char **object)
bool equalInt32Uint32G(int32_t p1, uint32_t p2)
bool equalInt64Uint32G(int64_t p1, uint32_t p2)
bool equalInt64FG(int64_t p1, int64_t p2)
int rmAllO(smallStringt *path)
threadpool tpool
Definition: tpool.c:47
bool equalBoolUint64G(bool p1, uint64_t p2)
bool equalUint32SmallIntG(uint32_t p1, smallIntt *p2)
char * toStringSmallContainerGF(smallContainert *object)
bool equalCharSmallBoolG(const char *s, smallBoolt *value)
smallDictt * shSysinfo(void)
sheepy sysinfo
bool isLink(const char *path)
is symbolic link
Definition: libsheepy.c:4293
smallArrayt * walkDirDirO(const char *dirPath)
list all directories in a directory recursively and sort the list
int32_t rtInt32_t
char * toStringSmallBoolGF(smallBoolt *object)
#define equalBoolO(self, p2)
free(s)
bool equalOUint64G(baset *p1, uint64_t p2)
void finalizeSmallArray(void)
sStringt * allocSStringTiny(const char *data)
allocate a small string
void finalizeRecycleSmallInt(void *arg UNUSED)
#define ssGet(obj)
get a pointer to the string in the smallString object
char * toStringInt32PGF(int32_t *object)
#define tpoolKill
Definition: tpool.h:46
void readToFileSmallJsonNotSupported(void *self UNUSED, smallJsont *path UNUSED)
#define rangeDown(index, maxCount)
range down loop, index is ssize_t
Definition: libsheepy.h:2786
smallBytest * B
void finalizeSmallJson(void)
sIntt * allocSInt(int64_t value)
allocate a small int
sContainert * sc
int mkdirParentsO(smallStringt *path)
char * joinCS(const char **list, const char *delim)
join list, the elements are seperated with delim in the resulting string
Definition: libsheepy.c:51633
bool listEqCG(char **list1, const char **list2)
int renameOS(smallStringt *src, const char *dst)
bool equalOOG(baset *p1, baset *p2)
bool icListEqC1S(const char **list1, char **list2)
ignore case const(list1) list Equal String compare each element of list1 and list2 ...
Definition: libsheepy.c:55046
bool equalOArrayG(baset *p1, char **p2)
void putsDoubleGF(double object)
int shMove(const char *src, const char *dst)
move files recursively
Definition: libsheepy.c:5845
int moveSmallJsonSmallJson(smallJsont *src, smallJsont *dst)
int renameSSmallJsonO(const char *src, smallJsont *dst)
int renameSmallJsonOS(smallJsont *src, const char *dst)
bool writeTextSG(char **list, const char *filePath)
call writeText (for writeFileG) (swaps parameters)
bool equalUint64SmallIntG(uint64_t p1, smallIntt *p2)
int moveSmallJsonOS(smallJsont *src, const char *dst)
bool notEqualDoubleOG(double p1 UNUSED, void *p2 UNUSED)
uint64_t rtUint64_t
char * toStringInt16GF(int16_t object)
char * toStringOF(baset *object)
convert data in obj to string
bool equalBoolSmallStringG(bool p1, smallStringt *p2)
ssize_t icListIndexOfCG(const char **list, const char *string)
bool equalUint64BaseG(uint64_t p1, baset *p2)
freeSContainerFt free
bool notEqualUint32OG(uint32_t p1 UNUSED, void *p2 UNUSED)
bool equalInt64DoubleG(int64_t p1, double p2)
bool equalDoubleCharG(double p1, const char *p2)
char * toStringUint32GF(uint32_t object)
char * randomS(uint64_t length)
random string
Definition: libsheepy.c:6020
char * iListGetG(char **list, int retType UNUSED, int64_t index)
call iListGetS for getG
char * getCwd(void)
get current working directory
Definition: libsheepy.c:4054
bool icListHasCharCG(const char **list, char c)
bool equalModificationTimesO(smallStringt *path1, smallStringt *path2)
double rtF64
char * toStringUint16PGF(uint16_t *object)
int copySmallJsonSmallJson(smallJsont *src, smallJsont *dst)
void putsSmallIntGF(smallIntt *object)
int rmAllSmallJsonO(smallJsont *path)
remove all delete recursively files and directories
bool * rtBoolP
float rtF32
void putsUintPGF(uint64_t *object)
int mkdirParentsSmallJsonO(smallJsont *path)
recursive mkdir
#define isEmptyO(self)
smallArrayFunctionst * f
bool equalOSmallStringG(baset *p1, smallStringt *p2)
int64_t rtInt64_t
int listPrintS(char **list)
print list elements to stdout
Definition: libsheepy.c:53841
bool equalUint32SmallJsonG(uint32_t p1, smallJsont *p2)
#define isOSmallInt(obj)
test if obj type is smallInt
internal void walkADirAll(const char *dirPath, smallArrayt *list)
bool fileChmodO(smallStringt *filePath, mode_t mode)
smallt * i
double * rtDoubleP
void initiateAllocateSmallDouble(smallDoublet **self)
bool appendTextCG(const char **list, const char *filePath)
baset * rtBaset
Generic return types getG(dict, rtBool, "a");.
bool icEqS(const char *string1, const char *string2)
ignore case string Equal compare string1 to string2
Definition: libsheepy.c:9283
void * rtVoid
void cleanUpBaseFinishG(baset **val)
char * randomAlphaNumS(uint64_t length)
random alpha numerical string
Definition: libsheepy.c:6132
bool notEqualOInt64G(void *p1 UNUSED, int64_t p2 UNUSED)
const char * iListGetCS(const char **list, int64_t index)
const list Get String index can be negative
Definition: libsheepy.c:51070
int renameSO(const char *src, smallStringt *dst)
smallDoublet * rtSmallDoublet
array
int copyOS(smallStringt *src, const char *dst)
uint32_t rtU32
char ** listPrependS(char ***list, const char *s)
list Prepend String append s at the beginning of the list when list is NULL, a new list with one elem...
Definition: libsheepy.c:50641
bool equalCharDoubleG(const char *s, double value)
bool equalCArraySmallArrayG(const char **p1, smallArrayt *p2)
char * toStringVoidGF(void *object)
bool listHasCG(const char **list, const char *string)
bool icEqualChaOG(char c, baset *value)
char * toStringSmallJsonGF(smallJsont *object)
char * toStringUint8PGF(uint8_t *object)
bool equalUint64DoubleG(uint64_t p1, double p2)
#define pFuncError
print function name and system error
Definition: libsheepy.h:306
char * normalizePath(const char *path)
normalize path
Definition: libsheepy.c:3057
bool equalChaInt32G(char c, int32_t value)
bool equalUint64CharG(uint64_t p1, const char *p2)
bool equalUint64ChaG(uint64_t p1, char p2)
char * readS(void)
read String read user input (one line) as a string
Definition: libsheepy.c:6244
void putsInt32PGF(int32_t *object)
int writeStreamS(FILE *fp, const char *string)
write string to file
Definition: libsheepy.c:4963
bool equalUint32SmallBoolG(uint32_t p1, smallBoolt *p2)
char ** iicListUniqG(char ***list, int dum UNUSED)
call iicListUniqS for icUniqG
bool equalUint32SmallBytesG(uint32_t p1, smallBytest *p2)
char * readFileToG(char **string, const char *filePath)
size_t listLengthCG(const char **list)
internal finalizeRecycleContainersFuncst finalizeRecycleContainersFuncs
char * toStringSmallStringGF(smallStringt *object)
#define lenO(self)
base class for the small objects all small objects have a type
smallJsont * timeToJO(const time_t t)
time To String convert unix time to string (ctime is not used here because it adds at the end of th...
smallDictt * d
bool appendFileSG(const char *string, const char *filePath)
call appendFileS (for appendFileG) (swaps parameters)
void finalizeSmallInt(void)
uint32_t * rtUint32_tP
bool listHasCS(const char **list, const char *string)
return true when const list has string
Definition: libsheepy.c:54744
bool writeText(const char *filePath, char **list)
write list to filePath
Definition: libsheepy.c:54230
char ** listFromCArrayG(char **retType UNUSED, const char **array, size_t size)
#define tpoolLockCount
Definition: tpool.h:19
char * toStringListSGF(char **object)
bool equalUint32SmallDoubleG(uint32_t p1, smallDoublet *p2)
char ** iicListUniqS(char ***list)
ignore case and uniquify elements of list each elements are unique in the list
Definition: libsheepy.c:55329
smallDoublet * D
#define createAllocateSmallDict(obj)
char data[7]
Definition: libsheepy.c:19690
sBytest * allocSBytes(void)
allocate a small bytes object
bool equalChaInt64G(char c, int64_t value)
char * otos(void *basetObj)
object to string for debug this function is used for printing an object in gdb, lldb, any debugger, in gdb: p otos(obj) a longer alternative to print an object is: p obj->f->toString(obj)
smallArrayt * walkDirAllSmallJsonO(smallJsont *dirPath)
void putsDictGF(smallDictt *object)
char * toStringUintGF(uint64_t object)
bool icListEqC1G(const char **list1, char **list2)
int shRename(const char *src, const char *dst)
rename file
Definition: libsheepy.c:5808
bool fileExistsJO(smallJsont *filePath)
detect files and directories
bool writeCText(const char *filePath, const char **list)
write const list to filePath
Definition: libsheepy.c:54267
#define equalUint32O(self, p2)
bool isDirO(smallStringt *path)
bool equalCharUint32G(const char *s, uint32_t value)
uint64_t * rtUint64_tP
baset * b
void readTextSmallStringNotSupported(char ***self UNUSED, smallStringt *path UNUSED)
bool equalCharBoolG(const char *s, bool value)
int renameO(smallStringt *src, smallStringt *dst)
ssize_t icListIndexOfCharCS(const char **list, char c)
Definition: libsheepy.c:55228
bool notEqualBoolOG(bool p1 UNUSED, void *p2 UNUSED)
char * iListGetS(char **list, int64_t index)
list Get String index can be negative
Definition: libsheepy.c:51001
bool equalInt64SmallStringG(int64_t p1, smallStringt *p2)
bool listEqCCG(const char **list1, const char **list2)
bool equalDoubleSmallIntG(double p1, smallIntt *p2)
#define isError(assigned, left)
is Assigment Error catch error when assigned is false, 0 or NULL after being assigned with left ...
Definition: libsheepy.h:386
small bytes
int print_m(FILE *stream, const struct printf_info *info, const void *const *args)
m printf type specifier to print baset objects
int writeTextSmallJsonNotSupported(char **self UNUSED, smallJsont *path UNUSED)
char ** listFromArrayS(char **array, size_t size)
list From Array String
Definition: libsheepy.c:50427
smallArrayt * walkDirAllO(const char *dirPath)
list all files and directories in a directory recursively the directories are listed ...
smallArrayt * readDirDirSmallJsonO(smallJsont *dirPath)
#define icEqualSO(self, string)
bool equalInt32CharG(int32_t p1, const char *p2)
bool equalBoolOG(bool p1, baset *p2)
uint64_t rtU64
bool equalBoolSmallJsonG(bool p1, smallJsont *p2)
bool icListHasCharCS(const char **list, char c)
Definition: libsheepy.c:55148
bool listHasCharCS(const char **list, char c)
Definition: libsheepy.c:54761
void putsSmallContainerGF(smallContainert *object)
char * sStringGetTiny(sStringt *string)
get string in a small string object
bool notEqualOBoolG(void *p1 UNUSED, bool p2 UNUSED)
ssize_t fileSizeO(smallStringt *filePath)
sBoolt * value
bool value
void readTextSmallJsonNotSupported(char ***self UNUSED, smallJsont *path UNUSED)
void finalizeRecycleSmallArray(void *arg UNUSED)
int systemJO(smallJsont *command)
run system command in a smallString
bool icEqualCArrayOG(const char **p1, baset *p2)
char * intToS(int64_t n)
int To String
Definition: libsheepy.c:10970
char * toStringDoubleGF(double object)
int64_t rtI64
int writeStreamFromG(const char *string, FILE *fp)
int rmAll(const char *path)
remove all delete recursively files and directories
Definition: libsheepy.c:5510
int moveSmallJsonO(smallJsont *src, smallStringt *dst)
move files recursively
int writeTextCCSmallJsonNotSupported(const char **self UNUSED, smallJsont *path UNUSED)
smallJsont * randomAlphaNumSmallJsonO(uint64_t length)
random alpha numerical string
bool fileExistsO(smallStringt *filePath)
bool appendCText(const char *filePath, const char **list)
append const list to filePath
Definition: libsheepy.c:54389
time_t getModificationTimeO(smallStringt *path)
char * toStringSmallIntGF(smallIntt *object)
#define getTopTypeO(self)
void putsListSGF(char **object)
bool equalInt32SmallJsonG(int32_t p1, smallJsont *p2)
bool equalInt64Uint64G(int64_t p1, uint64_t p2)
#define parseIntO(self)
bool eqCharChar(char c, char value)
equality functions
#define isOSmallJson(obj)
test if obj type is smallJson
smallArrayt * readDirSmallStringO(smallStringt *dirPath)
smallIntt * rtSmallIntt
small int
void initiateAllocateSmallInt(smallIntt **self)
#define startMax
#define isOType(obj, className)
test obj type
bool equalOSmallDictG(baset *p1, smallDictt *p2)
smallArrayt * walkDirO(const char *dirPath)
list all files in a directory recursively the directories are not listed
smallStringFunctionst * f
void finalizeRecycleSmallBytes(void *arg UNUSED)
bool equalBoolInt64G(bool p1, int64_t p2)
char * array[]
internal void walkADir(const char *dirPath, smallArrayt *list)
bool icListEqCCG(const char **list1, const char **list2)
dArrayT(finalizeRecycleContainersFuncst, recycleContainersFt)
void finalizeRecycleSmallDict(void *arg UNUSED)
char * shDirname(const char *path)
sheepy dirname
Definition: libsheepy.c:2191
char * readLine(FILE *fp)
readLine from file stream the fist new line is converted to 0
Definition: libsheepy.c:6493
void freeBasetInContainer(void *baseo)
#define createAllocateSmallJson(obj)
ssize_t listIndexOfCharCG(const char **list, char c)
int moveSO(const char *src, smallStringt *dst)
void finalizeSmallDouble(void)
bool writeStream(FILE *fp, char **list)
write list to stream
Definition: libsheepy.c:54304
#define terminateO(obj)
free buffers and obj itself
void cleanUpBaseTerminateG(baset **val)
smallArrayt * readDirO(const char *dirPath)
list files in a directory and sort the list
#define err(str)
Definition: tpool.c:35
bool equalCharUint64G(const char *s, uint64_t value)
void finalizeRecycleSmallJson(void *arg UNUSED)
bool equalChaSmallJsonG(char c, smallJsont *value)
#define range(index, maxCount)
range loop ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a decl...
Definition: libsheepy.h:2772
bool equalUint64BoolG(uint64_t p1, bool p2)
char * toStringUint8GF(uint8_t object)
bool equalDoubleSmallJsonG(double p1, smallJsont *p2)
pErrorNULL(iPrependS(&ks, "[1]"))
char * toStringFloatPGF(float *object)
bool equalDoubleSmallBoolG(double p1, smallBoolt *p2)
void putsSmallStringGF(smallStringt *object)
int execSmallStringO(smallStringt *cmd, smallArrayt *out, smallArrayt *err)
char ** listDupCS(const char **list)
const list Duplicate String
Definition: libsheepy.c:51940
bool equalUint64SmallBytesG(uint64_t p1, smallBytest *p2)
bool isLinkO(smallStringt *path)
#define isOSmallBytes(obj)
test if obj type is smallBytes
char ** readText(const char *filePath)
return text from filePath in a list new line characters are removed
Definition: libsheepy.c:54122
bool appendTextSG(char **list, const char *filePath)
call appendText (for appendFileG) (swaps parameters)
bool equalCharSmallIntG(const char *s, smallIntt *value)
sContainert * allocSContainer(void *data)
allocate a small container The container holds a pointer to a user buffer
bool rtBool
char * joinCG(const char **list, const char *delim)
smallArrayt * readDirDirSmallStringO(smallStringt *dirPath)
char * doubleToSG(char *retType UNUSED, double n)
call doubleToS for doubleToG
bool equalUint32FG(uint32_t p1, uint32_t p2)
baset * toBaset(smallt *obj)
convert smallt object to baset
bool icListHasCS(const char **list, const char *string)
ignore case and return true when const list has string
Definition: libsheepy.c:55137
bool equalUint32Int64G(uint32_t p1, int64_t p2)
bool equalDoubleSmallBytesG(double p1, smallBytest *p2)
bool equalUint32DoubleG(uint32_t p1, double p2)
bool equalDoubleBaseG(double p1, baset *p2)
int writeFileS(const char *filePath, const char *string)
write string to file
Definition: libsheepy.c:4883
bool equalUint32SmallStringG(uint32_t p1, smallStringt *p2)
bool icListHasCG(const char **list, const char *string)
sUndefinedt * allocSUndefined(void)
allocate a small undefined object
bool equalOCharG(baset *p1, const char *p2)
char type
uint32_t count
int copy(const char *src, const char *dst)
copy files recursively This function is equivalent to &#39;cp -Ra&#39; without wildcards and circular link de...
Definition: libsheepy.c:5590
smallJsont * shDirnameJO(smallJsont *path)
sheepy dirname
uint32_t rtUint32_t
bool notEqualOUint32G(void *p1 UNUSED, uint32_t p2 UNUSED)
bool equalBoolUint32G(bool p1, uint32_t p2)
bool isDir(const char *path)
is directory
Definition: libsheepy.c:4119
char * listGetG(char **list, int retType UNUSED, int64_t index)
call listGetS for getG
bool equalCArrayOG(const char **p1, baset *p2)
smallContainert * rtSmallContainert
smallJsont * expandHomeJO(smallJsont *path)
expands ~/ ($HOME) or ~USER duplicate and expand path.
bool equalDoubleFG(double p1, double p2)
void(* recycleContainersFt)(void *arg)
function pointer freeing the unused containers of a class in a thread
#define dArrayCount(name)
return element count
Definition: libsheepy.h:7090
bool equalUint64SmallJsonG(uint64_t p1, smallJsont *p2)
int64_t * rtInt64_tP
smallArrayt * readDirAllSmallStringO(smallStringt *dirPath)
int execSmallJsonO(smallJsont *cmd, smallArrayt *out, smallArrayt *err)
int copySmallJsonOS(smallJsont *src, const char *dst)
char * doubleToS(double n)
double To String
Definition: libsheepy.c:11008
bool equalModificationTimesSJO(const char *path1, smallJsont *path2)
bool equalBoolInt32G(bool p1, int32_t p2)
bool equalDoubleInt64G(double p1, int64_t p2)
#define equalInt32O(self, p2)
int setModificationTimeJO(smallJsont *path, time_t mtime)
set modification time for path
bool equalInt32Uint64G(int32_t p1, uint64_t p2)
bool equalUint64SmallBoolG(uint64_t p1, smallBoolt *p2)
bool equalUint32ChaG(uint32_t p1, char p2)
#define equalInt64O(self, p2)
bool equalDoubleUint64G(double p1, uint64_t p2)
smallBoolt * rtSmallBoolt
smallArrayt * readDirAllSmallJsonO(smallJsont *dirPath)
char * toStringInt16PGF(int16_t *object)
void putsUint32GF(uint32_t object)
bool fileChmod(const char *filePath, mode_t mode)
like chmod in stdlibc but return true/false
Definition: libsheepy.c:4345
bool isDirJO(smallJsont *path)
is directory
bool equalChaSmallStringG(char c, smallStringt *value)
char * toStringIntPGF(int64_t *object)
void freeManyOF(void *paramType,...)
free many buffers in baset objects
bool equalInt32SmallStringG(int32_t p1, smallStringt *p2)
bool equalModificationTimesSO(const char *path1, smallStringt *path2)
int systemO(smallStringt *command)
bool notEqualCharG(char c UNUSED, void *value UNUSED)
return false, used in eqG when object types don&#39;t match
char ** listFromCArrayS(const char **array, size_t size)
list From Const Array String
Definition: libsheepy.c:50465
char * toStringUint16GF(uint16_t object)
END_TEST FILE * fp
char * listGetCG(const char **list, int retType UNUSED, int64_t index)
void finalizeSmallDict(void)
int renameSmallJsonSmallJson(smallJsont *src, smallJsont *dst)
smallArrayt * readDirSmallJsonO(smallJsont *dirPath)
#define cast(type, casted, toCast)
define variable and cast pointer
Definition: libsheepy.h:617
char * readStreamToG(char **string, FILE *fp)
#define parseDoubleO(self)
char * join(char **list, const char *delim)
join list, the elements are seperated with delim in the resulting string when updating this function...
Definition: libsheepy.c:51554
bool equalCharSmallDoubleG(const char *s, smallDoublet *value)
#define splitSO(self, delim)
void smashManyOF(void *paramType,...)
smash many baset objects
char ** listDupCG(const char **list)
void initiateAllocateSmallDict(smallDictt **self)
char * listDequeueS(char ***list)
list Dequeue String return first string from list and remove it from the list
Definition: libsheepy.c:50746
char c
bool icEqualOCharG(baset *p1, const char *p2)
uint32_t * rtU32P
bool equalCharInt32G(const char *s, int32_t value)
smallStringt * normalizePathO(smallStringt *path)
int copyOSmallJson(smallStringt *src, smallJsont *dst)
int writeTextSmallStringNotSupported(char **self UNUSED, smallStringt *path UNUSED)
smallArrayt * walkDirDirSmallStringO(smallStringt *dirPath)
int32_t rtI32
#define toStringO(obj)
convert data in obj to string
bool listEqC1S(const char **list1, char **list2)
const(list1) list Equal String compare each element of list1 and list2
Definition: libsheepy.c:54659
bool equalInt64SmallJsonG(int64_t p1, smallJsont *p2)
char ** listAddCS(char **list1, const char **list2)
const list Add String add list1 and list2 in a new list
Definition: libsheepy.c:52423
void putsOF(baset *object)
puts for objects using toString
bool isNumber(const char *string)
is Number (integer or float) String
Definition: libsheepy.c:10749
bool icEqualOCArrayG(baset *p1, const char **p2)
void finalizeSmallBool(void)
bool equalDoubleSmallStringG(double p1, smallStringt *p2)
unsigned registerFinalizeRecycleContainersInThreadPool(recycleContainersFt f)
register function freeing the unused containers a finalizeRecycle must be registered for each class i...
void putsDoublePGF(double *object)
void initiateAllocateSmallArray(smallArrayt **self)
bool equalInt64ChaG(int64_t p1, char p2)
bool fileChmodJO(smallJsont *filePath, mode_t mode)
like chmod in stdlibc but return true/false
void * readFileToS(const char *filePath)
read file to string
Definition: libsheepy.c:4427
pthread_mutex_t tpoolLocks[tpoolLockCount]
Definition: tpool.c:45
bool equalCharOG(const char *s, baset *value)
void initiateAllocateSmallBool(smallBoolt **self)
smallBytesFunctionst * f
bool equalInt32BoolG(int32_t p1, bool p2)
char * toStringListCSGF(const char **object)
void putsUintGF(uint64_t object)
bool isLinkJO(smallJsont *path)
is symbolic link
sDictt * allocSDict(void)
allocate a small dict
void finalizeRecycleSmallContainer(void *arg UNUSED)
bool icEqualArraySmallArrayG(char **p1, smallArrayt *p2)
bool icEqualOSmallJsonG(baset *p1, smallJsont *p2)
sContainert * data
pointer to data in smallContainer
bool equalChaDoubleG(char c, double value)
bool equalInt32SmallIntG(int32_t p1, smallIntt *p2)
bool listHasCharCG(const char **list, char c)
#define shPrintError
print error with line number, function name and file name to stderr
Definition: libsheepy.h:319
bool equalOSmallBytesG(baset *p1, smallBytest *p2)
bool icEqualChaSmallStringG(char c, smallStringt *value)
const char * iListGetCG(const char **list, int retType UNUSED, int64_t index)
bool notEqualInt64OG(int64_t p1 UNUSED, void *p2 UNUSED)
int execO(const char *cmd, smallArrayt *out, smallArrayt *err UNUSED)
bool icListEqCS(char **list1, const char **list2)
ignore case const(list2) list Equal String compare each element of list1 and list2 ...
Definition: libsheepy.c:55016
smallStringt * getCwdO(void)
bool equalCharPSmallStringG(const char *s, smallStringt *value)
smallJsont * getRealProgPathJO(void)
get real program path The first call allocates libSheepyRealProgPath, it is freed with freeRealProgPa...
bool equalUint32CharG(uint32_t p1, const char *p2)
smallStringt * expandHomeO(smallStringt *path)
smallStringt * S
ssize_t icListIndexOfCharCG(const char **list, char c)
#define setTopStringO(self, value)
smallJsont * readLineSmallJsonO(FILE *fp)
readLine from file stream the fist new line is converted to 0
char * rtChar
void initiateAllocateSmallString(smallStringt **self)
void * readStreamToNewG(void *none UNUSED, FILE *fp)
int mkdirParents(const char *path)
recursive mkdir
Definition: libsheepy.c:5457
void terminateManyOF(void *paramType,...)
terminate many baset objects
smallDictt * o
bool isInt(const char *string)
is Integer String
Definition: libsheepy.c:10811
bool icEqualArrayOG(char **p1, baset *p2)
bool icEqualOChaG(baset *p1, char p2)
int writeFileFromG(const char *string, const char *filePath)
call writeFileS (for writeFileG) (swaps parameters)
smallStringt * getRealProgPathO(void)
ssize_t fileSizeJO(smallJsont *filePath)
get file size
bool equalOSmallIntG(baset *p1, smallIntt *p2)
#define pErrorNot0(func)
print error when function failed.
Definition: libsheepy.h:334
bool icEqualOSmallArrayG(baset *p1, smallArrayt *p2)
bool equalModificationTimesOJO(smallStringt *path1, smallJsont *path2)
char * toStringSmallBytesGF(smallBytest *object)
int64_t value
char * listPopS(char ***list)
list Pop String return last string from list and remove last element from the list ...
Definition: libsheepy.c:50602
smallBytest * rtSmallBytest
bool equalOChaG(baset *p1, char p2)
char * toStringInt32GF(int32_t object)
#define isOSmallDouble(obj)
test if obj type is smallDouble
char * toStringIntGF(int64_t object)
void * sBytesGet(sBytest *bytes)
get buffer in small bytes
smallDictt * rtSmallDictt
#define equalSO(self, string)
double parseDouble(const char *string)
convert string to double
Definition: libsheepy.c:10914
void finalizeSmallContainer(void)
uint8_t rtU8
bool equalUint32BaseG(uint32_t p1, baset *p2)
bool notEqualOInt32G(void *p1 UNUSED, int32_t p2 UNUSED)
void initLibsheepyObject(void)
called from initLibsheepy in libsheepy.c start the thread pool
smallStringt * readLineO(FILE *fp)
char * expandHome(const char *path)
expands ~/ ($HOME) or ~USER duplicate and expand path.
Definition: libsheepy.c:2443
void putsUndefinedGF(undefinedt *object)
smallArrayt * readDirDirO(const char *dirPath)
list directories in a directory and sort the list
threadpool tpool_init(int num_threads)
Definition: tpool.c:137
bool listEqCS(char **list1, const char **list2)
const(list2) list Equal String compare each element of list1 and list2
Definition: libsheepy.c:54629
#define dArrayAt(a, index)
get / set element at index
Definition: libsheepy.h:7207
void putsSmallBoolGF(smallBoolt *object)
char ** iListCompactS(char ***list)
remove empty strings from list
Definition: libsheepy.c:55407
bool icEqualCArraySmallJsonG(const char **p1, smallJsont *p2)
sDoublet * allocSDouble(double value)
allocate a small double
char * intToSG(char *retType UNUSED, int64_t n)
call intToS for intToG
bool notEqualInt32OG(int32_t p1 UNUSED, void *p2 UNUSED)
char * listGetS(char **list, int64_t index)
list Get String duplicate string at given index index can be negative
Definition: libsheepy.c:50967
#define isOSmallDict(obj)
test if obj type is smallDictt
bool equalModificationTimesJOO(smallJsont *path1, smallStringt *path2)
bool listIsEmptyS(char **list)
list Is Empty String
Definition: libsheepy.c:50351
const char * getProgPath(void)
get program path When initLibsheepy is called before this function, it returns the given program path...
Definition: libsheepy.c:1795
void finalizeLibsheepyRecycleContainers(void *arg UNUSED)
function called automatically (registered in tpool) when a thread exits This function calls all the r...
time_t getModificationTimeJO(smallJsont *path)
get modification time for path
int moveOSmallJson(smallStringt *src, smallJsont *dst)
bool equalArraySmallArrayG(char **p1, smallArrayt *p2)
char * dupS(const char *string)
duplicate string
Definition: libsheepy.c:6548
bool icEqualOOG(baset *p1, baset *p2)
#define listFreeManyS(...)
Definition: libsheepy.h:2634
bool notEqualCCOG(const char *a UNUSED, void *b UNUSED)
char * toStringFloatGF(float object)
bool equalChaOG(char c, baset *value)
void finalizeRecycleSmallDouble(void *arg UNUSED)
char * toStringSGF(const char *object)
#define sheepyRGBFP
Definition: libsheepy.h:818
char getS(const char *string, int64_t index)
get string
Definition: libsheepy.c:13872
size_t listLengthCS(const char **list)
const list Length String return number of elements until the first NULL element
Definition: libsheepy.c:50843
char * toStringCharGF(char object)
bool equalBoolDoubleG(bool p1, double p2)
#define strEq
Definition: libsheepy.h:2018
bool equalChaSmallBytesG(char c, smallBytest *value)
void putsSGF(const char *object)
bool equalDoubleChaG(double p1, char p2)
smallJsont * getCwdJO(void)
get current working directory
smallStringt * readO(void)
int print_m_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtypes, int *size)
procress printf argument
bool equalModificationTimesJOS(smallJsont *path1, const char *path2)
char ** readTextStreamG(char ***list, FILE *fp)
bool equalDoubleUint32G(double p1, uint32_t p2)
smallArrayt * readDirAllO(const char *dirPath)
list files in a directory and sort the list
smallArrayt * a
int systemNFreeJOF(smallJsont *command, int line, const char *thisFunc, const char *thisFileName)
in value value
bool writeTextStreamG(char **list, FILE *fp)
#define isOSmallBool(obj)
test if obj type is smallBool
int chDirO(smallStringt *path)
bool equalInt32BaseG(int32_t p1, baset *p2)
uint64_t * rtU64P
char * toStringDictGF(smallDictt *object)
bool icListEqCCS(const char **list1, const char **list2)
ignore case const(list1 and 2) list Equal String compare each element of list1 and list2 ...
Definition: libsheepy.c:55076
const char * getRealProgPath(void)
get real program path The first call allocates libSheepyRealProgPath, it is freed with freeRealProgPa...
Definition: libsheepy.c:1812
bool equalBoolSmallBoolG(bool p1, smallBoolt *p2)
bool icEqualChaSmallJsonG(char c, smallJsont *value)
void putsVoidGF(void *object)
dictionary
#define dArrayAppend(a, v)
append element and expand the dynamic array
Definition: libsheepy.h:7134
smallDictFunctionst * f
bool equalInt32SmallBytesG(int32_t p1, smallBytest *p2)
double value
bool equalDoubleInt32G(double p1, int32_t p2)
int listPrintCG(const char **list)
bool equalUint32Uint64G(uint32_t p1, uint64_t p2)
bool icListEqCG(char **list1, const char **list2)
bool equalInt64BaseG(int64_t p1, baset *p2)
internal void walkADirDir(const char *dirPath, smallArrayt *list)
void finalizeLibsheepyAtExit(void)
free class methods for all classes the objects and classes are not usuable after this an object has t...
void cleanUpBaseFreeG(baset **val)
void putsBoolGF(bool object)
bool equalCharPSmallJsonG(const char *s, smallJsont *value)
bool equalBoolFG(bool p1, bool p2)
small string
int moveSSmallJsonO(const char *src, smallJsont *dst)
void finishManyOF(void *paramType,...)
finish many baset objects
char ** iListUniqG(char ***list, int dum UNUSED)
call iListUniqS for uniqG
void initiateAllocateSmallContainer(smallContainert **self)
bool equalInt32SmallDoubleG(int32_t p1, smallDoublet *p2)
#define catS(...)
Definition: libsheepy.h:1911
void initiateAllocateSmallBytes(smallBytest **self)
int copySmallJsonO(smallJsont *src, smallStringt *dst)
bool equalUint64Int32G(uint64_t p1, int32_t p2)
char * toStringUint32PGF(uint32_t *object)
bool writeTextCG(const char **list, const char *filePath)
#define logI(...)
Definition: libsheepy.h:1064
small bool
int setModificationTime(const char *path, time_t mtime)
set modification time for path
Definition: libsheepy.c:1890
smallArrayt * walkDirAllSmallStringO(smallStringt *dirPath)
bool appendFileS(const char *filePath, const char *string)
append string to filePath
Definition: libsheepy.c:5023
bool equalUint64SmallStringG(uint64_t p1, smallStringt *p2)
char * toStringUintPGF(uint64_t *object)
smallJsonFunctionst * f
bool equalODoubleG(baset *p1, double p2)
int copySSmallJsonO(const char *src, smallJsont *dst)
bool equalOCArrayG(baset *p1, const char **p2)
char getSG(const char *string, int retType UNUSED, int64_t index)
call getS for getG
bool notEqualOG(void *a UNUSED, void *b UNUSED)
void finalizeRecycleSmallBool(void *arg UNUSED)
#define UNUSED
Definition: libsheepy.h:8195
smallStringt * randomAlphaNumSO(uint64_t length)
bool equalBoolCharG(bool p1, const char *p2)
bool equalOSmallDoubleG(baset *p1, smallDoublet *p2)
sBoolt * allocSBool(bool value)
allocate a small bool
bool equalDoubleBoolG(double p1, bool p2)
int chDirJO(smallJsont *path)
change directory
ssize_t listIndexOfCS(const char **list, const char *string)
return index of string in const list
Definition: libsheepy.c:54813
smallJsont * getProgPathJO(void)
get program path When initLibsheepy is called before this function, it returns the given program path...
smallJsont * randomSmallJsonO(uint64_t length)
random string
int copyO(smallStringt *src, smallStringt *dst)
copy files recursively
bool equalBoolSmallBytesG(bool p1, smallBytest *p2)
#define forEachCharP(list, element)
forEach - loop macro on list indexes to access the element in the loop, use *element ...
Definition: libsheepy.h:2979
bool equalOInt64G(baset *p1, int64_t p2)
smallStringt * allocSmallString(const char *string)
smallJsont * normalizePathJO(smallJsont *path)
normalize path
void readToFileSmallStringNotSupported(void *self UNUSED, smallStringt *path UNUSED)
#define createAllocateSmallString(obj)
char * joinCharCG(const char **list, char delim)
smallBoolFunctionst * f
smallStringt * timeToSO(const time_t t)
bool equalOSmallJsonG(baset *p1, smallJsont *p2)
char * toStringBoolPGF(bool *object)
bool icEqualArraySmallJsonG(char **p1, smallJsont *p2)
bool icEqualOSmallStringG(baset *p1, smallStringt *p2)
bool equalModificationTimesOS(smallStringt *path1, const char *path2)
int renameSmallJsonO(smallJsont *src, smallStringt *dst)
rename file
bool listEqC1G(const char **list1, char **list2)
bool r
bool equalInt64BoolG(int64_t p1, bool p2)
int systemNFreeOF(smallStringt *command, int line, const char *thisFunc, const char *thisFileName)
char ** readStream(FILE *fp)
return text from stream fp in a list new line characters are removed
Definition: libsheepy.c:54187
bool equalChaUint32G(char c, uint32_t value)
#define sjGet(obj)
get a pointer to the string in the smallJson object
#define equalUint64O(self, p2)
bool equalBoolSmallDoubleG(bool p1, smallDoublet *p2)
void shEPrintfS(const char *fmt,...)
sheepy Error printf String print with logE
Definition: libsheepy.c:6589
void finalizeRecycleSmallString(void *arg UNUSED)
bool equalInt32ChaG(int32_t p1, char p2)
bool equalChaBoolG(char c UNUSED, bool value UNUSED)
void putsBoolPGF(bool *object)
base class
smallArrayt * walkDirDirSmallJsonO(smallJsont *dirPath)
int64_t * rtI64P
bool equalOSmallBoolG(baset *p1, smallBoolt *p2)
#define freeO(obj)
free buffers in obj
small double
char * listGetCS(const char **list, int64_t index)
const list Get String duplicate string at given index index can be negative
Definition: libsheepy.c:51036
void putsSmallBytesGF(smallBytest *object)
double * rtF64P
int32_t * rtI32P
#define enumerateSArray(array, element, index)
uint16_t rtU16
#define command(cmd)
Definition: libsheepy.h:3151
void putsIntPGF(int64_t *object)
time_t getModificationTime(const char *path)
get modification time for path
Definition: libsheepy.c:1864
undefinedt * rtUndefinedt
char * toStringArrayGF(smallArrayt *object)
char * listPopG(char ***list, int retType UNUSED)
call listPopS for popG
bool fileExists(const char *filePath)
detect files and directories
Definition: libsheepy.c:4321
smallArrayt * rtSmallArrayt
int cpuCount(void)
return number of online CPUs, also number of threads in the thread pool
void putsSmallDoubleGF(smallDoublet *object)
bool equalUint32BoolG(uint32_t p1, bool p2)
bool notEqualUint64OG(uint64_t p1 UNUSED, void *p2 UNUSED)
#define setTopNFreeStringO(self, value)
bool appendText(const char *filePath, char **list)
append list to filePath
Definition: libsheepy.c:54352
size_t listLengthS(char **list)
list Length String return number of elements until the first NULL element
Definition: libsheepy.c:50820
int moveOS(smallStringt *src, const char *dst)
char ** listPushS(char ***list, const char *s)
list Push String append s at the end of the list when list is NULL, a new list with one element is re...
Definition: libsheepy.c:50504
int copySO(const char *src, smallStringt *dst)
bool equalChaUint64G(char c, uint64_t value)
bool equalInt32Int64G(int32_t p1, int64_t p2)
void finalizeSmallString(void)
smallStringt * shDirnameO(smallStringt *path)
int64_t parseInt(const char *string)
convert string to decimal integer
Definition: libsheepy.c:10846
int writeTextCCSmallStringNotSupported(const char **self UNUSED, smallStringt *path UNUSED)
ssize_t fileSize(const char *filePath)
get file size
Definition: libsheepy.c:4369
bool equalCharInt64G(const char *s, int64_t value)
bool equalOUint32G(baset *p1, uint32_t p2)
smallIntFunctionst * f
bool notEqualOCharG(void *a UNUSED, char c UNUSED)
bool equalUint64Uint32G(uint64_t p1, uint32_t p2)
bool icEqualCharOG(const char *s, baset *value)
#define equalDoubleO(self, p2)
smallJsont * rtSmallJsont
bool icEqCharChar(char c, char value)
ignore case equality functions
bool equalInt64Int32G(int64_t p1, int32_t p2)
smallArrayt * walkDirSmallStringO(smallStringt *dirPath)
sArrayt * allocSArray(void)
allocate a small array
bool equalModificationTimesJO(smallJsont *path1, smallJsont *path2)
compare modification times for path1 and path2
bool value
void finalizeUndefined(void)
bool equalUint32Int32G(uint32_t p1, int32_t p2)
bool equalOInt32G(baset *p1, int32_t p2)
char ** readTextSG(char ***list, const char *filePath)
call readText (for readFileG)
#define freeManyS(...)
Definition: libsheepy.h:1867
char * toStringDoublePGF(double *object)
smallStringt * formatO(const char *fmt,...)
format string allocate and format string using asprintf
int chDir(const char *path)
change directory
Definition: libsheepy.c:4092
void putsIntGF(int64_t object)
undefinedt * u
bool equalInt64SmallBoolG(int64_t p1, smallBoolt *p2)
bool equalBoolChaG(bool p1 UNUSED, char p2 UNUSED)
bool equalBoolSmallIntG(bool p1, smallIntt *p2)
smallStringt * rtSmallStringt
#define createAllocateSmallArray(obj)
bool equalInt64SmallBytesG(int64_t p1, smallBytest *p2)
ssize_t listIndexOfCG(const char **list, const char *string)
int setModificationTimeO(smallStringt *path, time_t mtime)
#define dArrayInit(a)
initialize dynamic array with minimum element count
Definition: libsheepy.h:7018
ssize_t listIndexOfCharCS(const char **list, char c)
Definition: libsheepy.c:54841
#define finishO(obj)
free container only
bool equalCharSmallBytesG(const char *s, smallBytest *value)
#define isOSmallArray(obj)
test if obj type is smallArray
smallArrayt * walkDirSmallJsonO(smallJsont *dirPath)
void initiateAllocateUndefined(undefinedt **self)
void * readStreamToS(FILE *fp)
read file to string
Definition: libsheepy.c:4482
bool notEqualOUint64G(void *p1 UNUSED, uint64_t p2 UNUSED)
#define pError0(func)
print error when function failed.
Definition: libsheepy.h:329
char * listDequeueG(char ***list, int retType UNUSED)
call listDequeueS for dequeueG
bool equalOSmallArrayG(baset *p1, smallArrayt *p2)
#define setIntO(self, key, value)
#define isBlankO(self)
#define smashO(obj)
free object and keep data
int moveO(smallStringt *src, smallStringt *dst)
bool equalInt32DoubleG(int32_t p1, double p2)
bool icEqualOArrayG(baset *p1, char **p2)
smallDoubleFunctionst * f
bool equalUint64FG(uint64_t p1, uint64_t p2)
bool listEqCCS(const char **list1, const char **list2)
const(list1 and 2) list Equal String compare each element of list1 and list2
Definition: libsheepy.c:54689
void putsJsonGF(smallJsont *object)
bool icEqualCharPSmallJsonG(const char *s, smallJsont *value)
bool equalArraySmallJsonG(char **p1, smallJsont *p2)
bool writeTextStreamCG(const char **list, FILE *fp)
bool equalInt64SmallIntG(int64_t p1, smallIntt *p2)
bool icEqualCArraySmallArrayG(const char **p1, smallArrayt *p2)
bool equalChaSmallDoubleG(char c, smallDoublet *value)
baset * duplicateBaseG(baset *self)
bool equalInt64CharG(int64_t p1, const char *p2)
int32_t * rtInt32_tP
void putsUint32PGF(uint32_t *object)
bool equalChaSmallIntG(char c, smallIntt *value)
#define isOSmallString(obj)
test if obj type is smallString
double rtDouble