| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wmem_strbuf.h
Go to the documentation of this file.
1
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
20extern "C" {
21#endif /* __cplusplus */
22
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
63typedef struct _wmem_strbuf_t wmem_strbuf_t;
64
75WS_DLL_PUBLIC
76 wmem_strbuf_t *
77 wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size)
78G_GNUC_MALLOC;
79
90WS_DLL_PUBLIC
91 wmem_strbuf_t *
92 wmem_strbuf_new(wmem_allocator_t *allocator, const char *str)
93G_GNUC_MALLOC;
94
95
105#define wmem_strbuf_create(allocator) \
106 wmem_strbuf_new(allocator, "")
107
120WS_DLL_PUBLIC
121 wmem_strbuf_t *
122 wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len)
123G_GNUC_MALLOC;
124
135WS_DLL_PUBLIC
136 wmem_strbuf_t *
137 wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *strbuf)
138G_GNUC_MALLOC;
139
149WS_DLL_PUBLIC
150void
151 wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str);
152
164WS_DLL_PUBLIC
165void
166 wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len);
167
178WS_DLL_PUBLIC
179void
180wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format, ...)
181G_GNUC_PRINTF(2, 3);
182
194WS_DLL_PUBLIC
195void
196 wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap);
197
207WS_DLL_PUBLIC
208void
209 wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c);
210
221WS_DLL_PUBLIC
222void
223 wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count);
224
235WS_DLL_PUBLIC
236void
237 wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c);
238
247#define wmem_strbuf_append_unichar_repl(buf) \
248 wmem_strbuf_append_unichar(buf, UNICODE_REPLACEMENT_CHARACTER)
249
261WS_DLL_PUBLIC
262void
263 wmem_strbuf_append_unichar_validated(wmem_strbuf_t *strbuf, const gunichar c);
264
275WS_DLL_PUBLIC
276void
277 wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch);
278
289WS_DLL_PUBLIC
290size_t
291 wmem_strbuf_append_hex_unichar(wmem_strbuf_t *strbuf, gunichar ch);
292
305WS_DLL_PUBLIC
306void
307 wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len);
308
318WS_DLL_PUBLIC
319const char *
320 wmem_strbuf_get_str(const wmem_strbuf_t *strbuf);
321
332WS_DLL_PUBLIC
333size_t
334 wmem_strbuf_get_len(const wmem_strbuf_t *strbuf);
335
349WS_DLL_PUBLIC
350int
351 wmem_strbuf_strcmp(const wmem_strbuf_t *sb1, const wmem_strbuf_t *sb2);
352
364WS_DLL_PUBLIC
365const char *
366 wmem_strbuf_strstr(const wmem_strbuf_t *haystack, const wmem_strbuf_t *needle);
367
382WS_DLL_PUBLIC
383char *
384 wmem_strbuf_finalize(wmem_strbuf_t *strbuf);
385
398WS_DLL_PUBLIC
399void
400 wmem_strbuf_destroy(wmem_strbuf_t *strbuf);
401
414WS_DLL_PUBLIC
415bool
416 wmem_strbuf_utf8_validate(wmem_strbuf_t *strbuf, const char **endptr);
417
418
430WS_DLL_PUBLIC
431void
432 wmem_strbuf_utf8_make_valid(wmem_strbuf_t *strbuf);
433
437#ifdef __cplusplus
438}
439#endif /* __cplusplus */
440
441#endif /* __WMEM_STRBUF_H__ */
442
443/*
444 * Editor modelines - https://www.wireshark.org/tools/modelines.html
445 *
446 * Local variables:
447 * c-basic-offset: 4
448 * tab-width: 8
449 * indent-tabs-mode: nil
450 * End:
451 *
452 * vi: set shiftwidth=4 tabstop=8 expandtab:
453 * :indentSize=4:tabSize=8:noTabs=true:
454 */
wmem_strbuf_dup
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *strbuf) G_GNUC_MALLOC
Duplicate an existing string buffer using the specified memory allocator.
Definition wmem_strbuf.c:80
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_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_vprintf
WS_DLL_PUBLIC void WS_DLL_PUBLIC 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_new_len
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new_len(wmem_allocator_t *allocator, const char *str, size_t len) G_GNUC_MALLOC
Create a new string buffer initialized with a substring of specified length.
Definition wmem_strbuf.c:49
wmem_strbuf_append_unichar
WS_DLL_PUBLIC 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
WS_DLL_PUBLIC 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_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_append_printf
WS_DLL_PUBLIC void wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format,...) G_GNUC_PRINTF(2
Append formatted text to a string buffer.
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 a hexadecimal 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_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
WS_DLL_PUBLIC 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_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_new
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new(wmem_allocator_t *allocator, const char *str) G_GNUC_MALLOC
Create a new string buffer initialized with a copy of the given string.
Definition wmem_strbuf.c:74
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_new_sized
WS_DLL_PUBLIC wmem_strbuf_t * wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size) G_GNUC_MALLOC
Create a new string buffer with a specified initial allocation size.
Definition wmem_strbuf.c:31
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 a hexadecimal representation of a byte to a wmem string buffer.
Definition wmem_strbuf.c:263
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_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