*/}}

la_util.h 23 KB

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