Wireshark 4.7.2
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
value_string.h
Go to the documentation of this file.
1
10
11#ifndef __VALUE_STRING_H__
12#define __VALUE_STRING_H__
13
14#include <stdint.h>
15
16#include "ws_symbol_export.h"
17
18#include <wsutil/nstime.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
24/* VALUE TO STRING MATCHING */
25
33typedef struct _value_string {
34 uint32_t value;
35 const char *strptr;
37
38
39#if 0
40 /* ----- VALUE_STRING "Helper" macros ----- */
41
42 /* Essentially: Provide the capability to define a list of value_strings once and
43 then to expand the list as an enum and/or as a value_string array. */
44
45 /* Usage: */
46
47 /*- define list of value strings -*/
48 #define foo_VALUE_STRING_LIST(XXX) \
49 XXX( FOO_A, 1, "aaa" ) \
50 XXX( FOO_B, 3, "bbb" )
51
52 /*- gen enum -*/
53 VALUE_STRING_ENUM(foo); /* gen's 'enum {FOO_A=1, FOO_B=3};' */
54
55 /*- gen value_string array -*/
56 /* local */
57 VALUE_STRING_ARRAY(foo); /* gen's 'static const value_string foo[] = {{1,"aaa"}, {3,"bbb"}}; */
58
59 /* global */
60 VALUE_STRING_ARRAY_GLOBAL_DEF(foo); /* gen's 'const value_string foo[] = {{1,"aaa"}, {3,"bbb"}}; */
61 VALUE_STRING_ARRAY_GLOBAL_DCL(foo); /* gen's 'const value_string foo[]; */
62
63 /* Alternatively: */
64 #define bar_VALUE_STRING_LIST(XXX) \
65 XXX( BAR_A, 1) \
66 XXX( BAR_B, 3)
67
68 VALUE_STRING_ENUM2(bar); /* gen's 'enum {BAR_A=1, BAR_B=3};' */
69 VALUE_STRING_ARRAY2(bar); /* gen's 'static const value_string bar[] = {{1,"BAR_A"}, {3,"BAR_B"}}; */
70 ...
71#endif
72
73/* -- Public -- */
74#define VALUE_STRING_ENUM( array_name) _VS_ENUM_XXX( array_name, _VS_ENUM_ENTRY)
75#define VALUE_STRING_ARRAY( array_name) _VS_ARRAY_SC_XXX(array_name, _VS_ARRAY_ENTRY, static)
76#define VALUE_STRING_ARRAY_GLOBAL_DEF( array_name) _VS_ARRAY_XXX(array_name, _VS_ARRAY_ENTRY)
77#define VALUE_STRING_ARRAY_GLOBAL_DCL( array_name) _VS_ARRAY_SC_TYPE_NAME(array_name, extern)
78
79#define VALUE_STRING_ENUM2( array_name) _VS_ENUM_XXX( array_name, _VS_ENUM_ENTRY2)
80#define VALUE_STRING_ARRAY2( array_name) _VS_ARRAY_SC_XXX(array_name, _VS_ARRAY_ENTRY2, static)
81#define VALUE_STRING_ARRAY2_GLOBAL_DEF( array_name) _VS_ARRAY_XXX(array_name, _VS_ARRAY_ENTRY2)
82#define VALUE_STRING_ARRAY2_GLOBAL_DCL( array_name) _VS_ARRAY_SC_TYPE_NAME(array_name, extern)
83
84/* -- Private -- */
85#define _VS_ENUM_XXX(array_name, macro) \
86enum { \
87 array_name##_VALUE_STRING_LIST(macro) \
88 _##array_name##_ENUM_DUMMY = 0 \
89}
90
91#define _VS_ARRAY_SC_XXX(array_name, macro, sc) \
92 _VS_ARRAY_SC_TYPE_NAME(array_name, sc) = { \
93 array_name##_VALUE_STRING_LIST(macro) \
94 { 0, NULL } \
95}
96
97#define _VS_ARRAY_XXX(array_name, macro) \
98 _VS_ARRAY_TYPE_NAME(array_name) = { \
99 array_name##_VALUE_STRING_LIST(macro) \
100 { 0, NULL } \
101}
102
103#define _VS_ARRAY_SC_TYPE_NAME(array_name, sc) sc const value_string array_name[]
104#define _VS_ARRAY_TYPE_NAME(array_name) const value_string array_name[]
105
106#define _VS_ENUM_ENTRY( name, value, string) name = value,
107#define _VS_ARRAY_ENTRY(name, value, string) { value, string },
108
109#define _VS_ENUM_ENTRY2( name, value) name = value,
110#define _VS_ARRAY_ENTRY2(name, value) { value, #name },
111/* ----- ----- */
112
127WS_DLL_PUBLIC
128char *
129val_to_str(wmem_allocator_t *scope, const uint32_t val, const value_string *vs, const char *fmt)
130G_GNUC_PRINTF(4, 0);
131
147WS_DLL_PUBLIC
148const char *
149val_to_str_const(const uint32_t val, const value_string *vs, const char *unknown_str);
150
164WS_DLL_PUBLIC
165const char *
166try_val_to_str(const uint32_t val, const value_string *vs);
167
183WS_DLL_PUBLIC
184const char *
185try_val_to_str_idx(const uint32_t val, const value_string *vs, int *idx);
186
187/* 64-BIT VALUE TO STRING MATCHING */
188
196typedef struct _val64_string {
197 uint64_t value;
198 const char *strptr;
200
215WS_DLL_PUBLIC
216const char *
217val64_to_str_wmem(wmem_allocator_t* scope, const uint64_t val, const val64_string *vs, const char *fmt)
218G_GNUC_PRINTF(4, 0);
219
235WS_DLL_PUBLIC
236const char *
237val64_to_str_const(const uint64_t val, const val64_string *vs, const char *unknown_str);
238
252WS_DLL_PUBLIC
253const char *
254try_val64_to_str(const uint64_t val, const val64_string *vs);
255
271WS_DLL_PUBLIC
272const char *
273try_val64_to_str_idx(const uint64_t val, const val64_string *vs, int *idx);
274
275/* STRING TO VALUE MATCHING */
276
291WS_DLL_PUBLIC
292uint32_t
293str_to_val(const char *val, const value_string *vs, const uint32_t err_val);
294
309WS_DLL_PUBLIC
310int
311str_to_val_idx(const char *val, const value_string *vs);
312
313/* EXTENDED VALUE TO STRING MATCHING */
314
315typedef struct _value_string_ext value_string_ext;
316typedef const value_string *(*_value_string_match2_t)(const uint32_t, value_string_ext*);
317
326 _value_string_match2_t _vs_match2;
330 const char *_vs_name;
332};
333
334
335#define VALUE_STRING_EXT_VS_P(x) (x)->_vs_p
336#define VALUE_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries
337#define VALUE_STRING_EXT_VS_NAME(x) (x)->_vs_name
338
351WS_DLL_PUBLIC
352const value_string *
353_try_val_to_str_ext_init(const uint32_t val, value_string_ext *vse);
354#define VALUE_STRING_EXT_INIT(x) { _try_val_to_str_ext_init, 0, G_N_ELEMENTS(x)-1, x, #x, NULL }
355
368WS_DLL_PUBLIC
369value_string_ext *
370value_string_ext_new(wmem_allocator_t* scope, const value_string *vs, unsigned vs_tot_num_entries, const char *vs_name);
371
381WS_DLL_PUBLIC
382void
383value_string_ext_free(value_string_ext *vse);
384
402WS_DLL_PUBLIC
403char *
404val_to_str_ext(wmem_allocator_t *scope, const uint32_t val, value_string_ext *vse, const char *fmt)
405G_GNUC_PRINTF(4, 0);
406
422WS_DLL_PUBLIC
423const char *
424val_to_str_ext_const(const uint32_t val, value_string_ext *vs, const char *unknown_str);
425
439WS_DLL_PUBLIC
440const char *
441try_val_to_str_ext(const uint32_t val, value_string_ext *vse);
442
459WS_DLL_PUBLIC
460const char *
461try_val_to_str_idx_ext(const uint32_t val, value_string_ext *vse, int *idx);
462
463/* EXTENDED 64-BIT VALUE TO STRING MATCHING */
464
465typedef struct _val64_string_ext val64_string_ext;
466typedef const val64_string *(*_val64_string_match2_t)(const uint64_t, val64_string_ext*);
467
475 _val64_string_match2_t _vs_match2;
479 const char *_vs_name;
481};
482
483#define VAL64_STRING_EXT_VS_P(x) (x)->_vs_p
484#define VAL64_STRING_EXT_VS_NUM_ENTRIES(x) (x)->_vs_num_entries
485#define VAL64_STRING_EXT_VS_NAME(x) (x)->_vs_name
486
498WS_DLL_PUBLIC
499int
500value_str_value_compare(const void* a, const void* b);
501
518WS_DLL_PUBLIC
519const val64_string *
520_try_val64_to_str_ext_init(const uint64_t val, val64_string_ext *vse);
521#define VAL64_STRING_EXT_INIT(x) { _try_val64_to_str_ext_init, 0, G_N_ELEMENTS(x)-1, x, #x, NULL }
522
532WS_DLL_PUBLIC
533val64_string_ext *
534val64_string_ext_new(wmem_allocator_t* scope, const val64_string *vs, unsigned vs_tot_num_entries, const char *vs_name);
535
541WS_DLL_PUBLIC
542void
543val64_string_ext_free(val64_string_ext *vse);
544
554WS_DLL_PUBLIC
555char *
556val64_to_str_ext_wmem(wmem_allocator_t *scope, const uint64_t val, val64_string_ext *vse, const char *fmt)
557G_GNUC_PRINTF(4, 0);
558
567WS_DLL_PUBLIC
568const char *
569val64_to_str_ext_const(const uint64_t val, val64_string_ext *vs, const char *unknown_str);
570
578WS_DLL_PUBLIC
579const char *
580try_val64_to_str_ext(const uint64_t val, val64_string_ext *vse);
581
590WS_DLL_PUBLIC
591const char *
592try_val64_to_str_idx_ext(const uint64_t val, val64_string_ext *vse, int *idx);
593
594/* STRING TO STRING MATCHING */
595
599typedef struct _string_string {
600 const char *value;
601 const char *strptr;
603
613WS_DLL_PUBLIC
614const char *
615str_to_str_wmem(wmem_allocator_t* scope, const char *val, const string_string *vs, const char *fmt)
616G_GNUC_PRINTF(4, 0);
617
625WS_DLL_PUBLIC
626const char *
627try_str_to_str(const char *val, const string_string *vs);
628
637WS_DLL_PUBLIC
638const char *
639try_str_to_str_idx(const char *val, const string_string *vs, int *idx);
640
641/* RANGE TO STRING MATCHING */
642
646typedef struct _range_string {
647 uint64_t value_min;
648 uint64_t value_max;
649 const char *strptr;
651
661WS_DLL_PUBLIC
662const char *
663rval_to_str_wmem(wmem_allocator_t* scope, const uint32_t val, const range_string *rs, const char *fmt)
664G_GNUC_PRINTF(4, 0);
665
673WS_DLL_PUBLIC
674const char *
675rval_to_str_const(const uint32_t val, const range_string *rs, const char *unknown_str);
676
684WS_DLL_PUBLIC
685const char *
686try_rval_to_str(const uint32_t val, const range_string *rs);
687
696WS_DLL_PUBLIC
697const char *
698try_rval_to_str_idx(const uint32_t val, const range_string *rs, int *idx);
699
707WS_DLL_PUBLIC
708const char *
709try_rval64_to_str(const uint64_t val, const range_string *rs);
710
723WS_DLL_PUBLIC
724const char *
725try_rval64_to_str_idx(const uint64_t val, const range_string *rs, int *idx);
726
727/* TIME TO STRING MATCHING */
728
736
744WS_DLL_PUBLIC
745const char *
746try_time_val_to_str(const nstime_t *val, const time_value_string *vs);
747
748/* BYTES TO STRING MATCHING */
749
753typedef struct _bytes_string {
754 const uint8_t *value;
755 const size_t value_length;
756 const char *strptr;
758
772WS_DLL_PUBLIC
773const char *
774bytesval_to_str_wmem(wmem_allocator_t* scope, const uint8_t *val, const size_t val_len, const bytes_string *bs, const char *fmt)
775G_GNUC_PRINTF(5, 0);
776
789WS_DLL_PUBLIC
790const char *
791try_bytesval_to_str(const uint8_t *val, const size_t val_len, const bytes_string *bs);
792
807WS_DLL_PUBLIC
808const char *
809bytesprefix_to_str(wmem_allocator_t* scope, const uint8_t *haystack, const size_t haystack_len, const bytes_string *bs, const char *fmt)
810G_GNUC_PRINTF(5, 0);
811
820WS_DLL_PUBLIC
821const char *
822try_bytesprefix_to_str(const uint8_t *haystack, const size_t haystack_len, const bytes_string *bs);
823
830WS_DLL_PUBLIC
831void register_external_value_string(const char* name, const value_string* vs);
832
839WS_DLL_PUBLIC
840value_string* get_external_value_string(const char* name);
841
848WS_DLL_PUBLIC
849void register_external_value_string_ext(const char* name, const value_string_ext* vse);
850
857WS_DLL_PUBLIC
858value_string_ext* get_external_value_string_ext(const char* name);
859
860/* MISC (generally do not use) */
861
867WS_DLL_PUBLIC
869
875WS_DLL_PUBLIC
877
886WS_DLL_PUBLIC
887bool
888value_string_ext_validate(const value_string_ext *vse);
889
896WS_DLL_PUBLIC
897const char *
898value_string_ext_match_type_str(const value_string_ext *vse);
899
908WS_DLL_PUBLIC
909bool
910val64_string_ext_validate(const val64_string_ext *vse);
911
918WS_DLL_PUBLIC
919const char *
920val64_string_ext_match_type_str(const val64_string_ext *vse);
921
922#ifdef __cplusplus
923}
924#endif /* __cplusplus */
925
926#endif /* __VALUE_STRING_H__ */
927
928/*
929 * Editor modelines - https://www.wireshark.org/tools/modelines.html
930 *
931 * Local variables:
932 * c-basic-offset: 4
933 * tab-width: 8
934 * indent-tabs-mode: nil
935 * End:
936 *
937 * vi: set shiftwidth=4 tabstop=8 expandtab:
938 * :indentSize=4:tabSize=8:noTabs=true:
939 */
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
Maps a byte sequence key to a string value, used for table-driven binary-pattern-to-string lookups.
Definition value_string.h:753
const size_t value_length
Definition value_string.h:755
const uint8_t * value
Definition value_string.h:754
const char * strptr
Definition value_string.h:756
Maps an inclusive numeric range to a string value, used for table-driven range-to-string lookups.
Definition value_string.h:646
uint64_t value_max
Definition value_string.h:648
uint64_t value_min
Definition value_string.h:647
const char * strptr
Definition value_string.h:649
Maps a string key to a string value, used for table-driven string-to-string lookups.
Definition value_string.h:599
const char * strptr
Definition value_string.h:601
const char * value
Definition value_string.h:600
Maps a timestamp key to a string value, used for table-driven time-to-string lookups.
Definition value_string.h:732
const char * strptr
Definition value_string.h:734
nstime_t value
Definition value_string.h:733
Extended metadata for a 64-bit value-string mapping array.
Definition value_string.h:474
const char * _vs_name
Definition value_string.h:479
uint64_t _vs_first_value
Definition value_string.h:476
unsigned _vs_num_entries
Definition value_string.h:477
_val64_string_match2_t _vs_match2
Definition value_string.h:475
wmem_allocator_t * _scope
Definition value_string.h:480
const val64_string * _vs_p
Definition value_string.h:478
Mapping between a 64-bit integer value and its string representation.
Definition value_string.h:196
uint64_t value
Definition value_string.h:197
const char * strptr
Definition value_string.h:198
Extended metadata for a value_string array.
Definition value_string.h:325
const value_string * _vs_p
Definition value_string.h:329
const char * _vs_name
Definition value_string.h:330
unsigned _vs_num_entries
Definition value_string.h:328
uint32_t _vs_first_value
Definition value_string.h:327
_value_string_match2_t _vs_match2
Definition value_string.h:326
wmem_allocator_t * _scope
Definition value_string.h:331
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
const char * strptr
Definition value_string.h:35
uint32_t value
Definition value_string.h:34
Definition nstime.h:26
WS_DLL_PUBLIC const char * value_string_ext_match_type_str(const value_string_ext *vse)
Returns a string representation of the match type for a value_string_ext.
Definition value_string.c:1067
WS_DLL_PUBLIC value_string_ext * value_string_ext_new(wmem_allocator_t *scope, const value_string *vs, unsigned vs_tot_num_entries, const char *vs_name)
Create a new extended value-string mapping structure.
Definition value_string.c:258
WS_DLL_PUBLIC const char * try_val_to_str_idx(const uint32_t val, const value_string *vs, int *idx)
Attempt to convert a numeric value to a string and retrieve its index.
Definition value_string.c:90
WS_DLL_PUBLIC const char * try_bytesprefix_to_str(const uint8_t *haystack, const size_t haystack_len, const bytes_string *bs)
Tries to find a string representation for a byte prefix in a bytes_string array.
Definition value_string.c:991
WS_DLL_PUBLIC void val64_string_ext_free(val64_string_ext *vse)
Frees a val64_string_ext structure.
Definition value_string.c:554
WS_DLL_PUBLIC const char * try_val_to_str_ext(const uint32_t val, value_string_ext *vse)
Attempt to convert a numeric value to a string using an extended value-string mapping.
Definition value_string.c:289
struct _val64_string val64_string
Mapping between a 64-bit integer value and its string representation.
WS_DLL_PUBLIC const char * try_rval_to_str(const uint32_t val, const range_string *rs)
Convert a 32-bit unsigned integer to its corresponding string representation based on a range string.
Definition value_string.c:872
WS_DLL_PUBLIC const char * try_time_val_to_str(const nstime_t *val, const time_value_string *vs)
Tries to match a time value against an array of time_value_string entries.
Definition value_string.c:913
WS_DLL_PUBLIC char * val_to_str(wmem_allocator_t *scope, const uint32_t val, const value_string *vs, const char *fmt)
Convert a numeric value to a string using a value-string mapping.
Definition value_string.c:51
WS_DLL_PUBLIC int value_str_value_compare(const void *a, const void *b)
Compare two value_string entries by their numeric value.
Definition value_string.c:32
WS_DLL_PUBLIC const char * try_val_to_str(const uint32_t val, const value_string *vs)
Attempt to convert a numeric value to a string using a value-string mapping.
Definition value_string.c:112
WS_DLL_PUBLIC void value_string_ext_free(value_string_ext *vse)
Free an extended value-string mapping structure.
Definition value_string.c:282
struct _string_string string_string
Maps a string key to a string value, used for table-driven string-to-string lookups.
struct _bytes_string bytes_string
Maps a byte sequence key to a string value, used for table-driven binary-pattern-to-string lookups.
WS_DLL_PUBLIC value_string * get_external_value_string(const char *name)
Retrieves an external value string by name.
Definition value_string.c:1028
WS_DLL_PUBLIC char * val_to_str_ext(wmem_allocator_t *scope, const uint32_t val, value_string_ext *vse, const char *fmt)
Convert a numeric value to a string using an extended value-string mapping.
Definition value_string.c:319
WS_DLL_PUBLIC const char * try_val_to_str_idx_ext(const uint32_t val, value_string_ext *vse, int *idx)
Attempt to convert a numeric value to a string and retrieve its index from an extended mapping.
Definition value_string.c:304
WS_DLL_PUBLIC const char * val64_to_str_wmem(wmem_allocator_t *scope, const uint64_t val, const val64_string *vs, const char *fmt)
Convert a 64-bit value to a string using a value-string mapping.
Definition value_string.c:120
WS_DLL_PUBLIC const char * try_val64_to_str(const uint64_t val, const val64_string *vs)
Attempt to convert a 64-bit value to a string using a value-string mapping.
Definition value_string.c:173
WS_DLL_PUBLIC void value_string_externals_cleanup(void)
Cleans up external value string resources.
Definition value_string.c:1015
WS_DLL_PUBLIC const char * val_to_str_ext_const(const uint32_t val, value_string_ext *vs, const char *unknown_str)
Convert a numeric value to a constant string using an extended value-string mapping.
Definition value_string.c:335
WS_DLL_PUBLIC const char * try_val64_to_str_ext(const uint64_t val, val64_string_ext *vse)
Convert a 64-bit value to its corresponding string index and pointer.
Definition value_string.c:561
WS_DLL_PUBLIC bool val64_string_ext_validate(const val64_string_ext *vse)
Validates a value_string_ext structure.
Definition value_string.c:1081
WS_DLL_PUBLIC int str_to_val_idx(const char *val, const value_string *vs)
Retrieve the index of a string in a value-string mapping array.
Definition value_string.c:200
WS_DLL_PUBLIC char * val64_to_str_ext_wmem(wmem_allocator_t *scope, const uint64_t val, val64_string_ext *vse, const char *fmt)
Convert a 64-bit unsigned integer to a string using an extended value string structure.
Definition value_string.c:590
WS_DLL_PUBLIC const char * try_rval_to_str_idx(const uint32_t val, const range_string *rs, int *idx)
Converts a 32-bit unsigned integer value to its corresponding string representation based on a range_...
Definition value_string.c:852
WS_DLL_PUBLIC val64_string_ext * val64_string_ext_new(wmem_allocator_t *scope, const val64_string *vs, unsigned vs_tot_num_entries, const char *vs_name)
Create a new extended value string structure.
Definition value_string.c:530
WS_DLL_PUBLIC const char * try_val64_to_str_idx_ext(const uint64_t val, val64_string_ext *vse, int *idx)
Convert a 64-bit value to its corresponding string index and pointer.
Definition value_string.c:576
struct _time_value_string time_value_string
Maps a timestamp key to a string value, used for table-driven time-to-string lookups.
WS_DLL_PUBLIC const char * try_bytesval_to_str(const uint8_t *val, const size_t val_len, const bytes_string *bs)
Convert a byte prefix to a string using a value_string array.
Definition value_string.c:954
WS_DLL_PUBLIC bool value_string_ext_validate(const value_string_ext *vse)
Validates a value_string_ext structure.
Definition value_string.c:1052
struct _value_string value_string
Mapping between a 32-bit integer value and its string representation.
WS_DLL_PUBLIC const char * bytesprefix_to_str(wmem_allocator_t *scope, const uint8_t *haystack, const size_t haystack_len, const bytes_string *bs, const char *fmt)
Convert a byte prefix to a string using a value_string array.
Definition value_string.c:973
WS_DLL_PUBLIC void register_external_value_string(const char *name, const value_string *vs)
Registers an external value string with a given name.
Definition value_string.c:1022
WS_DLL_PUBLIC const value_string * _try_val_to_str_ext_init(const uint32_t val, value_string_ext *vse)
Attempt to initialize and retrieve a value-string entry from an extended mapping.
Definition value_string.c:402
WS_DLL_PUBLIC const char * try_str_to_str(const char *val, const string_string *vs)
Converts a string to another string based on a value-string mapping.
Definition value_string.c:806
WS_DLL_PUBLIC const char * val_to_str_const(const uint32_t val, const value_string *vs, const char *unknown_str)
Convert a numeric value to a constant string using a value-string mapping.
Definition value_string.c:70
WS_DLL_PUBLIC const char * val64_to_str_const(const uint64_t val, const val64_string *vs, const char *unknown_str)
Convert a 64-bit value to a constant string using a value-string mapping.
Definition value_string.c:136
WS_DLL_PUBLIC const char * str_to_str_wmem(wmem_allocator_t *scope, const char *val, const string_string *vs, const char *fmt)
Converts a string value to a formatted string using a value string table.
Definition value_string.c:770
struct _range_string range_string
Maps an inclusive numeric range to a string value, used for table-driven range-to-string lookups.
WS_DLL_PUBLIC const char * val64_to_str_ext_const(const uint64_t val, val64_string_ext *vs, const char *unknown_str)
Convert a 64-bit unsigned integer to a string using an extended value string structure.
Definition value_string.c:606
WS_DLL_PUBLIC void register_external_value_string_ext(const char *name, const value_string_ext *vse)
Registers an external value string extension.
Definition value_string.c:1034
WS_DLL_PUBLIC const val64_string * _try_val64_to_str_ext_init(const uint64_t val, val64_string_ext *vse)
Attempt to initialize and retrieve a 64-bit value-string entry from an extended mapping.
Definition value_string.c:673
WS_DLL_PUBLIC const char * try_val64_to_str_idx(const uint64_t val, const val64_string *vs, int *idx)
Attempt to convert a 64-bit value to a string and retrieve its index.
Definition value_string.c:152
WS_DLL_PUBLIC const char * try_rval64_to_str(const uint64_t val, const range_string *rs)
Convert a 64-bit unsigned integer value to a string based on a range of strings.
Definition value_string.c:900
WS_DLL_PUBLIC const char * bytesval_to_str_wmem(wmem_allocator_t *scope, const uint8_t *val, const size_t val_len, const bytes_string *bs, const char *fmt)
Converts a byte value to a string using a format string.
Definition value_string.c:933
WS_DLL_PUBLIC const char * rval_to_str_wmem(wmem_allocator_t *scope, const uint32_t val, const range_string *rs, const char *fmt)
Convert a 32-bit unsigned integer to its corresponding string representation based on a range string.
Definition value_string.c:819
WS_DLL_PUBLIC void value_string_externals_init(void)
Initializes external value string and extension registries.
Definition value_string.c:1009
WS_DLL_PUBLIC const char * try_rval64_to_str_idx(const uint64_t val, const range_string *rs, int *idx)
Converts a 64-bit unsigned integer value to its corresponding string representation based on a range ...
Definition value_string.c:880
WS_DLL_PUBLIC const char * try_str_to_str_idx(const char *val, const string_string *vs, int *idx)
Converts a string to an index in a string-string mapping table.
Definition value_string.c:786
WS_DLL_PUBLIC uint32_t str_to_val(const char *val, const value_string *vs, const uint32_t err_val)
Convert a string to its corresponding numeric value using a value-string mapping.
Definition value_string.c:185
WS_DLL_PUBLIC const char * val64_string_ext_match_type_str(const val64_string_ext *vse)
Returns a string representation of the match type for a 64-bit value string extension.
Definition value_string.c:1096
WS_DLL_PUBLIC value_string_ext * get_external_value_string_ext(const char *name)
Retrieves an external value string extension by name.
Definition value_string.c:1040
WS_DLL_PUBLIC const char * rval_to_str_const(const uint32_t val, const range_string *rs, const char *unknown_str)
Convert a 32-bit unsigned integer to its corresponding string representation based on a range string.
Definition value_string.c:835