SWILIB API (NSG)    
Loading...
Searching...
No Matches
wstring.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef __IN_SWILIB__
4#include "base.h"
5#endif
6
8
17typedef struct WSBODY WSBODY;
18typedef struct WSHDR WSHDR;
19
23#pragma pack(1)
24struct WSBODY {
25 uint16_t len;
26 uint16_t data[];
27};
28#pragma pack()
29
30#define wsbody(ws) ((WSBODY *) ((ws)->wsbody))
31
43
49__swi_begin(0x125)
50WSHDR *AllocWS(int size)
51__swi_end(0x125, AllocWS, (size));
52
60__swi_begin(0x128)
61WSHDR *CreateWS(malloc_func_t malloc_func, mfree_func_t mfree_func, int size)
62__swi_end(0x128, CreateWS, (malloc_func, mfree_func, size));
63
71__swi_begin(0x127)
72WSHDR *CreateLocalWS(WSHDR *header, uint16_t *body, int size)
73__swi_end(0x127, CreateLocalWS, (header, body, size));
74
79__swi_begin(0x129)
80void FreeWS(WSHDR *str)
81__swi_end(0x129, FreeWS, (str));
82
88__swi_begin(0x126)
89void CutWSTR(WSHDR *str, int length)
90__swi_end(0x126, CutWSTR, (str, length));
91
97__swi_begin(0x01C)
98void wsAppendChar(WSHDR *destination, int character)
99__swi_end(0x01C, wsAppendChar, (destination, character));
100
107__swi_begin(0x0A2)
108uint16_t wsCharAt(const WSHDR *str, short pos)
109__swi_end(0x0A2, wsCharAt, (str, pos));
110
116__swi_begin(0x3DC)
118__swi_end(0x3DC, GetUnicodeSymbolByDynIcon, (dyn_icon));
119
127__swi_begin(0x01D)
128int wsInsertChar(WSHDR *destination, int character, int position)
129__swi_end(0x01D, wsInsertChar, (destination, character, position));
130
137__swi_begin(0x215)
138void wsRemoveChars(WSHDR *destination, int position, int length)
139__swi_end(0x215, wsRemoveChars, (destination, position, length));
140
147__swi_begin(0x11F)
148WSHDR *wstrcpy(WSHDR *destination, WSHDR *source)
149__swi_end(0x11F, wstrcpy, (destination, source));
150
157__swi_begin(0x110)
158uint16_t *wstrcopy(uint16_t *destination, const uint16_t *source)
159__swi_end(0x110, wstrcopy, (destination, source));
160
168__swi_begin(0x120)
169WSHDR *wstrncpy(WSHDR *destination, WSHDR *source, int num)
170__swi_end(0x120, wstrncpy, (destination, source, num));
171
179__swi_begin(0x214)
180void wstrcpybypos(WSHDR *destination, WSHDR *source, int from, int num)
181__swi_end(0x214, wstrcpybypos, (destination, source, from, num));
182
189__swi_begin(0x121)
190WSHDR *wstrcat(WSHDR *destination, WSHDR *source)
191__swi_end(0x121, wstrcat, (destination, source));
192
200__swi_begin(0x122)
201WSHDR *wstrncat(WSHDR *destination, WSHDR *source, int num)
202__swi_end(0x122, wstrncat, (destination, source, num));
203
211__swi_begin(0x1DC)
212short wstrchr(WSHDR *str, uint32_t start, uint32_t character)
213__swi_end(0x1DC, wstrchr, (str, start, character));
214
222__swi_begin(0x1DD)
223short wstrrchr(WSHDR *str, uint32_t rstart, uint32_t character)
224__swi_end(0x1DD, wstrrchr, (str, rstart, character));
225
234__swi_begin(0x2E2)
235int wstrcmp(const WSHDR *str1, const WSHDR *str2)
236__swi_end(0x2E2, wstrcmp, (str1, str2));
237
247__swi_begin(0x3C9)
248int wstrncmp(const WSHDR *ws1, const WSHDR *ws2, size_t n)
249__swi_end(0x3C9, wstrncmp, (ws1, ws2, n));
250
260__swi_begin(0x3CA)
262__swi_end(0x3CA, wstricmp, (ws1, ws2));
263
273__swi_begin(0x3CB)
274int wstrnicmp(const WSHDR *ws1, const WSHDR *ws2, size_t n)
275__swi_end(0x3CB, wstrnicmp, (ws1, ws2, n));
276
282__swi_begin(0x123)
283uint16_t wstrlen(const WSHDR *str)
284__swi_end(0x123, wstrlen, (str));
285
293__swi_begin(0x3DA)
294uint16_t wstriwstr(const WSHDR *ws, const WSHDR *search, uint32_t start_pos)
295__swi_end(0x3DA, wstriwstr, (ws, search, start_pos));
296
303__swi_begin(0x3DB)
304void wstrreplace(WSHDR *dest, const WSHDR *src, uint32_t pos)
305__swi_end(0x3DB, wstrreplace, (dest, src, pos));
306
328int wsprintf(WSHDR *s, const char *format, ...)
329__swi_variadic_end(0x124, wsprintf, s, format);
330
343void wstrcatprintf(WSHDR *s, const char *format, ...)
344__swi_variadic_end(0x216, wstrcatprintf, s, format);
345
361__swi_begin(0x1E2)
362int ws_2utf8(const WSHDR *source, char *destination, int *new_length, uint32_t size)
363__swi_end(0x1E2, ws_2utf8, (source, destination, new_length, size));
364
372__swi_begin(0x1E3)
373int utf8_2ws(WSHDR *destination, const char *source, uint32_t size)
374__swi_end(0x1E3, utf8_2ws, (destination, source, size));
375
383__swi_begin(0x16C)
384int str_2ws(WSHDR *destination, const char *source, uint32_t size)
385__swi_end(0x16C, str_2ws, (destination, source, size));
386
396__swi_begin(0x0A3)
397void ws_2str(const WSHDR *source, char *destination, uint32_t size)
398__swi_end(0x0A3, ws_2str, (source, destination, size));
399
404__swi_begin(0x3CD)
406__swi_end(0x3CD, wstrtoupper, (ws));
407
412__swi_begin(0x3CE)
414__swi_end(0x3CE, wstrtolower, (ws));
415
420__swi_begin(0x3CF)
422__swi_end(0x3CF, wstrcapitalize, (ws));
423
427
#define __swi_variadic_begin(number)
Definition doxygen.h:40
#define __swilib_begin
Definition doxygen.h:29
#define __swi_end(number, func, call)
Definition doxygen.h:33
#define __swi_variadic_end(number, func,...)
Definition doxygen.h:41
#define __swi_begin(number)
Definition doxygen.h:32
#define __swilib_end
Definition doxygen.h:30
void *(* malloc_func_t)(size_t size)
malloc()
Definition base.h:64
void(* mfree_func_t)(void *ptr)
free()
Definition base.h:65
uint16_t len
The first item is string length.
Definition wstring.h:25
uint16_t maxlen
Maximum length of the string.
Definition wstring.h:40
mfree_func_t ws_mfree
Pointer to the free()
Definition wstring.h:38
uint16_t data[]
Other items are string characters.
Definition wstring.h:26
int isbody_allocated
1: When a string is allocated by AllocWS or CreateWS, 0: When as string is allocated by CreateLocalWS
Definition wstring.h:39
uint16_t * wsbody
wsbody[0] - len, wsbody[1] - first char
Definition wstring.h:36
malloc_func_t ws_malloc
Pointer to the malloc()
Definition wstring.h:37
uint16_t unk1
Definition wstring.h:41
int utf8_2ws(WSHDR *destination, const char *source, uint32_t size)
Convert UTF-8 C-string to WSHDR.
int wstrncmp(const WSHDR *ws1, const WSHDR *ws2, size_t n)
Compare two WSHDR strings, up to a specific length.
void wstrcatprintf(WSHDR *s, const char *format,...)
Append formatted output to the end of WSHDR.
short wstrchr(WSHDR *str, uint32_t start, uint32_t character)
Locate first occurrence of character in WSHDR.
WSHDR * CreateLocalWS(WSHDR *header, uint16_t *body, int size)
Initialize new empty WSHDR with static allocation.
void wstrreplace(WSHDR *dest, const WSHDR *src, uint32_t pos)
Replace substring in dest with src starting from position pos.
uint16_t wstrlen(const WSHDR *str)
Get WSHDR length.
void CutWSTR(WSHDR *str, int length)
Truncate string.
int str_2ws(WSHDR *destination, const char *source, uint32_t size)
Convert CP1252 (Latin) C-string to WSHDR.
int wstrcmp(const WSHDR *str1, const WSHDR *str2)
Compare two WSHDR strings.
void wstrcpybypos(WSHDR *destination, WSHDR *source, int from, int num)
Copy characters from WSHDR.
void wstrtolower(WSHDR *ws)
Convert WSHDR string to lowercase in-place.
void FreeWS(WSHDR *str)
Free WSHDR.
void wstrcapitalize(WSHDR *ws)
Convert WSHDR string to capitalized form in-place (first character uppercase, rest lowercase)
uint16_t wstriwstr(const WSHDR *ws, const WSHDR *search, uint32_t start_pos)
Find the first occurrence of a substring in a WSHDR string, ignoring case, starting from given positi...
int wsprintf(WSHDR *s, const char *format,...)
Write formatted output to WSHDR.
WSHDR * wstrcat(WSHDR *destination, WSHDR *source)
Concatenate two WSHDR.
int wstrnicmp(const WSHDR *ws1, const WSHDR *ws2, size_t n)
Compare two WSHDR strings without case sensitivity, up to a specific length.
void ws_2str(const WSHDR *source, char *destination, uint32_t size)
Convert WSHDR to the UTF-8 C-string with special mark.
int GetUnicodeSymbolByDynIcon(int dyn_icon)
Get character by dynamic icon id.
WSHDR * wstrncpy(WSHDR *destination, WSHDR *source, int num)
Copy characters from WSHDR.
void wsAppendChar(WSHDR *destination, int character)
Append a character to the end of WSHDR.
uint16_t wsCharAt(const WSHDR *str, short pos)
Get charater at the given position (safe).
WSHDR * AllocWS(int size)
Create new empty WSHDR.
void wsRemoveChars(WSHDR *destination, int position, int length)
Remove characters from the WSHDR.
int ws_2utf8(const WSHDR *source, char *destination, int *new_length, uint32_t size)
Convert WSHDR to the UTF-8 C-string.
WSHDR * wstrcpy(WSHDR *destination, WSHDR *source)
Copy WSHDR.
int wsInsertChar(WSHDR *destination, int character, int position)
Insert a character at the given position of the WSHDR.
void wstrtoupper(WSHDR *ws)
Convert WSHDR string to uppercase in-place.
int wstricmp(const WSHDR *ws1, const WSHDR *ws2)
Compare two WSHDR strings without case sensitivity.
short wstrrchr(WSHDR *str, uint32_t rstart, uint32_t character)
Locate last occurrence of character in WSHDR.
WSHDR * CreateWS(malloc_func_t malloc_func, mfree_func_t mfree_func, int size)
Create new empty WSHDR with custom allocator.
WSHDR * wstrncat(WSHDR *destination, WSHDR *source, int num)
Concatenate two WSHDR.
uint16_t * wstrcopy(uint16_t *destination, const uint16_t *source)
Copy WSHDR body.
Wide-string body.
Definition wstring.h:24
Wide-string header.
Definition wstring.h:35
#define const
Definition zconf.h:115