New test.
[mono.git] / eglib / src / glib.h
1 #ifndef __GLIB_H
2 #define __GLIB_H
3
4 #include <stdarg.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <ctype.h>
10 #include <eglib-config.h>
11
12 /*
13  * Basic data types
14  */
15 typedef int            gboolean;
16 typedef int            gint;
17 typedef unsigned int   guint;
18 typedef short          gshort;
19 typedef unsigned short gushort;
20 typedef long           glong;
21 typedef unsigned long  gulong;
22 typedef void *         gpointer;
23 typedef const void *   gconstpointer;
24 typedef char           gchar;
25 typedef unsigned char  guchar;
26
27 /* Types defined in terms of the stdint.h */
28 typedef int8_t         gint8;
29 typedef uint8_t        guint8;
30 typedef int16_t        gint16;
31 typedef uint16_t       guint16;
32 typedef int32_t        gint32;
33 typedef uint32_t       guint32;
34 typedef int64_t        gint64;
35 typedef uint64_t       guint64;
36 typedef float          gfloat;
37 typedef double         gdouble;
38 typedef uint16_t       gunichar2;
39 /*
40  * Macros
41  */
42 #define G_N_ELEMENTS(s)      (sizeof(s) / sizeof ((s) [0]))
43
44 #define FALSE                0
45 #define TRUE                 1
46
47 #define G_MAXINT32           INT32_MAX
48 #define G_MININT32           INT32_MIN
49
50 #define G_LITTLE_ENDIAN 1234
51 #define G_BIG_ENDIAN    4321
52 #define G_STMT_START    do 
53 #define G_STMT_END      while (0)
54
55 #define ABS(a,b)        (((a)>(b)) ? ((a)-(b)) : ((b)-(a)))
56
57 #define G_STRUCT_OFFSET(p_type,field) \
58         ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
59
60
61 /*
62  * Allocation
63  */
64 #define g_new(type,size)        ((type *) malloc (sizeof (type) * (size)))
65 #define g_new0(type,size)       ((type *) calloc (sizeof (type), (size)))
66 #define g_newa(type,size)       ((type *) alloca (sizeof (type) * (size)))
67 #define g_realloc(obj,size)     realloc((obj), (size))
68 #define g_strdup(x)             strdup(x)
69 #define g_malloc(x)             malloc(x)
70 #define g_try_malloc(x)         malloc(x)
71 #define g_try_realloc(obj,size) realloc((obj),(size))
72 #define g_malloc0(x)            calloc(1,x)
73 #define g_memmove(dest,src,len) memmove (dest, src, len)
74 #define g_renew(struct_type, mem, n_structs) realloc (mem, sizeof (struct_type) * n_structs)
75 #define g_alloca(size)          alloca (size)
76 #define g_free                  free
77
78 gpointer g_memdup (gconstpointer mem, guint byte_size);
79
80 /*
81  * Misc.
82  */
83 #define g_atexit(func)  ((void) atexit (func))
84
85 const gchar *    g_getenv(const gchar *variable);
86 gboolean         g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
87 void             g_unsetenv(const gchar *variable);
88
89 /*
90  * Precondition macros
91  */
92 #define g_return_if_fail(x)  G_STMT_START { if (!(x)) { printf ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
93 #define g_return_val_if_fail(x,e)  G_STMT_START { if (!(x)) { printf ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
94
95 /*
96  * Hashtables
97  */
98 typedef struct _GHashTable GHashTable;
99 typedef void     (*GFunc)          (gpointer data, gpointer user_data);
100 typedef gint     (*GCompareFunc)   (gconstpointer a, gconstpointer b);
101 typedef gint     (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
102 typedef void     (*GHFunc)         (gpointer key, gpointer value, gpointer user_data);
103 typedef gboolean (*GHRFunc)        (gpointer key, gpointer value, gpointer user_data);
104 typedef void     (*GDestroyNotify) (gpointer data);
105 typedef guint    (*GHashFunc)      (gconstpointer key);
106 typedef gboolean (*GEqualFunc)     (gconstpointer a, gconstpointer b);
107
108 GHashTable     *g_hash_table_new             (GHashFunc hash_func, GEqualFunc key_equal_func);
109 GHashTable     *g_hash_table_new_full        (GHashFunc hash_func, GEqualFunc key_equal_func,
110                                               GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
111 void            g_hash_table_insert_replace  (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
112 guint           g_hash_table_size            (GHashTable *hash);
113 gpointer        g_hash_table_lookup          (GHashTable *hash, gconstpointer key);
114 gboolean        g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
115 void            g_hash_table_foreach         (GHashTable *hash, GHFunc func, gpointer user_data);
116 gpointer        g_hash_table_find            (GHashTable *hash, GHRFunc predicate, gpointer user_data);
117 gboolean        g_hash_table_remove          (GHashTable *hash, gconstpointer key);
118 guint           g_hash_table_foreach_remove  (GHashTable *hash, GHRFunc func, gpointer user_data);
119 void            g_hash_table_destroy         (GHashTable *hash);
120
121 #define g_hash_table_insert(h,k,v)    g_hash_table_insert_replace ((h),(k),(v),FALSE)
122 #define g_hash_table_replace(h,k,v)   g_hash_table_insert_replace ((h),(k),(v),TRUE)
123
124 gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
125 guint    g_direct_hash  (gconstpointer v1);
126 gboolean g_int_equal    (gconstpointer v1, gconstpointer v2);
127 guint    g_int_hash     (gconstpointer v1);
128 gboolean g_str_equal    (gconstpointer v1, gconstpointer v2);
129 guint    g_str_hash     (gconstpointer v1);
130
131 #define  g_assert(x)     G_STMT_START { if (!(x)) g_error ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x);  } G_STMT_END
132 #define  g_assert_not_reached() G_STMT_START { g_error ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } G_STMT_END
133
134 /*
135  * Errors
136  */
137 typedef struct {
138         /* In the real glib, this is a GQuark, but we dont use/need that */
139         gpointer domain;
140         gint     code;
141         gchar   *message;
142 } GError;
143
144 void    g_error_free (GError *error);
145 GError *g_error_new  (gpointer domain, gint code, const char *format, ...);
146 void    g_set_error  (GError **err, gpointer domain, gint code, const gchar *format, ...);
147
148 /*
149  * Strings utility
150  */
151 gchar       *g_strdup_printf  (const gchar *format, ...);
152 gchar       *g_strdup_vprintf (const gchar *format, va_list args);
153 gchar       *g_strndup        (const gchar *str, gsize n);
154 const gchar *g_strerror       (gint errnum);
155 gchar       *g_strndup        (const gchar *str, gsize n);
156 void         g_strfreev       (gchar **str_array);
157 gchar       *g_strconcat      (const gchar *first, ...);
158 gchar      **g_strsplit       (const gchar *string, const gchar *delimiter, gint max_tokens);
159 gchar       *g_strreverse     (gchar *str);
160 gboolean     g_str_has_prefix (const gchar *str, const gchar *prefix);
161 gboolean     g_str_has_suffix (const gchar *str, const gchar *suffix);
162 guint        g_strv_length    (gchar **str_array);
163 gchar       *g_strjoin        (const gchar *separator, ...);
164 gchar       *g_strchug        (gchar *str);
165 gchar       *g_strchomp       (gchar *str);
166
167 gchar       *g_filename_to_uri   (const gchar *filename, const gchar *hostname, GError **error);
168 gchar       *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
169
170 gint         g_printf          (gchar const *format, ...);
171 gint         g_fprintf         (FILE *file, gchar const *format, ...);
172 gint         g_sprintf         (gchar *string, gchar const *format, ...);
173 gint         g_snprintf        (gchar *string, gulong n, gchar const *format, ...);
174 #define g_vprintf vprintf
175 #define g_vfprintf vfprintf
176 #define g_vsprintf vsprintf
177 #define g_vsnprintf vsnprintf
178 #define g_vasprintf vasprintf
179
180 #define g_ascii_isspace(c) (isspace (c) != 0)
181 #define g_ascii_isalpha(c) (isalpha (c) != 0)
182 #define g_ascii_isprint(c) (isprint (c) != 0)
183 #define g_ascii_isxdigit(c) (isxdigit (c) != 0)
184
185 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
186 #define g_strcasecmp strcasecmp
187 #define g_ascii_strcasecmp strcasecmp
188 #define g_strncasecmp strncasecmp
189 #define g_strstrip(a) g_strchug (g_strchomp (a))
190
191 /*
192  * String type
193  */
194 typedef struct {
195         char *str;
196         gsize len;
197         gsize allocated_len;
198 } GString;
199
200 GString     *g_string_new           (const gchar *init);
201 GString     *g_string_new_len       (const gchar *init, gssize len);
202 GString     *g_string_sized_new     (gsize default_size);
203 gchar       *g_string_free          (GString *string, gboolean free_segment);
204 GString     *g_string_append        (GString *string, const gchar *val);
205 void         g_string_printf        (GString *string, const gchar *format, ...);
206 void         g_string_append_printf (GString *string, const gchar *format, ...);
207 GString     *g_string_append_c      (GString *string, gchar c);
208 GString     *g_string_append        (GString *string, const gchar *val);
209 GString     *g_string_append_len    (GString *string, const gchar *val, gssize len);
210 GString     *g_string_truncate      (GString *string, gsize len);
211 GString     *g_string_prepend       (GString *string, const gchar *val);
212
213 #define g_string_sprintfa g_string_append_printf
214
215 /*
216  * Lists
217  */
218 typedef struct _GSList GSList;
219 struct _GSList {
220         gpointer data;
221         GSList *next;
222 };
223
224 GSList *g_slist_alloc         (void);
225 GSList *g_slist_append        (GSList        *list,
226                                gpointer       data);
227 GSList *g_slist_prepend       (GSList        *list,
228                                gpointer       data);
229 void    g_slist_free          (GSList        *list);
230 void    g_slist_free_1        (GSList        *list);
231 GSList *g_slist_copy          (GSList        *list);
232 GSList *g_slist_concat        (GSList        *list1,
233                                GSList        *list2);
234 void    g_slist_foreach       (GSList        *list,
235                                GFunc          func,
236                                gpointer       user_data);
237 GSList *g_slist_last          (GSList        *list);
238 GSList *g_slist_find          (GSList        *list,
239                                gconstpointer  data);
240 GSList *g_slist_remove        (GSList        *list,
241                                gconstpointer  data);
242 GSList *g_slist_remove_all    (GSList        *list,
243                                gconstpointer  data);
244 GSList *g_slist_reverse       (GSList        *list);
245 guint   g_slist_length        (GSList        *list);
246 GSList *g_slist_remove_link   (GSList        *list,
247                                GSList        *link);
248 GSList *g_slist_delete_link   (GSList        *list,
249                                GSList        *link);
250 GSList *g_slist_insert_sorted (GSList        *list,
251                                gpointer       data,
252                                GCompareFunc   func);
253 GSList *g_slist_insert_before (GSList        *list,
254                                GSList        *sibling,
255                                gpointer       data);
256 GSList *g_slist_sort          (GSList        *list,
257                                GCompareFunc   func);
258
259 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
260
261 typedef struct _GList GList;
262 struct _GList {
263   gpointer data;
264   GList *next;
265   GList *prev;
266 };
267
268 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL);
269
270 GList *g_list_alloc         (void);
271 GList *g_list_append        (GList         *list,
272                              gpointer       data);
273 GList *g_list_prepend       (GList         *list,
274                              gpointer       data);
275 void   g_list_free          (GList         *list);
276 void   g_list_free_1        (GList         *list);
277 GList *g_list_copy          (GList         *list);
278 guint  g_list_length        (GList         *list);
279 gint   g_list_index         (GList         *list,
280                              gconstpointer  data);
281 GList *g_list_nth           (GList         *list,
282                              guint          n);
283 gpointer g_list_nth_data      (GList         *list,
284                              guint          n);
285 GList *g_list_last          (GList         *list);
286 GList *g_list_concat        (GList         *list1,
287                              GList         *list2);
288 void   g_list_foreach       (GList         *list,
289                              GFunc          func,
290                              gpointer       user_data);
291 GList *g_list_first         (GList         *list);
292 GList *g_list_find          (GList         *list,
293                              gconstpointer  data);
294 GList *g_list_remove        (GList         *list,
295                              gconstpointer  data);
296 GList *g_list_reverse       (GList         *list);
297 GList *g_list_remove_link   (GList         *list,
298                              GList         *link);
299 GList *g_list_delete_link   (GList         *list,
300                              GList         *link);
301 GList *g_list_insert_sorted (GList         *list,
302                              gpointer       data,
303                              GCompareFunc   func);
304 GList *g_list_insert_before (GList         *list,
305                              GList         *sibling,
306                              gpointer       data);
307 GList *g_list_sort          (GList         *sort,
308                              GCompareFunc   func);
309
310 /*
311  * Array
312  */
313
314 typedef struct _GArray GArray;
315 struct _GArray {
316         gchar *data;
317         gint len;
318 };
319
320 GArray *g_array_new               (gboolean zero_terminated, gboolean clear_, guint element_size);
321 gchar*  g_array_free              (GArray *array, gboolean free_segment);
322 GArray *g_array_append_vals       (GArray *array, gconstpointer data, guint len);
323 GArray* g_array_insert_vals       (GArray *array, guint index_, gconstpointer data, guint len);
324 GArray* g_array_remove_index      (GArray *array, guint index_);
325
326 #define g_array_append_val(a,v)   (g_array_append_vals((a),&(v),1))
327 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
328 #define g_array_index(a,t,i)      *(t*)(((a)->data) + sizeof(t) * (i))
329
330 /*
331  * Pointer Array
332  */
333
334 typedef struct _GPtrArray GPtrArray;
335 struct _GPtrArray {
336         gpointer *pdata;
337         guint len;
338 };
339
340 GPtrArray *g_ptr_array_new                ();
341 GPtrArray *g_ptr_array_sized_new          (guint reserved_size);
342 void       g_ptr_array_add                (GPtrArray *array, gpointer data);
343 gboolean   g_ptr_array_remove             (GPtrArray *array, gpointer data);
344 gpointer   g_ptr_array_remove_index       (GPtrArray *array, guint index);
345 gboolean   g_ptr_array_remove_fast        (GPtrArray *array, gpointer data);
346 gpointer   g_ptr_array_remove_index_fast  (GPtrArray *array, gpointer data);
347 void       g_ptr_array_sort               (GPtrArray *array, GCompareFunc compare_func);
348 void       g_ptr_array_sort_with_data     (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
349 void       g_ptr_array_set_size           (GPtrArray *array, gint length);
350 gpointer  *g_ptr_array_free               (GPtrArray *array, gboolean free_seg);
351 void       g_ptr_array_foreach            (GPtrArray *array, GFunc func, gpointer user_data);
352 #define    g_ptr_array_index(array,index) (array)->pdata[(index)]
353
354 /*
355  * Queues
356  */
357 typedef struct {
358         GList *head;
359         GList *tail;
360         guint length;
361 } GQueue;
362
363 gpointer g_queue_pop_head  (GQueue   *queue);
364 void     g_queue_push_head (GQueue   *queue,
365                             gpointer  data);
366 gboolean g_queue_is_empty  (GQueue   *queue);
367 GQueue  *g_queue_new       (void);
368 void     g_queue_free      (GQueue   *queue);
369
370
371 /*
372  * Modules
373  */
374 typedef enum {
375         G_MODULE_BIND_LAZY = 0x01,
376         G_MODULE_BIND_LOCAL = 0x02,
377         G_MODULE_BIND_MASK = 0x03
378 } GModuleFlags;
379 typedef struct _GModule GModule;
380
381 GModule *g_module_open (const gchar *file, GModuleFlags flags);
382 gboolean g_module_symbol (GModule *module, const gchar *symbol_name,
383                           gpointer *symbol);
384 const gchar *g_module_error (void);
385 gboolean g_module_close (GModule *module);
386 gchar *  g_module_build_path (const gchar *directory, const gchar *module_name);
387 /*
388  * Messages
389  */
390 #ifndef G_LOG_DOMAIN
391 #define G_LOG_DOMAIN ((gchar*) 0)
392 #endif
393
394 typedef enum {
395         G_LOG_FLAG_RECURSION          = 1 << 0,
396         G_LOG_FLAG_FATAL              = 1 << 1,
397         
398         G_LOG_LEVEL_ERROR             = 1 << 2,
399         G_LOG_LEVEL_CRITICAL          = 1 << 3,
400         G_LOG_LEVEL_WARNING           = 1 << 4,
401         G_LOG_LEVEL_MESSAGE           = 1 << 5,
402         G_LOG_LEVEL_INFO              = 1 << 6,
403         G_LOG_LEVEL_DEBUG             = 1 << 7,
404         
405         G_LOG_LEVEL_MASK              = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
406 } GLogLevelFlags;
407
408 void           g_print                (const gchar *format, ...);
409 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
410 GLogLevelFlags g_log_set_fatal_mask   (const gchar *log_domain, GLogLevelFlags fatal_mask);
411 void           g_logv                 (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
412 void           g_log                  (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
413
414 #define g_error(format...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format)
415 #define g_critical(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format)
416 #define g_warning(format...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format)
417 #define g_message(format...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format)
418 #define g_debug(format...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
419
420 /*
421  * Conversions
422  */
423
424 gpointer g_convert_error_quark();
425
426
427 /*
428  * Unicode Manipulation: most of this is not used by Mono by default, it is
429  * only used if the old collation code is activated, so this is only the
430  * bare minimum to build.
431  */
432 typedef guint32 gunichar;
433
434 typedef enum {
435         G_UNICODE_LOWERCASE_LETTER,
436 } GUnicodeType;
437
438 gunichar       g_unichar_tolower (gunichar c);
439 GUnicodeType   g_unichar_type    (gunichar c);
440
441 #ifndef MAX
442 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
443 #endif
444
445 /* FIXME: Implement these two for gcc */
446 #define G_LIKELY(x) (x)
447 #define G_UNLIKELY(x) (x)
448
449 /*
450  * Unicode conversion
451  */
452
453 #define G_CONVERT_ERROR g_convert_error_quark()
454
455 typedef enum {
456         G_CONVERT_ERROR_NO_CONVERSION,
457         G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
458         G_CONVERT_ERROR_FAILED,
459         G_CONVERT_ERROR_PARTIAL_INPUT,
460         G_CONVERT_ERROR_BAD_URI,
461         G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
462 } GConvertError;
463
464 gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong     *items_written, GError **error);
465 glong     utf8_to_utf16_len (const gchar *str, glong len, glong *items_read, GError **error);
466 gchar     *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong     *items_written, GError **error);
467 glong     utf16_to_utf8_len (const gunichar2 *str, glong len, glong *items_read, GError **error);
468
469 /*
470  * Path
471  */
472 gchar  *g_build_path           (const gchar *separator, const gchar *first_element, ...);
473 #define g_build_filename(x...) g_build_path(G_DIR_SEPARATOR_S, x)
474 gchar  *g_path_get_dirname     (const gchar *filename);
475 gchar  *g_path_get_basename    (const char *filename);
476 gchar  *g_find_program_in_path (const gchar *program);
477 gchar  *g_get_current_dir      (void);
478 gboolean g_path_is_absolute    (const char *filename);
479
480 const gchar *g_get_home_dir    (void);
481 const gchar *g_get_tmp_dir     (void);
482 const gchar *g_get_user_name   (void);
483
484 /*
485  * Shell
486  */
487
488 gboolean g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
489
490 /*
491  * Spawn
492  */
493 typedef enum {
494         G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
495         G_SPAWN_DO_NOT_REAP_CHILD      = 1 << 1,
496         G_SPAWN_SEARCH_PATH            = 1 << 2,
497         G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
498         G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
499         G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
500         G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
501 } GSpawnFlags;
502
503 typedef pid_t GPid;
504
505 typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
506
507 gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
508 gboolean g_spawn_async_with_pipes  (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
509                                 gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
510
511
512 /*
513  * Timer
514  */
515 typedef struct _GTimer GTimer;
516
517 GTimer *g_timer_new (void);
518 void g_timer_destroy (GTimer *timer);
519 gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
520 void g_timer_stop (GTimer *timer);
521 void g_timer_start (GTimer *timer);
522
523 /*
524  * Date and time
525  */
526 typedef struct {
527         glong tv_sec;
528         glong tv_usec;
529 } GTimeVal;
530
531 void g_get_current_time (GTimeVal *result);
532
533 /*
534  * File
535  */
536
537 typedef enum {
538         G_FILE_ERROR_EXIST,
539         G_FILE_ERROR_ISDIR,
540         G_FILE_ERROR_ACCES,
541         G_FILE_ERROR_NAMETOOLONG,
542         G_FILE_ERROR_NOENT,
543         G_FILE_ERROR_NOTDIR,
544         G_FILE_ERROR_NXIO,
545         G_FILE_ERROR_NODEV,
546         G_FILE_ERROR_ROFS,
547         G_FILE_ERROR_TXTBSY,
548         G_FILE_ERROR_FAULT,
549         G_FILE_ERROR_LOOP,
550         G_FILE_ERROR_NOSPC,
551         G_FILE_ERROR_NOMEM,
552         G_FILE_ERROR_MFILE,
553         G_FILE_ERROR_NFILE,
554         G_FILE_ERROR_BADF,
555         G_FILE_ERROR_INVAL,
556         G_FILE_ERROR_PIPE,
557         G_FILE_ERROR_AGAIN,
558         G_FILE_ERROR_INTR,
559         G_FILE_ERROR_IO,
560         G_FILE_ERROR_PERM,
561         G_FILE_ERROR_NOSYS,
562         G_FILE_ERROR_FAILED
563 } GFileError;
564
565 typedef enum {
566         G_FILE_TEST_IS_REGULAR = 1 << 0,
567         G_FILE_TEST_IS_SYMLINK = 1 << 1,
568         G_FILE_TEST_IS_DIR = 1 << 2,
569         G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
570         G_FILE_TEST_EXISTS = 1 << 4
571 } GFileTest;
572
573
574 gboolean   g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
575 GFileError g_file_error_from_errno (gint err_no);
576 gint       g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
577 gboolean   g_file_test (const gchar *filename, GFileTest test);
578
579 /*
580  * Pattern matching
581  */
582 typedef struct _GPatternSpec GPatternSpec;
583 GPatternSpec * g_pattern_spec_new (const gchar *pattern);
584 void           g_pattern_spec_free (GPatternSpec *pspec);
585 gboolean       g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
586
587 /*
588  * Directory
589  */
590 typedef struct _GDir GDir;
591 GDir        *g_dir_open (const gchar *path, guint flags, GError **error);
592 const gchar *g_dir_read_name (GDir *dir);
593 void         g_dir_rewind (GDir *dir);
594 void         g_dir_close (GDir *dir);
595
596 /*
597  * GMarkup
598  */
599 typedef struct _GMarkupParseContext GMarkupParseContext;
600
601 typedef enum
602 {
603         G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
604         G_MARKUP_TREAT_CDATA_AS_TEXT              = 1 << 1
605 } GMarkupParseFlags;
606
607 typedef struct {
608         void (*start_element)  (GMarkupParseContext *context,
609                                 const gchar *element_name,
610                                 const gchar **attribute_names,
611                                 const gchar **attribute_values,
612                                 gpointer user_data,
613                                 GError **error);
614
615         void (*end_element)    (GMarkupParseContext *context,
616                                 const gchar         *element_name,
617                                 gpointer             user_data,
618                                 GError             **error);
619         
620         void (*text)           (GMarkupParseContext *context,
621                                 const gchar         *text,
622                                 gsize                text_len,  
623                                 gpointer             user_data,
624                                 GError             **error);
625         
626         void (*passthrough)    (GMarkupParseContext *context,
627                                 const gchar         *passthrough_text,
628                                 gsize                text_len,  
629                                 gpointer             user_data,
630                                 GError             **error);
631         void (*error)          (GMarkupParseContext *context,
632                                 GError              *error,
633                                 gpointer             user_data);
634 } GMarkupParser;
635
636 GMarkupParseContext *g_markup_parse_context_new   (const GMarkupParser *parser,
637                                                    GMarkupParseFlags flags,
638                                                    gpointer user_data,
639                                                    GDestroyNotify user_data_dnotify);
640 void                 g_markup_parse_context_free  (GMarkupParseContext *context);
641 gboolean             g_markup_parse_context_parse (GMarkupParseContext *context,
642                                                    const gchar *text, gssize text_len,
643                                                    GError **error);
644 gboolean         g_markup_parse_context_end_parse (GMarkupParseContext *context,
645                                                    GError **error);
646
647 #endif
648