typo fixed for alphas for gint64
[platform/upstream/glib.git] / glib.h
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 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.
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  * Library General Public License for more details.
13  *
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.
18  */
19 #ifndef __G_LIB_H__
20 #define __G_LIB_H__
21
22 #include <glibconfig.h>
23
24 #ifdef USE_DMALLOC
25 #include "dmalloc.h"
26 #endif
27
28
29 /* glib provides definitions for the extrema of many
30  *  of the standard types. These are:
31  * G_MINFLOAT
32  * G_MAXFLOAT
33  * G_MINDOUBLE
34  * G_MAXDOUBLE
35  * G_MINSHORT
36  * G_MAXSHORT
37  * G_MININT
38  * G_MAXINT
39  * G_MINLONG
40  * G_MAXLONG
41  */
42
43 #ifdef HAVE_FLOAT_H
44
45 #include <float.h>
46
47 #define G_MINFLOAT   FLT_MIN
48 #define G_MAXFLOAT   FLT_MAX
49 #define G_MINDOUBLE  DBL_MIN
50 #define G_MAXDOUBLE  DBL_MAX
51
52 #elif HAVE_VALUES_H
53
54 #include <values.h>
55
56 #define G_MINFLOAT  MINFLOAT
57 #define G_MAXFLOAT  MAXFLOAT
58 #define G_MINDOUBLE MINDOUBLE
59 #define G_MAXDOUBLE MAXDOUBLE
60
61 #endif /* HAVE_VALUES_H */
62
63
64 #ifdef HAVE_LIMITS_H
65
66 #include <limits.h>
67
68 #define G_MINSHORT  SHRT_MIN
69 #define G_MAXSHORT  SHRT_MAX
70 #define G_MININT    INT_MIN
71 #define G_MAXINT    INT_MAX
72 #define G_MINLONG   LONG_MIN
73 #define G_MAXLONG   LONG_MAX
74
75 #elif HAVE_VALUES_H
76
77 #ifdef HAVE_FLOAT_H
78 #include <values.h>
79 #endif /* HAVE_FLOAT_H */
80
81 #define G_MINSHORT  MINSHORT
82 #define G_MAXSHORT  MAXSHORT
83 #define G_MININT    MININT
84 #define G_MAXINT    MAXINT
85 #define G_MINLONG   MINLONG
86 #define G_MAXLONG   MAXLONG
87
88 #endif /* HAVE_VALUES_H */
89
90
91 /* Provide definitions for some commonly used macros.
92  *  Some of them are only provided if they haven't already
93  *  been defined. It is assumed that if they are already
94  *  defined then the current definition is correct.
95  */
96 #ifndef NULL
97 #define NULL    ((void*) 0)
98 #endif
99
100 #ifndef FALSE
101 #define FALSE   (0)
102 #endif
103
104 #ifndef TRUE
105 #define TRUE    (!FALSE)
106 #endif
107
108 #undef  MAX
109 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
110
111 #undef  MIN
112 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
113
114 #undef  ABS
115 #define ABS(a)     (((a) < 0) ? -(a) : (a))
116
117 #undef  CLAMP
118 #define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
119
120
121 /* Provide simple enum value macro wrappers that ease automated enum value
122  * stringification code.
123  */
124 #if     !defined (G_CODE_GENERATION)
125 #define G_ENUM( EnumerationName )               EnumerationName
126 #define G_FLAGS( EnumerationName )              EnumerationName
127 #define G_NV( VALUE_NAME , value_nick, VALUE)   VALUE_NAME = (VALUE)
128 #define G_SV( VALUE_NAME, value_nick )          VALUE_NAME
129 #else   /* G_CODE_GENERATION */
130 #define G_ENUM( EnumerationName )               G_ENUM_E + EnumerationName +
131 #define G_FLAGS( EnumerationName )              G_ENUM_F + EnumerationName +
132 #define G_NV( VALUE_NAME , value_nick, VALUE)   G_ENUM_V + VALUE_NAME + value_nick +
133 #define G_SV( VALUE_NAME, value_nick )          G_ENUM_V + VALUE_NAME + value_nick +
134 #endif  /* G_CODE_GENERATION */
135
136
137 /* Provide simple macro statement wrappers (adapted from Perl):
138  *  G_STMT_START { statements; } G_STMT_END;
139  *  can be used as a single statement, as in
140  *  if (x) G_STMT_START { ... } G_STMT_END; else ...
141  *
142  *  For gcc we will wrap the statements within `({' and `})' braces.
143  *  For SunOS they will be wrapped within `if (1)' and `else (void) 0',
144  *  and otherwise within `do' and `while (0)'.
145  */
146 #if !(defined (G_STMT_START) && defined (G_STMT_END))
147 #  if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
148 #    define G_STMT_START        (void)(
149 #    define G_STMT_END          )
150 #  else
151 #    if (defined (sun) || defined (__sun__))
152 #      define G_STMT_START      if (1)
153 #      define G_STMT_END        else (void)0
154 #    else
155 #      define G_STMT_START      do
156 #      define G_STMT_END        while (0)
157 #    endif
158 #  endif
159 #endif
160
161 /* Provide macros to feature the GCC function attribute.
162  */
163 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
164 #define G_GNUC_PRINTF( format_idx, arg_idx )    \
165   __attribute__((format (printf, format_idx, arg_idx)))
166 #define G_GNUC_SCANF( format_idx, arg_idx )     \
167   __attribute__((format (scanf, format_idx, arg_idx)))
168 #define G_GNUC_FORMAT( arg_idx )                \
169   __attribute__((format_arg (arg_idx)))
170 #define G_GNUC_NORETURN                         \
171   __attribute__((noreturn))
172 #define G_GNUC_CONST                            \
173   __attribute__((const))
174 #else   /* !__GNUC__ */
175 #define G_GNUC_PRINTF( format_idx, arg_idx )
176 #define G_GNUC_SCANF( format_idx, arg_idx )
177 #define G_GNUC_FORMAT( arg_idx )
178 #define G_GNUC_NORETURN
179 #define G_GNUC_CONST
180 #endif  /* !__GNUC__ */
181
182 /* Hacker macro to place breakpoints for x86 machines.
183  * Actual use is strongly deprecated of course ;)
184  */
185 #if     defined (__i386__)
186 #define G_BREAKPOINT()          G_STMT_START{ __asm__ ("int $03"); }G_STMT_END
187 #else   /* !__i386__ */
188 #define G_BREAKPOINT()
189 #endif  /* __i386__ */
190
191 /* Wrap the __PRETTY_FUNCTION__ and __FUNCTION__ variables with macros,
192  * so we can refer to them as strings unconditionally.
193  */
194 #ifdef  __GNUC__
195 #define G_GNUC_FUNCTION         (__FUNCTION__)
196 #define G_GNUC_PRETTY_FUNCTION  (__PRETTY_FUNCTION__)
197 #else   /* !__GNUC__ */
198 #define G_GNUC_FUNCTION         ("")
199 #define G_GNUC_PRETTY_FUNCTION  ("")
200 #endif  /* !__GNUC__ */
201
202
203 #ifndef ATEXIT
204 #  ifdef HAVE_ATEXIT
205 #    define ATEXIT(proc)   (atexit (proc))
206 #  elif defined (HAVE_ON_EXIT)
207 #    define ATEXIT(proc)   (on_exit ((void (*)(int, void *))(proc), NULL))
208 #  endif    
209 #endif /* ATEXIT */
210
211
212 /* Provide macros for easily allocating memory. The macros
213  *  will cast the allocated memory to the specified type
214  *  in order to avoid compiler warnings. (Makes the code neater).
215  */
216
217 #ifdef __DMALLOC_H__
218
219 #define g_new(type,count)        ALLOC(type,count)
220 #define g_new0(type,count)       CALLOC(type,count)
221
222 #else /* __DMALLOC_H__ */
223
224 #define g_new(type, count)        \
225     ((type *) g_malloc ((unsigned) sizeof (type) * (count)))
226 #define g_new0(type, count)       \
227     ((type *) g_malloc0 ((unsigned) sizeof (type) * (count)))
228 #endif /* __DMALLOC_H__ */
229
230 #define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
231   g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
232                    sizeof (type), \
233                    sizeof (type) * (pre_alloc), \
234                    (alloc_type)) \
235 )
236 #define g_chunk_new(type, chunk)        ( \
237   (type *) g_mem_chunk_alloc (chunk) \
238 )
239 #define g_chunk_new0(type, chunk)       ( \
240   (type *) memset (g_mem_chunk_alloc (chunk), 0, sizeof (type)) \
241 )
242 #define g_chunk_free(mem, mem_chunk)    G_STMT_START { \
243   g_mem_chunk_free ((mem_chunk), (mem)); \
244 } G_STMT_END
245
246 #define g_string(x) #x
247
248
249 /* Provide macros for error handling. The "assert" macros will
250  *  exit on failure. The "return" macros will exit the current
251  *  function. Two different definitions are given for the macros
252  *  in order to support gcc's __PRETTY_FUNCTION__ capability.
253  */
254
255 #ifdef G_DISABLE_ASSERT
256
257 #define g_assert(expr)
258 #define g_assert_not_reached()
259
260 #else /* !G_DISABLE_ASSERT */
261
262 #ifdef __GNUC__
263
264 #define g_assert(expr)                  G_STMT_START{\
265      if (!(expr))                                    \
266        g_error ("file %s: line %d (%s): \"%s\"",     \
267                 __FILE__,                            \
268                 __LINE__,                            \
269                 __PRETTY_FUNCTION__,                 \
270                 #expr);                 }G_STMT_END
271
272 #define g_assert_not_reached()          G_STMT_START{                 \
273      g_error ("file %s: line %d (%s): \"should not be reached\"",     \
274               __FILE__,                                               \
275               __LINE__,                                               \
276               __PRETTY_FUNCTION__);     }G_STMT_END
277
278 #else /* !__GNUC__ */
279
280 #define g_assert(expr)                  G_STMT_START{\
281      if (!(expr))                                    \
282        g_error ("file %s: line %d: \"%s\"",          \
283                 __FILE__,                            \
284                 __LINE__,                            \
285                 #expr);                 }G_STMT_END
286
287 #define g_assert_not_reached()          G_STMT_START{                 \
288      g_error ("file %s: line %d: \"should not be reached\"",          \
289               __FILE__,                                               \
290               __LINE__);                }G_STMT_END
291
292 #endif /* __GNUC__ */
293
294 #endif /* G_DISABLE_ASSERT */
295
296 #ifdef G_DISABLE_CHECKS
297
298 #define g_return_if_fail(expr)
299 #define g_return_val_if_fail(expr,val)
300
301 #else /* !G_DISABLE_CHECKS */
302
303 #ifdef __GNUC__
304
305 #define g_return_if_fail(expr)          G_STMT_START{                  \
306      if (!(expr))                                                      \
307        {                                                               \
308          g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
309                     __FILE__,                                          \
310                     __LINE__,                                          \
311                     __PRETTY_FUNCTION__,                               \
312                     #expr);                                            \
313          return;                                                       \
314        };                               }G_STMT_END
315
316 #define g_return_val_if_fail(expr,val)  G_STMT_START{                  \
317      if (!(expr))                                                      \
318        {                                                               \
319          g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
320                     __FILE__,                                          \
321                     __LINE__,                                          \
322                     __PRETTY_FUNCTION__,                               \
323                     #expr);                                            \
324          return val;                                                   \
325        };                               }G_STMT_END
326
327 #else /* !__GNUC__ */
328
329 #define g_return_if_fail(expr)          G_STMT_START{             \
330      if (!(expr))                                                 \
331        {                                                          \
332          g_warning ("file %s: line %d: assertion. \"%s\" failed", \
333                     __FILE__,                                     \
334                     __LINE__,                                     \
335                     #expr);                                       \
336          return;                                                  \
337        };                               }G_STMT_END
338
339 #define g_return_val_if_fail(expr, val) G_STMT_START{             \
340      if (!(expr))                                                 \
341        {                                                          \
342          g_warning ("file %s: line %d: assertion \"%s\" failed.", \
343                     __FILE__,                                     \
344                     __LINE__,                                     \
345                     #expr);                                       \
346          return val;                                              \
347        };                               }G_STMT_END
348
349 #endif /* !__GNUC__ */
350
351 #endif /* G_DISABLE_CHECKS */
352
353
354 #ifdef __cplusplus
355 extern "C" {
356 #pragma }
357 #endif /* __cplusplus */
358
359 /* Provide type definitions for commonly used types.
360  *  These are useful because a "gint8" can be adjusted
361  *  to be 1 byte (8 bits) on all platforms. Similarly and
362  *  more importantly, "gint32" can be adjusted to be
363  *  4 bytes (32 bits) on all platforms.
364  */
365
366 typedef char   gchar;
367 typedef short  gshort;
368 typedef long   glong;
369 typedef int    gint;
370 typedef gint   gboolean;
371
372 typedef unsigned char   guchar;
373 typedef unsigned short  gushort;
374 typedef unsigned long   gulong;
375 typedef unsigned int    guint;
376
377 typedef float   gfloat;
378 typedef double  gdouble;
379
380 /* HAVE_LONG_DOUBLE doesn't work correctly on all platforms. 
381  * Since gldouble isn't used anywhere, just disable it for now */
382
383 #if 0
384 #ifdef HAVE_LONG_DOUBLE
385 typedef long double gldouble;
386 #else /* HAVE_LONG_DOUBLE */
387 typedef double gldouble;
388 #endif /* HAVE_LONG_DOUBLE */
389 #endif /* 0 */
390
391 typedef void* gpointer;
392 typedef const void *gconstpointer;
393
394 #if (SIZEOF_CHAR == 1)
395 typedef signed char     gint8;
396 typedef unsigned char   guint8;
397 #endif /* SIZEOF_CHAR */
398
399
400 #if (SIZEOF_SHORT == 2)
401 typedef signed short    gint16;
402 typedef unsigned short  guint16;
403 #endif /* SIZEOF_SHORT */
404
405
406 #if (SIZEOF_INT == 4)
407 typedef signed int      gint32;
408 typedef unsigned int    guint32;
409 #elif (SIZEOF_LONG == 4)
410 typedef signed long     gint32;
411 typedef unsigned long   guint32;
412 #endif /* SIZEOF_INT */
413
414 #if (SIZEOF_LONG == 8)
415 #define HAVE_GINT64 1
416 typedef signed long gint64;
417 typedef unsigned long guint64;
418 #elif (SIZEOF_LONG_LONG == 8)
419 #define HAVE_GINT64 1
420 typedef signed long long gint64;
421 typedef unsigned long long guint64;
422 #else
423 /* No gint64 */
424 #undef HAVE_GINT64
425 #endif
426
427
428 /* Define macros for storing integers inside pointers */
429
430 #if (SIZEOF_INT == SIZEOF_VOID_P)
431
432 #define GPOINTER_TO_INT(p) ((gint)(p))
433 #define GPOINTER_TO_UINT(p) ((guint)(p))
434
435 #define GINT_TO_POINTER(i) ((gpointer)(i))
436 #define GUINT_TO_POINTER(u) ((gpointer)(u))
437
438 #elif (SIZEOF_LONG == SIZEOF_VOID_P)
439
440 #define GPOINTER_TO_INT(p) ((gint)(glong)(p))
441 #define GPOINTER_TO_UINT(p) ((guint)(gulong)(p))
442
443 #define GINT_TO_POINTER(i) ((gpointer)(glong)(i))
444 #define GUINT_TO_POINTER(u) ((gpointer)(gulong)(u))
445
446 #else
447 /* This should never happen */
448 #endif
449
450 typedef gint32  gssize;
451 typedef guint32 gsize;
452 typedef gint32  gtime;
453 typedef guint32 GQuark;
454
455 typedef struct _GList           GList;
456 typedef struct _GSList          GSList;
457 typedef struct _GHashTable      GHashTable;
458 typedef struct _GCache          GCache;
459 typedef struct _GTree           GTree;
460 typedef struct _GTimer          GTimer;
461 typedef struct _GMemChunk       GMemChunk;
462 typedef struct _GListAllocator  GListAllocator;
463 typedef struct _GStringChunk    GStringChunk;
464 typedef struct _GString         GString;
465 typedef struct _GArray          GArray;
466 typedef struct _GPtrArray       GPtrArray;
467 typedef struct _GByteArray      GByteArray;
468 typedef struct _GDebugKey       GDebugKey;
469 typedef struct _GScannerConfig  GScannerConfig;
470 typedef struct _GScanner        GScanner;
471 typedef union  _GValue          GValue;
472 typedef struct _GRelation       GRelation;
473 typedef struct _GTuples         GTuples;
474
475
476 typedef void            (*GFunc)                (gpointer  data,
477                                                  gpointer  user_data);
478 typedef void            (*GHFunc)               (gpointer  key,
479                                                  gpointer  value,
480                                                  gpointer  user_data);
481 typedef gpointer        (*GCacheNewFunc)        (gpointer  key);
482 typedef gpointer        (*GCacheDupFunc)        (gpointer  value);
483 typedef void            (*GCacheDestroyFunc)    (gpointer  value);
484 typedef gint            (*GTraverseFunc)        (gpointer  key,
485                                                  gpointer  value,
486                                                  gpointer  data);
487 typedef gint            (*GSearchFunc)          (gpointer  key,
488                                                  gpointer  data);
489 typedef void            (*GErrorFunc)           (gchar    *str);
490 typedef void            (*GWarningFunc)         (gchar    *str);
491 typedef void            (*GPrintFunc)           (gchar    *str);
492 typedef void            (*GScannerMsgFunc)      (GScanner *scanner,
493                                                  gchar    *message,
494                                                  gint      error);
495 typedef void            (*GDestroyNotify)       (gpointer  data);
496
497 typedef guint           (*GHashFunc)            (gconstpointer    key);
498 typedef gint            (*GCompareFunc)         (gconstpointer    a,
499                                                  gconstpointer    b);
500
501 struct _GList
502 {
503   gpointer data;
504   GList *next;
505   GList *prev;
506 };
507
508 struct _GSList
509 {
510   gpointer data;
511   GSList *next;
512 };
513
514 struct _GString
515 {
516   gchar *str;
517   gint len;
518 };
519
520 struct _GArray
521 {
522   gchar *data;
523   guint len;
524 };
525
526 struct _GByteArray
527 {
528   guint8 *data;
529   guint   len;
530 };
531
532 struct _GPtrArray
533 {
534   gpointer *pdata;
535   guint     len;
536 };
537
538 struct _GTuples
539 {
540   guint len;
541 };
542
543 struct _GDebugKey
544 {
545   gchar *key;
546   guint  value;
547 };
548
549 struct _GCache { gint dummy; };
550 struct _GTree { gint dummy; };
551 struct _GTimer { gint dummy; };
552 struct _GMemChunk { gint dummy; };
553 struct _GListAllocator { gint dummy; };
554 struct _GStringChunk { gint dummy; };
555
556 typedef enum
557 {
558   G_IN_ORDER,
559   G_PRE_ORDER,
560   G_POST_ORDER
561 } GTraverseType;
562
563 /* Doubly linked lists
564  */
565 GList* g_list_alloc             (void);
566 void   g_list_free              (GList          *list);
567 void   g_list_free_1            (GList          *list);
568 GList* g_list_append            (GList          *list,
569                                  gpointer        data);
570 GList* g_list_prepend           (GList          *list,
571                                  gpointer        data);
572 GList* g_list_insert            (GList          *list,
573                                  gpointer        data,
574                                  gint            position);
575 GList* g_list_insert_sorted     (GList          *list,
576                                  gpointer        data,
577                                  GCompareFunc    func);                     
578 GList* g_list_concat            (GList          *list1, 
579                                  GList          *list2);
580 GList* g_list_remove            (GList          *list,
581                                  gpointer        data);
582 GList* g_list_remove_link       (GList          *list,
583                                  GList          *link);
584 GList* g_list_reverse           (GList          *list);
585 GList* g_list_nth               (GList          *list,
586                                  guint           n);
587 GList* g_list_find              (GList          *list,
588                                  gpointer        data);
589 GList* g_list_find_custom       (GList          *list,
590                                  gpointer        data,
591                                  GCompareFunc    func);
592 gint   g_list_position          (GList          *list,
593                                  GList          *link);
594 gint   g_list_index             (GList          *list,
595                                  gpointer        data);
596 GList* g_list_last              (GList          *list);
597 GList* g_list_first             (GList          *list);
598 guint  g_list_length            (GList          *list);
599 void   g_list_foreach           (GList          *list,
600                                  GFunc           func,
601                                  gpointer        user_data);
602 gpointer g_list_nth_data        (GList          *list,
603                                  guint           n);
604
605 #define g_list_previous(list)   ((list) ? (((GList *)(list))->prev) : NULL)
606 #define g_list_next(list)       ((list) ? (((GList *)(list))->next) : NULL)
607
608 /* Singly linked lists
609  */
610 GSList* g_slist_alloc           (void);
611 void    g_slist_free            (GSList         *list);
612 void    g_slist_free_1          (GSList         *list);
613 GSList* g_slist_append          (GSList         *list,
614                                  gpointer        data);
615 GSList* g_slist_prepend         (GSList         *list,
616                                  gpointer        data);
617 GSList* g_slist_insert          (GSList         *list,
618                                  gpointer        data,
619                                  gint            position);
620 GSList* g_slist_insert_sorted   (GSList         *list,
621                                  gpointer        data,
622                                  GCompareFunc    func);                     
623 GSList* g_slist_concat          (GSList         *list1, 
624                                  GSList         *list2);
625 GSList* g_slist_remove          (GSList         *list,
626                                  gpointer        data);
627 GSList* g_slist_remove_link     (GSList         *list,
628                                  GSList         *link);
629 GSList* g_slist_reverse         (GSList         *list);
630 GSList* g_slist_nth             (GSList         *list,
631                                  guint           n);
632 GSList* g_slist_find            (GSList         *list,
633                                  gpointer        data);
634 GSList* g_slist_find_custom     (GSList         *list,
635                                  gpointer        data,
636                                  GCompareFunc    func);
637 gint    g_slist_position        (GSList         *list,
638                                  GSList         *link);
639 gint    g_slist_index           (GSList         *list,
640                                  gpointer        data);
641 GSList* g_slist_last            (GSList         *list);
642 guint   g_slist_length          (GSList         *list);
643 void    g_slist_foreach         (GSList         *list,
644                                  GFunc           func,
645                                  gpointer        user_data);
646 gpointer g_slist_nth_data       (GSList         *list,
647                                  guint           n);
648
649 #define g_slist_next(slist)     ((slist) ? (((GSList *)(slist))->next) : NULL)
650
651 /* List Allocators
652  */
653 GListAllocator* g_list_allocator_new  (void);
654 void            g_list_allocator_free (GListAllocator* allocator);
655 GListAllocator* g_slist_set_allocator (GListAllocator* allocator);
656 GListAllocator* g_list_set_allocator  (GListAllocator* allocator);
657
658
659 /* Hash tables
660  */
661 GHashTable* g_hash_table_new            (GHashFunc       hash_func,
662                                          GCompareFunc    key_compare_func);
663 void        g_hash_table_destroy        (GHashTable     *hash_table);
664 void        g_hash_table_insert         (GHashTable     *hash_table,
665                                          gpointer        key,
666                                          gpointer        value);
667 void        g_hash_table_remove         (GHashTable     *hash_table,
668                                          gconstpointer   key);
669 gpointer    g_hash_table_lookup         (GHashTable     *hash_table,
670                                          gconstpointer   key);
671 gboolean    g_hash_table_lookup_extended(GHashTable     *hash_table,
672                                          gconstpointer   lookup_key,
673                                          gpointer       *orig_key,
674                                          gpointer       *value);
675 void        g_hash_table_freeze         (GHashTable     *hash_table);
676 void        g_hash_table_thaw           (GHashTable     *hash_table);
677 void        g_hash_table_foreach        (GHashTable     *hash_table,
678                                          GHFunc          func,
679                                          gpointer        user_data);
680 gint        g_hash_table_size           (GHashTable     *hash_table);
681
682
683 /* Caches
684  */
685 GCache*  g_cache_new           (GCacheNewFunc      value_new_func,
686                                 GCacheDestroyFunc  value_destroy_func,
687                                 GCacheDupFunc      key_dup_func,
688                                 GCacheDestroyFunc  key_destroy_func,
689                                 GHashFunc          hash_key_func,
690                                 GHashFunc          hash_value_func,
691                                 GCompareFunc       key_compare_func);
692 void     g_cache_destroy       (GCache            *cache);
693 gpointer g_cache_insert        (GCache            *cache,
694                                 gpointer           key);
695 void     g_cache_remove        (GCache            *cache,
696                                 gpointer           value);
697 void     g_cache_key_foreach   (GCache            *cache,
698                                 GHFunc             func,
699                                 gpointer           user_data);
700 void     g_cache_value_foreach (GCache            *cache,
701                                 GHFunc             func,
702                                 gpointer           user_data);
703
704
705 /* Trees
706  */
707 GTree*   g_tree_new      (GCompareFunc   key_compare_func);
708 void     g_tree_destroy  (GTree         *tree);
709 void     g_tree_insert   (GTree         *tree,
710                           gpointer       key,
711                           gpointer       value);
712 void     g_tree_remove   (GTree         *tree,
713                           gpointer       key);
714 gpointer g_tree_lookup   (GTree         *tree,
715                           gpointer       key);
716 void     g_tree_traverse (GTree         *tree,
717                           GTraverseFunc  traverse_func,
718                           GTraverseType  traverse_type,
719                           gpointer       data);
720 gpointer g_tree_search   (GTree         *tree,
721                           GSearchFunc    search_func,
722                           gpointer       data);
723 gint     g_tree_height   (GTree         *tree);
724 gint     g_tree_nnodes   (GTree         *tree);
725
726
727 /* Memory
728  */
729
730 #ifdef USE_DMALLOC
731
732 #define g_malloc(size)       (gpointer) MALLOC(size)
733 #define g_malloc0(size)      (gpointer) CALLOC(char,size)
734 #define g_realloc(mem,size)  (gpointer) REALLOC(mem,char,size)
735 #define g_free(mem)          FREE(mem)
736
737 #else /* USE_DMALLOC */
738
739 gpointer g_malloc      (gulong    size);
740 gpointer g_malloc0     (gulong    size);
741 gpointer g_realloc     (gpointer  mem,
742                         gulong    size);
743 void     g_free        (gpointer  mem);
744
745 #endif /* USE_DMALLOC */
746
747 void     g_mem_profile (void);
748 void     g_mem_check   (gpointer  mem);
749
750
751 /* "g_mem_chunk_new" creates a new memory chunk.
752  * Memory chunks are used to allocate pieces of memory which are
753  *  always the same size. Lists are a good example of such a data type.
754  * The memory chunk allocates and frees blocks of memory as needed.
755  *  Just be sure to call "g_mem_chunk_free" and not "g_free" on data
756  *  allocated in a mem chunk. ("g_free" will most likely cause a seg
757  *  fault...somewhere).
758  *
759  * Oh yeah, GMemChunk is an opaque data type. (You don't really
760  *  want to know what's going on inside do you?)
761  */
762
763 /* ALLOC_ONLY MemChunk's can only allocate memory. The free operation
764  *  is interpreted as a no op. ALLOC_ONLY MemChunk's save 4 bytes per
765  *  atom. (They are also useful for lists which use MemChunk to allocate
766  *  memory but are also part of the MemChunk implementation).
767  * ALLOC_AND_FREE MemChunk's can allocate and free memory.
768  */
769
770 #define G_ALLOC_ONLY      1
771 #define G_ALLOC_AND_FREE  2
772
773 GMemChunk* g_mem_chunk_new     (gchar     *name,
774                                 gint       atom_size,
775                                 gulong     area_size,
776                                 gint       type);
777 void       g_mem_chunk_destroy (GMemChunk *mem_chunk);
778 gpointer   g_mem_chunk_alloc   (GMemChunk *mem_chunk);
779 void       g_mem_chunk_free    (GMemChunk *mem_chunk,
780                                 gpointer   mem);
781 void       g_mem_chunk_clean   (GMemChunk *mem_chunk);
782 void       g_mem_chunk_reset   (GMemChunk *mem_chunk);
783 void       g_mem_chunk_print   (GMemChunk *mem_chunk);
784 void       g_mem_chunk_info    (void);
785
786 /* Ah yes...we have a "g_blow_chunks" function.
787  * "g_blow_chunks" simply compresses all the chunks. This operation
788  *  consists of freeing every memory area that should be freed (but
789  *  which we haven't gotten around to doing yet). And, no,
790  *  "g_blow_chunks" doesn't follow the naming scheme, but it is a
791  *  much better name than "g_mem_chunk_clean_all" or something
792  *  similar.
793  */
794 void g_blow_chunks (void);
795
796
797 /* Timer
798  */
799 GTimer* g_timer_new     (void);
800 void    g_timer_destroy (GTimer  *timer);
801 void    g_timer_start   (GTimer  *timer);
802 void    g_timer_stop    (GTimer  *timer);
803 void    g_timer_reset   (GTimer  *timer);
804 gdouble g_timer_elapsed (GTimer  *timer,
805                          gulong  *microseconds);
806
807
808 /* Output
809  */
810 void g_error   (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
811 void g_warning (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
812 void g_message (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
813 void g_print   (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
814
815
816 /* String utility functions
817  */
818 #define G_STR_DELIMITERS     "_-|> <."
819 void    g_strdelimit            (gchar       *string,
820                                  const gchar *delimiters,
821                                  gchar        new_delimiter);
822 gchar*  g_strdup                (const gchar *str);
823 gchar*  g_strconcat             (const gchar *string1,
824                                  ...); /* NULL terminated */
825 gdouble g_strtod                (const gchar *nptr,
826                                  gchar      **endptr);
827 gchar*  g_strerror              (gint         errnum);
828 gchar*  g_strsignal             (gint         signum);
829 gint    g_strcasecmp            (const gchar *s1,
830                                  const gchar *s2);
831 void    g_strdown               (gchar       *string);
832 void    g_strup                 (gchar       *string);
833 void    g_strreverse            (gchar       *string);
834
835
836 /* Retrive static info
837  */
838 gchar*  g_get_user_name         (void);
839 gchar*  g_get_real_name         (void);
840 gchar*  g_get_home_dir          (void);
841 gchar*  g_get_tmp_dir           (void);
842 gchar*  g_get_prgname           (void);
843 void    g_set_prgname           (const gchar *prgname);
844
845
846 /* Miscellaneous utility functions
847  */
848 guint   g_parse_debug_string    (const gchar *string, 
849                                  GDebugKey   *keys, 
850                                  guint        nkeys);
851 gint    g_snprintf              (gchar       *string,
852                                  gulong       n,
853                                  gchar const *format,
854                                  ...) G_GNUC_PRINTF (3, 4);
855 gchar*  g_basename              (const gchar *file_name);
856 gchar*  g_getcwd                (void);
857 gchar*  g_dirname               (const gchar *file_name);
858      
859
860 /* We make the assumption that if memmove isn't available, then
861  * bcopy will do the job. This isn't safe everywhere. (bcopy can't
862  * necessarily handle overlapping copies) */
863 #ifdef HAVE_MEMMOVE
864 #define g_memmove memmove
865 #else 
866 #define g_memmove(a,b,c) bcopy(b,a,c)
867 #endif
868
869 /* Errors
870  */
871 GErrorFunc   g_set_error_handler   (GErrorFunc   func);
872 GWarningFunc g_set_warning_handler (GWarningFunc func);
873 GPrintFunc   g_set_message_handler (GPrintFunc func);
874 GPrintFunc   g_set_print_handler   (GPrintFunc func);
875
876 void g_debug          (const gchar *progname);
877 void g_attach_process (const gchar *progname,
878                        gint         query);
879 void g_stack_trace    (const gchar *progname,
880                        gint         query);
881
882
883 /* String Chunks
884  */
885 GStringChunk* g_string_chunk_new           (gint size);
886 void          g_string_chunk_free          (GStringChunk *chunk);
887 gchar*        g_string_chunk_insert        (GStringChunk *chunk,
888                                             const gchar  *string);
889 gchar*        g_string_chunk_insert_const  (GStringChunk *chunk,
890                                             const gchar  *string);
891
892 /* Strings
893  */
894 GString* g_string_new       (const gchar *init);
895 GString* g_string_sized_new (guint        dfl_size);
896 void     g_string_free      (GString     *string,
897                              gint         free_segment);
898 GString* g_string_assign    (GString     *lval,
899                              const gchar *rval);
900 GString* g_string_truncate  (GString     *string,
901                              gint         len);
902 GString* g_string_append    (GString     *string,
903                              const gchar *val);
904 GString* g_string_append_c  (GString     *string,
905                              gchar        c);
906 GString* g_string_prepend   (GString     *string,
907                              const gchar *val);
908 GString* g_string_prepend_c (GString     *string,
909                              gchar        c);
910 GString* g_string_insert    (GString     *string, 
911                              gint         pos, 
912                              const gchar *val);
913 GString* g_string_insert_c  (GString     *string, 
914                              gint         pos, 
915                              gchar        c);
916 GString* g_string_erase     (GString     *string, 
917                              gint         pos, 
918                              gint         len);
919 GString* g_string_down      (GString     *string);
920 GString* g_string_up        (GString     *string);
921 void     g_string_sprintf   (GString     *string,
922                              const gchar *format,
923                              ...) G_GNUC_PRINTF (2, 3);
924 void     g_string_sprintfa  (GString     *string,
925                              const gchar *format,
926                              ...) G_GNUC_PRINTF (2, 3);
927
928 /* Resizable arrays
929  */
930 #define g_array_length(array,type) \
931      (((array)->len)/sizeof(type))
932 #define g_array_append_val(array,type,val) \
933      g_rarray_append (array, (gpointer) &val, sizeof (type))
934 #define g_array_append_vals(array,type,vals,nvals) \
935      g_rarray_append (array, (gpointer) vals, sizeof (type) * nvals)
936 #define g_array_prepend_val(array,type,val) \
937      g_rarray_prepend (array, (gpointer) &val, sizeof (type))
938 #define g_array_prepend_vals(array,type,vals,nvals) \
939      g_rarray_prepend (array, (gpointer) vals, sizeof (type) * nvals)
940 #define g_array_truncate(array,type,length) \
941      g_rarray_truncate (array, length, sizeof (type))
942 #define g_array_index(array,type,index) \
943      ((type*) array->data)[index]
944
945 GArray* g_array_new       (gint      zero_terminated);
946 void    g_array_free      (GArray   *array,
947                            gint      free_segment);
948 GArray* g_rarray_append   (GArray   *array,
949                            gpointer  data,
950                            gint      size);
951 GArray* g_rarray_prepend  (GArray   *array,
952                            gpointer  data,
953                            gint      size);
954 GArray* g_rarray_truncate (GArray   *array,
955                            gint      length,
956                            gint      size);
957
958 /* Resizable pointer array.  This interface is much less complicated
959  * than the above.  Add appends appends a pointer.  Remove fills any
960  * cleared spot and shortens the array.
961  */
962
963 #define     g_ptr_array_index(array,index) (array->pdata)[index]
964
965 GPtrArray*  g_ptr_array_new                (void);
966 void        g_ptr_array_free               (GPtrArray   *array,
967                                             gboolean     free_seg);
968 void        g_ptr_array_set_size           (GPtrArray   *array,
969                                             gint         length);
970 void        g_ptr_array_remove_index       (GPtrArray   *array,
971                                             gint         index);
972 gboolean    g_ptr_array_remove             (GPtrArray   *array,
973                                             gpointer     data);
974 void        g_ptr_array_add                (GPtrArray   *array,
975                                             gpointer     data);
976
977 /* Byte arrays, an array of guint8.  Implemented as a GArray,
978  * but type-safe.
979  */
980
981 GByteArray* g_byte_array_new      (void);
982 void        g_byte_array_free     (GByteArray *array,
983                                    gint        free_segment);
984
985 GByteArray* g_byte_array_append   (GByteArray   *array,
986                                    const guint8 *data,
987                                    guint         len);
988
989 GByteArray* g_byte_array_prepend  (GByteArray   *array,
990                                    const guint8 *data,
991                                    guint         len);
992
993 GByteArray* g_byte_array_truncate (GByteArray *array,
994                                    gint        length);
995
996
997 /* Hash Functions
998  */
999 gint  g_str_equal (gconstpointer   v,
1000                    gconstpointer   v2);
1001 guint g_str_hash  (gconstpointer v);
1002
1003 gint  g_int_equal (gconstpointer v,
1004                    gconstpointer v2);
1005 guint g_int_hash  (gconstpointer v);
1006
1007 /* This "hash" function will just return the key's adress as an
1008  * unsigned integer. Useful for hashing on plain adresses or
1009  * simple integer values.
1010  */
1011 guint g_direct_hash  (gconstpointer v);
1012 gint  g_direct_equal (gconstpointer v,
1013                       gconstpointer v2);
1014
1015
1016 /* Quarks (string<->id association)
1017  */
1018 GQuark    g_quark_try_string            (const gchar    *string);
1019 GQuark    g_quark_from_static_string    (const gchar    *string);
1020 GQuark    g_quark_from_string           (const gchar    *string);
1021 gchar*    g_quark_to_string             (GQuark          quark);
1022
1023 /* Location Associated Data
1024  */
1025 void      g_dataset_destroy             (gconstpointer   dataset_location);
1026 gpointer  g_dataset_id_get_data         (gconstpointer   dataset_location,
1027                                          GQuark          key_id);
1028 void      g_dataset_id_set_data_full    (gconstpointer   dataset_location,
1029                                          GQuark          key_id,
1030                                          gpointer        data,
1031                                          GDestroyNotify  destroy_func);
1032 void      g_dataset_id_set_destroy      (gconstpointer   dataset_location,
1033                                          GQuark          key_id,
1034                                          GDestroyNotify  destroy_func);
1035
1036 #define   g_dataset_id_set_data(l,k,d)  G_STMT_START{g_dataset_id_set_data_full((l),(k),(d),NULL);}G_STMT_END
1037 #define   g_dataset_id_remove_data(l,k) G_STMT_START{g_dataset_id_set_data((l),(k),NULL);}G_STMT_END
1038 #define   g_dataset_get_data(l,k)       (g_dataset_id_get_data((l),g_quark_try_string(k)))
1039 #define   g_dataset_set_data_full(l,k,d,f) G_STMT_START{g_dataset_id_set_data_full((l),g_quark_from_string(k),(d),(f));}G_STMT_END
1040 #define   g_dataset_set_destroy(l,k,f)  G_STMT_START{g_dataset_id_set_destroy((l),g_quark_from_string(k),(f));}G_STMT_END
1041 #define   g_dataset_set_data(l,k,d)     G_STMT_START{g_dataset_set_data_full((l),(k),(d),NULL);}G_STMT_END
1042 #define   g_dataset_remove_data(l,k)    G_STMT_START{g_dataset_set_data((l),(k),NULL);}G_STMT_END
1043
1044
1045 /* GScanner: Flexible lexical scanner for general purpose.
1046  */
1047
1048 /* Character sets */
1049 #define G_CSET_A_2_Z    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1050 #define G_CSET_a_2_z    "abcdefghijklmnopqrstuvwxyz"
1051 #define G_CSET_LATINC   "\300\301\302\303\304\305\306"\
1052                         "\307\310\311\312\313\314\315\316\317\320"\
1053                         "\321\322\323\324\325\326"\
1054                         "\330\331\332\333\334\335\336"
1055 #define G_CSET_LATINS   "\337\340\341\342\343\344\345\346"\
1056                         "\347\350\351\352\353\354\355\356\357\360"\
1057                         "\361\362\363\364\365\366"\
1058                         "\370\371\372\373\374\375\376\377"
1059
1060 /* Error types */
1061 typedef enum
1062 {
1063   G_ERR_UNKNOWN,
1064   G_ERR_UNEXP_EOF,
1065   G_ERR_UNEXP_EOF_IN_STRING,
1066   G_ERR_UNEXP_EOF_IN_COMMENT,
1067   G_ERR_NON_DIGIT_IN_CONST,
1068   G_ERR_DIGIT_RADIX,
1069   G_ERR_FLOAT_RADIX,
1070   G_ERR_FLOAT_MALFORMED
1071 } GErrorType;
1072
1073 /* Token types */
1074 typedef enum
1075 {
1076   G_TOKEN_EOF                   =   0,
1077   
1078   G_TOKEN_LEFT_PAREN            = '(',
1079   G_TOKEN_RIGHT_PAREN           = ')',
1080   G_TOKEN_LEFT_CURLY            = '{',
1081   G_TOKEN_RIGHT_CURLY           = '}',
1082   G_TOKEN_LEFT_BRACE            = '[',
1083   G_TOKEN_RIGHT_BRACE           = ']',
1084   G_TOKEN_EQUAL_SIGN            = '=',
1085   G_TOKEN_COMMA                 = ',',
1086   
1087   G_TOKEN_NONE                  = 256,
1088   
1089   G_TOKEN_ERROR,
1090   
1091   G_TOKEN_CHAR,
1092   G_TOKEN_BINARY,
1093   G_TOKEN_OCTAL,
1094   G_TOKEN_INT,
1095   G_TOKEN_HEX,
1096   G_TOKEN_FLOAT,
1097   G_TOKEN_STRING,
1098   
1099   G_TOKEN_SYMBOL,
1100   G_TOKEN_IDENTIFIER,
1101   G_TOKEN_IDENTIFIER_NULL,
1102   
1103   G_TOKEN_COMMENT_SINGLE,
1104   G_TOKEN_COMMENT_MULTI,
1105   G_TOKEN_LAST
1106 } GTokenType;
1107
1108 union   _GValue
1109 {
1110   gpointer      v_symbol;
1111   gchar         *v_identifier;
1112   gulong        v_binary;
1113   gulong        v_octal;
1114   gulong        v_int;
1115   gdouble       v_float;
1116   gulong        v_hex;
1117   gchar         *v_string;
1118   gchar         *v_comment;
1119   guchar        v_char;
1120   guint         v_error;
1121 };
1122
1123 struct  _GScannerConfig
1124 {
1125   /* Character sets
1126    */
1127   gchar         *cset_skip_characters;          /* default: " \t\n" */
1128   gchar         *cset_identifier_first;
1129   gchar         *cset_identifier_nth;
1130   gchar         *cpair_comment_single;          /* default: "#\n" */
1131   
1132   /* Should symbol lookup work case sensitive?
1133    */
1134   guint         case_sensitive : 1;
1135   
1136   /* Boolean values to be adjusted "on the fly"
1137    * to configure scanning behaviour.
1138    */
1139   guint         skip_comment_multi : 1;         /* C like comment */
1140   guint         skip_comment_single : 1;        /* single line comment */
1141   guint         scan_comment_multi : 1;         /* scan multi line comments? */
1142   guint         scan_identifier : 1;
1143   guint         scan_identifier_1char : 1;
1144   guint         scan_identifier_NULL : 1;
1145   guint         scan_symbols : 1;
1146   guint         scan_binary : 1;
1147   guint         scan_octal : 1;
1148   guint         scan_float : 1;
1149   guint         scan_hex : 1;                   /* `0x0ff0' */
1150   guint         scan_hex_dollar : 1;            /* `$0ff0' */
1151   guint         scan_string_sq : 1;             /* string: 'anything' */
1152   guint         scan_string_dq : 1;             /* string: "\\-escapes!\n" */
1153   guint         numbers_2_int : 1;              /* bin, octal, hex => int */
1154   guint         int_2_float : 1;                /* int => G_TOKEN_FLOAT? */
1155   guint         identifier_2_string : 1;
1156   guint         char_2_token : 1;               /* return G_TOKEN_CHAR? */
1157   guint         symbol_2_token : 1;
1158 };
1159
1160 struct  _GScanner
1161 {
1162   /* unused fields */
1163   gpointer              user_data;
1164   guint                 max_parse_errors;
1165
1166   /* g_scanner_error() increments this field */
1167   guint                 parse_errors;
1168
1169   /* name of input stream, featured by the default message handler */
1170   const gchar           *input_name;
1171
1172   /* data pointer for derived structures */
1173   gpointer              derived_data;
1174
1175   /* link into the scanner configuration */
1176   GScannerConfig        *config;
1177
1178   /* fields filled in after g_scanner_get_next_token() */
1179   GTokenType            token;
1180   GValue                value;
1181   guint                 line;
1182   guint                 position;
1183
1184   /* fields filled in after g_scanner_peek_next_token() */
1185   GTokenType            next_token;
1186   GValue                next_value;
1187   guint                 next_line;
1188   guint                 next_position;
1189
1190   /* to be considered private */
1191   GHashTable            *symbol_table;
1192   const gchar           *text;
1193   guint                 text_len;
1194   gint                  input_fd;
1195   gint                  peeked_char;
1196
1197   /* handler function for _warn and _error */
1198   GScannerMsgFunc       msg_handler;
1199 };
1200
1201 GScanner*       g_scanner_new                   (GScannerConfig *config_templ);
1202 void            g_scanner_destroy               (GScanner       *scanner);
1203 void            g_scanner_input_file            (GScanner       *scanner,
1204                                                  gint           input_fd);
1205 void            g_scanner_input_text            (GScanner       *scanner,
1206                                                  const  gchar   *text,
1207                                                  guint          text_len);
1208 GTokenType      g_scanner_get_next_token        (GScanner       *scanner);
1209 GTokenType      g_scanner_peek_next_token       (GScanner       *scanner);
1210 GTokenType      g_scanner_cur_token             (GScanner       *scanner);
1211 GValue          g_scanner_cur_value             (GScanner       *scanner);
1212 guint           g_scanner_cur_line              (GScanner       *scanner);
1213 guint           g_scanner_cur_position          (GScanner       *scanner);
1214 gboolean        g_scanner_eof                   (GScanner       *scanner);
1215 void            g_scanner_add_symbol            (GScanner       *scanner,
1216                                                  const gchar    *symbol,
1217                                                  gpointer       value);
1218 gpointer        g_scanner_lookup_symbol         (GScanner       *scanner,
1219                                                  const gchar    *symbol);
1220 void            g_scanner_foreach_symbol        (GScanner       *scanner,
1221                                                  GHFunc          func,
1222                                                  gpointer        func_data);
1223 void            g_scanner_remove_symbol         (GScanner       *scanner,
1224                                                  const gchar    *symbol);
1225 void            g_scanner_freeze_symbol_table   (GScanner       *scanner);
1226 void            g_scanner_thaw_symbol_table     (GScanner       *scanner);
1227 void            g_scanner_unexp_token           (GScanner       *scanner,
1228                                                  GTokenType     expected_token,
1229                                                  const gchar    *identifier_spec,
1230                                                  const gchar    *symbol_spec,
1231                                                  const gchar    *symbol_name,
1232                                                  const gchar    *message,
1233                                                  gint            is_error);
1234 void            g_scanner_error                 (GScanner       *scanner,
1235                                                  const gchar    *format,
1236                                                  ...) G_GNUC_PRINTF (2,3);
1237 void            g_scanner_warn                  (GScanner       *scanner,
1238                                                  const gchar    *format,
1239                                                  ...) G_GNUC_PRINTF (2,3);
1240 gint            g_scanner_stat_mode             (const gchar    *filename);
1241
1242
1243 /* Completion */
1244
1245 typedef gchar* (*GCompletionFunc)(gpointer);
1246
1247 typedef struct _GCompletion GCompletion;
1248
1249 struct _GCompletion {
1250         GList* items;
1251         GCompletionFunc func;
1252
1253         gchar* prefix;
1254         GList* cache;
1255
1256 };
1257
1258 GCompletion* g_completion_new          (GCompletionFunc func);
1259 void         g_completion_add_items    (GCompletion* cmp, 
1260                                         GList* items);
1261 void         g_completion_remove_items (GCompletion* cmp, 
1262                                         GList* items);
1263 void         g_completion_clear_items  (GCompletion* cmp);
1264 GList*       g_completion_complete     (GCompletion* cmp, 
1265                                         gchar* prefix,
1266                                         gchar** new_prefix);
1267 void         g_completion_free         (GCompletion* cmp);
1268
1269 /* GRelation: Indexed Relations.  Imagine a really simple table in a
1270  * database.  Relations are not ordered.  This data type is meant for
1271  * maintaining a N-way mapping.
1272  *
1273  * g_relation_new() creates a relation with FIELDS fields
1274  *
1275  * g_relation_destroy() frees all resources
1276  * g_tuples_destroy() frees the result of g_relation_select()
1277  *
1278  * g_relation_index() indexes relation FIELD with the provided
1279  *   equality and hash functions.  this must be done before any
1280  *   calls to insert are made.
1281  *
1282  * g_relation_insert() inserts a new tuple.  you are expected to
1283  *   provide the right number of fields.
1284  *
1285  * g_relation_delete() deletes all relations with KEY in FIELD
1286  * g_relation_select() returns ...
1287  * g_relation_count() counts ...
1288  */
1289
1290 GRelation* g_relation_new     (gint         fields);
1291 void       g_relation_destroy (GRelation   *relation);
1292 void       g_relation_index   (GRelation   *relation,
1293                                gint         field,
1294                                GHashFunc    hash_func,
1295                                GCompareFunc key_compare_func);
1296 void       g_relation_insert  (GRelation   *relation,
1297                                ...);
1298 gint       g_relation_delete  (GRelation   *relation,
1299                                gconstpointer  key,
1300                                gint         field);
1301 GTuples*   g_relation_select  (GRelation   *relation,
1302                                gconstpointer  key,
1303                                gint         field);
1304 gint       g_relation_count   (GRelation   *relation,
1305                                gconstpointer  key,
1306                                gint         field);
1307 gboolean   g_relation_exists  (GRelation   *relation,
1308                                ...);
1309 void       g_relation_print   (GRelation   *relation);
1310
1311 void       g_tuples_destroy   (GTuples     *tuples);
1312 gpointer   g_tuples_index     (GTuples     *tuples,
1313                                gint         index,
1314                                gint         field);
1315
1316
1317 /* Glib version.
1318  */
1319 extern const guint glib_major_version;
1320 extern const guint glib_minor_version;
1321 extern const guint glib_micro_version;
1322
1323 #ifdef __cplusplus
1324 }
1325 #endif /* __cplusplus */
1326
1327
1328 #endif /* __G_LIB_H__ */