Implemented g_iconv() w/ needing libiconv
[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 <stddef.h>
9 #include <ctype.h>
10 #include <limits.h>
11
12 #ifdef _MSC_VER
13 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
14 #endif
15
16 /* VS 2010 and later have stdint.h */
17 #if defined(_MSC_VER) && _MSC_VER < 1600
18 #else
19 #include <stdint.h>
20 #endif
21
22 #include <eglib-config.h>
23 #ifndef EGLIB_NO_REMAP
24 #include <eglib-remap.h>
25 #endif
26
27 #ifdef G_HAVE_ALLOCA_H
28 #include <alloca.h>
29 #endif
30
31 #ifdef WIN32
32 /* For alloca */
33 #include <malloc.h>
34 #endif
35
36 #ifndef offsetof
37 #   define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
38 #endif
39
40 #define __EGLIB_X11 1
41
42 #ifdef  __cplusplus
43 #define G_BEGIN_DECLS  extern "C" {
44 #define G_END_DECLS    }
45 #else
46 #define G_BEGIN_DECLS
47 #define G_END_DECLS
48 #endif
49
50 G_BEGIN_DECLS
51
52 #ifdef G_OS_WIN32
53 /* MSC and Cross-compilatin will use this */
54 int vasprintf (char **strp, const char *fmt, va_list ap);
55 #endif
56
57
58 /*
59  * Basic data types
60  */
61 typedef int            gint;
62 typedef unsigned int   guint;
63 typedef short          gshort;
64 typedef unsigned short gushort;
65 typedef long           glong;
66 typedef unsigned long  gulong;
67 typedef void *         gpointer;
68 typedef const void *   gconstpointer;
69 typedef char           gchar;
70 typedef unsigned char  guchar;
71
72 #if !G_TYPES_DEFINED
73 /* VS 2010 and later have stdint.h */
74 #if defined(_MSC_VER) && _MSC_VER < 1600
75 typedef __int8                  gint8;
76 typedef unsigned __int8         guint8;
77 typedef __int16                 gint16;
78 typedef unsigned __int16        guint16;
79 typedef __int32                 gint32;
80 typedef unsigned __int32        guint32;
81 typedef __int64                 gint64;
82 typedef unsigned __int64        guint64;
83 typedef float                   gfloat;
84 typedef double                  gdouble;
85 typedef int                     gboolean;
86 #else
87 /* Types defined in terms of the stdint.h */
88 typedef int8_t         gint8;
89 typedef uint8_t        guint8;
90 typedef int16_t        gint16;
91 typedef uint16_t       guint16;
92 typedef int32_t        gint32;
93 typedef uint32_t       guint32;
94 typedef int64_t        gint64;
95 typedef uint64_t       guint64;
96 typedef float          gfloat;
97 typedef double         gdouble;
98 typedef int32_t        gboolean;
99 #endif
100 #endif
101
102 typedef guint16 gunichar2;
103 typedef guint32 gunichar;
104
105 /*
106  * Macros
107  */
108 #define G_N_ELEMENTS(s)      (sizeof(s) / sizeof ((s) [0]))
109
110 #define FALSE                0
111 #define TRUE                 1
112
113 #define G_MAXINT             INT_MAX
114 #define G_MININT             INT_MIN
115 #define G_MAXINT32           INT32_MAX
116 #define G_MAXUINT32          UINT32_MAX
117 #define G_MININT32           INT32_MIN
118 #define G_MININT64           INT64_MIN
119 #define G_MAXINT64           INT64_MAX
120 #define G_MAXUINT64          UINT64_MAX
121
122 #define G_LITTLE_ENDIAN 1234
123 #define G_BIG_ENDIAN    4321
124 #define G_STMT_START    do 
125 #define G_STMT_END      while (0)
126
127 #define G_USEC_PER_SEC  1000000
128
129 #define ABS(a)         ((a) > 0 ? (a) : -(a))
130
131 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
132
133 #define EGLIB_STRINGIFY(x) #x
134 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
135 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
136
137 #define G_CONST_RETURN const
138
139 /*
140  * Allocation
141  */
142 void g_free (void *ptr);
143 gpointer g_realloc (gpointer obj, gsize size);
144 gpointer g_malloc (gsize x);
145 gpointer g_malloc0 (gsize x);
146 gpointer g_try_malloc (gsize x);
147 gpointer g_try_realloc (gpointer obj, gsize size);
148
149 #define g_new(type,size)        ((type *) g_malloc (sizeof (type) * (size)))
150 #define g_new0(type,size)       ((type *) g_malloc0 (sizeof (type)* (size)))
151 #define g_newa(type,size)       ((type *) alloca (sizeof (type) * (size)))
152
153 #define g_memmove(dest,src,len) memmove (dest, src, len)
154 #define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
155 #define g_alloca(size)          alloca (size)
156
157 gpointer g_memdup (gconstpointer mem, guint byte_size);
158 static inline gchar   *g_strdup (const gchar *str) { if (str) {return strdup (str);} return NULL; }
159 gchar **g_strdupv (gchar **str_array);
160
161 typedef struct {
162         gpointer (*malloc)      (gsize    n_bytes);
163         gpointer (*realloc)     (gpointer mem, gsize n_bytes);
164         void     (*free)        (gpointer mem);
165         gpointer (*calloc)      (gsize    n_blocks, gsize n_block_bytes);
166         gpointer (*try_malloc)  (gsize    n_bytes);
167         gpointer (*try_realloc) (gpointer mem, gsize n_bytes);
168 } GMemVTable;
169
170 #define g_mem_set_vtable(x)
171
172 struct _GMemChunk {
173         guint alloc_size;
174 };
175
176 typedef struct _GMemChunk GMemChunk;
177 /*
178  * Misc.
179  */
180 #define g_atexit(func)  ((void) atexit (func))
181
182 const gchar *    g_getenv(const gchar *variable);
183 gboolean         g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
184 void             g_unsetenv(const gchar *variable);
185
186 gchar*           g_win32_getlocale(void);
187
188 /*
189  * Precondition macros
190  */
191 #define g_warn_if_fail(x)  G_STMT_START { if (!(x)) { g_warning ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); } } G_STMT_END
192 #define g_return_if_fail(x)  G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
193 #define g_return_val_if_fail(x,e)  G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
194
195 /*
196  * Hashtables
197  */
198 typedef struct _GHashTable GHashTable;
199 typedef struct _GHashTableIter GHashTableIter;
200
201 /* Private, but needed for stack allocation */
202 struct _GHashTableIter
203 {
204         gpointer dummy [8];
205 };
206
207 typedef void     (*GFunc)          (gpointer data, gpointer user_data);
208 typedef gint     (*GCompareFunc)   (gconstpointer a, gconstpointer b);
209 typedef gint     (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
210 typedef void     (*GHFunc)         (gpointer key, gpointer value, gpointer user_data);
211 typedef gboolean (*GHRFunc)        (gpointer key, gpointer value, gpointer user_data);
212 typedef void     (*GDestroyNotify) (gpointer data);
213 typedef guint    (*GHashFunc)      (gconstpointer key);
214 typedef gboolean (*GEqualFunc)     (gconstpointer a, gconstpointer b);
215 typedef void     (*GFreeFunc)      (gpointer       data);
216
217 GHashTable     *g_hash_table_new             (GHashFunc hash_func, GEqualFunc key_equal_func);
218 GHashTable     *g_hash_table_new_full        (GHashFunc hash_func, GEqualFunc key_equal_func,
219                                               GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
220 void            g_hash_table_insert_replace  (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
221 guint           g_hash_table_size            (GHashTable *hash);
222 gpointer        g_hash_table_lookup          (GHashTable *hash, gconstpointer key);
223 gboolean        g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
224 void            g_hash_table_foreach         (GHashTable *hash, GHFunc func, gpointer user_data);
225 gpointer        g_hash_table_find            (GHashTable *hash, GHRFunc predicate, gpointer user_data);
226 gboolean        g_hash_table_remove          (GHashTable *hash, gconstpointer key);
227 gboolean        g_hash_table_steal           (GHashTable *hash, gconstpointer key);
228 void            g_hash_table_remove_all      (GHashTable *hash);
229 guint           g_hash_table_foreach_remove  (GHashTable *hash, GHRFunc func, gpointer user_data);
230 guint           g_hash_table_foreach_steal   (GHashTable *hash, GHRFunc func, gpointer user_data);
231 void            g_hash_table_destroy         (GHashTable *hash);
232 void            g_hash_table_print_stats     (GHashTable *table);
233
234 void            g_hash_table_iter_init       (GHashTableIter *iter, GHashTable *hash_table);
235 gboolean        g_hash_table_iter_next       (GHashTableIter *iter, gpointer *key, gpointer *value);
236
237 guint           g_spaced_primes_closest      (guint x);
238
239 #define g_hash_table_insert(h,k,v)    g_hash_table_insert_replace ((h),(k),(v),FALSE)
240 #define g_hash_table_replace(h,k,v)   g_hash_table_insert_replace ((h),(k),(v),TRUE)
241
242 gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
243 guint    g_direct_hash  (gconstpointer v1);
244 gboolean g_int_equal    (gconstpointer v1, gconstpointer v2);
245 guint    g_int_hash     (gconstpointer v1);
246 gboolean g_str_equal    (gconstpointer v1, gconstpointer v2);
247 guint    g_str_hash     (gconstpointer v1);
248
249 /*
250  * Errors
251  */
252 typedef struct {
253         /* In the real glib, this is a GQuark, but we dont use/need that */
254         gpointer domain;
255         gint     code;
256         gchar   *message;
257 } GError;
258
259 void    g_clear_error (GError **error);
260 void    g_error_free (GError *error);
261 GError *g_error_new  (gpointer domain, gint code, const char *format, ...);
262 void    g_set_error  (GError **err, gpointer domain, gint code, const gchar *format, ...);
263 void    g_propagate_error (GError **dest, GError *src);
264
265 /*
266  * Strings utility
267  */
268 gchar       *g_strdup_printf  (const gchar *format, ...);
269 gchar       *g_strdup_vprintf (const gchar *format, va_list args);
270 gchar       *g_strndup        (const gchar *str, gsize n);
271 const gchar *g_strerror       (gint errnum);
272 gchar       *g_strndup        (const gchar *str, gsize n);
273 void         g_strfreev       (gchar **str_array);
274 gchar       *g_strconcat      (const gchar *first, ...);
275 gchar      **g_strsplit       (const gchar *string, const gchar *delimiter, gint max_tokens);
276 gchar      **g_strsplit_set   (const gchar *string, const gchar *delimiter, gint max_tokens);
277 gchar       *g_strreverse     (gchar *str);
278 gboolean     g_str_has_prefix (const gchar *str, const gchar *prefix);
279 gboolean     g_str_has_suffix (const gchar *str, const gchar *suffix);
280 guint        g_strv_length    (gchar **str_array);
281 gchar       *g_strjoin        (const gchar *separator, ...);
282 gchar       *g_strjoinv       (const gchar *separator, gchar **str_array);
283 gchar       *g_strchug        (gchar *str);
284 gchar       *g_strchomp       (gchar *str);
285 void         g_strdown        (gchar *string);
286 gchar       *g_strnfill       (gsize length, gchar fill_char);
287
288 gchar       *g_strdelimit     (gchar *string, const gchar *delimiters, gchar new_delimiter);
289 gchar       *g_strescape      (const gchar *source, const gchar *exceptions);
290
291 gchar       *g_filename_to_uri   (const gchar *filename, const gchar *hostname, GError **error);
292 gchar       *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
293
294 gint         g_printf          (gchar const *format, ...);
295 gint         g_fprintf         (FILE *file, gchar const *format, ...);
296 gint         g_sprintf         (gchar *string, gchar const *format, ...);
297 gint         g_snprintf        (gchar *string, gulong n, gchar const *format, ...);
298 #define g_vprintf vprintf
299 #define g_vfprintf vfprintf
300 #define g_vsprintf vsprintf
301 #define g_vsnprintf vsnprintf
302 #define g_vasprintf vasprintf
303
304 gsize   g_strlcpy            (gchar *dest, const gchar *src, gsize dest_size);
305 gchar  *g_stpcpy             (gchar *dest, const char *src);
306
307
308 gchar   g_ascii_tolower      (gchar c);
309 gchar  *g_ascii_strdown      (const gchar *str, gssize len);
310 gint    g_ascii_strncasecmp  (const gchar *s1, const gchar *s2, gsize n);
311 gint    g_ascii_strcasecmp   (const gchar *s1, const gchar *s2);
312 gint    g_ascii_xdigit_value (gchar c);
313 #define g_ascii_isspace(c)   (isspace (c) != 0)
314 #define g_ascii_isalpha(c)   (isalpha (c) != 0)
315 #define g_ascii_isprint(c)   (isprint (c) != 0)
316 #define g_ascii_isxdigit(c)  (isxdigit (c) != 0)
317
318 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
319 #ifdef _MSC_VER
320 #define g_strcasecmp stricmp
321 #define g_ascii_strcasecmp stricmp
322 #define g_strncasecmp strnicmp
323 #define g_strstrip(a) g_strchug (g_strchomp (a))
324 #else
325 #define g_strcasecmp strcasecmp
326 #define g_ascii_strcasecmp strcasecmp
327 #define g_ascii_strtoull strtoull
328 #define g_strncasecmp strncasecmp
329 #define g_strstrip(a) g_strchug (g_strchomp (a))
330 #endif
331 #define g_ascii_strdup strdup
332
333
334 #define G_STR_DELIMITERS "_-|> <."
335
336 /*
337  * String type
338  */
339 typedef struct {
340         char *str;
341         gsize len;
342         gsize allocated_len;
343 } GString;
344
345 GString     *g_string_new           (const gchar *init);
346 GString     *g_string_new_len       (const gchar *init, gssize len);
347 GString     *g_string_sized_new     (gsize default_size);
348 gchar       *g_string_free          (GString *string, gboolean free_segment);
349 GString     *g_string_append        (GString *string, const gchar *val);
350 void         g_string_printf        (GString *string, const gchar *format, ...);
351 void         g_string_append_printf (GString *string, const gchar *format, ...);
352 void         g_string_append_vprintf (GString *string, const gchar *format, va_list args);
353 GString     *g_string_append_unichar (GString *string, gunichar c);
354 GString     *g_string_append_c      (GString *string, gchar c);
355 GString     *g_string_append        (GString *string, const gchar *val);
356 GString     *g_string_append_len    (GString *string, const gchar *val, gssize len);
357 GString     *g_string_truncate      (GString *string, gsize len);
358 GString     *g_string_prepend       (GString *string, const gchar *val);
359 GString     *g_string_insert        (GString *string, gssize pos, const gchar *val);
360 GString     *g_string_set_size      (GString *string, gsize len);
361 GString     *g_string_erase         (GString *string, gssize pos, gssize len);
362
363 #define g_string_sprintfa g_string_append_printf
364
365 /*
366  * Lists
367  */
368 typedef struct _GSList GSList;
369 struct _GSList {
370         gpointer data;
371         GSList *next;
372 };
373
374 GSList *g_slist_alloc         (void);
375 GSList *g_slist_append        (GSList        *list,
376                                gpointer       data);
377 GSList *g_slist_prepend       (GSList        *list,
378                                gpointer       data);
379 void    g_slist_free          (GSList        *list);
380 void    g_slist_free_1        (GSList        *list);
381 GSList *g_slist_copy          (GSList        *list);
382 GSList *g_slist_concat        (GSList        *list1,
383                                GSList        *list2);
384 void    g_slist_foreach       (GSList        *list,
385                                GFunc          func,
386                                gpointer       user_data);
387 GSList *g_slist_last          (GSList        *list);
388 GSList *g_slist_find          (GSList        *list,
389                                gconstpointer  data);
390 GSList *g_slist_find_custom   (GSList        *list,
391                                gconstpointer  data,
392                                GCompareFunc   func);
393 GSList *g_slist_remove        (GSList        *list,
394                                gconstpointer  data);
395 GSList *g_slist_remove_all    (GSList        *list,
396                                gconstpointer  data);
397 GSList *g_slist_reverse       (GSList        *list);
398 guint   g_slist_length        (GSList        *list);
399 GSList *g_slist_remove_link   (GSList        *list,
400                                GSList        *link);
401 GSList *g_slist_delete_link   (GSList        *list,
402                                GSList        *link);
403 GSList *g_slist_insert_sorted (GSList        *list,
404                                gpointer       data,
405                                GCompareFunc   func);
406 GSList *g_slist_insert_before (GSList        *list,
407                                GSList        *sibling,
408                                gpointer       data);
409 GSList *g_slist_sort          (GSList        *list,
410                                GCompareFunc   func);
411 gint    g_slist_index         (GSList        *list,
412                                gconstpointer  data);
413 GSList *g_slist_nth           (GSList        *list,
414                                guint          n);
415 gpointer g_slist_nth_data     (GSList        *list,
416                                guint          n);
417
418 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
419
420
421 typedef struct _GList GList;
422 struct _GList {
423   gpointer data;
424   GList *next;
425   GList *prev;
426 };
427
428 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
429 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
430
431 GList *g_list_alloc         (void);
432 GList *g_list_append        (GList         *list,
433                              gpointer       data);
434 GList *g_list_prepend       (GList         *list,
435                              gpointer       data);
436 void   g_list_free          (GList         *list);
437 void   g_list_free_1        (GList         *list);
438 GList *g_list_copy          (GList         *list);
439 guint  g_list_length        (GList         *list);
440 gint   g_list_index         (GList         *list,
441                              gconstpointer  data);
442 GList *g_list_nth           (GList         *list,
443                              guint          n);
444 gpointer g_list_nth_data      (GList         *list,
445                              guint          n);
446 GList *g_list_last          (GList         *list);
447 GList *g_list_concat        (GList         *list1,
448                              GList         *list2);
449 void   g_list_foreach       (GList         *list,
450                              GFunc          func,
451                              gpointer       user_data);
452 GList *g_list_first         (GList         *list);
453 GList *g_list_find          (GList         *list,
454                              gconstpointer  data);
455 GList *g_list_find_custom   (GList         *list,
456                              gconstpointer  data,
457                              GCompareFunc   func);
458 GList *g_list_remove        (GList         *list,
459                              gconstpointer  data);
460 GList *g_list_remove_all    (GList         *list,
461                              gconstpointer  data);
462 GList *g_list_reverse       (GList         *list);
463 GList *g_list_remove_link   (GList         *list,
464                              GList         *link);
465 GList *g_list_delete_link   (GList         *list,
466                              GList         *link);
467 GList *g_list_insert_sorted (GList         *list,
468                              gpointer       data,
469                              GCompareFunc   func);
470 GList *g_list_insert_before (GList         *list,
471                              GList         *sibling,
472                              gpointer       data);
473 GList *g_list_sort          (GList         *sort,
474                              GCompareFunc   func);
475
476 /*
477  * ByteArray
478  */
479
480 typedef struct _GByteArray GByteArray;
481 struct _GByteArray {
482         guint8 *data;
483         gint len;
484 };
485
486 GByteArray *g_byte_array_new    (void);
487 GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
488 guint8*  g_byte_array_free      (GByteArray *array, gboolean free_segment);
489
490 /*
491  * Array
492  */
493
494 typedef struct _GArray GArray;
495 struct _GArray {
496         gchar *data;
497         gint len;
498 };
499
500 GArray *g_array_new               (gboolean zero_terminated, gboolean clear_, guint element_size);
501 GArray *g_array_sized_new         (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size);
502 gchar*  g_array_free              (GArray *array, gboolean free_segment);
503 GArray *g_array_append_vals       (GArray *array, gconstpointer data, guint len);
504 GArray* g_array_insert_vals       (GArray *array, guint index_, gconstpointer data, guint len);
505 GArray* g_array_remove_index      (GArray *array, guint index_);
506 GArray* g_array_remove_index_fast (GArray *array, guint index_);
507 void    g_array_set_size          (GArray *array, gint length);
508
509 #define g_array_append_val(a,v)   (g_array_append_vals((a),&(v),1))
510 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
511 #define g_array_index(a,t,i)      *(t*)(((a)->data) + sizeof(t) * (i))
512
513 /*
514  * QSort
515 */
516
517 void g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data);
518
519 /*
520  * Pointer Array
521  */
522
523 typedef struct _GPtrArray GPtrArray;
524 struct _GPtrArray {
525         gpointer *pdata;
526         guint len;
527 };
528
529 GPtrArray *g_ptr_array_new                (void);
530 GPtrArray *g_ptr_array_sized_new          (guint reserved_size);
531 void       g_ptr_array_add                (GPtrArray *array, gpointer data);
532 gboolean   g_ptr_array_remove             (GPtrArray *array, gpointer data);
533 gpointer   g_ptr_array_remove_index       (GPtrArray *array, guint index);
534 gboolean   g_ptr_array_remove_fast        (GPtrArray *array, gpointer data);
535 gpointer   g_ptr_array_remove_index_fast  (GPtrArray *array, guint index);
536 void       g_ptr_array_sort               (GPtrArray *array, GCompareFunc compare_func);
537 void       g_ptr_array_sort_with_data     (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
538 void       g_ptr_array_set_size           (GPtrArray *array, gint length);
539 gpointer  *g_ptr_array_free               (GPtrArray *array, gboolean free_seg);
540 void       g_ptr_array_foreach            (GPtrArray *array, GFunc func, gpointer user_data);
541 #define    g_ptr_array_index(array,index) (array)->pdata[(index)]
542
543 /*
544  * Queues
545  */
546 typedef struct {
547         GList *head;
548         GList *tail;
549         guint length;
550 } GQueue;
551
552 gpointer g_queue_pop_head  (GQueue   *queue);
553 void     g_queue_push_head (GQueue   *queue,
554                             gpointer  data);
555 void     g_queue_push_tail (GQueue   *queue,
556                             gpointer  data);
557 gboolean g_queue_is_empty  (GQueue   *queue);
558 GQueue  *g_queue_new       (void);
559 void     g_queue_free      (GQueue   *queue);
560 void     g_queue_foreach   (GQueue   *queue, GFunc func, gpointer user_data);
561
562 /*
563  * Messages
564  */
565 #ifndef G_LOG_DOMAIN
566 #define G_LOG_DOMAIN ((gchar*) 0)
567 #endif
568
569 typedef enum {
570         G_LOG_FLAG_RECURSION          = 1 << 0,
571         G_LOG_FLAG_FATAL              = 1 << 1,
572         
573         G_LOG_LEVEL_ERROR             = 1 << 2,
574         G_LOG_LEVEL_CRITICAL          = 1 << 3,
575         G_LOG_LEVEL_WARNING           = 1 << 4,
576         G_LOG_LEVEL_MESSAGE           = 1 << 5,
577         G_LOG_LEVEL_INFO              = 1 << 6,
578         G_LOG_LEVEL_DEBUG             = 1 << 7,
579         
580         G_LOG_LEVEL_MASK              = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
581 } GLogLevelFlags;
582
583 void           g_print                (const gchar *format, ...);
584 void           g_printerr             (const gchar *format, ...);
585 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
586 GLogLevelFlags g_log_set_fatal_mask   (const gchar *log_domain, GLogLevelFlags fatal_mask);
587 void           g_logv                 (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
588 void           g_log                  (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
589 void           g_assertion_message    (const gchar *format, ...) G_GNUC_NORETURN;
590
591 #ifdef HAVE_C99_SUPPORT
592 /* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
593 #define g_error(format, ...)    do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
594 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
595 #define g_warning(format, ...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
596 #define g_message(format, ...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
597 #define g_debug(format, ...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
598 #else   /* HAVE_C99_SUPPORT */
599 #define g_error(...)    do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
600 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
601 #define g_warning(...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
602 #define g_message(...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
603 #define g_debug(...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
604 #endif  /* ndef HAVE_C99_SUPPORT */
605 #define g_log_set_handler(a,b,c,d)
606
607 #define G_GNUC_INTERNAL
608
609 /*
610  * Conversions
611  */
612
613 gpointer g_convert_error_quark(void);
614
615
616 /*
617  * Unicode Manipulation: most of this is not used by Mono by default, it is
618  * only used if the old collation code is activated, so this is only the
619  * bare minimum to build.
620  */
621
622 typedef enum {
623         G_UNICODE_CONTROL,
624         G_UNICODE_FORMAT,
625         G_UNICODE_UNASSIGNED,
626         G_UNICODE_PRIVATE_USE,
627         G_UNICODE_SURROGATE,
628         G_UNICODE_LOWERCASE_LETTER,
629         G_UNICODE_MODIFIER_LETTER,
630         G_UNICODE_OTHER_LETTER,
631         G_UNICODE_TITLECASE_LETTER,
632         G_UNICODE_UPPERCASE_LETTER,
633         G_UNICODE_COMBINING_MARK,
634         G_UNICODE_ENCLOSING_MARK,
635         G_UNICODE_NON_SPACING_MARK,
636         G_UNICODE_DECIMAL_NUMBER,
637         G_UNICODE_LETTER_NUMBER,
638         G_UNICODE_OTHER_NUMBER,
639         G_UNICODE_CONNECT_PUNCTUATION,
640         G_UNICODE_DASH_PUNCTUATION,
641         G_UNICODE_CLOSE_PUNCTUATION,
642         G_UNICODE_FINAL_PUNCTUATION,
643         G_UNICODE_INITIAL_PUNCTUATION,
644         G_UNICODE_OTHER_PUNCTUATION,
645         G_UNICODE_OPEN_PUNCTUATION,
646         G_UNICODE_CURRENCY_SYMBOL,
647         G_UNICODE_MODIFIER_SYMBOL,
648         G_UNICODE_MATH_SYMBOL,
649         G_UNICODE_OTHER_SYMBOL,
650         G_UNICODE_LINE_SEPARATOR,
651         G_UNICODE_PARAGRAPH_SEPARATOR,
652         G_UNICODE_SPACE_SEPARATOR
653 } GUnicodeType;
654
655 typedef enum {
656         G_UNICODE_BREAK_MANDATORY,
657         G_UNICODE_BREAK_CARRIAGE_RETURN,
658         G_UNICODE_BREAK_LINE_FEED,
659         G_UNICODE_BREAK_COMBINING_MARK,
660         G_UNICODE_BREAK_SURROGATE,
661         G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
662         G_UNICODE_BREAK_INSEPARABLE,
663         G_UNICODE_BREAK_NON_BREAKING_GLUE,
664         G_UNICODE_BREAK_CONTINGENT,
665         G_UNICODE_BREAK_SPACE,
666         G_UNICODE_BREAK_AFTER,
667         G_UNICODE_BREAK_BEFORE,
668         G_UNICODE_BREAK_BEFORE_AND_AFTER,
669         G_UNICODE_BREAK_HYPHEN,
670         G_UNICODE_BREAK_NON_STARTER,
671         G_UNICODE_BREAK_OPEN_PUNCTUATION,
672         G_UNICODE_BREAK_CLOSE_PUNCTUATION,
673         G_UNICODE_BREAK_QUOTATION,
674         G_UNICODE_BREAK_EXCLAMATION,
675         G_UNICODE_BREAK_IDEOGRAPHIC,
676         G_UNICODE_BREAK_NUMERIC,
677         G_UNICODE_BREAK_INFIX_SEPARATOR,
678         G_UNICODE_BREAK_SYMBOL,
679         G_UNICODE_BREAK_ALPHABETIC,
680         G_UNICODE_BREAK_PREFIX,
681         G_UNICODE_BREAK_POSTFIX,
682         G_UNICODE_BREAK_COMPLEX_CONTEXT,
683         G_UNICODE_BREAK_AMBIGUOUS,
684         G_UNICODE_BREAK_UNKNOWN,
685         G_UNICODE_BREAK_NEXT_LINE,
686         G_UNICODE_BREAK_WORD_JOINER,
687         G_UNICODE_BREAK_HANGUL_L_JAMO,
688         G_UNICODE_BREAK_HANGUL_V_JAMO,
689         G_UNICODE_BREAK_HANGUL_T_JAMO,
690         G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
691         G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
692 } GUnicodeBreakType;
693
694 gunichar       g_unichar_toupper (gunichar c);
695 gunichar       g_unichar_tolower (gunichar c);
696 gunichar       g_unichar_totitle (gunichar c);
697 GUnicodeType   g_unichar_type    (gunichar c);
698 gboolean       g_unichar_isspace (gunichar c);
699 gboolean       g_unichar_isxdigit (gunichar c);
700 gint           g_unichar_xdigit_value (gunichar c);
701 GUnicodeBreakType   g_unichar_break_type (gunichar c);
702
703 #ifndef MAX
704 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
705 #endif
706
707 #ifndef MIN
708 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
709 #endif
710
711 #ifndef CLAMP
712 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
713 #endif
714
715 #if defined(__GNUC__) && (__GNUC__ > 2)
716 #define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
717 #define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
718 #else
719 #define G_LIKELY(x) (x)
720 #define G_UNLIKELY(x) (x)
721 #endif
722
723 #define  g_assert(x)     G_STMT_START { if (G_UNLIKELY (!(x))) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x);  } G_STMT_END
724 #define  g_assert_not_reached() G_STMT_START { g_assertion_message ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } G_STMT_END
725
726 /*
727  * Unicode conversion
728  */
729
730 #define G_CONVERT_ERROR g_convert_error_quark()
731
732 typedef enum {
733         G_CONVERT_ERROR_NO_CONVERSION,
734         G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
735         G_CONVERT_ERROR_FAILED,
736         G_CONVERT_ERROR_PARTIAL_INPUT,
737         G_CONVERT_ERROR_BAD_URI,
738         G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
739 } GConvertError;
740
741 gchar     *g_utf8_strup (const gchar *str, gssize len);
742 gchar     *g_utf8_strdown (const gchar *str, gssize len);
743 gint       g_unichar_to_utf8 (gunichar c, gchar *outbuf);
744 gunichar*  g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written);
745 gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **error);
746 gchar     *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **error);
747 gunichar  *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **error);
748 gchar     *g_ucs4_to_utf8  (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **error);
749 gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **error);
750
751 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
752
753 #ifdef G_OS_WIN32
754 #define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
755 #else
756 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
757 #endif
758
759 /*
760  * Path
761  */
762 gchar  *g_build_path           (const gchar *separator, const gchar *first_element, ...);
763 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
764 gchar  *g_path_get_dirname     (const gchar *filename);
765 gchar  *g_path_get_basename    (const char *filename);
766 gchar  *g_find_program_in_path (const gchar *program);
767 gchar  *g_get_current_dir      (void);
768 gboolean g_path_is_absolute    (const char *filename);
769
770 const gchar *g_get_home_dir    (void);
771 const gchar *g_get_tmp_dir     (void);
772 const gchar *g_get_user_name   (void);
773 gchar *g_get_prgname           (void);
774 void  g_set_prgname            (const gchar *prgname);
775
776 /*
777  * Shell
778  */
779
780 gboolean  g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
781 gchar    *g_shell_unquote    (const gchar *quoted_string, GError **error);
782 gchar    *g_shell_quote      (const gchar *unquoted_string);
783
784 /*
785  * Spawn
786  */
787 typedef enum {
788         G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
789         G_SPAWN_DO_NOT_REAP_CHILD      = 1 << 1,
790         G_SPAWN_SEARCH_PATH            = 1 << 2,
791         G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
792         G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
793         G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
794         G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
795 } GSpawnFlags;
796
797 typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
798
799 gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
800 gboolean g_spawn_async_with_pipes  (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
801                                 gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
802
803
804 /*
805  * Timer
806  */
807 typedef struct _GTimer GTimer;
808
809 GTimer *g_timer_new (void);
810 void g_timer_destroy (GTimer *timer);
811 gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
812 void g_timer_stop (GTimer *timer);
813 void g_timer_start (GTimer *timer);
814
815 /*
816  * Date and time
817  */
818 typedef struct {
819         glong tv_sec;
820         glong tv_usec;
821 } GTimeVal;
822
823 void g_get_current_time (GTimeVal *result);
824 void g_usleep (gulong microseconds);
825
826 /*
827  * File
828  */
829
830 typedef enum {
831         G_FILE_ERROR_EXIST,
832         G_FILE_ERROR_ISDIR,
833         G_FILE_ERROR_ACCES,
834         G_FILE_ERROR_NAMETOOLONG,
835         G_FILE_ERROR_NOENT,
836         G_FILE_ERROR_NOTDIR,
837         G_FILE_ERROR_NXIO,
838         G_FILE_ERROR_NODEV,
839         G_FILE_ERROR_ROFS,
840         G_FILE_ERROR_TXTBSY,
841         G_FILE_ERROR_FAULT,
842         G_FILE_ERROR_LOOP,
843         G_FILE_ERROR_NOSPC,
844         G_FILE_ERROR_NOMEM,
845         G_FILE_ERROR_MFILE,
846         G_FILE_ERROR_NFILE,
847         G_FILE_ERROR_BADF,
848         G_FILE_ERROR_INVAL,
849         G_FILE_ERROR_PIPE,
850         G_FILE_ERROR_AGAIN,
851         G_FILE_ERROR_INTR,
852         G_FILE_ERROR_IO,
853         G_FILE_ERROR_PERM,
854         G_FILE_ERROR_NOSYS,
855         G_FILE_ERROR_FAILED
856 } GFileError;
857
858 typedef enum {
859         G_FILE_TEST_IS_REGULAR = 1 << 0,
860         G_FILE_TEST_IS_SYMLINK = 1 << 1,
861         G_FILE_TEST_IS_DIR = 1 << 2,
862         G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
863         G_FILE_TEST_EXISTS = 1 << 4
864 } GFileTest;
865
866
867 gboolean   g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
868 GFileError g_file_error_from_errno (gint err_no);
869 gint       g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
870 gboolean   g_file_test (const gchar *filename, GFileTest test);
871
872 #define g_open open
873 #define g_rename rename
874 #define g_stat stat
875 #define g_unlink unlink
876 #define g_fopen fopen
877 #define g_lstat lstat
878 #define g_rmdir rmdir
879 #define g_mkstemp mkstemp
880 #define g_ascii_isdigit isdigit
881 #define g_ascii_strtod strtod
882 #define g_ascii_isalnum isalnum
883
884 /*
885  * Pattern matching
886  */
887 typedef struct _GPatternSpec GPatternSpec;
888 GPatternSpec * g_pattern_spec_new (const gchar *pattern);
889 void           g_pattern_spec_free (GPatternSpec *pspec);
890 gboolean       g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
891
892 /*
893  * Directory
894  */
895 typedef struct _GDir GDir;
896 GDir        *g_dir_open (const gchar *path, guint flags, GError **error);
897 const gchar *g_dir_read_name (GDir *dir);
898 void         g_dir_rewind (GDir *dir);
899 void         g_dir_close (GDir *dir);
900
901 int          g_mkdir_with_parents (const gchar *pathname, int mode);
902 #define g_mkdir mkdir
903
904 /*
905  * GMarkup
906  */
907 typedef struct _GMarkupParseContext GMarkupParseContext;
908
909 typedef enum
910 {
911         G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
912         G_MARKUP_TREAT_CDATA_AS_TEXT              = 1 << 1
913 } GMarkupParseFlags;
914
915 typedef struct {
916         void (*start_element)  (GMarkupParseContext *context,
917                                 const gchar *element_name,
918                                 const gchar **attribute_names,
919                                 const gchar **attribute_values,
920                                 gpointer user_data,
921                                 GError **error);
922
923         void (*end_element)    (GMarkupParseContext *context,
924                                 const gchar         *element_name,
925                                 gpointer             user_data,
926                                 GError             **error);
927         
928         void (*text)           (GMarkupParseContext *context,
929                                 const gchar         *text,
930                                 gsize                text_len,  
931                                 gpointer             user_data,
932                                 GError             **error);
933         
934         void (*passthrough)    (GMarkupParseContext *context,
935                                 const gchar         *passthrough_text,
936                                 gsize                text_len,  
937                                 gpointer             user_data,
938                                 GError             **error);
939         void (*error)          (GMarkupParseContext *context,
940                                 GError              *error,
941                                 gpointer             user_data);
942 } GMarkupParser;
943
944 GMarkupParseContext *g_markup_parse_context_new   (const GMarkupParser *parser,
945                                                    GMarkupParseFlags flags,
946                                                    gpointer user_data,
947                                                    GDestroyNotify user_data_dnotify);
948 void                 g_markup_parse_context_free  (GMarkupParseContext *context);
949 gboolean             g_markup_parse_context_parse (GMarkupParseContext *context,
950                                                    const gchar *text, gssize text_len,
951                                                    GError **error);
952 gboolean         g_markup_parse_context_end_parse (GMarkupParseContext *context,
953                                                    GError **error);
954
955 /*
956  * Character set conversion
957  */
958 typedef struct _GIConv *GIConv;
959
960 gsize g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, gchar **outbytes, gsize *outbytesleft);
961 GIConv g_iconv_open (const gchar *to_charset, const gchar *from_charset);
962 int g_iconv_close (GIConv cd);
963
964 gboolean  g_get_charset        (G_CONST_RETURN char **charset);
965 gchar    *g_locale_to_utf8     (const gchar *opsysstring, gssize len,
966                                 gsize *bytes_read, gsize *bytes_written,
967                                 GError **error);
968 gchar    *g_locale_from_utf8   (const gchar *utf8string, gssize len, gsize *bytes_read,
969                                 gsize *bytes_written, GError **error);
970 gchar    *g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
971                                 gsize *bytes_written, GError **error);
972 gchar    *g_convert            (const gchar *str, gssize len,
973                                 const gchar *to_codeset, const gchar *from_codeset,
974                                 gsize *bytes_read, gsize *bytes_written, GError **error);
975
976 /*
977  * Unicode manipulation
978  */
979 /*
980 * Index into the table below with the first byte of a UTF-8 sequence to
981 * get the number of trailing bytes that are supposed to follow it.
982 * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
983 * left as-is for anyone who may want to do such conversion, which was
984 * allowed in earlier algorithms.
985 */
986 extern const gchar g_trailingBytesForUTF8[256];
987
988 gboolean  g_utf8_validate      (const gchar *str, gssize max_len, const gchar **end);
989 gunichar  g_utf8_get_char      (const gchar *src);
990 glong     g_utf8_strlen        (const gchar *str, gssize max);
991 #define   g_utf8_next_char(p) p + (g_trailingBytesForUTF8[(guchar)(*p)] + 1)
992 gchar *   g_utf8_offset_to_pointer (const gchar *str, glong offset);
993 glong     g_utf8_pointer_to_offset (const gchar *str, const gchar *pos);
994 gchar *   g_utf8_prev_char (const char *str);
995 gchar *   g_utf8_find_prev_char (const char *str, const char *p);
996
997 /*
998  * priorities
999  */
1000 #define G_PRIORITY_DEFAULT 0
1001 #define G_PRIORITY_DEFAULT_IDLE 200
1002
1003 /*
1004  * Empty thread functions, not used by eglib
1005  */
1006 #define g_thread_supported()   TRUE
1007 #define g_thread_init(x)       G_STMT_START { if (x != NULL) { g_error ("No vtable supported in g_thread_init"); } } G_STMT_END
1008
1009 #define G_LOCK_DEFINE(name)        int name;
1010 #define G_LOCK_DEFINE_STATIC(name) static int name;
1011 #define G_LOCK_EXTERN(name)
1012 #define G_LOCK(name)
1013 #define G_TRYLOCK(name)
1014 #define G_UNLOCK(name)
1015
1016 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
1017
1018 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
1019 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
1020                                ( (((guint32) (x)) << 24)| \
1021                                  ((((guint32) (x)) & 0xff0000) >> 8) | \
1022                                  ((((guint32) (x)) & 0xff00) << 8) | \
1023                                  (((guint32) (x)) >> 24)) )
1024  
1025 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
1026                                GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
1027
1028                                   
1029  
1030 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1031 #   define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
1032 #   define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
1033 #   define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
1034 #   define GUINT_FROM_BE(x)   GUINT32_SWAP_LE_BE(x)
1035 #   define GUINT64_FROM_LE(x) (x)
1036 #   define GUINT32_FROM_LE(x) (x)
1037 #   define GUINT16_FROM_LE(x) (x)
1038 #   define GUINT_FROM_LE(x)   (x)
1039 #   define GUINT64_TO_BE(x)   GUINT64_SWAP_LE_BE(x)
1040 #   define GUINT32_TO_BE(x)   GUINT32_SWAP_LE_BE(x)
1041 #   define GUINT16_TO_BE(x)   GUINT16_SWAP_LE_BE(x)
1042 #   define GUINT_TO_BE(x)     GUINT32_SWAP_LE_BE(x)
1043 #   define GUINT64_TO_LE(x)   (x)
1044 #   define GUINT32_TO_LE(x)   (x)
1045 #   define GUINT16_TO_LE(x)   (x)
1046 #   define GUINT_TO_LE(x)     (x)
1047 #else
1048 #   define GUINT64_FROM_BE(x) (x)
1049 #   define GUINT32_FROM_BE(x) (x)
1050 #   define GUINT16_FROM_BE(x) (x)
1051 #   define GUINT_FROM_BE(x)   (x)
1052 #   define GUINT64_FROM_LE(x) GUINT64_SWAP_LE_BE(x)
1053 #   define GUINT32_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
1054 #   define GUINT16_FROM_LE(x) GUINT16_SWAP_LE_BE(x)
1055 #   define GUINT_FROM_LE(x)   GUINT32_SWAP_LE_BE(x)
1056 #   define GUINT64_TO_BE(x)   (x)
1057 #   define GUINT32_TO_BE(x)   (x)
1058 #   define GUINT16_TO_BE(x)   (x)
1059 #   define GUINT_TO_BE(x)     (x)
1060 #   define GUINT64_TO_LE(x)   GUINT64_SWAP_LE_BE(x)
1061 #   define GUINT32_TO_LE(x)   GUINT32_SWAP_LE_BE(x)
1062 #   define GUINT16_TO_LE(x)   GUINT16_SWAP_LE_BE(x)
1063 #   define GUINT_TO_LE(x)     GUINT32_SWAP_LE_BE(x)
1064 #endif
1065
1066 #define GINT64_FROM_BE(x)   (GUINT64_TO_BE (x))
1067 #define GINT32_FROM_BE(x)   (GUINT32_TO_BE (x))
1068 #define GINT16_FROM_BE(x)   (GUINT16_TO_BE (x))
1069 #define GINT64_FROM_LE(x)   (GUINT64_TO_LE (x))
1070 #define GINT32_FROM_LE(x)   (GUINT32_TO_LE (x))
1071 #define GINT16_FROM_LE(x)   (GUINT16_TO_LE (x))
1072
1073 #define _EGLIB_MAJOR  2
1074 #define _EGLIB_MIDDLE 4
1075 #define _EGLIB_MINOR  0
1076  
1077 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
1078  
1079 G_END_DECLS
1080
1081 #endif
1082
1083
1084