*/}}

la_util.h 22 KB

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