*/}}

la_util.h 22 KB

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