1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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.
22 /* system specific config file
24 #include <glibconfig.h>
26 /* include varargs functions for assertment macros
30 /* optionally feature DMALLOC memory allocation debugger
37 /* glib provides definitions for the extrema of many
38 * of the standard types. These are:
55 #define G_MINFLOAT FLT_MIN
56 #define G_MAXFLOAT FLT_MAX
57 #define G_MINDOUBLE DBL_MIN
58 #define G_MAXDOUBLE DBL_MAX
64 #define G_MINFLOAT MINFLOAT
65 #define G_MAXFLOAT MAXFLOAT
66 #define G_MINDOUBLE MINDOUBLE
67 #define G_MAXDOUBLE MAXDOUBLE
69 #endif /* HAVE_VALUES_H */
75 #define G_MINSHORT SHRT_MIN
76 #define G_MAXSHORT SHRT_MAX
77 #define G_MININT INT_MIN
78 #define G_MAXINT INT_MAX
79 #define G_MINLONG LONG_MIN
80 #define G_MAXLONG LONG_MAX
86 #endif /* HAVE_FLOAT_H */
88 #define G_MINSHORT MINSHORT
89 #define G_MAXSHORT MAXSHORT
90 #define G_MININT MININT
91 #define G_MAXINT MAXINT
92 #define G_MINLONG MINLONG
93 #define G_MAXLONG MAXLONG
95 #endif /* HAVE_VALUES_H */
98 /* the #pragma } statment is used to fix up emacs' c-mode which gets
99 * confused by extern "C" {. the ansi standard says that compilers
100 * have to ignore #pragma directives that they don't know about,
101 * so we should be save in using this.
106 #endif /* __cplusplus */
109 /* Provide definitions for some commonly used macros.
110 * Some of them are only provided if they haven't already
111 * been defined. It is assumed that if they are already
112 * defined then the current definition is correct.
115 #define NULL ((void*) 0)
123 #define TRUE (!FALSE)
127 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
130 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
133 #define ABS(a) (((a) < 0) ? -(a) : (a))
136 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
139 /* Define G_VA_COPY() to do the right thing for copying va_list variables.
140 * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.
142 #if !defined (G_VA_COPY)
143 # if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
144 # define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
145 # elif defined (G_VA_COPY_AS_ARRAY)
146 # define G_VA_COPY(ap1, ap2) g_memmove ((ap1), (ap2), sizeof (va_list))
147 # else /* va_list is a pointer */
148 # define G_VA_COPY(ap1, ap2) ((ap1) = (ap2))
149 # endif /* va_list is a pointer */
150 #endif /* !G_VA_COPY */
153 /* Provide simple enum value macro wrappers that ease automated
154 * enum value stringification code. [abandoned]
156 #if !defined (G_CODE_GENERATION)
157 #define G_ENUM( EnumerationName ) EnumerationName
158 #define G_FLAGS( EnumerationName ) EnumerationName
159 #define G_NV( VALUE_NAME , value_nick, VALUE) VALUE_NAME = (VALUE)
160 #define G_SV( VALUE_NAME, value_nick ) VALUE_NAME
161 #else /* G_CODE_GENERATION */
162 #define G_ENUM( EnumerationName ) G_ENUM_E + EnumerationName +
163 #define G_FLAGS( EnumerationName ) G_ENUM_F + EnumerationName +
164 #define G_NV( VALUE_NAME , value_nick, VALUE) G_ENUM_V + VALUE_NAME + value_nick +
165 #define G_SV( VALUE_NAME, value_nick ) G_ENUM_V + VALUE_NAME + value_nick +
166 #endif /* G_CODE_GENERATION */
169 /* inlining hassle. for compilers that don't allow the `inline' keyword,
170 * mostly because of strict ANSI C compliance or dumbness, we try to fall
171 * back to either `__inline__' or `__inline'.
172 * we define G_CAN_INLINE, if the compiler seems to be actually
173 * *capable* to do function inlining, in which case inline function bodys
174 * do make sense. we also define G_INLINE_FUNC to properly export the
175 * function prototypes if no inlinig can be performed.
176 * we special case most of the stuff, so inline functions can have a normal
177 * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1.
179 #ifndef G_INLINE_FUNC
180 # define G_CAN_INLINE 1
183 # if defined (__GNUC__) && defined (__STRICT_ANSI__)
185 # define inline __inline__
187 #else /* !G_HAVE_INLINE */
189 # if defined (G_HAVE___INLINE__)
190 # define inline __inline__
191 # else /* !inline && !__inline__ */
192 # if defined (G_HAVE___INLINE)
193 # define inline __inline
194 # else /* !inline && !__inline__ && !__inline */
195 # define inline /* don't inline, then */
196 # ifndef G_INLINE_FUNC
202 #ifndef G_INLINE_FUNC
205 # define G_INLINE_FUNC extern inline
208 # define G_INLINE_FUNC extern
210 # else /* !__GNUC__ */
212 # define G_INLINE_FUNC static inline
214 # define G_INLINE_FUNC extern
216 # endif /* !__GNUC__ */
217 #endif /* !G_INLINE_FUNC */
220 /* Provide simple macro statement wrappers (adapted from Perl):
221 * G_STMT_START { statements; } G_STMT_END;
222 * can be used as a single statement, as in
223 * if (x) G_STMT_START { ... } G_STMT_END; else ...
225 * For gcc we will wrap the statements within `({' and `})' braces.
226 * For SunOS they will be wrapped within `if (1)' and `else (void) 0',
227 * and otherwise within `do' and `while (0)'.
229 #if !(defined (G_STMT_START) && defined (G_STMT_END))
230 # if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
231 # define G_STMT_START (void)(
232 # define G_STMT_END )
234 # if (defined (sun) || defined (__sun__))
235 # define G_STMT_START if (1)
236 # define G_STMT_END else (void)0
238 # define G_STMT_START do
239 # define G_STMT_END while (0)
245 /* Provide macros to feature the GCC function attribute.
247 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
248 #define G_GNUC_PRINTF( format_idx, arg_idx ) \
249 __attribute__((format (printf, format_idx, arg_idx)))
250 #define G_GNUC_SCANF( format_idx, arg_idx ) \
251 __attribute__((format (scanf, format_idx, arg_idx)))
252 #define G_GNUC_FORMAT( arg_idx ) \
253 __attribute__((format_arg (arg_idx)))
254 #define G_GNUC_NORETURN \
255 __attribute__((noreturn))
256 #define G_GNUC_CONST \
257 __attribute__((const))
258 #else /* !__GNUC__ */
259 #define G_GNUC_PRINTF( format_idx, arg_idx )
260 #define G_GNUC_SCANF( format_idx, arg_idx )
261 #define G_GNUC_FORMAT( arg_idx )
262 #define G_GNUC_NORETURN
264 #endif /* !__GNUC__ */
267 /* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
268 * macros, so we can refer to them as strings unconditionally.
271 #define G_GNUC_FUNCTION (__FUNCTION__)
272 #define G_GNUC_PRETTY_FUNCTION (__PRETTY_FUNCTION__)
273 #else /* !__GNUC__ */
274 #define G_GNUC_FUNCTION ("")
275 #define G_GNUC_PRETTY_FUNCTION ("")
276 #endif /* !__GNUC__ */
279 /* Hacker macro to place breakpoints for x86 machines.
280 * Actual use is strongly deprecated of course ;)
282 #if defined (__i386__) && defined (__GNUC__)
283 #define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
284 #else /* !__i386__ */
285 #define G_BREAKPOINT()
286 #endif /* __i386__ */
291 # ifdef NeXT /* @#%@! NeXTStep */
292 # define ATEXIT(proc) (!atexit (proc))
294 # define ATEXIT(proc) (atexit (proc))
296 # elif defined (HAVE_ON_EXIT)
297 # define ATEXIT(proc) (on_exit ((void (*)(int, void *))(proc), NULL))
302 /* Provide macros for easily allocating memory. The macros
303 * will cast the allocated memory to the specified type
304 * in order to avoid compiler warnings. (Makes the code neater).
309 #define g_new(type, count) (ALLOC (type, count))
310 #define g_new0(type, count) (CALLOC (type, count))
312 #else /* __DMALLOC_H__ */
314 #define g_new(type, count) \
315 ((type *) g_malloc ((unsigned) sizeof (type) * (count)))
316 #define g_new0(type, count) \
317 ((type *) g_malloc0 ((unsigned) sizeof (type) * (count)))
318 #endif /* __DMALLOC_H__ */
320 #define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
321 g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
323 sizeof (type) * (pre_alloc), \
326 #define g_chunk_new(type, chunk) ( \
327 (type *) g_mem_chunk_alloc (chunk) \
329 #define g_chunk_new0(type, chunk) ( \
330 (type *) g_mem_chunk_alloc0 (chunk) \
332 #define g_chunk_free(mem, mem_chunk) G_STMT_START { \
333 g_mem_chunk_free ((mem_chunk), (mem)); \
337 #define g_string(x) #x
340 /* Provide macros for error handling. The "assert" macros will
341 * exit on failure. The "return" macros will exit the current
342 * function. Two different definitions are given for the macros
343 * if G_DISABLE_ASSERT is not defined, in order to support gcc's
344 * __PRETTY_FUNCTION__ capability.
347 #ifdef G_DISABLE_ASSERT
349 #define g_assert(expr)
350 #define g_assert_not_reached()
352 #else /* !G_DISABLE_ASSERT */
356 #define g_assert(expr) G_STMT_START{ \
358 g_log (G_LOG_DOMAIN, \
360 "file %s: line %d (%s): assertion failed: (%s)", \
363 __PRETTY_FUNCTION__, \
366 #define g_assert_not_reached() G_STMT_START{ \
367 g_log (G_LOG_DOMAIN, \
369 "file %s: line %d (%s): should not be reached", \
372 __PRETTY_FUNCTION__); }G_STMT_END
374 #else /* !__GNUC__ */
376 #define g_assert(expr) G_STMT_START{ \
378 g_log (G_LOG_DOMAIN, \
380 "file %s: line %d: assertion failed: (%s)", \
385 #define g_assert_not_reached() G_STMT_START{ \
386 g_log (G_LOG_DOMAIN, \
388 "file %s: line %d: should not be reached", \
390 __LINE__); }G_STMT_END
392 #endif /* __GNUC__ */
394 #endif /* !G_DISABLE_ASSERT */
397 #ifdef G_DISABLE_CHECKS
399 #define g_return_if_fail(expr)
400 #define g_return_val_if_fail(expr,val)
402 #else /* !G_DISABLE_CHECKS */
406 #define g_return_if_fail(expr) G_STMT_START{ \
409 g_log (G_LOG_DOMAIN, \
410 G_LOG_LEVEL_CRITICAL, \
411 "file %s: line %d (%s): assertion `%s' failed.", \
414 __PRETTY_FUNCTION__, \
419 #define g_return_val_if_fail(expr,val) G_STMT_START{ \
422 g_log (G_LOG_DOMAIN, \
423 G_LOG_LEVEL_CRITICAL, \
424 "file %s: line %d (%s): assertion `%s' failed.", \
427 __PRETTY_FUNCTION__, \
432 #else /* !__GNUC__ */
434 #define g_return_if_fail(expr) G_STMT_START{ \
437 g_log (G_LOG_DOMAIN, \
438 G_LOG_LEVEL_CRITICAL, \
439 "file %s: line %d: assertion `%s' failed.", \
446 #define g_return_val_if_fail(expr, val) G_STMT_START{ \
449 g_log (G_LOG_DOMAIN, \
450 G_LOG_LEVEL_CRITICAL, \
451 "file %s: line %d: assertion `%s' failed.", \
458 #endif /* !__GNUC__ */
460 #endif /* !G_DISABLE_CHECKS */
463 /* Provide type definitions for commonly used types.
464 * These are useful because a "gint8" can be adjusted
465 * to be 1 byte (8 bits) on all platforms. Similarly and
466 * more importantly, "gint32" can be adjusted to be
467 * 4 bytes (32 bits) on all platforms.
471 typedef short gshort;
474 typedef gint gboolean;
476 typedef unsigned char guchar;
477 typedef unsigned short gushort;
478 typedef unsigned long gulong;
479 typedef unsigned int guint;
481 typedef float gfloat;
482 typedef double gdouble;
484 /* HAVE_LONG_DOUBLE doesn't work correctly on all platforms.
485 * Since gldouble isn't used anywhere, just disable it for now */
488 #ifdef HAVE_LONG_DOUBLE
489 typedef long double gldouble;
490 #else /* HAVE_LONG_DOUBLE */
491 typedef double gldouble;
492 #endif /* HAVE_LONG_DOUBLE */
495 typedef void* gpointer;
496 typedef const void *gconstpointer;
498 #if (SIZEOF_CHAR == 1)
499 typedef signed char gint8;
500 typedef unsigned char guint8;
501 #endif /* SIZEOF_CHAR */
503 #if (SIZEOF_SHORT == 2)
504 typedef signed short gint16;
505 typedef unsigned short guint16;
506 #endif /* SIZEOF_SHORT */
508 #if (SIZEOF_INT == 4)
509 typedef signed int gint32;
510 typedef unsigned int guint32;
511 #elif (SIZEOF_LONG == 4)
512 typedef signed long gint32;
513 typedef unsigned long guint32;
514 #endif /* SIZEOF_INT */
516 #if (SIZEOF_LONG == 8)
517 #define HAVE_GINT64 1
518 typedef signed long gint64;
519 typedef unsigned long guint64;
520 #elif (SIZEOF_LONG_LONG == 8)
521 #define HAVE_GINT64 1
522 typedef signed long long gint64;
523 typedef unsigned long long guint64;
530 /* Define macros for storing integers inside pointers
532 #if (SIZEOF_INT == SIZEOF_VOID_P)
534 #define GPOINTER_TO_INT(p) ((gint)(p))
535 #define GPOINTER_TO_UINT(p) ((guint)(p))
537 #define GINT_TO_POINTER(i) ((gpointer)(i))
538 #define GUINT_TO_POINTER(u) ((gpointer)(u))
540 #elif (SIZEOF_LONG == SIZEOF_VOID_P)
542 #define GPOINTER_TO_INT(p) ((gint)(glong)(p))
543 #define GPOINTER_TO_UINT(p) ((guint)(gulong)(p))
545 #define GINT_TO_POINTER(i) ((gpointer)(glong)(i))
546 #define GUINT_TO_POINTER(u) ((gpointer)(gulong)(u))
549 #error SIZEOF_VOID_P unknown - This should never happen
552 typedef gint32 gssize;
553 typedef guint32 gsize;
554 typedef guint32 GQuark;
555 typedef gint32 GTime;
560 extern const guint glib_major_version;
561 extern const guint glib_minor_version;
562 extern const guint glib_micro_version;
563 extern const guint glib_interface_age;
564 extern const guint glib_binary_age;
567 /* Forward declarations of glib types.
570 typedef struct _GList GList;
571 typedef struct _GSList GSList;
572 typedef struct _GHashTable GHashTable;
573 typedef struct _GCache GCache;
574 typedef struct _GTree GTree;
575 typedef struct _GTimer GTimer;
576 typedef struct _GMemChunk GMemChunk;
577 typedef struct _GListAllocator GListAllocator;
578 typedef struct _GStringChunk GStringChunk;
579 typedef struct _GString GString;
580 typedef struct _GArray GArray;
581 typedef struct _GPtrArray GPtrArray;
582 typedef struct _GByteArray GByteArray;
583 typedef struct _GDebugKey GDebugKey;
584 typedef struct _GScannerConfig GScannerConfig;
585 typedef struct _GScanner GScanner;
586 typedef union _GValue GValue;
587 typedef struct _GCompletion GCompletion;
588 typedef struct _GRelation GRelation;
589 typedef struct _GTuples GTuples;
590 typedef struct _GNode GNode;
595 G_TRAVERSE_LEAFS = 1 << 0,
596 G_TRAVERSE_NON_LEAFS = 1 << 1,
597 G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
598 G_TRAVERSE_MASK = 0x03
609 /* Log level shift offset for user defined
610 * log levels (0-7 are used by GLib).
612 #define G_LOG_LEVEL_USER_SHIFT (8)
614 /* Glib log levels and flags.
619 G_LOG_FLAG_RECURSION = 1 << 0,
620 G_LOG_FLAG_FATAL = 1 << 1,
622 /* GLib log levels */
623 G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
624 G_LOG_LEVEL_CRITICAL = 1 << 3,
625 G_LOG_LEVEL_WARNING = 1 << 4,
626 G_LOG_LEVEL_MESSAGE = 1 << 5,
627 G_LOG_LEVEL_INFO = 1 << 6,
628 G_LOG_LEVEL_DEBUG = 1 << 7,
630 G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
633 /* GLib log levels that are considered fatal by default */
634 #define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
637 typedef gpointer (*GCacheNewFunc) (gpointer key);
638 typedef gpointer (*GCacheDupFunc) (gpointer value);
639 typedef void (*GCacheDestroyFunc) (gpointer value);
640 typedef gint (*GCompareFunc) (gconstpointer a,
642 typedef gchar* (*GCompletionFunc) (gpointer);
643 typedef void (*GDestroyNotify) (gpointer data);
644 typedef void (*GFunc) (gpointer data,
646 typedef guint (*GHashFunc) (gconstpointer key);
647 typedef void (*GHFunc) (gpointer key,
650 typedef void (*GLogFunc) (const gchar *log_domain,
651 GLogLevelFlags log_level,
652 const gchar *message,
654 typedef gboolean (*GNodeTraverseFunc) (GNode *node,
656 typedef void (*GNodeForeachFunc) (GNode *node,
658 typedef gint (*GSearchFunc) (gpointer key,
660 typedef void (*GScannerMsgFunc) (GScanner *scanner,
663 typedef gint (*GTraverseFunc) (gpointer key,
716 struct _GCache { gint dummy; };
717 struct _GTree { gint dummy; };
718 struct _GTimer { gint dummy; };
719 struct _GMemChunk { gint dummy; };
720 struct _GListAllocator { gint dummy; };
721 struct _GStringChunk { gint dummy; };
724 /* Doubly linked lists
726 GList* g_list_alloc (void);
727 void g_list_free (GList *list);
728 void g_list_free_1 (GList *list);
729 GList* g_list_append (GList *list,
731 GList* g_list_prepend (GList *list,
733 GList* g_list_insert (GList *list,
736 GList* g_list_insert_sorted (GList *list,
739 GList* g_list_concat (GList *list1,
741 GList* g_list_remove (GList *list,
743 GList* g_list_remove_link (GList *list,
745 GList* g_list_reverse (GList *list);
746 GList* g_list_nth (GList *list,
748 GList* g_list_find (GList *list,
750 GList* g_list_find_custom (GList *list,
753 gint g_list_position (GList *list,
755 gint g_list_index (GList *list,
757 GList* g_list_last (GList *list);
758 GList* g_list_first (GList *list);
759 guint g_list_length (GList *list);
760 void g_list_foreach (GList *list,
763 gpointer g_list_nth_data (GList *list,
765 #define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
766 #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
769 /* Singly linked lists
771 GSList* g_slist_alloc (void);
772 void g_slist_free (GSList *list);
773 void g_slist_free_1 (GSList *list);
774 GSList* g_slist_append (GSList *list,
776 GSList* g_slist_prepend (GSList *list,
778 GSList* g_slist_insert (GSList *list,
781 GSList* g_slist_insert_sorted (GSList *list,
784 GSList* g_slist_concat (GSList *list1,
786 GSList* g_slist_remove (GSList *list,
788 GSList* g_slist_remove_link (GSList *list,
790 GSList* g_slist_reverse (GSList *list);
791 GSList* g_slist_nth (GSList *list,
793 GSList* g_slist_find (GSList *list,
795 GSList* g_slist_find_custom (GSList *list,
798 gint g_slist_position (GSList *list,
800 gint g_slist_index (GSList *list,
802 GSList* g_slist_last (GSList *list);
803 guint g_slist_length (GSList *list);
804 void g_slist_foreach (GSList *list,
807 gpointer g_slist_nth_data (GSList *list,
809 #define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
814 GListAllocator* g_list_allocator_new (void);
815 void g_list_allocator_free (GListAllocator* allocator);
816 GListAllocator* g_slist_set_allocator (GListAllocator* allocator);
817 GListAllocator* g_list_set_allocator (GListAllocator* allocator);
822 GHashTable* g_hash_table_new (GHashFunc hash_func,
823 GCompareFunc key_compare_func);
824 void g_hash_table_destroy (GHashTable *hash_table);
825 void g_hash_table_insert (GHashTable *hash_table,
828 void g_hash_table_remove (GHashTable *hash_table,
830 gpointer g_hash_table_lookup (GHashTable *hash_table,
832 gboolean g_hash_table_lookup_extended(GHashTable *hash_table,
833 gconstpointer lookup_key,
836 void g_hash_table_freeze (GHashTable *hash_table);
837 void g_hash_table_thaw (GHashTable *hash_table);
838 void g_hash_table_foreach (GHashTable *hash_table,
841 gint g_hash_table_size (GHashTable *hash_table);
846 GCache* g_cache_new (GCacheNewFunc value_new_func,
847 GCacheDestroyFunc value_destroy_func,
848 GCacheDupFunc key_dup_func,
849 GCacheDestroyFunc key_destroy_func,
850 GHashFunc hash_key_func,
851 GHashFunc hash_value_func,
852 GCompareFunc key_compare_func);
853 void g_cache_destroy (GCache *cache);
854 gpointer g_cache_insert (GCache *cache,
856 void g_cache_remove (GCache *cache,
858 void g_cache_key_foreach (GCache *cache,
861 void g_cache_value_foreach (GCache *cache,
866 /* Balanced binary trees
868 GTree* g_tree_new (GCompareFunc key_compare_func);
869 void g_tree_destroy (GTree *tree);
870 void g_tree_insert (GTree *tree,
873 void g_tree_remove (GTree *tree,
875 gpointer g_tree_lookup (GTree *tree,
877 void g_tree_traverse (GTree *tree,
878 GTraverseFunc traverse_func,
879 GTraverseType traverse_type,
881 gpointer g_tree_search (GTree *tree,
882 GSearchFunc search_func,
884 gint g_tree_height (GTree *tree);
885 gint g_tree_nnodes (GTree *tree);
889 /* N-way tree implementation
900 #define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \
901 ((GNode*) (node))->prev == NULL && \
902 ((GNode*) (node))->next == NULL)
903 #define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL)
905 GNode* g_node_new (gpointer data);
906 void g_node_destroy (GNode *root);
907 void g_node_unlink (GNode *node);
908 GNode* g_node_insert (GNode *parent,
911 GNode* g_node_insert_before (GNode *parent,
914 GNode* g_node_prepend (GNode *parent,
916 guint g_node_n_nodes (GNode *root,
917 GTraverseFlags flags);
918 GNode* g_node_get_root (GNode *node);
919 gboolean g_node_is_ancestor (GNode *node,
921 guint g_node_depth (GNode *node);
922 GNode* g_node_find (GNode *root,
924 GTraverseFlags flags,
927 /* convenience macros */
928 #define g_node_append(parent, node) \
929 g_node_insert_before ((parent), NULL, (node))
930 #define g_node_insert_data(parent, position, data) \
931 g_node_insert ((parent), (position), g_node_new (data))
932 #define g_node_insert_data_before(parent, sibling, data) \
933 g_node_insert_before ((parent), (sibling), g_node_new (data))
934 #define g_node_prepend_data(parent, data) \
935 g_node_prepend ((parent), g_node_new (data))
936 #define g_node_append_data(parent, data) \
937 g_node_insert_before ((parent), NULL, g_node_new (data))
939 /* traversal function, assumes that `node' is root
940 * (only traverses `node' and its subtree).
941 * this function is just a high level interface to
942 * low level traversal functions, optimized for speed.
944 void g_node_traverse (GNode *root,
946 GTraverseFlags flags,
948 GNodeTraverseFunc func,
951 /* return the maximum tree height starting with `node', this is an expensive
952 * operation, since we need to visit all nodes. this could be shortened by
953 * adding `guint height' to struct _GNode, but then again, this is not very
954 * often needed, and would make g_node_insert() more time consuming.
956 guint g_node_max_height (GNode *root);
958 void g_node_children_foreach (GNode *node,
959 GTraverseFlags flags,
960 GNodeForeachFunc func,
962 void g_node_reverse_children (GNode *node);
963 guint g_node_n_children (GNode *node);
964 GNode* g_node_nth_child (GNode *node,
966 GNode* g_node_last_child (GNode *node);
967 GNode* g_node_find_child (GNode *node,
968 GTraverseFlags flags,
970 gint g_node_child_position (GNode *node,
972 gint g_node_child_index (GNode *node,
975 GNode* g_node_first_sibling (GNode *node);
976 GNode* g_node_last_sibling (GNode *node);
978 #define g_node_prev_sibling(node) ((node) ? \
979 ((GNode*) (node))->prev : NULL)
980 #define g_node_next_sibling(node) ((node) ? \
981 ((GNode*) (node))->next : NULL)
982 #define g_node_first_child(node) ((node) ? \
983 ((GNode*) (node))->children : NULL)
986 /* Fatal error handlers.
987 * g_on_error_query() will prompt the user to either
988 * [E]xit, [H]alt, [P]roceed or show [S]tack trace.
989 * g_on_error_stack_trace() invokes gdb, which attaches to the current
990 * process and shows a stack trace.
991 * These function may cause different actions on non-unix platforms.
992 * The prg_name arg is required by gdb to find the executable, if it is
993 * passed as NULL, g_on_error_query() will try g_get_prgname().
995 void g_on_error_query (const gchar *prg_name);
996 void g_on_error_stack_trace (const gchar *prg_name);
1001 extern const gchar *g_log_domain_glib;
1002 guint g_log_set_handler (const gchar *log_domain,
1003 GLogLevelFlags log_levels,
1005 gpointer user_data);
1006 void g_log_remove_handler (const gchar *log_domain,
1008 void g_log_default_handler (const gchar *log_domain,
1009 GLogLevelFlags log_level,
1010 const gchar *message,
1011 gpointer unused_data);
1012 void g_log (const gchar *log_domain,
1013 GLogLevelFlags log_level,
1014 const gchar *format,
1015 ...) G_GNUC_PRINTF (3, 4);
1016 void g_logv (const gchar *log_domain,
1017 GLogLevelFlags log_level,
1018 const gchar *format,
1020 GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
1021 GLogLevelFlags fatal_mask);
1022 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
1023 #ifndef G_LOG_DOMAIN
1024 #define G_LOG_DOMAIN (NULL)
1025 #endif /* G_LOG_DOMAIN */
1027 #define g_error(format, args...) g_log (G_LOG_DOMAIN, \
1028 G_LOG_LEVEL_ERROR, \
1030 #define g_message(format, args...) g_log (G_LOG_DOMAIN, \
1031 G_LOG_LEVEL_MESSAGE, \
1033 #define g_warning(format, args...) g_log (G_LOG_DOMAIN, \
1034 G_LOG_LEVEL_WARNING, \
1036 #else /* !__GNUC__ */
1038 g_error (const gchar *format,
1042 va_start (args, format);
1043 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
1047 g_message (const gchar *format,
1051 va_start (args, format);
1052 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args);
1056 g_warning (const gchar *format,
1060 va_start (args, format);
1061 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args);
1064 #endif /* !__GNUC__ */
1066 typedef void (*GPrintFunc) (const gchar *string);
1067 void g_print (const gchar *format,
1068 ...) G_GNUC_PRINTF (1, 2);
1069 GPrintFunc g_set_print_handler (GPrintFunc func);
1070 void g_printerr (const gchar *format,
1071 ...) G_GNUC_PRINTF (1, 2);
1072 GPrintFunc g_set_printerr_handler (GPrintFunc func);
1074 /* deprecated compatibility functions, use g_log_set_handler() instead */
1075 typedef void (*GErrorFunc) (const gchar *str);
1076 typedef void (*GWarningFunc) (const gchar *str);
1077 GErrorFunc g_set_error_handler (GErrorFunc func);
1078 GWarningFunc g_set_warning_handler (GWarningFunc func);
1079 GPrintFunc g_set_message_handler (GPrintFunc func);
1082 /* Memory allocation and debugging
1086 #define g_malloc(size) ((gpointer) MALLOC (size))
1087 #define g_malloc0(size) ((gpointer) CALLOC (char, size))
1088 #define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))
1089 #define g_free(mem) FREE (mem)
1091 #else /* !USE_DMALLOC */
1093 gpointer g_malloc (gulong size);
1094 gpointer g_malloc0 (gulong size);
1095 gpointer g_realloc (gpointer mem,
1097 void g_free (gpointer mem);
1099 #endif /* !USE_DMALLOC */
1101 void g_mem_profile (void);
1102 void g_mem_check (gpointer mem);
1105 /* "g_mem_chunk_new" creates a new memory chunk.
1106 * Memory chunks are used to allocate pieces of memory which are
1107 * always the same size. Lists are a good example of such a data type.
1108 * The memory chunk allocates and frees blocks of memory as needed.
1109 * Just be sure to call "g_mem_chunk_free" and not "g_free" on data
1110 * allocated in a mem chunk. ("g_free" will most likely cause a seg
1111 * fault...somewhere).
1113 * Oh yeah, GMemChunk is an opaque data type. (You don't really
1114 * want to know what's going on inside do you?)
1117 /* ALLOC_ONLY MemChunk's can only allocate memory. The free operation
1118 * is interpreted as a no op. ALLOC_ONLY MemChunk's save 4 bytes per
1119 * atom. (They are also useful for lists which use MemChunk to allocate
1120 * memory but are also part of the MemChunk implementation).
1121 * ALLOC_AND_FREE MemChunk's can allocate and free memory.
1124 #define G_ALLOC_ONLY 1
1125 #define G_ALLOC_AND_FREE 2
1127 GMemChunk* g_mem_chunk_new (gchar *name,
1131 void g_mem_chunk_destroy (GMemChunk *mem_chunk);
1132 gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
1133 gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
1134 void g_mem_chunk_free (GMemChunk *mem_chunk,
1136 void g_mem_chunk_clean (GMemChunk *mem_chunk);
1137 void g_mem_chunk_reset (GMemChunk *mem_chunk);
1138 void g_mem_chunk_print (GMemChunk *mem_chunk);
1139 void g_mem_chunk_info (void);
1141 /* Ah yes...we have a "g_blow_chunks" function.
1142 * "g_blow_chunks" simply compresses all the chunks. This operation
1143 * consists of freeing every memory area that should be freed (but
1144 * which we haven't gotten around to doing yet). And, no,
1145 * "g_blow_chunks" doesn't follow the naming scheme, but it is a
1146 * much better name than "g_mem_chunk_clean_all" or something
1149 void g_blow_chunks (void);
1154 GTimer* g_timer_new (void);
1155 void g_timer_destroy (GTimer *timer);
1156 void g_timer_start (GTimer *timer);
1157 void g_timer_stop (GTimer *timer);
1158 void g_timer_reset (GTimer *timer);
1159 gdouble g_timer_elapsed (GTimer *timer,
1160 gulong *microseconds);
1163 /* String utility functions
1165 #define G_STR_DELIMITERS "_-|> <."
1166 void g_strdelimit (gchar *string,
1167 const gchar *delimiters,
1168 gchar new_delimiter);
1169 gchar* g_strdup (const gchar *str);
1170 gchar* g_strdup_printf (const gchar *format,
1171 ...) G_GNUC_PRINTF (1, 2);
1172 gchar* g_strdup_vprintf (const gchar *format,
1174 gchar* g_strndup (const gchar *str,
1176 gchar* g_strnfill (guint length,
1178 gchar* g_strconcat (const gchar *string1,
1179 ...); /* NULL terminated */
1180 gdouble g_strtod (const gchar *nptr,
1182 gchar* g_strerror (gint errnum);
1183 gchar* g_strsignal (gint signum);
1184 gint g_strcasecmp (const gchar *s1,
1186 void g_strdown (gchar *string);
1187 void g_strup (gchar *string);
1188 void g_strreverse (gchar *string);
1190 /* calculate a string size, guarranteed to fit format + args.
1192 guint g_printf_string_upper_bound (const gchar* format,
1196 /* Retrive static string info
1198 gchar* g_get_user_name (void);
1199 gchar* g_get_real_name (void);
1200 gchar* g_get_home_dir (void);
1201 gchar* g_get_tmp_dir (void);
1202 gchar* g_get_prgname (void);
1203 void g_set_prgname (const gchar *prgname);
1206 /* Miscellaneous utility functions
1208 guint g_parse_debug_string (const gchar *string,
1211 gint g_snprintf (gchar *string,
1213 gchar const *format,
1214 ...) G_GNUC_PRINTF (3, 4);
1215 gint g_vsnprintf (gchar *string,
1217 gchar const *format,
1219 gchar* g_basename (const gchar *file_name);
1221 /* strings are newly allocated with g_malloc() */
1222 gchar* g_dirname (const gchar *file_name);
1223 gchar* g_get_current_dir (void);
1225 /* We make the assumption that if memmove isn't available, then
1226 * bcopy will do the job. This isn't safe everywhere. (bcopy can't
1227 * necessarily handle overlapping copies).
1228 * Either way, g_memmove() will not return a value.
1231 #define g_memmove(dest, src, size) G_STMT_START { \
1232 memmove ((dest), (src), (size)); \
1235 #define g_memmove(dest, src, size) G_STMT_START { \
1236 bcopy ((src), (dest), (size)); \
1244 g_bit_nth_lsf (guint32 mask,
1251 if (mask & (1 << (guint) nth_bit))
1254 while (nth_bit < 32);
1261 g_bit_nth_msf (guint32 mask,
1270 if (mask & (1 << (guint) nth_bit))
1273 while (nth_bit > 0);
1280 g_bit_storage (guint number)
1283 register guint n_bits = 0;
1288 number = number >> 1;
1299 GStringChunk* g_string_chunk_new (gint size);
1300 void g_string_chunk_free (GStringChunk *chunk);
1301 gchar* g_string_chunk_insert (GStringChunk *chunk,
1302 const gchar *string);
1303 gchar* g_string_chunk_insert_const (GStringChunk *chunk,
1304 const gchar *string);
1309 GString* g_string_new (const gchar *init);
1310 GString* g_string_sized_new (guint dfl_size);
1311 void g_string_free (GString *string,
1313 GString* g_string_assign (GString *lval,
1315 GString* g_string_truncate (GString *string,
1317 GString* g_string_append (GString *string,
1319 GString* g_string_append_c (GString *string,
1321 GString* g_string_prepend (GString *string,
1323 GString* g_string_prepend_c (GString *string,
1325 GString* g_string_insert (GString *string,
1328 GString* g_string_insert_c (GString *string,
1331 GString* g_string_erase (GString *string,
1334 GString* g_string_down (GString *string);
1335 GString* g_string_up (GString *string);
1336 void g_string_sprintf (GString *string,
1337 const gchar *format,
1338 ...) G_GNUC_PRINTF (2, 3);
1339 void g_string_sprintfa (GString *string,
1340 const gchar *format,
1341 ...) G_GNUC_PRINTF (2, 3);
1347 #define g_array_append_val(a,v) g_array_append_vals(a,&v,1)
1348 #define g_array_prepend_val(a,v) g_array_prepend_vals(a,&v,1)
1349 #define g_array_index(a,t,i) (((t*)a->data)[i])
1351 GArray* g_array_new (gboolean zero_terminated,
1353 guint element_size);
1354 void g_array_free (GArray *array,
1355 gboolean free_segment);
1356 GArray* g_array_append_vals (GArray *array,
1359 GArray* g_array_prepend_vals (GArray *array,
1362 GArray* g_array_set_size (GArray *array,
1365 /* Resizable pointer array. This interface is much less complicated
1366 * than the above. Add appends appends a pointer. Remove fills any
1367 * cleared spot and shortens the array.
1369 #define g_ptr_array_index(array,index) (array->pdata)[index]
1370 GPtrArray* g_ptr_array_new (void);
1371 void g_ptr_array_free (GPtrArray *array,
1373 void g_ptr_array_set_size (GPtrArray *array,
1375 gpointer g_ptr_array_remove_index (GPtrArray *array,
1377 gboolean g_ptr_array_remove (GPtrArray *array,
1379 void g_ptr_array_add (GPtrArray *array,
1382 /* Byte arrays, an array of guint8. Implemented as a GArray,
1386 GByteArray* g_byte_array_new (void);
1387 void g_byte_array_free (GByteArray *array,
1388 gboolean free_segment);
1389 GByteArray* g_byte_array_append (GByteArray *array,
1392 GByteArray* g_byte_array_prepend (GByteArray *array,
1395 GByteArray* g_byte_array_set_size (GByteArray *array,
1401 gint g_str_equal (gconstpointer v,
1403 guint g_str_hash (gconstpointer v);
1405 gint g_int_equal (gconstpointer v,
1407 guint g_int_hash (gconstpointer v);
1409 /* This "hash" function will just return the key's adress as an
1410 * unsigned integer. Useful for hashing on plain adresses or
1411 * simple integer values.
1413 guint g_direct_hash (gconstpointer v);
1414 gint g_direct_equal (gconstpointer v,
1418 /* Quarks (string<->id association)
1420 GQuark g_quark_try_string (const gchar *string);
1421 GQuark g_quark_from_static_string (const gchar *string);
1422 GQuark g_quark_from_string (const gchar *string);
1423 gchar* g_quark_to_string (GQuark quark);
1426 /* Location Associated Data
1428 void g_dataset_destroy (gconstpointer dataset_location);
1429 gpointer g_dataset_id_get_data (gconstpointer dataset_location,
1431 void g_dataset_id_set_data_full (gconstpointer dataset_location,
1434 GDestroyNotify destroy_func);
1435 void g_dataset_id_set_destroy (gconstpointer dataset_location,
1437 GDestroyNotify destroy_func);
1438 #define g_dataset_id_set_data(l, k, d) \
1439 g_dataset_id_set_data_full ((l), (k), (d), NULL)
1440 #define g_dataset_id_remove_data(l, k) \
1441 g_dataset_id_set_data ((l), (k), NULL)
1442 #define g_dataset_get_data(l, k) \
1443 (g_dataset_id_get_data ((l), g_quark_try_string (k)))
1444 #define g_dataset_set_data_full(l, k, d, f) \
1445 g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
1446 #define g_dataset_set_destroy(l, k, f) \
1447 g_dataset_id_set_destroy ((l), g_quark_from_string (k), (f))
1448 #define g_dataset_set_data(l, k, d) \
1449 g_dataset_set_data_full ((l), (k), (d), NULL)
1450 #define g_dataset_remove_data(l,k) \
1451 g_dataset_set_data ((l), (k), NULL)
1454 /* GScanner: Flexible lexical scanner for general purpose.
1457 /* Character sets */
1458 #define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1459 #define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz"
1460 #define G_CSET_LATINC "\300\301\302\303\304\305\306"\
1461 "\307\310\311\312\313\314\315\316\317\320"\
1462 "\321\322\323\324\325\326"\
1463 "\330\331\332\333\334\335\336"
1464 #define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\
1465 "\347\350\351\352\353\354\355\356\357\360"\
1466 "\361\362\363\364\365\366"\
1467 "\370\371\372\373\374\375\376\377"
1474 G_ERR_UNEXP_EOF_IN_STRING,
1475 G_ERR_UNEXP_EOF_IN_COMMENT,
1476 G_ERR_NON_DIGIT_IN_CONST,
1479 G_ERR_FLOAT_MALFORMED
1487 G_TOKEN_LEFT_PAREN = '(',
1488 G_TOKEN_RIGHT_PAREN = ')',
1489 G_TOKEN_LEFT_CURLY = '{',
1490 G_TOKEN_RIGHT_CURLY = '}',
1491 G_TOKEN_LEFT_BRACE = '[',
1492 G_TOKEN_RIGHT_BRACE = ']',
1493 G_TOKEN_EQUAL_SIGN = '=',
1494 G_TOKEN_COMMA = ',',
1510 G_TOKEN_IDENTIFIER_NULL,
1512 G_TOKEN_COMMENT_SINGLE,
1513 G_TOKEN_COMMENT_MULTI,
1520 gchar *v_identifier;
1532 struct _GScannerConfig
1536 gchar *cset_skip_characters; /* default: " \t\n" */
1537 gchar *cset_identifier_first;
1538 gchar *cset_identifier_nth;
1539 gchar *cpair_comment_single; /* default: "#\n" */
1541 /* Should symbol lookup work case sensitive?
1543 guint case_sensitive : 1;
1545 /* Boolean values to be adjusted "on the fly"
1546 * to configure scanning behaviour.
1548 guint skip_comment_multi : 1; /* C like comment */
1549 guint skip_comment_single : 1; /* single line comment */
1550 guint scan_comment_multi : 1; /* scan multi line comments? */
1551 guint scan_identifier : 1;
1552 guint scan_identifier_1char : 1;
1553 guint scan_identifier_NULL : 1;
1554 guint scan_symbols : 1;
1555 guint scan_binary : 1;
1556 guint scan_octal : 1;
1557 guint scan_float : 1;
1558 guint scan_hex : 1; /* `0x0ff0' */
1559 guint scan_hex_dollar : 1; /* `$0ff0' */
1560 guint scan_string_sq : 1; /* string: 'anything' */
1561 guint scan_string_dq : 1; /* string: "\\-escapes!\n" */
1562 guint numbers_2_int : 1; /* bin, octal, hex => int */
1563 guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */
1564 guint identifier_2_string : 1;
1565 guint char_2_token : 1; /* return G_TOKEN_CHAR? */
1566 guint symbol_2_token : 1;
1567 guint scope_0_fallback : 1; /* try scope 0 on lookups? */
1574 guint max_parse_errors;
1576 /* g_scanner_error() increments this field */
1579 /* name of input stream, featured by the default message handler */
1580 const gchar *input_name;
1582 /* data pointer for derived structures */
1583 gpointer derived_data;
1585 /* link into the scanner configuration */
1586 GScannerConfig *config;
1588 /* fields filled in after g_scanner_get_next_token() */
1594 /* fields filled in after g_scanner_peek_next_token() */
1595 GTokenType next_token;
1598 guint next_position;
1600 /* to be considered private */
1601 GHashTable *symbol_table;
1608 /* handler function for _warn and _error */
1609 GScannerMsgFunc msg_handler;
1612 GScanner* g_scanner_new (GScannerConfig *config_templ);
1613 void g_scanner_destroy (GScanner *scanner);
1614 void g_scanner_input_file (GScanner *scanner,
1616 void g_scanner_input_text (GScanner *scanner,
1619 GTokenType g_scanner_get_next_token (GScanner *scanner);
1620 GTokenType g_scanner_peek_next_token (GScanner *scanner);
1621 GTokenType g_scanner_cur_token (GScanner *scanner);
1622 GValue g_scanner_cur_value (GScanner *scanner);
1623 guint g_scanner_cur_line (GScanner *scanner);
1624 guint g_scanner_cur_position (GScanner *scanner);
1625 gboolean g_scanner_eof (GScanner *scanner);
1626 guint g_scanner_set_scope (GScanner *scanner,
1628 void g_scanner_scope_add_symbol (GScanner *scanner,
1630 const gchar *symbol,
1632 void g_scanner_scope_remove_symbol (GScanner *scanner,
1634 const gchar *symbol);
1635 gpointer g_scanner_scope_lookup_symbol (GScanner *scanner,
1637 const gchar *symbol);
1638 void g_scanner_scope_foreach_symbol (GScanner *scanner,
1641 gpointer func_data);
1642 gpointer g_scanner_lookup_symbol (GScanner *scanner,
1643 const gchar *symbol);
1644 void g_scanner_freeze_symbol_table (GScanner *scanner);
1645 void g_scanner_thaw_symbol_table (GScanner *scanner);
1646 void g_scanner_unexp_token (GScanner *scanner,
1647 GTokenType expected_token,
1648 const gchar *identifier_spec,
1649 const gchar *symbol_spec,
1650 const gchar *symbol_name,
1651 const gchar *message,
1653 void g_scanner_error (GScanner *scanner,
1654 const gchar *format,
1655 ...) G_GNUC_PRINTF (2,3);
1656 void g_scanner_warn (GScanner *scanner,
1657 const gchar *format,
1658 ...) G_GNUC_PRINTF (2,3);
1659 gint g_scanner_stat_mode (const gchar *filename);
1660 /* keep downward source compatibility */
1661 #define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \
1662 g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \
1664 #define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \
1665 g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \
1667 #define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \
1668 g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \
1677 GCompletionFunc func;
1683 GCompletion* g_completion_new (GCompletionFunc func);
1684 void g_completion_add_items (GCompletion* cmp,
1686 void g_completion_remove_items (GCompletion* cmp,
1688 void g_completion_clear_items (GCompletion* cmp);
1689 GList* g_completion_complete (GCompletion* cmp,
1691 gchar** new_prefix);
1692 void g_completion_free (GCompletion* cmp);
1695 /* GRelation: Indexed Relations. Imagine a really simple table in a
1696 * database. Relations are not ordered. This data type is meant for
1697 * maintaining a N-way mapping.
1699 * g_relation_new() creates a relation with FIELDS fields
1701 * g_relation_destroy() frees all resources
1702 * g_tuples_destroy() frees the result of g_relation_select()
1704 * g_relation_index() indexes relation FIELD with the provided
1705 * equality and hash functions. this must be done before any
1706 * calls to insert are made.
1708 * g_relation_insert() inserts a new tuple. you are expected to
1709 * provide the right number of fields.
1711 * g_relation_delete() deletes all relations with KEY in FIELD
1712 * g_relation_select() returns ...
1713 * g_relation_count() counts ...
1716 GRelation* g_relation_new (gint fields);
1717 void g_relation_destroy (GRelation *relation);
1718 void g_relation_index (GRelation *relation,
1720 GHashFunc hash_func,
1721 GCompareFunc key_compare_func);
1722 void g_relation_insert (GRelation *relation,
1724 gint g_relation_delete (GRelation *relation,
1727 GTuples* g_relation_select (GRelation *relation,
1730 gint g_relation_count (GRelation *relation,
1733 gboolean g_relation_exists (GRelation *relation,
1735 void g_relation_print (GRelation *relation);
1737 void g_tuples_destroy (GTuples *tuples);
1738 gpointer g_tuples_index (GTuples *tuples,
1746 /* This function returns prime numbers spaced by approximately 1.5-2.0
1747 * and is for use in resizing data structures which prefer
1748 * prime-valued sizes. The closest spaced prime function returns the
1749 * next largest prime, or the highest it knows about which is about
1753 guint g_spaced_primes_closest (guint num);
1757 extern const guint glib_major_version;
1758 extern const guint glib_minor_version;
1759 extern const guint glib_micro_version;
1763 #endif /* __cplusplus */
1766 #endif /* __G_LIB_H__ */