*/}}

la_util.h 22 KB

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