00001 /* GLIB - Library of useful routines for C programming 00002 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the 00016 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /* 00021 * Modified by the GLib Team and others 1997-2000. See the AUTHORS 00022 * file for a list of people on the GLib Team. See the ChangeLog 00023 * files for a list of changes. These files are distributed with 00024 * GLib at ftp://ftp.gtk.org/pub/gtk/. 00025 */ 00026 00027 #ifndef __G_STRFUNCS_H__ 00028 #define __G_STRFUNCS_H__ 00029 00030 #include <stdarg.h> 00031 #include <g_types.h> 00032 00033 G_BEGIN_DECLS 00034 00035 /* String utility functions that modify a string argument or 00036 * return a constant string that must not be freed. 00037 */ 00038 #define G_STR_DELIMITERS "_-|> <." 00039 gchar* g_strdelimit (gchar *string, 00040 const gchar *delimiters, 00041 gchar new_delimiter); 00042 gchar* g_strcanon (gchar *string, 00043 const gchar *valid_chars, 00044 gchar subsitutor); 00045 gdouble g_strtod (const gchar *nptr, 00046 gchar **endptr); 00047 gchar* g_strerror (gint errnum) G_GNUC_CONST; 00048 gchar* g_strsignal (gint signum) G_GNUC_CONST; 00049 gint g_strcasecmp (const gchar *s1, 00050 const gchar *s2); 00051 gint g_strncasecmp (const gchar *s1, 00052 const gchar *s2, 00053 guint n); 00054 gchar* g_strdown (gchar *string); 00055 gchar* g_strup (gchar *string); 00056 gchar* g_strreverse (gchar *string); 00057 gsize g_strlcpy (gchar *dest, 00058 const gchar *src, 00059 gsize dest_size); 00060 gsize g_strlcat (gchar *dest, 00061 const gchar *src, 00062 gsize dest_size); 00063 /* removes leading spaces */ 00064 gchar* g_strchug (gchar *string); 00065 /* removes trailing spaces */ 00066 gchar* g_strchomp (gchar *string); 00067 /* removes leading & trailing spaces */ 00068 #define g_strstrip( string ) g_strchomp (g_strchug (string)) 00069 00070 /* String utility functions that return a newly allocated string which 00071 * ought to be freed with g_free from the caller at some point. 00072 */ 00073 gchar* g_strdup (const gchar *str); 00074 gchar* g_strdup_printf (const gchar *format, 00075 ...) G_GNUC_PRINTF (1, 2); 00076 gchar* g_strdup_vprintf (const gchar *format, 00077 va_list args); 00078 gchar* g_strndup (const gchar *str, 00079 guint n); 00080 gchar* g_strnfill (guint length, 00081 gchar fill_char); 00082 gchar* g_strconcat (const gchar *string1, 00083 ...); /* NULL terminated */ 00084 gchar* g_strjoin (const gchar *separator, 00085 ...); /* NULL terminated */ 00086 /* Make a copy of a string interpreting C string -style escape 00087 * sequences. Inverse of g_strescape. The recognized sequences are \b 00088 * \f \n \r \t \\ \" and the octal format. 00089 */ 00090 gchar* g_strcompress (const gchar *source); 00091 00092 /* Copy a string escaping nonprintable characters like in C strings. 00093 * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points 00094 * to a string containing characters that are not to be escaped. 00095 * 00096 * Deprecated API: gchar* g_strescape (const gchar *source); 00097 * Luckily this function wasn't used much, using NULL as second parameter 00098 * provides mostly identical semantics. 00099 */ 00100 gchar* g_strescape (const gchar *source, 00101 const gchar *exceptions); 00102 00103 gpointer g_memdup (gconstpointer mem, 00104 guint byte_size); 00105 00106 /* NULL terminated string arrays. 00107 * g_strsplit() splits up string into max_tokens tokens at delim and 00108 * returns a newly allocated string array. 00109 * g_strjoinv() concatenates all of str_array's strings, sliding in an 00110 * optional separator, the returned string is newly allocated. 00111 * g_strfreev() frees the array itself and all of its strings. 00112 * g_strdupv() copies a NULL-terminated array of strings 00113 */ 00114 gchar** g_strsplit (const gchar *string, 00115 const gchar *delimiter, 00116 gint max_tokens); 00117 gchar* g_strjoinv (const gchar *separator, 00118 gchar **str_array); 00119 void g_strfreev (gchar **str_array); 00120 gchar** g_strdupv (gchar **str_array); 00121 00122 G_END_DECLS 00123 00124 #endif /* __G_STRFUNCS_H__ */