* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
- * Modified by the GLib Team and others 1997-1999. See the AUTHORS
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
* gint16, guint16
* gint32, guint32
* gint64, guint64
+ * gssize, gsize
*
* It defines the G_BYTE_ORDER symbol to one of G_*_ENDIAN (see later in
* this file).
#define g_return_if_fail(expr)
#define g_return_val_if_fail(expr,val)
+#define g_return_if_reached() return
+#define g_return_val_if_reached(val) return (val)
#else /* !G_DISABLE_CHECKS */
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d (%s): assertion `%s' failed.", \
+ "file %s: line %d (%s): assertion `%s' failed", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d (%s): assertion `%s' failed.", \
+ "file %s: line %d (%s): assertion `%s' failed", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
- return val; \
+ return (val); \
}; }G_STMT_END
+#define g_return_if_reached() G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): should not be reached", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__); \
+ return; }G_STMT_END
+
+#define g_return_val_if_reached(val) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d (%s): should not be reached", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__); \
+ return (val); }G_STMT_END
+
#else /* !__GNUC__ */
#define g_return_if_fail(expr) G_STMT_START{ \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: assertion `%s' failed.", \
+ "file %s: line %d: assertion `%s' failed", \
__FILE__, \
__LINE__, \
#expr); \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: assertion `%s' failed.", \
+ "file %s: line %d: assertion `%s' failed", \
__FILE__, \
__LINE__, \
#expr); \
- return val; \
+ return (val); \
}; }G_STMT_END
+#define g_return_if_reached() G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d: should not be reached", \
+ __FILE__, \
+ __LINE__); \
+ return; }G_STMT_END
+
+#define g_return_val_if_reached(val) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ "file %s: line %d: should not be reached", \
+ __FILE__, \
+ __LINE__); \
+ return (val); }G_STMT_END
+
#endif /* !__GNUC__ */
#endif /* !G_DISABLE_CHECKS */
typedef long glong;
typedef int gint;
typedef gint gboolean;
+typedef gchar* gstring;
typedef unsigned char guchar;
typedef unsigned short gushort;
typedef const void *gconstpointer;
-typedef gint32 gssize;
-typedef guint32 gsize;
typedef guint32 GQuark;
typedef gint32 GTime;
*/
#ifdef G_OS_WIN32
# ifdef GLIB_COMPILATION
-# define GUTILS_C_VAR __declspec(dllexport)
+# define GLIB_VAR __declspec(dllexport)
# else /* !GLIB_COMPILATION */
-# define GUTILS_C_VAR extern __declspec(dllimport)
+# define GLIB_VAR extern __declspec(dllimport)
# endif /* !GLIB_COMPILATION */
#else /* !G_OS_WIN32 */
-# define GUTILS_C_VAR extern
+# define GLIB_VAR extern
#endif /* !G_OS_WIN32 */
-GUTILS_C_VAR const guint glib_major_version;
-GUTILS_C_VAR const guint glib_minor_version;
-GUTILS_C_VAR const guint glib_micro_version;
-GUTILS_C_VAR const guint glib_interface_age;
-GUTILS_C_VAR const guint glib_binary_age;
+GLIB_VAR const guint glib_major_version;
+GLIB_VAR const guint glib_minor_version;
+GLIB_VAR const guint glib_micro_version;
+GLIB_VAR const guint glib_interface_age;
+GLIB_VAR const guint glib_binary_age;
#define GLIB_CHECK_VERSION(major,minor,micro) \
(GLIB_MAJOR_VERSION > (major) || \
gconstpointer lookup_key,
gpointer *orig_key,
gpointer *value);
-void g_hash_table_freeze (GHashTable *hash_table);
-void g_hash_table_thaw (GHashTable *hash_table);
void g_hash_table_foreach (GHashTable *hash_table,
GHFunc func,
gpointer user_data);
gpointer user_data);
guint g_hash_table_size (GHashTable *hash_table);
+/* The following two functions are deprecated and will be removed in
+ * the next major release. They do no good. */
+void g_hash_table_freeze (GHashTable *hash_table);
+void g_hash_table_thaw (GHashTable *hash_table);
/* Caches
*/
#define g_message(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_MESSAGE, \
format, ##args)
+#define g_critical(format, args...) g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_CRITICAL, \
+ format, ##args)
#define g_warning(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
format, ##args)
va_end (args);
}
static void
+g_critical (const gchar *format,
+ ...)
+{
+ va_list args;
+ va_start (args, format);
+ g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args);
+ va_end (args);
+}
+static void
g_warning (const gchar *format,
...)
{
gchar* g_strdown (gchar *string);
gchar* g_strup (gchar *string);
gchar* g_strreverse (gchar *string);
+gsize g_strlcpy (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
+gsize g_strlcat (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
/* removes leading spaces */
gchar* g_strchug (gchar *string);
/* removes trailing spaces */
gulong n,
gchar const *format,
va_list args);
-gchar* g_basename (const gchar *file_name);
/* Check if a file name is an absolute path */
gboolean g_path_is_absolute (const gchar *file_name);
/* In case of absolute paths, skip the root part */
gchar* g_path_skip_root (gchar *file_name);
-/* strings are newly allocated with g_malloc() */
+/* These two functions are deprecated and will be removed in the next
+ * major release of GLib. Use g_path_get_dirname/g_path_get_basename
+ * instead. Whatch out! The string returned by g_path_get_basename
+ * must be g_freed, while the string returned by g_basename must not.*/
+gchar* g_basename (const gchar *file_name);
gchar* g_dirname (const gchar *file_name);
+
+/* The returned strings are newly allocated with g_malloc() */
gchar* g_get_current_dir (void);
+gchar* g_path_get_basename (const gchar *file_name);
+gchar* g_path_get_dirname (const gchar *file_name);
+
+/* Get the codeset for the current locale */
+/* gchar * g_get_codeset (void); */
/* return the environment string for the variable. The returned memory
* must not be freed. */
GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gboolean free_segment);
+gboolean g_string_equal (const GString *v,
+ const GString *v2);
+guint g_string_hash (const GString *str);
GString* g_string_assign (GString *string,
const gchar *rval);
GString* g_string_truncate (GString *string,
/* Hash Functions
*/
-gint g_str_equal (gconstpointer v,
- gconstpointer v2);
-guint g_str_hash (gconstpointer v);
+gboolean g_str_equal (gconstpointer v,
+ gconstpointer v2);
+guint g_str_hash (gconstpointer v);
-gint g_int_equal (gconstpointer v,
- gconstpointer v2);
-guint g_int_hash (gconstpointer v);
+gint g_int_equal (gconstpointer v,
+ gconstpointer v2);
+guint g_int_hash (gconstpointer v);
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or
gpointer user_data);
gpointer g_scanner_lookup_symbol (GScanner *scanner,
const gchar *symbol);
-void g_scanner_freeze_symbol_table (GScanner *scanner);
-void g_scanner_thaw_symbol_table (GScanner *scanner);
void g_scanner_unexp_token (GScanner *scanner,
GTokenType expected_token,
const gchar *identifier_spec,
g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \
} G_STMT_END
+/* The following two functions are deprecated and will be removed in
+ * the next major release. They do no good. */
+void g_scanner_freeze_symbol_table (GScanner *scanner);
+void g_scanner_thaw_symbol_table (GScanner *scanner);
/* GCompletion
*/
#ifdef G_OS_WIN32
-GUTILS_C_VAR guint g_pipe_readable_msg;
+GLIB_VAR guint g_pipe_readable_msg;
#define G_WIN32_MSG_HANDLE 19981206
void (*thread_self) (gpointer thread);
};
-GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use;
-GUTILS_C_VAR gboolean g_thread_use_default_impl;
-GUTILS_C_VAR gboolean g_threads_got_initialized;
+GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use;
+GLIB_VAR gboolean g_thread_use_default_impl;
+GLIB_VAR gboolean g_threads_got_initialized;
/* initializes the mutex/cond/private implementation for glib, might
* only be called once, and must not be called directly or indirectly
}
#endif /* __cplusplus */
+#include <gunicode.h>
+#include <gerror.h>
#endif /* __G_LIB_H__ */