*/}}

la_util.h 22 KB

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