Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
str_util.h
1 /* str_util.h
2  * String utility definitions
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef __STR_UTIL_H__
12 #define __STR_UTIL_H__
13 
14 #include <glib.h>
15 #include "ws_symbol_export.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
20 
36 WS_DLL_PUBLIC
37 gchar *ascii_strdown_inplace(gchar *str);
38 
54 WS_DLL_PUBLIC
55 gchar *ascii_strup_inplace(gchar *str);
56 
62 WS_DLL_PUBLIC
63 gboolean isprint_string(const gchar *string);
64 
71 WS_DLL_PUBLIC
72 gboolean isprint_utf8_string(const gchar *string, guint length);
73 
79 WS_DLL_PUBLIC
80 gboolean isdigit_string(guchar *string);
81 
82 WS_DLL_PUBLIC
83 int ws_xton(char ch);
84 
85 typedef enum {
86  format_size_unit_none = 0,
87  format_size_unit_bytes = 1,
88  format_size_unit_bits = 2,
89  format_size_unit_bits_s = 3,
90  format_size_unit_bytes_s = 4,
91  format_size_unit_packets = 5,
92  format_size_unit_packets_s = 6,
93  format_size_prefix_si = 0 << 8,
94  format_size_prefix_iec = 1 << 8
95  /* XXX format_size_prefix_default_for_this_particular_os ? */
96 } format_size_flags_e;
97 
107 WS_DLL_PUBLIC
108 gchar *format_size(gint64 size, format_size_flags_e flags);
109 
110 WS_DLL_PUBLIC
111 gchar printable_char_or_period(gchar c);
112 
113 /* To pass one of two strings, singular or plural */
114 #define plurality(d,s,p) ((d) == 1 ? (s) : (p))
115 
116 #ifdef __cplusplus
117 }
118 
119 /* Should we just have separate unit and prefix enums instead? */
120 extern format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs);
121 #endif /* __cplusplus */
122 
123 #endif /* __STR_UTIL_H__ */