*/}}

la_util.h 21 KB

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