Export libwsutil symbols using WS_DLL_PUBLIC define
[metze/wireshark/wip.git] / wsutil / str_util.h
1 /* str_util.h
2  * String utility definitions
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifndef __STR_UTIL_H__
26 #define __STR_UTIL_H__
27
28 #include "ws_symbol_export.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
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.
39  *
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.
45  *
46  * @param str The string to be lower-cased.
47  * @return    ptr to the string
48  */
49 WS_DLL_PUBLIC
50 gchar *ascii_strdown_inplace(gchar *str);
51
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.
57  *
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.
63  *
64  * @param str The string to be upper-cased.
65  * @return    ptr to the string
66  */
67 WS_DLL_PUBLIC
68 gchar *ascii_strup_inplace(gchar *str);
69
70 /** Check if an entire string consists of printable characters
71  *
72  * @param str The string to be checked
73  * @return    TRUE if the entire string is printable, otherwise FALSE
74  */
75 WS_DLL_PUBLIC
76 gboolean isprint_string(const gchar *string);
77
78 /** Check if an entire string consists of digits
79  *
80  * @param str The string to be checked
81  * @return    TRUE if the entire string is digits, otherwise FALSE
82  */
83 WS_DLL_PUBLIC
84 gboolean isdigit_string(guchar *string);
85
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;
96
97 #ifdef __cplusplus
98 /* Should we just have separate unit and prefix enums instead? */
99 extern format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs);
100 #endif /* __cplusplus */
101
102 /** Given a size, return its value in a human-readable format
103  *
104  * Prefixes up to "T/Ti" (tera, tebi) are currently supported.
105  *
106  * @param size The size value
107  * @param flags Flags to control the output (unit of measurement,
108  * SI vs IEC, etc). Unit and prefix flags may be ORed together.
109  * @return A newly-allocated string representing the value.
110  */
111 WS_DLL_PUBLIC
112 gchar *format_size(gint64 size, format_size_flags_e flags);
113
114
115 #ifdef __cplusplus
116 }
117 #endif /* __cplusplus */
118
119 #endif /* __STR_UTIL_H__ */