| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wmem_strbuf.h
Go to the documentation of this file.
1
11
12#ifndef __WMEM_STRBUF_H__
13#define __WMEM_STRBUF_H__
14
15#include <ws_codepoints.h>
16
17#include "wmem_core.h"
18
19#ifdef __cplusplus
20 extern "C" {
21#endif /* __cplusplus */
22
31
38 struct _wmem_strbuf_t {
42 wmem_allocator_t *allocator;
43
48 char *str;
49
54 size_t len;
55
60 size_t alloc_size;
61};
62
63 typedef struct _wmem_strbuf_t wmem_strbuf_t;
64
75WS_DLL_PUBLIC
76wmem_strbuf_t *
77 wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size);
78
89WS_DLL_PUBLIC
90wmem_strbuf_t *
91 wmem_strbuf_new(wmem_allocator_t *allocator, const char *str);
92
93
103#define wmem_strbuf_create(allocator) \
104 wmem_strbuf_new(allocator, "")
105
123WS_DLL_PUBLIC
124wmem_strbuf_t *
125 wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len);
126
137WS_DLL_PUBLIC
138wmem_strbuf_t *
139 wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *strbuf);
140
150WS_DLL_PUBLIC
151 void
152 wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str);
153
170WS_DLL_PUBLIC
171 void
172 wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len);
173
184WS_DLL_PUBLIC
185 void
186 wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format, ...)
187G_GNUC_PRINTF(2, 3);
188
200WS_DLL_PUBLIC
201 void
202 wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap);
203
213WS_DLL_PUBLIC
214 void
215 wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c);
216
227WS_DLL_PUBLIC
228 void
229 wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count);
230
241WS_DLL_PUBLIC
242 void
243 wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c);
244
253#define wmem_strbuf_append_unichar_repl(buf) \
254 wmem_strbuf_append_unichar(buf, UNICODE_REPLACEMENT_CHARACTER)
255
267WS_DLL_PUBLIC
268 void
269 wmem_strbuf_append_unichar_validated(wmem_strbuf_t *strbuf, const gunichar c);
270
282WS_DLL_PUBLIC
283 void
284 wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch);
285
304WS_DLL_PUBLIC
305 size_t
306 wmem_strbuf_append_hex_unichar(wmem_strbuf_t *strbuf, gunichar ch);
307
320WS_DLL_PUBLIC
321 void
322 wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len);
323
333WS_DLL_PUBLIC
334 const char *
335 wmem_strbuf_get_str(const wmem_strbuf_t *strbuf);
336
347WS_DLL_PUBLIC
348 size_t
349 wmem_strbuf_get_len(const wmem_strbuf_t *strbuf);
350
364WS_DLL_PUBLIC
365 int
366 wmem_strbuf_strcmp(const wmem_strbuf_t *sb1, const wmem_strbuf_t *sb2);
367
379WS_DLL_PUBLIC
380 const char *
381 wmem_strbuf_strstr(const wmem_strbuf_t *haystack, const wmem_strbuf_t *needle);
382
397WS_DLL_PUBLIC
398 char *
399 wmem_strbuf_finalize(wmem_strbuf_t *strbuf);
400
413WS_DLL_PUBLIC
414 void
415 wmem_strbuf_destroy(wmem_strbuf_t *strbuf);
416
429WS_DLL_PUBLIC
430 bool
431 wmem_strbuf_utf8_validate(wmem_strbuf_t *strbuf, const char **endptr);
432
433
445WS_DLL_PUBLIC
446 void
447 wmem_strbuf_utf8_make_valid(wmem_strbuf_t *strbuf);
448
451
452#ifdef __cplusplus
453}
454#endif /* __cplusplus */
455
456#endif /* __WMEM_STRBUF_H__ */
457
458/*
459 * Editor modelines - https://www.wireshark.org/tools/modelines.html
460 *
461 * Local variables:
462 * c-basic-offset: 4
463 * tab-width: 8
464 * indent-tabs-mode: nil
465 * End:
466 *
467 * vi: set shiftwidth=4 tabstop=8 expandtab:
468 * :indentSize=4:tabSize=8:noTabs=true:
469 */
wmem_strbuf_append_vprintf
void wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap)
Append formatted text to a string buffer using a va_list.
Definition wmem_strbuf.c:182
wmem_strbuf_utf8_make_valid
WS_DLL_PUBLIC void wmem_strbuf_utf8_make_valid(wmem_strbuf_t *strbuf)
Ensure the contents of a wmem string buffer are valid UTF-8.
Definition wmem_strbuf.c:446
wmem_strbuf_new_sized
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size)
Create a new string buffer with a specified initial allocation size.
Definition wmem_strbuf.c:31
wmem_strbuf_get_str
WS_DLL_PUBLIC const char * wmem_strbuf_get_str(const wmem_strbuf_t *strbuf)
Retrieve the current string content from a wmem string buffer.
Definition wmem_strbuf.c:337
wmem_strbuf_append_unichar
void wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c)
Append a Unicode character to a string buffer.
Definition wmem_strbuf.c:233
wmem_strbuf_append_unichar_validated
WS_DLL_PUBLIC void wmem_strbuf_append_unichar_validated(wmem_strbuf_t *strbuf, const gunichar c)
Append a validated Unicode character to a string buffer.
Definition wmem_strbuf.c:248
wmem_strbuf_append_c_count
void wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count)
Append a character to a string buffer multiple times.
Definition wmem_strbuf.c:222
wmem_strbuf_utf8_validate
WS_DLL_PUBLIC bool wmem_strbuf_utf8_validate(wmem_strbuf_t *strbuf, const char **endptr)
Validate the contents of a wmem string buffer as UTF-8.
Definition wmem_strbuf.c:440
wmem_strbuf_new_len
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len)
Create a new string buffer initialized with a substring of specified length.
Definition wmem_strbuf.c:49
wmem_strbuf_append_len
WS_DLL_PUBLIC void wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len)
Append a specified number of bytes from a string to a string buffer.
Definition wmem_strbuf.c:141
wmem_strbuf_get_len
WS_DLL_PUBLIC size_t wmem_strbuf_get_len(const wmem_strbuf_t *strbuf)
Retrieve the current length of a wmem string buffer.
Definition wmem_strbuf.c:343
wmem_strbuf_append_hex_unichar
WS_DLL_PUBLIC size_t wmem_strbuf_append_hex_unichar(wmem_strbuf_t *strbuf, gunichar ch)
Append an escape sequence representation of a Unicode character to a wmem string buffer.
Definition wmem_strbuf.c:311
wmem_strbuf_strcmp
WS_DLL_PUBLIC int wmem_strbuf_strcmp(const wmem_strbuf_t *sb1, const wmem_strbuf_t *sb2)
Compare the contents of two wmem string buffers.
Definition wmem_strbuf.c:366
wmem_strbuf_new
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new(wmem_allocator_t *allocator, const char *str)
Create a new string buffer initialized with a copy of the given string.
Definition wmem_strbuf.c:74
wmem_strbuf_finalize
WS_DLL_PUBLIC char * wmem_strbuf_finalize(wmem_strbuf_t *strbuf)
Finalize a wmem string buffer and extract its raw string.
Definition wmem_strbuf.c:382
wmem_strbuf_destroy
WS_DLL_PUBLIC void wmem_strbuf_destroy(wmem_strbuf_t *strbuf)
Destroy a wmem string buffer and release its associated memory.
Definition wmem_strbuf.c:395
wmem_strbuf_append_c
void wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c)
Append a single character to a string buffer.
Definition wmem_strbuf.c:212
wmem_strbuf_append_printf
WS_DLL_PUBLIC void wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format,...)
Append formatted text to a string buffer.
Definition wmem_strbuf.c:202
wmem_strbuf_strstr
WS_DLL_PUBLIC const char * wmem_strbuf_strstr(const wmem_strbuf_t *haystack, const wmem_strbuf_t *needle)
Search for a substring within a wmem string buffer.
Definition wmem_strbuf.c:372
wmem_strbuf_truncate
WS_DLL_PUBLIC void wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len)
Truncate a wmem string buffer to a specified length.
Definition wmem_strbuf.c:326
wmem_strbuf_dup
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *strbuf)
Duplicate an existing string buffer using the specified memory allocator.
Definition wmem_strbuf.c:80
wmem_strbuf_append
WS_DLL_PUBLIC void wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str)
Append a null-terminated string to the end of a string buffer.
Definition wmem_strbuf.c:123
wmem_strbuf_append_hex
WS_DLL_PUBLIC void wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch)
Append an escape sequence representation of a byte to a wmem string buffer.
Definition wmem_strbuf.c:263
wmem_allocator_t
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
_wmem_strbuf_t
Internal structure representing a wmem-allocated string buffer.
Definition wmem_strbuf.h:38
_wmem_strbuf_t::alloc_size
size_t alloc_size
Definition wmem_strbuf.h:60
_wmem_strbuf_t::allocator
wmem_allocator_t * allocator
Definition wmem_strbuf.h:42
_wmem_strbuf_t::str
char * str
Definition wmem_strbuf.h:48
_wmem_strbuf_t::len
size_t len
Definition wmem_strbuf.h:54
wmem_core.h