• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/glib/
1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20/*
21 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22 * file for a list of people on the GLib Team.  See the ChangeLog
23 * files for a list of changes.  These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27/*
28 * Modified by Bruno Haible for use as a gnulib module.
29 */
30
31#ifndef __G_STRFUNCS_H__
32#define __G_STRFUNCS_H__
33
34#include <stdarg.h>
35#include <glib/gtypes.h>
36
37G_BEGIN_DECLS
38
39/* Functions like the ones in <ctype.h> that are not affected by locale. */
40typedef enum {
41  G_ASCII_ALNUM  = 1 << 0,
42  G_ASCII_ALPHA  = 1 << 1,
43  G_ASCII_CNTRL  = 1 << 2,
44  G_ASCII_DIGIT  = 1 << 3,
45  G_ASCII_GRAPH  = 1 << 4,
46  G_ASCII_LOWER  = 1 << 5,
47  G_ASCII_PRINT  = 1 << 6,
48  G_ASCII_PUNCT  = 1 << 7,
49  G_ASCII_SPACE  = 1 << 8,
50  G_ASCII_UPPER  = 1 << 9,
51  G_ASCII_XDIGIT = 1 << 10
52} GAsciiType;
53
54GLIB_VAR const guint16 * const g_ascii_table;
55
56#define g_ascii_isalnum(c) \
57  ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0)
58
59#define g_ascii_isalpha(c) \
60  ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0)
61
62#define g_ascii_iscntrl(c) \
63  ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0)
64
65#define g_ascii_isdigit(c) \
66  ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0)
67
68#define g_ascii_isgraph(c) \
69  ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0)
70
71#define g_ascii_islower(c) \
72  ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0)
73
74#define g_ascii_isprint(c) \
75  ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0)
76
77#define g_ascii_ispunct(c) \
78  ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0)
79
80#define g_ascii_isspace(c) \
81  ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0)
82
83#define g_ascii_isupper(c) \
84  ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0)
85
86#define g_ascii_isxdigit(c) \
87  ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0)
88
89#if 0
90gchar                 g_ascii_tolower  (gchar        c) G_GNUC_CONST;
91#endif
92gchar                 g_ascii_toupper  (gchar        c) G_GNUC_CONST;
93
94#if 0
95gint                  g_ascii_digit_value  (gchar    c) G_GNUC_CONST;
96gint                  g_ascii_xdigit_value (gchar    c) G_GNUC_CONST;
97
98/* String utility functions that modify a string argument or
99 * return a constant string that must not be freed.
100 */
101#define	 G_STR_DELIMITERS	"_-|> <."
102gchar*	              g_strdelimit     (gchar	     *string,
103					const gchar  *delimiters,
104					gchar	      new_delimiter);
105gchar*	              g_strcanon       (gchar        *string,
106					const gchar  *valid_chars,
107					gchar         substitutor);
108G_CONST_RETURN gchar* g_strerror       (gint	      errnum) G_GNUC_CONST;
109G_CONST_RETURN gchar* g_strsignal      (gint	      signum) G_GNUC_CONST;
110gchar*	              g_strreverse     (gchar	     *string);
111gsize	              g_strlcpy	       (gchar	     *dest,
112					const gchar  *src,
113					gsize         dest_size);
114gsize	              g_strlcat        (gchar	     *dest,
115					const gchar  *src,
116					gsize         dest_size);
117#endif
118gchar *               g_strstr_len     (const gchar  *haystack,
119					gssize        haystack_len,
120					const gchar  *needle);
121#if 0
122gchar *               g_strrstr        (const gchar  *haystack,
123					const gchar  *needle);
124gchar *               g_strrstr_len    (const gchar  *haystack,
125					gssize        haystack_len,
126					const gchar  *needle);
127
128gboolean              g_str_has_suffix (const gchar  *str,
129					const gchar  *suffix);
130gboolean              g_str_has_prefix (const gchar  *str,
131					const gchar  *prefix);
132
133/* String to/from double conversion functions */
134
135gdouble	              g_strtod         (const gchar  *nptr,
136					gchar	    **endptr);
137gdouble	              g_ascii_strtod   (const gchar  *nptr,
138					gchar	    **endptr);
139guint64		      g_ascii_strtoull (const gchar *nptr,
140					gchar      **endptr,
141					guint        base);
142gint64		      g_ascii_strtoll  (const gchar *nptr,
143					gchar      **endptr,
144					guint        base);
145/* 29 bytes should enough for all possible values that
146 * g_ascii_dtostr can produce.
147 * Then add 10 for good measure */
148#define G_ASCII_DTOSTR_BUF_SIZE (29 + 10)
149gchar *               g_ascii_dtostr   (gchar        *buffer,
150					gint          buf_len,
151					gdouble       d);
152gchar *               g_ascii_formatd  (gchar        *buffer,
153					gint          buf_len,
154					const gchar  *format,
155					gdouble       d);
156
157/* removes leading spaces */
158gchar*                g_strchug        (gchar        *string);
159/* removes trailing spaces */
160gchar*                g_strchomp       (gchar        *string);
161/* removes leading & trailing spaces */
162#define g_strstrip( string )	g_strchomp (g_strchug (string))
163
164gint                  g_ascii_strcasecmp  (const gchar *s1,
165					   const gchar *s2);
166gint                  g_ascii_strncasecmp (const gchar *s1,
167					   const gchar *s2,
168					   gsize        n);
169gchar*                g_ascii_strdown     (const gchar *str,
170					   gssize       len) G_GNUC_MALLOC;
171#endif
172gchar*                g_ascii_strup       (const gchar *str,
173					   gssize       len) G_GNUC_MALLOC;
174
175#if 0
176
177#ifndef G_DISABLE_DEPRECATED
178
179/* The following four functions are deprecated and will be removed in
180 * the next major release. They use the locale-specific tolower and
181 * toupper, which is almost never the right thing.
182 */
183
184gint	              g_strcasecmp     (const gchar *s1,
185					const gchar *s2);
186gint	              g_strncasecmp    (const gchar *s1,
187					const gchar *s2,
188					guint        n);
189gchar*	              g_strdown	       (gchar	     *string);
190gchar*	              g_strup	       (gchar	     *string);
191
192#endif /* G_DISABLE_DEPRECATED */
193
194#endif
195
196/* String utility functions that return a newly allocated string which
197 * ought to be freed with g_free from the caller at some point.
198 */
199gchar*	              g_strdup	       (const gchar *str) G_GNUC_MALLOC;
200gchar*	              g_strdup_printf  (const gchar *format,
201					...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC;
202#if 0
203gchar*	              g_strdup_vprintf (const gchar *format,
204					va_list      args) G_GNUC_MALLOC;
205#endif
206gchar*	              g_strndup	       (const gchar *str,
207					gsize        n) G_GNUC_MALLOC;
208#if 0
209gchar*	              g_strnfill       (gsize        length,
210					gchar        fill_char) G_GNUC_MALLOC;
211#endif
212gchar*	              g_strconcat      (const gchar *string1,
213					...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
214#if 0
215gchar*                g_strjoin	       (const gchar  *separator,
216					...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
217
218/* Make a copy of a string interpreting C string -style escape
219 * sequences. Inverse of g_strescape. The recognized sequences are \b
220 * \f \n \r \t \\ \" and the octal format.
221 */
222gchar*                g_strcompress    (const gchar *source) G_GNUC_MALLOC;
223
224/* Copy a string escaping nonprintable characters like in C strings.
225 * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
226 * to a string containing characters that are not to be escaped.
227 *
228 * Deprecated API: gchar* g_strescape (const gchar *source);
229 * Luckily this function wasn't used much, using NULL as second parameter
230 * provides mostly identical semantics.
231 */
232gchar*                g_strescape      (const gchar *source,
233					const gchar *exceptions) G_GNUC_MALLOC;
234
235gpointer              g_memdup	       (gconstpointer mem,
236					guint	       byte_size) G_GNUC_MALLOC;
237
238/* NULL terminated string arrays.
239 * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens
240 * at delim and return a newly allocated string array.
241 * g_strjoinv() concatenates all of str_array's strings, sliding in an
242 * optional separator, the returned string is newly allocated.
243 * g_strfreev() frees the array itself and all of its strings.
244 * g_strdupv() copies a NULL-terminated array of strings
245 * g_strv_length() returns the length of a NULL-terminated array of strings
246 */
247gchar**	              g_strsplit       (const gchar  *string,
248					const gchar  *delimiter,
249					gint          max_tokens) G_GNUC_MALLOC;
250gchar **	      g_strsplit_set   (const gchar *string,
251					const gchar *delimiters,
252					gint         max_tokens) G_GNUC_MALLOC;
253gchar*                g_strjoinv       (const gchar  *separator,
254					gchar       **str_array) G_GNUC_MALLOC;
255void                  g_strfreev       (gchar       **str_array);
256gchar**               g_strdupv        (gchar       **str_array) G_GNUC_MALLOC;
257guint                 g_strv_length    (gchar       **str_array);
258
259gchar*                g_stpcpy         (gchar        *dest,
260                                        const char   *src);
261
262G_CONST_RETURN gchar *g_strip_context  (const gchar *msgid,
263					const gchar *msgval);
264
265#endif
266
267G_END_DECLS
268
269#endif /* __G_STRFUNCS_H__ */
270