MSWSP: parse_CColumnGroupArray() etc.
[wireshark-wip.git] / wsutil / str_util.h
blob505bb9088d71337826d0d65dacbc58d2ecbd7358
1 /* str_util.h
2 * String utility definitions
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __STR_UTIL_H__
26 #define __STR_UTIL_H__
28 #include "ws_symbol_export.h"
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
34 /** Convert all upper-case ASCII letters to their ASCII lower-case
35 * equivalents, in place, with a simple non-locale-dependent
36 * ASCII mapping (A-Z -> a-z).
37 * All other characters are left unchanged, as the mapping to
38 * lower case may be locale-dependent.
40 * The string is assumed to be in a character encoding, such as
41 * an ISO 8859 or other EUC encoding, or UTF-8, in which all
42 * bytes in the range 0x00 through 0x7F are ASCII characters and
43 * non-ASCII characters are constructed from one or more bytes in
44 * the range 0x80 through 0xFF.
46 * @param str The string to be lower-cased.
47 * @return ptr to the string
49 WS_DLL_PUBLIC
50 gchar *ascii_strdown_inplace(gchar *str);
52 /** Convert all lower-case ASCII letters to their ASCII upper-case
53 * equivalents, in place, with a simple non-locale-dependent
54 * ASCII mapping (a-z -> A-Z).
55 * All other characters are left unchanged, as the mapping to
56 * lower case may be locale-dependent.
58 * The string is assumed to be in a character encoding, such as
59 * an ISO 8859 or other EUC encoding, or UTF-8, in which all
60 * bytes in the range 0x00 through 0x7F are ASCII characters and
61 * non-ASCII characters are constructed from one or more bytes in
62 * the range 0x80 through 0xFF.
64 * @param str The string to be upper-cased.
65 * @return ptr to the string
67 WS_DLL_PUBLIC
68 gchar *ascii_strup_inplace(gchar *str);
70 /** Check if an entire string consists of printable characters
72 * @param string The string to be checked
73 * @return TRUE if the entire string is printable, otherwise FALSE
75 WS_DLL_PUBLIC
76 gboolean isprint_string(const gchar *string);
78 /** Check if an entire string consists of digits
80 * @param string The string to be checked
81 * @return TRUE if the entire string is digits, otherwise FALSE
83 WS_DLL_PUBLIC
84 gboolean isdigit_string(guchar *string);
86 typedef enum {
87 format_size_unit_none = 0, /**< No unit will be appended. You must supply your own. */
88 format_size_unit_bytes = 1, /**< "bytes" for un-prefixed sizes, "B" otherwise. */
89 format_size_unit_bits = 2, /**< "bits" for un-prefixed sizes, "b" otherwise. */
90 format_size_unit_bits_s = 3, /**< "bits/s" for un-prefixed sizes, "bps" otherwise. */
91 format_size_unit_bytes_s = 4, /**< "bytes/s" for un-prefixed sizes, "Bps" otherwise. */
92 format_size_prefix_si = 0 << 8, /**< SI (power of 1000) prefixes will be used. */
93 format_size_prefix_iec = 1 << 8 /**< IEC (power of 1024) prefixes will be used. */
94 /* XXX format_size_prefix_default_for_this_particular_os ? */
95 } format_size_flags_e;
97 /** Given a size, return its value in a human-readable format
99 * Prefixes up to "T/Ti" (tera, tebi) are currently supported.
101 * @param size The size value
102 * @param flags Flags to control the output (unit of measurement,
103 * SI vs IEC, etc). Unit and prefix flags may be ORed together.
104 * @return A newly-allocated string representing the value.
106 WS_DLL_PUBLIC
107 gchar *format_size(gint64 size, format_size_flags_e flags);
110 #ifdef __cplusplus
113 /* Should we just have separate unit and prefix enums instead? */
114 extern format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs);
115 #endif /* __cplusplus */
117 #endif /* __STR_UTIL_H__ */