*/}}

la_util.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #define _CRT_SECURE_NO_WARNINGS
  20. #define _GNU_SOURCE
  21. #include <time.h>
  22. #ifdef LA_USE_GLES
  23. #include <EGL/egl.h>
  24. #include <GL/gl.h>
  25. #ifdef LA_ANDROID
  26. #include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
  27. #include <android_native_app_glue.h> // Required for: android_app struct and activity management
  28. #include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL()]
  29. #endif
  30. #else
  31. #include <GL/glew.h>
  32. #include <GL/gl.h>
  33. #endif
  34. #include "ft2build.h"
  35. #include "freetype/freetype.h"
  36. #include "la_icon.h"
  37. #include <stddef.h>
  38. #include <stdint.h>
  39. #include <ctype.h>
  40. #ifdef __linux__
  41. #include <fcntl.h>
  42. #include <unistd.h>
  43. #include <errno.h>
  44. #include <wchar.h>
  45. #define SYSWINDOW Window
  46. #ifdef LA_USE_GLES
  47. #define SYSGLCONTEXT EGLContext
  48. #else
  49. #define SYSGLCONTEXT GLXContext
  50. #endif
  51. #define SYSTEMDC DC
  52. #define SYSTEMRC RC
  53. #define SYSTEMDISPLAY Display
  54. #define SYSLOCK pthread_spinlock_t
  55. #endif
  56. #ifdef _WIN32
  57. #include <Windows.h>
  58. #include "Shlwapi.h"
  59. #define SYSWINDOW HWND
  60. #define SYSGLCONTEXT HGLRC
  61. #define SYSTEMDC HDC
  62. #define SYSTEMRC HRC
  63. #define SYSTEMDISPLAY int
  64. #define PATH_MAX 4096
  65. #define SYSLOCK CRITICAL_SECTION
  66. #endif
  67. #ifdef LA_WITH_LUAJIT
  68. #define luajit_c
  69. #include "lua.h"
  70. #include "lauxlib.h"
  71. #include "lualib.h"
  72. #include "luajit.h"
  73. void tnsLuaInit(lua_State* L);
  74. void la_luaPrintStatus(lua_State *L);
  75. void la_luaLoadLibs(lua_State *L);
  76. void la_luaDumpStack(lua_State *L);
  77. #ifdef __cplusplus
  78. extern "C"{
  79. #endif
  80. extern const char* LA_LUA_LIB_COMMON;
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif /* luajit */
  85. #define NEED_STRUCTURE(a) \
  86. typedef struct _##a a;
  87. #define STRUCTURE(a) \
  88. typedef struct _##a a;\
  89. struct _##a
  90. #define lengthof(a) \
  91. (sizeof(a)/sizeof(a[0]))
  92. #ifdef _WIN32
  93. #define LA_PATH_SEP '\\'
  94. #define LA_PATH_SEPSTR "\\"
  95. #define realpath(N,R) _fullpath((R),(N),PATH_MAX)
  96. #else
  97. #define LA_PATH_SEP '/'
  98. #define LA_PATH_SEPSTR "/"
  99. #endif
  100. #define DBL_TRIANGLE_LIM 1e-11
  101. #define DBL_EDGE_LIM 1e-9
  102. #ifndef LAGUI_GIT_BRANCH
  103. #define LAGUI_GIT_BRANCH "Release 1"
  104. #endif
  105. // No need to show hash when not compiled from git repo.
  106. //#ifndef LAGUI_GIT_HASH
  107. //#define LAGUI_GIT_HASH "?"
  108. //#endif
  109. #define LA_HYPER_CREATED_TIME(hi) \
  110. hi->TimeCreated.Year,hi->TimeCreated.Month,hi->TimeCreated.Day,hi->TimeCreated.Hour,hi->TimeCreated.Minute,hi->TimeCreated.Second
  111. typedef double real;
  112. typedef unsigned long long u64bit;
  113. typedef unsigned int u32bit;
  114. typedef unsigned short u16bit;
  115. typedef unsigned short ushort;
  116. typedef unsigned char u8bit;
  117. typedef struct _laListSingle laListSingle;
  118. struct _laListSingle {
  119. void* pNext;
  120. };
  121. typedef struct _laListHandle laListHandle;
  122. struct _laListHandle {
  123. void* pFirst;
  124. void* pLast;
  125. };
  126. typedef struct _laListWithPivot laListWithPivot;
  127. struct _laListWithPivot {
  128. void* pFirst;
  129. void* pLast;
  130. void* Pivot;
  131. };
  132. typedef struct _laListItem laListItem;
  133. struct _laListItem {
  134. void* pPrev;
  135. void* pNext;
  136. };
  137. typedef struct _laListItem2 laListItem2;
  138. struct _laListItem2 {
  139. void* O1;
  140. void* O2;
  141. void* pPrev;
  142. void* pNext;
  143. };
  144. typedef struct _laListItem3 laListItem3;
  145. struct _laListItem3 {
  146. void* O1;
  147. void* O2;
  148. void* O3;
  149. void* O4;
  150. void* pPrev;
  151. void* pNext;
  152. };
  153. NEED_STRUCTURE(laSafeString);
  154. STRUCTURE(laAuthorInfo) {
  155. laListItem Item;
  156. laSafeString* Name;
  157. laSafeString* CopyrightString;
  158. };
  159. STRUCTURE(laTimeInfo) {
  160. u16bit Year;//Also Used As Timer [ms] counter
  161. u8bit Month;
  162. u8bit Day;
  163. u8bit Hour;
  164. u8bit Minute;
  165. u8bit Second;
  166. };
  167. NEED_STRUCTURE(laPropContainer);
  168. typedef struct _laUID laUID;
  169. struct _laUID {
  170. char String[32];//a simplified uuid, example: 0E3F9BA4802FDDC2-20160601123546 [\0]
  171. };
  172. typedef struct _laListItemPointer laListItemPointer;
  173. struct _laListItemPointer {
  174. void* pPrev;
  175. void* pNext;
  176. void* p;
  177. };
  178. typedef struct _laItemUserLinker laItemUserLinker;
  179. typedef void(*laUserRemoveFunc)(void* This, laItemUserLinker* iul);
  180. NEED_STRUCTURE(laProp);
  181. struct _laItemUserLinker {
  182. laListItemPointer Pointer;
  183. laUserRemoveFunc Remove;
  184. laProp* Which;
  185. void* Additional;
  186. unsigned int FrameDistinguish;
  187. int ForceRecalc;
  188. };
  189. typedef struct _laItemUserLinkerLocal laItemUserLinkerLocal;
  190. struct _laItemUserLinkerLocal {
  191. laItemUserLinker Link;
  192. void* Instance;
  193. };
  194. typedef struct _laElementListItem laElementListItem;
  195. struct _laElementListItem {
  196. laListItem Item;
  197. void* Ext;
  198. };
  199. typedef struct _laListNonRecursiveRoot laListNonRecursiveRoot;
  200. struct _laListNonRecursiveRoot {
  201. laListHandle NSItems;
  202. };
  203. typedef int(*laCompareFunc)(void*, void*);
  204. typedef void(*laListDoFunc)(void*);
  205. typedef void(*laListNonRecursiveDoFunc)(laListNonRecursiveRoot*, void*, void*);//item,custom
  206. typedef void(*laListNonRecursiveCopyFunc)(laListNonRecursiveRoot*, void*, void*, void*);//old,new,custom
  207. typedef void(*laListDoFuncArgp)(void*, void*);
  208. typedef void(*laCopyListFunc)(void*, void*);
  209. typedef void(*laListCustomDataRemover)(void*);
  210. //typedef void(*ListMatcherFunc)(void*,void*);//gotten value,enumed curent lst item.
  211. typedef struct _laListNonRecursiveItem laListNonRecursiveItem;
  212. struct _laListNonRecursiveItem {
  213. laListItem Item;
  214. laListHandle handle;
  215. laListHandle *ToHandle;//This Is Pointer!
  216. laListNonRecursiveDoFunc func;
  217. laListNonRecursiveCopyFunc CopyFunc;
  218. laListCustomDataRemover remover;
  219. void* CustomData;
  220. int bFreeList;
  221. int SizeEachNode;
  222. };
  223. typedef struct _laHash256 laHash256;
  224. struct _laHash256 {
  225. laListHandle Entries[256];
  226. };
  227. typedef struct _laHash65536 laHash65536;
  228. struct _laHash65536 {
  229. laListHandle Entries[65536];
  230. };
  231. typedef struct _laSafeString laSafeString;
  232. struct _laSafeString {
  233. laListItem Item;
  234. char * Ptr;
  235. };
  236. typedef struct _laSafeStringCollection laSafeStringCollection;
  237. struct _laSafeStringCollection {
  238. laListHandle SafeStrings;
  239. };
  240. typedef struct _laStringSplitor laStringSplitor;
  241. struct _laStringSplitor {
  242. int NumberParts;
  243. laListHandle parts;
  244. };
  245. typedef struct _laStringPart laStringPart;
  246. struct _laStringPart {
  247. laListItem Item;
  248. char * Content;
  249. int IntValue;
  250. real FloatValue;
  251. char Type;
  252. };
  253. STRUCTURE(laStringLine) {
  254. laListItem Item;
  255. uint32_t Buf[1024];//unicode
  256. };
  257. STRUCTURE(laStringEdit) {
  258. laListHandle Lines;
  259. int CursorLine, CursorBefore, CursorPreferBefore;
  260. int BeginLine, BeginBefore;
  261. int EndLine, EndBefore;
  262. int _BeginLine, _BeginBefore; // selection order
  263. int _EndLine, _EndBefore;
  264. int TotalLines;
  265. int ViewStartLine, ViewStartCol;
  266. int ViewHeight, ViewWidth;
  267. int MouseSelecting;
  268. };
  269. #define LA_SWAP(T,x,y) \
  270. { T SWAP = x; x = y; y = SWAP; }
  271. #define LA_MEMORY_POOL_1MB 1048576
  272. #define LA_MEMORY_POOL_128MB 134217728
  273. #define LA_MEMORY_POOL_256MB 268435456
  274. #define LA_MEMORY_POOL_512MB 536870912
  275. STRUCTURE(laMemoryPool) {
  276. laListItem Item;
  277. int NodeSize;
  278. int NextCount;
  279. int UsableCount;
  280. int Hyperlevel;
  281. laListHandle Pools;
  282. };
  283. STRUCTURE(laMemoryPoolPart) {
  284. laListItem Item;
  285. laListHandle FreeMemoryNodes;
  286. int UsedCount;
  287. laMemoryPool* PoolRoot;
  288. //<------Pool mem starts here
  289. };
  290. NEED_STRUCTURE(laDBInst);
  291. STRUCTURE(laMemNode0){
  292. laListItem Item;
  293. laMemoryPoolPart* InPool;//<---- Keep at the last
  294. //<------User mem starts here
  295. };
  296. STRUCTURE(laMemNode) {
  297. laListItem Item;
  298. laListHandle Users; //<---- Keep at the second
  299. void* ReadInstance;
  300. laMemoryPoolPart* InPool; //<---- Keep at the last
  301. //<------User mem starts here
  302. };
  303. NEED_STRUCTURE(laManagedUDF);
  304. STRUCTURE(laMemNodeHyper) {
  305. laListItem Item;
  306. laListHandle Users; //<---- Keep at the second
  307. laUID NUID;
  308. laTimeInfo TimeCreated;
  309. laManagedUDF* FromFile;
  310. int Modified;
  311. int UNUSEDUndoDirty;
  312. laMemoryPoolPart* InPool; //<---- Keep at the last
  313. //<------User mem starts here
  314. };
  315. STRUCTURE(laStaticMemoryPoolNode) {
  316. laListItem Item;
  317. int UsedByte;
  318. //<------User mem starts here
  319. };
  320. STRUCTURE(laStaticMemoryPool) {
  321. int EachSize;
  322. laListHandle Pools;
  323. //SYSLOCK csMem;
  324. };
  325. STRUCTURE(laAVLNodeReal64) {
  326. laAVLNodeReal64* Parent;
  327. u64bit Index;
  328. real Value;
  329. //real SmallestValue;
  330. //real GreatestValue;
  331. laAVLNodeReal64* Smaller;
  332. laAVLNodeReal64* Greater;
  333. char Height;
  334. void* Pointer;
  335. };
  336. STRUCTURE(laAVLTreeReal64) {
  337. laAVLNodeReal64* Root;
  338. u64bit ItemCount;
  339. laMemoryPool MemoryPool;
  340. };
  341. STRUCTURE(laTimeRecorder) {
  342. #ifdef __linux__
  343. struct timespec ts;
  344. #endif
  345. #ifdef _WIN32
  346. LARGE_INTEGER tm;
  347. #endif
  348. };
  349. STRUCTURE(laTranslationNode) {
  350. laListItem Item;
  351. laSafeString* LanguageName;
  352. laHash256 Matches;
  353. };
  354. STRUCTURE(laTranslation) {
  355. int EnableTranslation;
  356. laListHandle Languages;
  357. laTranslationNode* CurrentLanguage;
  358. laHash256 MisMatches;
  359. };
  360. STRUCTURE(laTranslationMatch) {
  361. laListItem Item;
  362. char * Target;
  363. char * Replacement;
  364. };
  365. NEED_STRUCTURE(laRackPage);
  366. STRUCTURE(laNodeVisitInfo){
  367. laListHandle* l;
  368. laListHandle* br;
  369. uint64_t Branch;
  370. int NextBranch;
  371. laRackPage* Page;
  372. };
  373. NEED_STRUCTURE(laBaseNode);
  374. typedef void (*laBaseNodeInitF)(laBaseNode*, int NoCreate);
  375. typedef void (*laBaseNodeDestroyF)(laBaseNode*);
  376. typedef int (*laBaseNodeVisitF)(laBaseNode*, laNodeVisitInfo*);
  377. typedef int (*laBaseNodeEvalF)(laBaseNode*);
  378. typedef void (*laBaseNodeCopyF)(laBaseNode* _new, laBaseNode* _old, int DoRematch);
  379. STRUCTURE(laBaseNodeType){
  380. laBaseNodeInitF Init;
  381. laBaseNodeDestroyF Destroy;
  382. laBaseNodeVisitF Visit;
  383. laBaseNodeEvalF Eval;
  384. laBaseNodeCopyF Copy;
  385. laPropContainer* pc;
  386. char* TypeName;
  387. char* Name;
  388. int Icon;
  389. int NodeSize;
  390. };
  391. NEED_STRUCTURE(laNodeRack);
  392. STRUCTURE(laBaseNode){
  393. laListItem Item;
  394. laSafeString* Name;
  395. laBaseNodeType* Type;
  396. laNodeRack* InRack;
  397. int Gap; int InitDone;
  398. uint64_t EvalMagic;
  399. uint64_t Branch;
  400. uint64_t BranchTemp;
  401. laBaseNode* Duplicated;
  402. };
  403. #define CreateNew(Type) \
  404. calloc(sizeof(Type),1)
  405. #define CreateNew_Size(size) \
  406. calloc(size,1)
  407. #define CreateNewBuffer(Type,Num) \
  408. calloc(sizeof(Type),Num);
  409. #define FreeMem(ptr) \
  410. nutFreeMem((&ptr))
  411. #define elif \
  412. else if
  413. #define LA_UNAVAILABLE_NAME "- Unknown -"
  414. uint32_t laToUnicode(const unsigned char* ch, int* advance);
  415. int laToUTF8(const uint32_t ch, unsigned char* out, unsigned char** next);
  416. int strToUnicode(uint32_t* target, unsigned char* const src);
  417. int strToUTF8(unsigned char* target, uint32_t* const src);
  418. int strlenU(uint32_t* const str);
  419. int strcpyU(uint32_t* target, uint32_t* const source );
  420. int strcatU(uint32_t* target, uint32_t* const source );
  421. struct tm* laGetFullTime();
  422. void laRecordTime(laTimeRecorder* tr);
  423. real laTimeElapsedSecondsf(laTimeRecorder* End, laTimeRecorder* Begin);
  424. int laTimeElapsedMilliseconds(laTimeRecorder* End, laTimeRecorder* Begin);
  425. void laSetAuthorInfo(char * Name, char * CopyrightString);
  426. void memCreateNUID(char* buf,laMemNodeHyper* Hyper);
  427. NEED_STRUCTURE(laPropPack);
  428. int nutHyperUserCount(void* instance, laProp* p_optional, int *p_count);
  429. void memHyperInfo(laPropPack* pp, char* buf);
  430. void memMakeHyperData(laMemNodeHyper* hi);
  431. void nutFreeMem(void** ptr);
  432. int nutFloatCompare(real l, real r);
  433. int nutSameAddress(void* l, void* r);
  434. void* arrElement(void* head, int i, int size);
  435. int arrEnsureLength(void** head, int next, int* max, size_t ElementSize);
  436. int arrInitLength(void** head, int max, int* pmax, size_t ElementSize);
  437. void arrFree(void** head, int* max);
  438. void lstPushSingle(void** Head, laListSingle* Item);
  439. void* lstPopSingle(void** Head, laListSingle* Item);
  440. void lstClearPrevNext(laListItem* li);
  441. int lstCountElements(laListHandle* Handle);
  442. void lstAppendItem(laListHandle* Handle, void* Item);
  443. void lstPushItem(laListHandle* Handle, void* Item);
  444. void* lstPopItem(laListHandle* Handle) ;
  445. void lstAppendItem2(laListHandle* Handle, void* Item);
  446. void* lstPopItem2(laListHandle* Handle);
  447. void lstPushItem2(laListHandle* Handle, void* Item);
  448. void lstAppendItem3(laListHandle* Handle, void* Item);
  449. void* lstPopItem3(laListHandle* Handle);
  450. void lstPushItem3(laListHandle* Handle, void* Item);
  451. int lstRemoveItem(laListHandle* Handle, laListItem* li) ;
  452. int lstRemoveItem2(laListHandle* Handle, laListItem2* li);
  453. int lstRemoveSegment(laListHandle* Handle, laListItem* Begin, laListItem* End);
  454. void lstInsertItemBefore(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  455. void lstInsertItemAfter(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  456. void lstInsertSegmentBefore(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  457. void lstInsertSegmentAfter(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  458. int lstHaveItemInList(laListHandle* Handle);
  459. /**/ void* lstGetTop(laListHandle* Handle);
  460. void lstPushSimpleItem(void** first, laItemUserLinker* iul);
  461. void* lstPushItemUser(void** first, void* p);
  462. void* lstPushItemUsing(void** first, void* p);
  463. void* lstAppendPointerOnly(laListHandle* h, void* p);
  464. void* lstAppendPointerSizedOnly(laListHandle* h, void* p, int size);
  465. void* lstPushPointerOnly(laListHandle* h, void* p);
  466. void* lstPushPointerSizedOnly(laListHandle* h, void* p, int size);
  467. void lstReverse(laListHandle* h);
  468. int lstHasPointer(laListHandle* h, void *p);
  469. void* lstAppendPointer(laListHandle* h, void* p);
  470. void* lstAppendPointerSized(laListHandle* h, void* p, int size);
  471. void* lstPushPointer(laListHandle* h, void* p);
  472. void* lstPushPointerSized(laListHandle* h, void* p, int size);
  473. void* lstAppendPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  474. void* lstAppendPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  475. void* lstPushPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  476. void* lstPushPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  477. void* lstPopPointerOnly(laListHandle* h);
  478. void lstRemovePointerItemOnly(laListHandle* h, laListItemPointer* lip);
  479. void lstRemovePointerOnly(laListHandle* h, void* p);
  480. void lstClearPointerOnly(laListHandle* h);
  481. void lstGeneratePointerListOnly(laListHandle* from1, laListHandle* from2, laListHandle* to);
  482. void* lstPopPointer(laListHandle* h);
  483. void lstRemovePointerItem(laListHandle* h, laListItemPointer* lip);
  484. void lstRemovePointer(laListHandle* h, void* p);
  485. void lstRemovePointerLeave(laListHandle *h, void *p);
  486. void lstClearPointer(laListHandle* h);
  487. void lstGeneratePointerList(laListHandle* from1, laListHandle* from2, laListHandle* to);
  488. void lstCopyHandle(laListHandle* target, laListHandle* src);
  489. void* lstAppendPointerStaticPool(laStaticMemoryPool* mph, laListHandle* h, void* p);
  490. void* lstPopPointerLeave(laListHandle* h);
  491. void lstRemovePointerItemNoFree(laListHandle* h, laListItemPointer* lip);
  492. void lstMoveUp(laListHandle* h, laListItem* li);
  493. void lstMoveDown(laListHandle* h, laListItem* li);
  494. void lstForAllItemsDo(laListDoFunc func, laListHandle* hList);
  495. void lstForAllItemsDoLNRR(laListNonRecursiveDoFunc func, laListHandle* hList);
  496. void lstForAllItemsDo_DirectFree(laListDoFunc func, laListHandle* hList);
  497. void lstForAllItemsDo_arg_ptr(laListDoFuncArgp func, laListHandle* hList, void* arg);
  498. void lstForAllItemsDo_NonRecursive_Root(laListHandle* FirstHandle, laListNonRecursiveDoFunc func, int bFreeItem, void* custom_data, laListCustomDataRemover remover);
  499. void lstCopy_NonRecursive_Root(laListHandle* FromHandle, laListHandle* ToHandle, int SizeEachNode, laListNonRecursiveCopyFunc func, void* custom_data, laListCustomDataRemover remover);
  500. void lstAddNonRecursiveListHandle(laListNonRecursiveRoot* root, laListHandle* newHandle, laListNonRecursiveDoFunc nrFunc, int bFreeList, void* custom_data, laListCustomDataRemover remover);
  501. void lstAddNonRecursiveListCopier(laListNonRecursiveRoot* root, laListHandle* oldHandle, laListHandle* newHandle, int sizeEach, laListNonRecursiveCopyFunc nrCpyFunc, void* custom_data, laListCustomDataRemover remover);
  502. void* lstFindItem(void* CmpData, laCompareFunc func, laListHandle* hList);
  503. void lstCombineLists(laListHandle* dest, laListHandle* src);
  504. void lstDestroyList(laListHandle* hlst);
  505. void* lstReMatch(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind);
  506. typedef int(*MatcherFunc)(void*, void*);
  507. void* lstReMatchEx(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind, MatcherFunc func);
  508. void lstAddElement(laListHandle* hlst, void* ext);
  509. void lstDestroyElementList(laListHandle* hlst);
  510. void hsh256InsertItemCSTR(laHash256* hash, laListItem* li, char * buckle);
  511. void hsh256InsertItem(laHash256* hash, laListItem* li, char buckle);
  512. void hsh65536InsertItem(laHash65536* hash, laListItem* li, long buckle);
  513. void hsh65536Init(laHash65536** h);
  514. void hshFree(laHash65536** h);
  515. laListHandle* hsh65536DoHashLongPtr(laHash65536* hash, unsigned long long buckle);
  516. laListHandle* hsh65536DoHashNUID(laHash65536* hash, char * NUID);
  517. laListItem* hsh256FindItemSTR(laHash256* hash, laCompareFunc func, char * buckle);
  518. unsigned char hsh256DoHashSTR(char * buckle);
  519. void memResetByteCount();
  520. int memGetByteCount();
  521. void* memGetHead(void* UserMem, int* HyperLevel);
  522. laListHandle* memGetUserList(void* UserMem);
  523. laMemoryPool *memInitPool(int NodeSize, int HyperLevel);
  524. void memInitPoolSmall(laMemoryPool* mph, int NodeSize);
  525. laMemoryPoolPart* memNewPoolPart(laMemoryPool* mph);
  526. void* memAcquireH(laMemoryPool* Handle);
  527. void* memAcquireSimple(int Size);
  528. void* memAcquireNoAppend(int Size);
  529. void* memAcquireHyperNoAppend(int Size);
  530. void* memAcquire(int Size);
  531. void* memAcquireHyper(int Size);
  532. void memFree(void* Data);
  533. void memDestroyPool(laMemoryPool* Handle);
  534. void memNoLonger();
  535. void memMarkClean(void* HyperUserMem);
  536. void memLeave(void *Data);
  537. void memTake(void* Data);
  538. void memFreeRemainingLeftNodes();
  539. laStaticMemoryPoolNode* memNewStaticPool(laStaticMemoryPool* smp);
  540. void* memStaticAcquire(laStaticMemoryPool*smp, int size);
  541. void* memStaticAcquireThread(laStaticMemoryPool*smp, int size);
  542. void* memStaticDestroy(laStaticMemoryPool*smp);
  543. NEED_STRUCTURE(laSubProp);
  544. void memAssignRef(void* This, void** ptr, void* instance);
  545. void memAssignRefSafe(laSubProp* sp, void* This, void** ptr, void* instance);
  546. char * strSub(char *input, char *substring, char *replace);
  547. int strGetStringTerminateBy(char * content, char terminator, char * Out);
  548. int strHeadOfStringMatch(char * Str, char * SubStr);
  549. int strSkipSegmet(char ** pivot, char * content);
  550. char * strGetLastSegment(char * Content, char Seperator);
  551. void strDiscardLastSegmentSeperateBy(char * Content, char Seperator);
  552. void strDiscardSameBeginningSeperatedBy(char * s1, char * s2, char ** Result1, char ** Result2, char Seperator);
  553. int strCountSegmentSeperateBy(char * Content, char Seperator);
  554. void strMakeDifferentName(char * Target);
  555. void strReplaceCharacter(char * Str, char Find, char Replace);
  556. void strToUpper(char * Str);
  557. void strToLower(char * Str);
  558. int tolowerGuarded(int a);
  559. laStringSplitor *strSplitPath(char *path,char terminator);
  560. int strMakeInstructions(laStringSplitor** result,char * content);
  561. laStringPart* strGetArgument(laStringSplitor* ss, char * content);
  562. char * strGetArgumentString(laStringSplitor* ss, char * content);
  563. int strArgumentMatch(laStringSplitor* ss, char * id, char * value);
  564. int strDestroyStringSplitor(laStringSplitor** ss);
  565. int strGetIntSimple(char * content);
  566. real strGetFloatSimple(char * content);
  567. void strConvInt_CString(int src, char * dest, int lenth);
  568. void strConvFloat_CString(real src, char * dest, int lenth);
  569. void strCopyFull(char * dest, char * src);
  570. void strCopySized(char * dest, int LenthLim, char * src);
  571. #define strAppend strcat
  572. void strPrintFloatAfter(char * dest, int LenthLim, int bits, real data);
  573. void strPrintIntAfter(char * dest, int LenthLim, int data);
  574. int strSame(char * src, char *dest);
  575. void strEscapePath(char* OutCanBeSame, char* path);
  576. void strSafeDestroy(laSafeString** ss);
  577. void strSafeSet(laSafeString** ss, char * Content);
  578. void strSafeAppend(laSafeString **ss, char *Content);
  579. void strSafePrint(laSafeString **ss, char *Format, ...);
  580. void strSafePrintV(laSafeString **ss, char *Format, va_list arg);
  581. void strSafeDump();
  582. #define SSTR(str) (((str) && (str)->Ptr)?(str)->Ptr:"")
  583. void strBeginEdit(laStringEdit** se, char * FullStr);
  584. char* strGetEditString(laStringEdit *se, int SelectionOnly);
  585. char* strEndEdit(laStringEdit** se, int FreeString);
  586. void strSetEditViewRange(laStringEdit* se, int Lines, int Cols);
  587. void strEnsureCursorVisible(laStringEdit* se);
  588. void strRemoveLine(laStringEdit* se, laStringLine* sl);
  589. void strRemoveLineI(laStringEdit* se, int LineIndex);
  590. void strSetCursor(laStringEdit* se, int LineIndex, int BeforeIndex);
  591. void strMoveCursor(laStringEdit* se, int Left, int Select);
  592. void strMoveCursorLine(laStringEdit *se, int Up, int Select);
  593. int strHasSelection(laStringEdit* se);
  594. void strCancelSelect(laStringEdit *se);
  595. void strLazySelect(laStringEdit *se);
  596. void strEndSelect(laStringEdit *se);
  597. void strSelectLineAll(laStringEdit* se);
  598. void strDeselectAll(laStringEdit* se);
  599. void strPanFoward(uint32_t * str, int Before, int Offset);
  600. void strSquishBackward(uint32_t * str, int Before, int EndBefore);
  601. void strClearSelection(laStringEdit* se);
  602. laStringLine *strGetCursorLine(laStringEdit *se, int* IndexIfLast);
  603. laStringLine* strGetBeginLine(laStringEdit* se);
  604. void strInsertChar(laStringEdit* se, uint32_t a);
  605. void strBackspace(laStringEdit* se);
  606. void strMoveView(laStringEdit *se, int DownLines, int RightCharacters);
  607. int laCopyFile(char *to, char *from);
  608. void transNewLanguage(const char * LanguageID);
  609. void transSetLanguage(const char * LanguageID);
  610. void transDumpMissMatchRecord(const char * filename);
  611. void transNewEntry(const char * Target, const char * replacement);
  612. char * transLate(char * Target);
  613. void transState(void* UNUSED, int val);
  614. void transInitTranslation_zh_cn();
  615. void laOpenInternetLink(char* url);
  616. #define SEND_PANIC_ERROR(msg) \
  617. {printf(msg); exit(0);}
  618. #ifdef _WIN32
  619. void usleep(unsigned int usec);
  620. #endif
  621. void laSpinInit(SYSLOCK* lock);
  622. void laSpinDestroy(SYSLOCK * lock);
  623. void laSpinLock(SYSLOCK* lock);
  624. void laSpinUnlock(SYSLOCK* lock);
  625. int terLoadLine(char* buf, int firstline);