11 #define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
16 #define G_MAXINT32 0xf7777777
17 #define G_MININT32 0x80000000
19 #define GPOINTER_TO_INT(ptr) ((int)(ptr))
20 #define GPOINTER_TO_UINT(ptr) ((uint)(ptr))
21 #define GINT_TO_POINTER(v) ((gpointer) (v))
22 #define GUINT_TO_POINTER(v) ((gpointer) (v))
24 #define G_STRUCT_OFFSET(p_type,field) \
25 ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
30 #define g_new(type,size) ((type *) malloc (sizeof (type) * (size)))
31 #define g_new0(type,size) ((type *) calloc (sizeof (type), (size)))
32 #define g_free(obj) free (obj);
33 #define g_realloc(obj,size) realloc((obj), (size))
34 #define g_strdup(x) strdup(x)
35 #define g_malloc(x) malloc(x)
36 #define g_try_malloc(x) malloc(x)
37 #define g_try_realloc(obj,size) realloc((obj),(size))
38 #define g_malloc0(x) calloc(1,x)
45 typedef unsigned int gsize;
46 typedef unsigned int guint;
48 typedef unsigned short gushort;
50 typedef unsigned long gulong;
51 typedef void * gpointer;
52 typedef const void * gconstpointer;
54 typedef unsigned char guchar;
59 #define g_return_if_fail(x) do { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return; } } while (0) ;
60 #define g_return_val_if_fail(x,e) do { if (!(x)) { printf ("%s:%d: assertion %s failed", __FILE__, __LINE__, #x); return (e); } } while (0) ;
65 typedef struct _GHashTable GHashTable;
66 typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
67 typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
68 typedef void (*GDestroyNotify) (gpointer data);
69 typedef guint (*GHashFunc) (gconstpointer key);
70 typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
72 GHashTable *g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func);
73 void g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
74 guint g_hash_table_size (GHashTable *hash);
75 gpointer g_hash_table_lookup (GHashTable *hash, gconstpointer key);
76 gboolean g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
77 void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data);
78 gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data);
79 gboolean g_hash_table_remove (GHashTable *hash, gconstpointer key);
80 guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data);
81 void g_hash_table_destroy (GHashTable *hash);
83 #define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
84 #define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
86 gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
87 guint g_direct_hash (gconstpointer v1);
88 gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
89 guint g_int_hash (gconstpointer v1);
90 gboolean g_str_equal (gconstpointer v1, gconstpointer v2);
91 guint g_str_hash (gconstpointer v1);
93 #define g_assert(x) do { fprintf (stderr, "* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); abort (); } while (0)
94 #define g_assert_not_reached() do { fprintf (stderr, "* This line should not be reached at %s:%d\n", __FILE__, __LINE__); } while (0)
99 gchar *g_strdup_printf (const gchar *format, ...);
100 gchar *g_strndup (const gchar *str, gsize n);
101 const gchar *g_strerror (gint errnum);
102 gchar *g_strndup (const gchar *str, gsize n);
103 void g_strfreev (gchar **str_array);
104 gchar *g_strconcat (const gchar *first, ...);
111 #define G_LOG_DOMAIN ((gchar*) 0)
115 G_LOG_FLAG_RECURSION = 1 << 0,
116 G_LOG_FLAG_FATAL = 1 << 1,
118 G_LOG_LEVEL_ERROR = 1 << 2,
119 G_LOG_LEVEL_CRITICAL = 1 << 3,
120 G_LOG_LEVEL_WARNING = 1 << 4,
121 G_LOG_LEVEL_MESSAGE = 1 << 5,
122 G_LOG_LEVEL_INFO = 1 << 6,
123 G_LOG_LEVEL_DEBUG = 1 << 7,
125 G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
128 void g_print (const gchar *format, ...);
129 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
130 GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask);
131 void g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
132 void g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
134 #define g_error(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format)
135 #define g_critical(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format)
136 #define g_warning(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format)
137 #define g_message(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format)
138 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)