*/}}

la_util.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. wchar_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(laBaseNode);
  336. typedef void (*laBaseNodeInitF)(laBaseNode*, int NoCreate);
  337. typedef void (*laBaseNodeDestroyF)(laBaseNode*);
  338. typedef int (*laBaseNodeVisitF)(laBaseNode*, laListHandle*);
  339. typedef int (*laBaseNodeEvalF)(laBaseNode*);
  340. STRUCTURE(laBaseNodeType){
  341. laBaseNodeInitF Init;
  342. laBaseNodeDestroyF Destroy;
  343. laBaseNodeVisitF Visit;
  344. laBaseNodeEvalF Eval;
  345. laPropContainer* pc;
  346. char* TypeName;
  347. char* Name;
  348. int Icon;
  349. int NodeSize;
  350. };
  351. NEED_STRUCTURE(laNodeRack);
  352. STRUCTURE(laBaseNode){
  353. laListItem Item;
  354. laSafeString* Name;
  355. laBaseNodeType* Type;
  356. laNodeRack* InRack;
  357. int Gap; int Eval; int InitDone;
  358. };
  359. #define CreateNew(Type) \
  360. calloc(sizeof(Type),1)
  361. #define CreateNew_Size(size) \
  362. calloc(size,1)
  363. #define CreateNewBuffer(Type,Num) \
  364. calloc(sizeof(Type),Num);
  365. #define FreeMem(ptr) \
  366. nutFreeMem((&ptr))
  367. #define elif \
  368. else if
  369. #define LA_UNAVAILABLE_NAME "- Unknown -"
  370. uint32_t laToUnicode(const unsigned char* ch, int* advance);
  371. int laToUTF8(const uint32_t ch, char* out, char** next);
  372. int strToUnicode(uint32_t* target, unsigned char* const src);
  373. int strToUTF8(unsigned char* target, uint32_t* const src);
  374. int strlenU(uint32_t* const str);
  375. int strcpyU(uint32_t* target, uint32_t* const source );
  376. int strcatU(uint32_t* target, uint32_t* const source );
  377. struct tm* laGetFullTime();
  378. void laRecordTime(laTimeRecorder* tr);
  379. real laTimeElapsedSecondsf(laTimeRecorder* End, laTimeRecorder* Begin);
  380. int laTimeElapsedMilliseconds(laTimeRecorder* End, laTimeRecorder* Begin);
  381. void laSetAuthorInfo(char * Name, char * CopyrightString);
  382. void memCreateNUID(char* buf,laMemNodeHyper* Hyper);
  383. NEED_STRUCTURE(laPropPack);
  384. int nutHyperUserCount(void* instance, laProp* p_optional, int *p_count);
  385. void memHyperInfo(laPropPack* pp, char* buf);
  386. void memMakeHyperData(laMemNodeHyper* hi);
  387. void nutFreeMem(void** ptr);
  388. int nutFloatCompare(real l, real r);
  389. int nutSameAddress(void* l, void* r);
  390. void* arrElement(void* head, int i, int size);
  391. int arrEnsureLength(void** head, int next, int* max, size_t ElementSize);
  392. int arrInitLength(void** head, int max, int* pmax, size_t ElementSize);
  393. void arrFree(void** head, int* max);
  394. void lstPushSingle(void** Head, laListSingle* Item);
  395. void* lstPopSingle(void** Head, laListSingle* Item);
  396. void lstClearPrevNext(laListItem* li);
  397. int lstCountElements(laListHandle* Handle);
  398. void lstAppendItem(laListHandle* Handle, void* Item);
  399. void lstPushItem(laListHandle* Handle, void* Item);
  400. void* lstPopItem(laListHandle* Handle) ;
  401. void lstAppendItem2(laListHandle* Handle, void* Item);
  402. void* lstPopItem2(laListHandle* Handle);
  403. void lstPushItem2(laListHandle* Handle, void* Item);
  404. void lstAppendItem3(laListHandle* Handle, void* Item);
  405. void* lstPopItem3(laListHandle* Handle);
  406. void lstPushItem3(laListHandle* Handle, void* Item);
  407. int lstRemoveItem(laListHandle* Handle, laListItem* li) ;
  408. int lstRemoveItem2(laListHandle* Handle, laListItem2* li);
  409. int lstRemoveSegment(laListHandle* Handle, laListItem* Begin, laListItem* End);
  410. void lstInsertItemBefore(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  411. void lstInsertItemAfter(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  412. void lstInsertSegmentBefore(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  413. void lstInsertSegmentAfter(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  414. int lstHaveItemInList(laListHandle* Handle);
  415. /**/ void* lstGetTop(laListHandle* Handle);
  416. void lstPushSimpleItem(void** first, laItemUserLinker* iul);
  417. void* lstPushItemUser(void** first, void* p);
  418. void* lstPushItemUsing(void** first, void* p);
  419. void* lstAppendPointerOnly(laListHandle* h, void* p);
  420. void* lstAppendPointerSizedOnly(laListHandle* h, void* p, int size);
  421. void* lstPushPointerOnly(laListHandle* h, void* p);
  422. void* lstPushPointerSizedOnly(laListHandle* h, void* p, int size);
  423. void lstReverse(laListHandle* h);
  424. int lstHasPointer(laListHandle* h, void *p);
  425. void* lstAppendPointer(laListHandle* h, void* p);
  426. void* lstAppendPointerSized(laListHandle* h, void* p, int size);
  427. void* lstPushPointer(laListHandle* h, void* p);
  428. void* lstPushPointerSized(laListHandle* h, void* p, int size);
  429. void* lstAppendPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  430. void* lstAppendPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  431. void* lstPushPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  432. void* lstPushPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  433. void* lstPopPointerOnly(laListHandle* h);
  434. void lstRemovePointerItemOnly(laListHandle* h, laListItemPointer* lip);
  435. void lstRemovePointerOnly(laListHandle* h, void* p);
  436. void lstClearPointerOnly(laListHandle* h);
  437. void lstGeneratePointerListOnly(laListHandle* from1, laListHandle* from2, laListHandle* to);
  438. void* lstPopPointer(laListHandle* h);
  439. void lstRemovePointerItem(laListHandle* h, laListItemPointer* lip);
  440. void lstRemovePointer(laListHandle* h, void* p);
  441. void lstRemovePointerLeave(laListHandle *h, void *p);
  442. void lstClearPointer(laListHandle* h);
  443. void lstGeneratePointerList(laListHandle* from1, laListHandle* from2, laListHandle* to);
  444. void lstCopyHandle(laListHandle* target, laListHandle* src);
  445. void* lstAppendPointerStaticPool(laStaticMemoryPool* mph, laListHandle* h, void* p);
  446. void* lstPopPointerLeave(laListHandle* h);
  447. void lstRemovePointerItemNoFree(laListHandle* h, laListItemPointer* lip);
  448. void lstMoveUp(laListHandle* h, laListItem* li);
  449. void lstMoveDown(laListHandle* h, laListItem* li);
  450. void lstForAllItemsDo(laListDoFunc func, laListHandle* hList);
  451. void lstForAllItemsDoLNRR(laListNonRecursiveDoFunc func, laListHandle* hList);
  452. void lstForAllItemsDo_DirectFree(laListDoFunc func, laListHandle* hList);
  453. void lstForAllItemsDo_arg_ptr(laListDoFuncArgp func, laListHandle* hList, void* arg);
  454. void lstForAllItemsDo_NonRecursive_Root(laListHandle* FirstHandle, laListNonRecursiveDoFunc func, int bFreeItem, void* custom_data, laListCustomDataRemover remover);
  455. void lstCopy_NonRecursive_Root(laListHandle* FromHandle, laListHandle* ToHandle, int SizeEachNode, laListNonRecursiveCopyFunc func, void* custom_data, laListCustomDataRemover remover);
  456. void lstAddNonRecursiveListHandle(laListNonRecursiveRoot* root, laListHandle* newHandle, laListNonRecursiveDoFunc nrFunc, int bFreeList, void* custom_data, laListCustomDataRemover remover);
  457. void lstAddNonRecursiveListCopier(laListNonRecursiveRoot* root, laListHandle* oldHandle, laListHandle* newHandle, int sizeEach, laListNonRecursiveCopyFunc nrCpyFunc, void* custom_data, laListCustomDataRemover remover);
  458. void* lstFindItem(void* CmpData, laCompareFunc func, laListHandle* hList);
  459. void lstCombineLists(laListHandle* dest, laListHandle* src);
  460. void lstDestroyList(laListHandle* hlst);
  461. void* lstReMatch(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind);
  462. typedef int(*MatcherFunc)(void*, void*);
  463. void* lstReMatchEx(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind, MatcherFunc func);
  464. void lstAddElement(laListHandle* hlst, void* ext);
  465. void lstDestroyElementList(laListHandle* hlst);
  466. void hsh256InsertItemCSTR(laHash256* hash, laListItem* li, char * buckle);
  467. void hsh256InsertItem(laHash256* hash, laListItem* li, char buckle);
  468. void hsh65536InsertItem(laHash65536* hash, laListItem* li, long buckle);
  469. void hsh65536Init(laHash65536** h);
  470. void hshFree(laHash65536** h);
  471. laListHandle* hsh65536DoHashLongPtr(laHash65536* hash, unsigned long long buckle);
  472. laListHandle* hsh65536DoHashNUID(laHash65536* hash, char * NUID);
  473. laListHandle* hsh16MDoHashLongPtr(laHash16M* hash, long long buckle);
  474. laListHandle* hsh16MDoHashNUID(laHash16M* hash, char * NUID);
  475. laListItem* hsh256FindItemSTR(laHash256* hash, laCompareFunc func, char * buckle);
  476. unsigned char hsh256DoHashSTR(char * buckle);
  477. void memResetByteCount();
  478. int memGetByteCount();
  479. void* memGetHead(void* UserMem, int* HyperLevel);
  480. laListHandle* memGetUserList(void* UserMem);
  481. laMemoryPool *memInitPool(int NodeSize, int HyperLevel);
  482. void memInitPoolSmall(laMemoryPool* mph, int NodeSize);
  483. laMemoryPoolPart* memNewPoolPart(laMemoryPool* mph);
  484. void* memAcquireH(laMemoryPool* Handle);
  485. void* memAcquireSimple(int Size);
  486. void* memAcquireNoAppend(int Size);
  487. void* memAcquireHyperNoAppend(int Size);
  488. void* memAcquire(int Size);
  489. void* memAcquireHyper(int Size);
  490. void memFree(void* Data);
  491. void memDestroyPool(laMemoryPool* Handle);
  492. void memNoLonger();
  493. void memMarkClean(void* HyperUserMem);
  494. void memLeave(void *Data);
  495. void memTake(void* Data);
  496. void memFreeRemainingLeftNodes();
  497. laStaticMemoryPoolNode* memNewStaticPool(laStaticMemoryPool* smp);
  498. void* memStaticAcquire(laStaticMemoryPool*smp, int size);
  499. void* memStaticAcquireThread(laStaticMemoryPool*smp, int size);
  500. void* memStaticDestroy(laStaticMemoryPool*smp);
  501. NEED_STRUCTURE(laSubProp);
  502. void memAssignRef(void* This, void** ptr, void* instance);
  503. void memAssignRefSafe(laSubProp* sp, void* This, void** ptr, void* instance);
  504. char * strSub(char *input, char *substring, char *replace);
  505. int strGetStringTerminateBy(char * content, char terminator, char * Out);
  506. int strHeadOfStringMatch(char * Str, char * SubStr);
  507. int strSkipSegmet(char ** pivot, char * content);
  508. char * strGetLastSegment(char * Content, char Seperator);
  509. void strDiscardLastSegmentSeperateBy(char * Content, char Seperator);
  510. void strDiscardSameBeginningSeperatedBy(char * s1, char * s2, char ** Result1, char ** Result2, char Seperator);
  511. int strCountSegmentSeperateBy(char * Content, char Seperator);
  512. void strMakeDifferentName(char * Target);
  513. void strReplaceCharacter(char * Str, char Find, char Replace);
  514. void strToUpper(char * Str);
  515. void strToLower(char * Str);
  516. laStringSplitor *strSplitPath(char *path,char terminator);
  517. int strMakeInstructions(laStringSplitor** result,char * content);
  518. laStringPart* strGetArgument(laStringSplitor* ss, char * content);
  519. char * strGetArgumentString(laStringSplitor* ss, char * content);
  520. int strArgumentMatch(laStringSplitor* ss, char * id, char * value);
  521. int strDestroyStringSplitor(laStringSplitor** ss);
  522. int strGetIntSimple(char * content);
  523. real strGetFloatSimple(char * content);
  524. void strConvInt_CString(int src, char * dest, int lenth);
  525. void strConvFloat_CString(real src, char * dest, int lenth);
  526. void strCopyFull(char * dest, char * src);
  527. void strCopySized(char * dest, int LenthLim, char * src);
  528. #define strAppend strcat
  529. void strPrintFloatAfter(char * dest, int LenthLim, int bits, real data);
  530. void strPrintIntAfter(char * dest, int LenthLim, int data);
  531. int strSame(char * src, char *dest);
  532. void strEscapePath(char* OutCanBeSame, char* path);
  533. void strSafeDestroy(laSafeString** ss);
  534. void strSafeSet(laSafeString** ss, char * Content);
  535. void strSafeAppend(laSafeString **ss, char *Content);
  536. void strSafePrint(laSafeString **ss, char *Format, ...);
  537. void strSafePrintV(laSafeString **ss, char *Format, va_list arg);
  538. void strSafeDump();
  539. void strBeginEdit(laStringEdit** se, char * FullStr);
  540. char* strGetEditString(laStringEdit *se, int SelectionOnly);
  541. char* strEndEdit(laStringEdit** se, int FreeString);
  542. void strSetEditViewRange(laStringEdit* se, int Lines, int Cols);
  543. void strEnsureCursorVisible(laStringEdit* se);
  544. void strRemoveLine(laStringEdit* se, laStringLine* sl);
  545. void strRemoveLineI(laStringEdit* se, int LineIndex);
  546. void strSetCursor(laStringEdit* se, int LineIndex, int BeforeIndex);
  547. void strMoveCursor(laStringEdit* se, int Left, int Select);
  548. void strMoveCursorLine(laStringEdit *se, int Up, int Select);
  549. int strHasSelection(laStringEdit* se);
  550. void strCancelSelect(laStringEdit *se);
  551. void strLazySelect(laStringEdit *se);
  552. void strEndSelect(laStringEdit *se);
  553. void strSelectLineAll(laStringEdit* se);
  554. void strDeselectAll(laStringEdit* se);
  555. void strPanFoward(uint32_t * str, int Before, int Offset);
  556. void strSquishBackward(uint32_t * str, int Before, int EndBefore);
  557. void strClearSelection(laStringEdit* se);
  558. laStringLine *strGetCursorLine(laStringEdit *se, int* IndexIfLast);
  559. laStringLine* strGetBeginLine(laStringEdit* se);
  560. void strInsertChar(laStringEdit* se, uint32_t a);
  561. void strBackspace(laStringEdit* se);
  562. void strMoveView(laStringEdit *se, int DownLines, int RightCharacters);
  563. int laCopyFile(char *to, char *from);
  564. void transNewLanguage(const char * LanguageID);
  565. void transSetLanguage(const char * LanguageID);
  566. void transDumpMissMatchRecord(const char * filename);
  567. void transNewEntry(const char * Target, const char * replacement);
  568. char * transLate(char * Target);
  569. void transState(void* UNUSED, int val);
  570. void transInitTranslation_zh_cn();
  571. void laOpenInternetLink(char* url);
  572. #define SEND_PANIC_ERROR(msg) \
  573. {printf(msg); exit(0);}
  574. #ifdef _WIN32
  575. void usleep(unsigned int usec);
  576. #endif