*/}}

la_util.h 20 KB

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