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
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
78
89WS_DLL_PUBLIC
92
93
103#define wmem_strbuf_create(allocator) \
104 wmem_strbuf_new(allocator, "")
105
118WS_DLL_PUBLIC
121
132WS_DLL_PUBLIC
135
145WS_DLL_PUBLIC
146void
147wmem_strbuf_append(wmem_strbuf_t *strbuf, const char *str);
148
160WS_DLL_PUBLIC
161void
162wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const char *str, size_t append_len);
163
174WS_DLL_PUBLIC
175void
176wmem_strbuf_append_printf(wmem_strbuf_t *strbuf, const char *format, ...)
177G_GNUC_PRINTF(2, 3);
178
190WS_DLL_PUBLIC
191void
192wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const char *fmt, va_list ap);
193
203WS_DLL_PUBLIC
204void
205wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const char c);
206
217WS_DLL_PUBLIC
218void
219wmem_strbuf_append_c_count(wmem_strbuf_t *strbuf, const char c, size_t count);
220
231WS_DLL_PUBLIC
232void
233wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c);
234
243#define wmem_strbuf_append_unichar_repl(buf) \
244 wmem_strbuf_append_unichar(buf, UNICODE_REPLACEMENT_CHARACTER)
245
257WS_DLL_PUBLIC
258void
259wmem_strbuf_append_unichar_validated(wmem_strbuf_t *strbuf, const gunichar c);
260
271WS_DLL_PUBLIC
272void
273wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch);
274
285WS_DLL_PUBLIC
286size_t
288
301WS_DLL_PUBLIC
302void
303wmem_strbuf_truncate(wmem_strbuf_t *strbuf, const size_t len);
304
314WS_DLL_PUBLIC
315const char *
317
328WS_DLL_PUBLIC
329size_t
331
345WS_DLL_PUBLIC
346int
347wmem_strbuf_strcmp(const wmem_strbuf_t *sb1, const wmem_strbuf_t *sb2);
348
360WS_DLL_PUBLIC
361const char *
362wmem_strbuf_strstr(const wmem_strbuf_t *haystack, const wmem_strbuf_t *needle);
363
378WS_DLL_PUBLIC
379char *
381
394WS_DLL_PUBLIC
395void
397
410WS_DLL_PUBLIC
411bool
412wmem_strbuf_utf8_validate(wmem_strbuf_t *strbuf, const char **endptr);
413
414
426WS_DLL_PUBLIC
427void
429
433#ifdef __cplusplus
434}
435#endif /* __cplusplus */
436
437#endif /* __WMEM_STRBUF_H__ */
438
439/*
440 * Editor modelines - https://www.wireshark.org/tools/modelines.html
441 *
442 * Local variables:
443 * c-basic-offset: 4
444 * tab-width: 8
445 * indent-tabs-mode: nil
446 * End:
447 *
448 * vi: set shiftwidth=4 tabstop=8 expandtab:
449 * :indentSize=4:tabSize=8:noTabs=true:
450 */
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Internal structure representing a wmem-allocated string buffer.
Definition wmem_strbuf.h:38
size_t alloc_size
Definition wmem_strbuf.h:60
wmem_allocator_t * allocator
Definition wmem_strbuf.h:42
char * str
Definition wmem_strbuf.h:48
size_t len
Definition wmem_strbuf.h:54