*/}}

la_util.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. #define SYSWINDOW HWND
  43. #define SYSGLCONTEXT HGLRC
  44. #define SYSTEMDC HDC
  45. #define SYSTEMRC HRC
  46. #define SYSTEMDISPLAY int
  47. #define PATH_MAX 4096
  48. #endif
  49. #define NEED_STRUCTURE(a) \
  50. typedef struct _##a a;
  51. #define STRUCTURE(a) \
  52. typedef struct _##a a;\
  53. struct _##a
  54. #define lengthof(a) \
  55. (sizeof(a)/sizeof(a[0]))
  56. #ifdef _WIN32
  57. #define LA_PATH_SEP '\\'
  58. #define LA_PATH_SEPSTR "\\"
  59. #else
  60. #define LA_PATH_SEP '/'
  61. #define LA_PATH_SEPSTR "/"
  62. #endif
  63. #define DBL_TRIANGLE_LIM 1e-11
  64. #define DBL_EDGE_LIM 1e-9
  65. #ifndef LAGUI_GIT_BRANCH
  66. #define LAGUI_GIT_BRANCH "Release 1"
  67. #endif
  68. // No need to show hash when not compiled from git repo.
  69. //#ifndef LAGUI_GIT_HASH
  70. //#define LAGUI_GIT_HASH "?"
  71. //#endif
  72. #define LA_HYPER_CREATED_TIME(hi) \
  73. hi->TimeCreated.Year,hi->TimeCreated.Month,hi->TimeCreated.Day,hi->TimeCreated.Hour,hi->TimeCreated.Minute,hi->TimeCreated.Second
  74. typedef double real;
  75. typedef unsigned long long u64bit;
  76. typedef unsigned int u32bit;
  77. typedef unsigned short u16bit;
  78. typedef unsigned short ushort;
  79. typedef unsigned char u8bit;
  80. typedef struct _laListSingle laListSingle;
  81. struct _laListSingle {
  82. void* pNext;
  83. };
  84. typedef struct _laListHandle laListHandle;
  85. struct _laListHandle {
  86. void* pFirst;
  87. void* pLast;
  88. };
  89. typedef struct _laListWithPivot laListWithPivot;
  90. struct _laListWithPivot {
  91. void* pFirst;
  92. void* pLast;
  93. void* Pivot;
  94. };
  95. typedef struct _laListItem laListItem;
  96. struct _laListItem {
  97. void* pPrev;
  98. void* pNext;
  99. };
  100. typedef struct _laListItem2 laListItem2;
  101. struct _laListItem2 {
  102. void* O1;
  103. void* O2;
  104. void* pPrev;
  105. void* pNext;
  106. };
  107. typedef struct _laListItem3 laListItem3;
  108. struct _laListItem3 {
  109. void* O1;
  110. void* O2;
  111. void* O3;
  112. void* O4;
  113. void* pPrev;
  114. void* pNext;
  115. };
  116. NEED_STRUCTURE(laSafeString);
  117. STRUCTURE(laAuthorInfo) {
  118. laListItem Item;
  119. laSafeString* Name;
  120. laSafeString* CopyrightString;
  121. };
  122. STRUCTURE(laTimeInfo) {
  123. u16bit Year;//Also Used As Timer [ms] counter
  124. u8bit Month;
  125. u8bit Day;
  126. u8bit Hour;
  127. u8bit Minute;
  128. u8bit Second;
  129. };
  130. NEED_STRUCTURE(laPropContainer);
  131. typedef struct _laUID laUID;
  132. struct _laUID {
  133. char String[32];//a simplified uuid, example: 0E3F9BA4802FDDC2-20160601123546 [\0]
  134. };
  135. typedef struct _laListItemPointer laListItemPointer;
  136. struct _laListItemPointer {
  137. void* pPrev;
  138. void* pNext;
  139. void* p;
  140. };
  141. typedef struct _laItemUserLinker laItemUserLinker;
  142. typedef void(*laUserRemoveFunc)(void* This, laItemUserLinker* iul);
  143. NEED_STRUCTURE(laProp);
  144. struct _laItemUserLinker {
  145. laListItemPointer Pointer;
  146. laUserRemoveFunc Remove;
  147. laProp* Which;
  148. void* Additional;
  149. unsigned int FrameDistinguish;
  150. int ForceRecalc;
  151. };
  152. typedef struct _laItemUserLinkerLocal laItemUserLinkerLocal;
  153. struct _laItemUserLinkerLocal {
  154. laItemUserLinker Link;
  155. void* Instance;
  156. };
  157. typedef struct _laElementListItem laElementListItem;
  158. struct _laElementListItem {
  159. laListItem Item;
  160. void* Ext;
  161. };
  162. typedef struct _laListNonRecursiveRoot laListNonRecursiveRoot;
  163. struct _laListNonRecursiveRoot {
  164. laListHandle NSItems;
  165. };
  166. typedef int(*laCompareFunc)(void*, void*);
  167. typedef void(*laListDoFunc)(void*);
  168. typedef void(*laListNonRecursiveDoFunc)(laListNonRecursiveRoot*, void*, void*);//item,custom
  169. typedef void(*laListNonRecursiveCopyFunc)(laListNonRecursiveRoot*, void*, void*, void*);//old,new,custom
  170. typedef void(*laListDoFuncArgp)(void*, void*);
  171. typedef void(*laCopyListFunc)(void*, void*);
  172. typedef void(*laListCustomDataRemover)(void*);
  173. //typedef void(*ListMatcherFunc)(void*,void*);//gotten value,enumed curent lst item.
  174. typedef struct _laListNonRecursiveItem laListNonRecursiveItem;
  175. struct _laListNonRecursiveItem {
  176. laListItem Item;
  177. laListHandle handle;
  178. laListHandle *ToHandle;//This Is Pointer!
  179. laListNonRecursiveDoFunc func;
  180. laListNonRecursiveCopyFunc CopyFunc;
  181. laListCustomDataRemover remover;
  182. void* CustomData;
  183. int bFreeList;
  184. int SizeEachNode;
  185. };
  186. typedef struct _laHash256 laHash256;
  187. struct _laHash256 {
  188. laListHandle Entries[256];
  189. };
  190. typedef struct _laHash65536 laHash65536;
  191. struct _laHash65536 {
  192. laListHandle Entries[65536];
  193. //laHash256 HashHandles[256];
  194. };
  195. typedef struct _laHash16M laHash16M;
  196. struct _laHash16M {
  197. laListHandle Entries[16777216];
  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. wchar_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. //pthread_spinlock_t 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(laBaseNode);
  334. typedef void (*laBaseNodeInitF)(laBaseNode*, int NoCreate);
  335. typedef void (*laBaseNodeDestroyF)(laBaseNode*);
  336. typedef int (*laBaseNodeVisitF)(laBaseNode*, laListHandle*);
  337. typedef int (*laBaseNodeEvalF)(laBaseNode*);
  338. STRUCTURE(laBaseNodeType){
  339. laBaseNodeInitF Init;
  340. laBaseNodeDestroyF Destroy;
  341. laBaseNodeVisitF Visit;
  342. laBaseNodeEvalF Eval;
  343. laPropContainer* pc;
  344. char* TypeName;
  345. char* Name;
  346. int Icon;
  347. int NodeSize;
  348. };
  349. NEED_STRUCTURE(laNodeRack);
  350. STRUCTURE(laBaseNode){
  351. laListItem Item;
  352. laSafeString* Name;
  353. laBaseNodeType* Type;
  354. laNodeRack* InRack;
  355. int Gap; int Eval; int InitDone;
  356. };
  357. #define CreateNew(Type) \
  358. calloc(sizeof(Type),1)
  359. #define CreateNew_Size(size) \
  360. calloc(size,1)
  361. #define CreateNewBuffer(Type,Num) \
  362. calloc(sizeof(Type),Num);
  363. #define FreeMem(ptr) \
  364. nutFreeMem((&ptr))
  365. #define elif \
  366. else if
  367. #define LA_UNAVAILABLE_NAME "- Unknown -"
  368. uint32_t laToUnicode(const unsigned char* ch, int* advance);
  369. int laToUTF8(const uint32_t ch, char* out, char** next);
  370. int strToUnicode(uint32_t* target, unsigned char* const src);
  371. int strToUTF8(unsigned char* target, uint32_t* const src);
  372. int strlenU(uint32_t* const str);
  373. int strcpyU(uint32_t* target, uint32_t* const source );
  374. int strcatU(uint32_t* target, uint32_t* const source );
  375. struct tm* laGetFullTime();
  376. void laRecordTime(laTimeRecorder* tr);
  377. real laTimeElapsedSecondsf(laTimeRecorder* End, laTimeRecorder* Begin);
  378. int laTimeElapsedMilliseconds(laTimeRecorder* End, laTimeRecorder* Begin);
  379. void laSetAuthorInfo(char * Name, char * CopyrightString);
  380. void memCreateNUID(char* buf,laMemNodeHyper* Hyper);
  381. NEED_STRUCTURE(laPropPack);
  382. int nutHyperUserCount(void* instance, laProp* p_optional, int *p_count);
  383. void memHyperInfo(laPropPack* pp, char* buf);
  384. void memMakeHyperData(laMemNodeHyper* hi);
  385. void nutFreeMem(void** ptr);
  386. int nutFloatCompare(real l, real r);
  387. int nutSameAddress(void* l, void* r);
  388. void* arrElement(void* head, int i, int size);
  389. int arrEnsureLength(void** head, int next, int* max, size_t ElementSize);
  390. int arrInitLength(void** head, int max, int* pmax, size_t ElementSize);
  391. void arrFree(void** head, int* max);
  392. void lstPushSingle(void** Head, laListSingle* Item);
  393. void* lstPopSingle(void** Head, laListSingle* Item);
  394. void lstClearPrevNext(laListItem* li);
  395. int lstCountElements(laListHandle* Handle);
  396. void lstAppendItem(laListHandle* Handle, void* Item);
  397. void lstPushItem(laListHandle* Handle, void* Item);
  398. void* lstPopItem(laListHandle* Handle) ;
  399. void lstAppendItem2(laListHandle* Handle, void* Item);
  400. void* lstPopItem2(laListHandle* Handle);
  401. void lstPushItem2(laListHandle* Handle, void* Item);
  402. void lstAppendItem3(laListHandle* Handle, void* Item);
  403. void* lstPopItem3(laListHandle* Handle);
  404. void lstPushItem3(laListHandle* Handle, void* Item);
  405. int lstRemoveItem(laListHandle* Handle, laListItem* li) ;
  406. int lstRemoveItem2(laListHandle* Handle, laListItem2* li);
  407. int lstRemoveSegment(laListHandle* Handle, laListItem* Begin, laListItem* End);
  408. void lstInsertItemBefore(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  409. void lstInsertItemAfter(laListHandle* Handle, laListItem* toIns, laListItem* pivot);
  410. void lstInsertSegmentBefore(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  411. void lstInsertSegmentAfter(laListHandle* Handle, laListItem* Begin, laListItem* End, laListItem* pivot);
  412. int lstHaveItemInList(laListHandle* Handle);
  413. /**/ void* lstGetTop(laListHandle* Handle);
  414. void lstPushSimpleItem(void** first, laItemUserLinker* iul);
  415. void* lstPushItemUser(void** first, void* p);
  416. void* lstPushItemUsing(void** first, void* p);
  417. void* lstAppendPointerOnly(laListHandle* h, void* p);
  418. void* lstAppendPointerSizedOnly(laListHandle* h, void* p, int size);
  419. void* lstPushPointerOnly(laListHandle* h, void* p);
  420. void* lstPushPointerSizedOnly(laListHandle* h, void* p, int size);
  421. void lstReverse(laListHandle* h);
  422. int lstHasPointer(laListHandle* h, void *p);
  423. void* lstAppendPointer(laListHandle* h, void* p);
  424. void* lstAppendPointerSized(laListHandle* h, void* p, int size);
  425. void* lstPushPointer(laListHandle* h, void* p);
  426. void* lstPushPointerSized(laListHandle* h, void* p, int size);
  427. void* lstAppendPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  428. void* lstAppendPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  429. void* lstPushPointerStatic(laListHandle* h, laStaticMemoryPool* smp, void* p);
  430. void* lstPushPointerStaticSized(laListHandle* h, laStaticMemoryPool* smp, void* p, int size);
  431. void* lstPopPointerOnly(laListHandle* h);
  432. void lstRemovePointerItemOnly(laListHandle* h, laListItemPointer* lip);
  433. void lstRemovePointerOnly(laListHandle* h, void* p);
  434. void lstClearPointerOnly(laListHandle* h);
  435. void lstGeneratePointerListOnly(laListHandle* from1, laListHandle* from2, laListHandle* to);
  436. void* lstPopPointer(laListHandle* h);
  437. void lstRemovePointerItem(laListHandle* h, laListItemPointer* lip);
  438. void lstRemovePointer(laListHandle* h, void* p);
  439. void lstRemovePointerLeave(laListHandle *h, void *p);
  440. void lstClearPointer(laListHandle* h);
  441. void lstGeneratePointerList(laListHandle* from1, laListHandle* from2, laListHandle* to);
  442. void lstCopyHandle(laListHandle* target, laListHandle* src);
  443. void* lstAppendPointerStaticPool(laStaticMemoryPool* mph, laListHandle* h, void* p);
  444. void* lstPopPointerLeave(laListHandle* h);
  445. void lstRemovePointerItemNoFree(laListHandle* h, laListItemPointer* lip);
  446. void lstMoveUp(laListHandle* h, laListItem* li);
  447. void lstMoveDown(laListHandle* h, laListItem* li);
  448. void lstForAllItemsDo(laListDoFunc func, laListHandle* hList);
  449. void lstForAllItemsDoLNRR(laListNonRecursiveDoFunc func, laListHandle* hList);
  450. void lstForAllItemsDo_DirectFree(laListDoFunc func, laListHandle* hList);
  451. void lstForAllItemsDo_arg_ptr(laListDoFuncArgp func, laListHandle* hList, void* arg);
  452. void lstForAllItemsDo_NonRecursive_Root(laListHandle* FirstHandle, laListNonRecursiveDoFunc func, int bFreeItem, void* custom_data, laListCustomDataRemover remover);
  453. void lstCopy_NonRecursive_Root(laListHandle* FromHandle, laListHandle* ToHandle, int SizeEachNode, laListNonRecursiveCopyFunc func, void* custom_data, laListCustomDataRemover remover);
  454. void lstAddNonRecursiveListHandle(laListNonRecursiveRoot* root, laListHandle* newHandle, laListNonRecursiveDoFunc nrFunc, int bFreeList, void* custom_data, laListCustomDataRemover remover);
  455. void lstAddNonRecursiveListCopier(laListNonRecursiveRoot* root, laListHandle* oldHandle, laListHandle* newHandle, int sizeEach, laListNonRecursiveCopyFunc nrCpyFunc, void* custom_data, laListCustomDataRemover remover);
  456. void* lstFindItem(void* CmpData, laCompareFunc func, laListHandle* hList);
  457. void lstCombineLists(laListHandle* dest, laListHandle* src);
  458. void lstDestroyList(laListHandle* hlst);
  459. void* lstReMatch(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind);
  460. typedef int(*MatcherFunc)(void*, void*);
  461. void* lstReMatchEx(laListHandle* SearchHandle, laListHandle* CurrentHandle, void* ItemToFind, MatcherFunc func);
  462. void lstAddElement(laListHandle* hlst, void* ext);
  463. void lstDestroyElementList(laListHandle* hlst);
  464. void hsh256InsertItemCSTR(laHash256* hash, laListItem* li, char * buckle);
  465. void hsh256InsertItem(laHash256* hash, laListItem* li, char buckle);
  466. void hsh65536InsertItem(laHash65536* hash, laListItem* li, long buckle);
  467. void hsh65536Init(laHash65536** h);
  468. void hshFree(laHash65536** h);
  469. laListHandle* hsh65536DoHashLongPtr(laHash65536* hash, unsigned long long buckle);
  470. laListHandle* hsh65536DoHashNUID(laHash65536* hash, char * NUID);
  471. laListHandle* hsh16MDoHashLongPtr(laHash16M* hash, long long buckle);
  472. laListHandle* hsh16MDoHashNUID(laHash16M* hash, char * NUID);
  473. laListItem* hsh256FindItemSTR(laHash256* hash, laCompareFunc func, char * buckle);
  474. unsigned char hsh256DoHashSTR(char * buckle);
  475. void memResetByteCount();
  476. int memGetByteCount();
  477. void* memGetHead(void* UserMem, int* HyperLevel);
  478. laListHandle* memGetUserList(void* UserMem);
  479. laMemoryPool *memInitPool(int NodeSize, int HyperLevel);
  480. void memInitPoolSmall(laMemoryPool* mph, int NodeSize);
  481. laMemoryPoolPart* memNewPoolPart(laMemoryPool* mph);
  482. void* memAcquireH(laMemoryPool* Handle);
  483. void* memAcquireSimple(int Size);
  484. void* memAcquireNoAppend(int Size);
  485. void* memAcquireHyperNoAppend(int Size);
  486. void* memAcquire(int Size);
  487. void* memAcquireHyper(int Size);
  488. void memFree(void* Data);
  489. void memDestroyPool(laMemoryPool* Handle);
  490. void memNoLonger();
  491. void memMarkClean(void* HyperUserMem);
  492. void memLeave(void *Data);
  493. void memTake(void* Data);
  494. void memFreeRemainingLeftNodes();
  495. laStaticMemoryPoolNode* memNewStaticPool(laStaticMemoryPool* smp);
  496. void* memStaticAcquire(laStaticMemoryPool*smp, int size);
  497. void* memStaticAcquireThread(laStaticMemoryPool*smp, int size);
  498. void* memStaticDestroy(laStaticMemoryPool*smp);
  499. NEED_STRUCTURE(laSubProp);
  500. void memAssignRef(void* This, void** ptr, void* instance);
  501. void memAssignRefSafe(laSubProp* sp, void* This, void** ptr, void* instance);
  502. char * strSub(char *input, char *substring, char *replace);
  503. int strGetStringTerminateBy(char * content, char terminator, char * Out);
  504. int strHeadOfStringMatch(char * Str, char * SubStr);
  505. int strSkipSegmet(char ** pivot, char * content);
  506. char * strGetLastSegment(char * Content, char Seperator);
  507. void strDiscardLastSegmentSeperateBy(char * Content, char Seperator);
  508. void strDiscardSameBeginningSeperatedBy(char * s1, char * s2, char ** Result1, char ** Result2, char Seperator);
  509. int strCountSegmentSeperateBy(char * Content, char Seperator);
  510. void strMakeDifferentName(char * Target);
  511. void strReplaceCharacter(char * Str, char Find, char Replace);
  512. void strToUpper(char * Str);
  513. void strToLower(char * Str);
  514. laStringSplitor *strSplitPath(char *path,char terminator);
  515. int strMakeInstructions(laStringSplitor** result,char * content);
  516. laStringPart* strGetArgument(laStringSplitor* ss, char * content);
  517. char * strGetArgumentString(laStringSplitor* ss, char * content);
  518. int strArgumentMatch(laStringSplitor* ss, char * id, char * value);
  519. int strDestroyStringSplitor(laStringSplitor** ss);
  520. int strGetIntSimple(char * content);
  521. real strGetFloatSimple(char * content);
  522. void strConvInt_CString(int src, char * dest, int lenth);
  523. void strConvFloat_CString(real src, char * dest, int lenth);
  524. void strCopyFull(char * dest, char * src);
  525. void strCopySized(char * dest, int LenthLim, char * src);
  526. #define strAppend strcat
  527. void strPrintFloatAfter(char * dest, int LenthLim, int bits, real data);
  528. void strPrintIntAfter(char * dest, int LenthLim, int data);
  529. int strSame(char * src, char *dest);
  530. void strEscapePath(char* OutCanBeSame, char* path);
  531. void strSafeDestroy(laSafeString** ss);
  532. void strSafeSet(laSafeString** ss, char * Content);
  533. void strSafeAppend(laSafeString **ss, char *Content);
  534. void strSafePrint(laSafeString **ss, char *Format, ...);
  535. void strSafePrintV(laSafeString **ss, char *Format, va_list arg);
  536. void strSafeDump();
  537. void strBeginEdit(laStringEdit** se, char * FullStr);
  538. char* strGetEditString(laStringEdit *se, int SelectionOnly);
  539. char* strEndEdit(laStringEdit** se, int FreeString);
  540. void strSetEditViewRange(laStringEdit* se, int Lines, int Cols);
  541. void strEnsureCursorVisible(laStringEdit* se);
  542. void strRemoveLine(laStringEdit* se, laStringLine* sl);
  543. void strRemoveLineI(laStringEdit* se, int LineIndex);
  544. void strSetCursor(laStringEdit* se, int LineIndex, int BeforeIndex);
  545. void strMoveCursor(laStringEdit* se, int Left, int Select);
  546. void strMoveCursorLine(laStringEdit *se, int Up, int Select);
  547. int strHasSelection(laStringEdit* se);
  548. void strCancelSelect(laStringEdit *se);
  549. void strLazySelect(laStringEdit *se);
  550. void strEndSelect(laStringEdit *se);
  551. void strSelectLineAll(laStringEdit* se);
  552. void strDeselectAll(laStringEdit* se);
  553. void strPanFoward(uint32_t * str, int Before, int Offset);
  554. void strSquishBackward(uint32_t * str, int Before, int EndBefore);
  555. void strClearSelection(laStringEdit* se);
  556. laStringLine *strGetCursorLine(laStringEdit *se, int* IndexIfLast);
  557. laStringLine* strGetBeginLine(laStringEdit* se);
  558. void strInsertChar(laStringEdit* se, uint32_t a);
  559. void strBackspace(laStringEdit* se);
  560. void strMoveView(laStringEdit *se, int DownLines, int RightCharacters);
  561. int laCopyFile(char *to, char *from);
  562. void transNewLanguage(const char * LanguageID);
  563. void transSetLanguage(const char * LanguageID);
  564. void transDumpMissMatchRecord(const char * filename);
  565. void transNewEntry(const char * Target, const char * replacement);
  566. char * transLate(char * Target);
  567. void transState(void* UNUSED, int val);
  568. void transInitTranslation_zh_cn();
  569. void laOpenInternetLink(char* url);
  570. #define SEND_PANIC_ERROR(msg) \
  571. {printf(msg); exit(0);}
  572. #ifdef _WIN32
  573. void usleep(unsigned int usec);
  574. #endif