*/}}
1
0

la_util.h 22 KB

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