11 #ifndef __STR_UTIL_H__
12 #define __STR_UTIL_H__
14 #include <wireshark.h>
24 G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
29 const
char *separator, const
char *first, ...)
30 G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
48 const
char *separator,
char **str_array)
65 const
char *delimiter,
int max_tokens);
194 const uint8_t *
ws_memrchr(const
void *haystack,
int ch,
size_t n);
197 char *ws_escape_string(
wmem_allocator_t *alloc, const
char *
string,
bool add_quotes);
200 char *ws_escape_string_len(
wmem_allocator_t *alloc, const
char *
string, ssize_t len,
bool add_quotes);
204 char *ws_escape_null(
wmem_allocator_t *alloc, const
char *
string,
size_t len,
bool add_quotes);
226 char *ws_escape_csv(
wmem_allocator_t *alloc, const
char *
string,
bool add_quotes,
char quote_char,
bool double_quote,
bool escape_whitespace);
229 int ws_xton(
char ch);
251 #define FORMAT_SIZE_PREFIX_SI (1 << 0)
252 #define FORMAT_SIZE_PREFIX_IEC (1 << 1)
286 #define format_size(size, unit, flags) \
287 format_size_wmem(NULL, size, unit, flags)
290 char printable_char_or_period(
char c);
292 WS_DLL_PUBLIC WS_RETNONNULL
293 const char *ws_strerrorname_r(
int errnum,
char *buf,
size_t buf_size);
296 char *ws_strdup_underline(
wmem_allocator_t *allocator,
long offset,
size_t len);
371 const char *
string,
size_t len,
char chr);
415 void EBCDIC_to_ASCII(uint8_t *buf,
unsigned bytes);
418 uint8_t EBCDIC_to_ASCII1(uint8_t c);
422 HEXDUMP_ENC_ASCII = 0,
423 HEXDUMP_ENC_EBCDIC = 1
430 #define HEXDUMP_ASCII_MASK (0x0003U)
431 #define HEXDUMP_ASCII_OPTION(option) ((option) & HEXDUMP_ASCII_MASK)
433 #define HEXDUMP_ASCII_INCLUDE (0x0000U)
434 #define HEXDUMP_ASCII_DELIMIT (0x0001U)
435 #define HEXDUMP_ASCII_EXCLUDE (0x0002U)
438 bool hex_dump_buffer(
bool (*print_line)(
void *,
const char *),
void *fp,
439 const unsigned char *cp,
unsigned length,
440 hex_dump_enc encoding,
441 unsigned ascii_option);
444 #define plurality(d,s,p) ((d) == 1 ? (s) : (p))
446 #define true_or_false(val) ((val) ? "TRUE" : "FALSE")
448 #define string_or_null(val) ((val) ? (val) : "[NULL]")
WS_DLL_PUBLIC char * ascii_strup_inplace(char *str)
Definition: str_util.c:254
WS_DLL_PUBLIC const char * ws_ascii_strcasestr(const char *haystack, const char *needle)
Definition: str_util.c:327
WS_DLL_PUBLIC bool isprint_string(const char *str)
Definition: str_util.c:267
WS_DLL_PUBLIC char * format_text_chr(wmem_allocator_t *allocator, const char *string, size_t len, char chr)
Definition: str_util.c:1269
WS_DLL_PUBLIC bool isprint_utf8_string(const char *str, const unsigned length)
Definition: str_util.c:285
WS_DLL_PUBLIC char * wmem_ascii_strdown(wmem_allocator_t *allocator, const char *str, ssize_t len)
Definition: str_util.c:199
WS_DLL_PUBLIC char * format_char(wmem_allocator_t *allocator, char c)
Definition: str_util.c:1289
WS_DLL_PUBLIC char * format_units(wmem_allocator_t *allocator, double size, format_size_units_e unit, uint16_t flags, int precision)
Definition: str_util.c:436
format_size_units_e
Definition: str_util.h:231
@ FORMAT_SIZE_UNIT_BITS_S
Definition: str_util.h:241
@ FORMAT_SIZE_UNIT_BYTES
Definition: str_util.h:239
@ FORMAT_SIZE_UNIT_PACKETS
Definition: str_util.h:243
@ FORMAT_SIZE_UNIT_BYTES_S
Definition: str_util.h:242
@ FORMAT_SIZE_UNIT_SECONDS
Definition: str_util.h:247
@ FORMAT_SIZE_UNIT_NONE
Definition: str_util.h:232
@ FORMAT_SIZE_UNIT_FIELDS
Definition: str_util.h:245
@ FORMAT_SIZE_UNIT_ERLANGS
Definition: str_util.h:248
@ FORMAT_SIZE_UNIT_PACKETS_S
Definition: str_util.h:244
@ FORMAT_SIZE_UNIT_BITS
Definition: str_util.h:240
WS_DLL_PUBLIC char * wmem_strjoinv(wmem_allocator_t *allocator, const char *separator, char **str_array) G_GNUC_MALLOC
Definition: str_util.c:99
WS_DLL_PUBLIC char * format_text_string(wmem_allocator_t *allocator, const char *string)
Definition: str_util.c:1240
WS_DLL_PUBLIC char * format_text_wsp(wmem_allocator_t *allocator, const char *line, size_t len)
Definition: str_util.c:1252
WS_DLL_PUBLIC char * ascii_strdown_inplace(char *str)
Definition: str_util.c:241
WS_DLL_PUBLIC char * format_text(wmem_allocator_t *allocator, const char *string, size_t len)
Definition: str_util.c:1215
WS_DLL_PUBLIC const uint8_t * ws_memrchr(const void *haystack, int ch, size_t n)
Definition: str_util.c:347
WS_DLL_PUBLIC char * ws_utf8_truncate(char *string, size_t len)
Definition: str_util.c:1317
WS_DLL_PUBLIC char ** wmem_strsplit(wmem_allocator_t *allocator, const char *src, const char *delimiter, int max_tokens)
Definition: str_util.c:141
WS_DLL_PUBLIC bool isdigit_string(const unsigned char *str)
Definition: str_util.c:310
WS_DLL_PUBLIC char * format_size_wmem(wmem_allocator_t *allocator, int64_t size, format_size_units_e unit, uint16_t flags)
Definition: str_util.c:589
Definition: wmem_allocator.h:27