13 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
16 /* VS 2010 and later have stdint.h */
17 #if defined(_MSC_VER) && _MSC_VER < 1600
22 #include <eglib-config.h>
23 #ifndef EGLIB_NO_REMAP
24 #include <eglib-remap.h>
27 #ifdef G_HAVE_ALLOCA_H
37 # define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
43 #define G_BEGIN_DECLS extern "C" {
53 /* MSC and Cross-compilatin will use this */
54 int vasprintf (char **strp, const char *fmt, va_list ap);
62 typedef unsigned int guint;
64 typedef unsigned short gushort;
66 typedef unsigned long gulong;
67 typedef void * gpointer;
68 typedef const void * gconstpointer;
70 typedef unsigned char guchar;
73 /* VS 2010 and later have stdint.h */
74 #if defined(_MSC_VER) && _MSC_VER < 1600
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;
84 typedef double gdouble;
87 /* Types defined in terms of the stdint.h */
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;
97 typedef double gdouble;
98 typedef int32_t gboolean;
102 typedef guint16 gunichar2;
103 typedef guint32 gunichar;
108 #define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
113 #define G_MAXINT INT_MAX
114 #define G_MININT INT_MIN
115 #define G_MAXINT32 INT32_MAX
116 #define G_MININT32 INT32_MIN
117 #define G_MININT64 INT64_MIN
118 #define G_MAXINT64 INT64_MAX
119 #define G_MAXUINT64 UINT64_MAX
121 #define G_LITTLE_ENDIAN 1234
122 #define G_BIG_ENDIAN 4321
123 #define G_STMT_START do
124 #define G_STMT_END while (0)
126 #define G_USEC_PER_SEC 1000000
128 #define ABS(a) ((a) > 0 ? (a) : -(a))
130 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
132 #define EGLIB_STRINGIFY(x) #x
133 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
134 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
136 #define G_CONST_RETURN const
141 void g_free (void *ptr);
142 gpointer g_realloc (gpointer obj, gsize size);
143 gpointer g_malloc (gsize x);
144 gpointer g_malloc0 (gsize x);
145 gpointer g_try_malloc (gsize x);
146 gpointer g_try_realloc (gpointer obj, gsize size);
148 #define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
149 #define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
150 #define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
152 #define g_memmove(dest,src,len) memmove (dest, src, len)
153 #define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
154 #define g_alloca(size) alloca (size)
156 gpointer g_memdup (gconstpointer mem, guint byte_size);
157 static inline gchar *g_strdup (const gchar *str) { if (str) {return strdup (str);} return NULL; }
158 gchar **g_strdupv (gchar **str_array);
161 gpointer (*malloc) (gsize n_bytes);
162 gpointer (*realloc) (gpointer mem, gsize n_bytes);
163 void (*free) (gpointer mem);
164 gpointer (*calloc) (gsize n_blocks, gsize n_block_bytes);
165 gpointer (*try_malloc) (gsize n_bytes);
166 gpointer (*try_realloc) (gpointer mem, gsize n_bytes);
169 #define g_mem_set_vtable(x)
175 typedef struct _GMemChunk GMemChunk;
179 #define g_atexit(func) ((void) atexit (func))
181 const gchar * g_getenv(const gchar *variable);
182 gboolean g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
183 void g_unsetenv(const gchar *variable);
185 gchar* g_win32_getlocale(void);
188 * Precondition macros
190 #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
191 #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
196 typedef struct _GHashTable GHashTable;
197 typedef struct _GHashTableIter GHashTableIter;
199 /* Private, but needed for stack allocation */
200 struct _GHashTableIter
205 typedef void (*GFunc) (gpointer data, gpointer user_data);
206 typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
207 typedef gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
208 typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
209 typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
210 typedef void (*GDestroyNotify) (gpointer data);
211 typedef guint (*GHashFunc) (gconstpointer key);
212 typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
213 typedef void (*GFreeFunc) (gpointer data);
215 GHashTable *g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func);
216 GHashTable *g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
217 GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
218 void g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
219 guint g_hash_table_size (GHashTable *hash);
220 gpointer g_hash_table_lookup (GHashTable *hash, gconstpointer key);
221 gboolean g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
222 void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data);
223 gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data);
224 gboolean g_hash_table_remove (GHashTable *hash, gconstpointer key);
225 gboolean g_hash_table_steal (GHashTable *hash, gconstpointer key);
226 void g_hash_table_remove_all (GHashTable *hash);
227 guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data);
228 guint g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data);
229 void g_hash_table_destroy (GHashTable *hash);
230 void g_hash_table_print_stats (GHashTable *table);
232 void g_hash_table_iter_init (GHashTableIter *iter, GHashTable *hash_table);
233 gboolean g_hash_table_iter_next (GHashTableIter *iter, gpointer *key, gpointer *value);
235 guint g_spaced_primes_closest (guint x);
237 #define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
238 #define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
240 gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
241 guint g_direct_hash (gconstpointer v1);
242 gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
243 guint g_int_hash (gconstpointer v1);
244 gboolean g_str_equal (gconstpointer v1, gconstpointer v2);
245 guint g_str_hash (gconstpointer v1);
251 /* In the real glib, this is a GQuark, but we dont use/need that */
257 void g_clear_error (GError **error);
258 void g_error_free (GError *error);
259 GError *g_error_new (gpointer domain, gint code, const char *format, ...);
260 void g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...);
261 void g_propagate_error (GError **dest, GError *src);
266 gchar *g_strdup_printf (const gchar *format, ...);
267 gchar *g_strdup_vprintf (const gchar *format, va_list args);
268 gchar *g_strndup (const gchar *str, gsize n);
269 const gchar *g_strerror (gint errnum);
270 gchar *g_strndup (const gchar *str, gsize n);
271 void g_strfreev (gchar **str_array);
272 gchar *g_strconcat (const gchar *first, ...);
273 gchar **g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
274 gchar **g_strsplit_set (const gchar *string, const gchar *delimiter, gint max_tokens);
275 gchar *g_strreverse (gchar *str);
276 gboolean g_str_has_prefix (const gchar *str, const gchar *prefix);
277 gboolean g_str_has_suffix (const gchar *str, const gchar *suffix);
278 guint g_strv_length (gchar **str_array);
279 gchar *g_strjoin (const gchar *separator, ...);
280 gchar *g_strjoinv (const gchar *separator, gchar **str_array);
281 gchar *g_strchug (gchar *str);
282 gchar *g_strchomp (gchar *str);
283 void g_strdown (gchar *string);
284 gchar *g_strnfill (gsize length, gchar fill_char);
286 gchar *g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);
287 gchar *g_strescape (const gchar *source, const gchar *exceptions);
289 gchar *g_filename_to_uri (const gchar *filename, const gchar *hostname, GError **error);
290 gchar *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
292 gint g_printf (gchar const *format, ...);
293 gint g_fprintf (FILE *file, gchar const *format, ...);
294 gint g_sprintf (gchar *string, gchar const *format, ...);
295 gint g_snprintf (gchar *string, gulong n, gchar const *format, ...);
296 #define g_vprintf vprintf
297 #define g_vfprintf vfprintf
298 #define g_vsprintf vsprintf
299 #define g_vsnprintf vsnprintf
300 #define g_vasprintf vasprintf
302 gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size);
304 gchar g_ascii_tolower (gchar c);
305 gchar *g_ascii_strdown (const gchar *str, gssize len);
306 gint g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n);
307 gint g_ascii_xdigit_value (gchar c);
308 #define g_ascii_isspace(c) (isspace (c) != 0)
309 #define g_ascii_isalpha(c) (isalpha (c) != 0)
310 #define g_ascii_isprint(c) (isprint (c) != 0)
311 #define g_ascii_isxdigit(c) (isxdigit (c) != 0)
313 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
315 #define g_strcasecmp stricmp
316 #define g_ascii_strcasecmp stricmp
317 #define g_strncasecmp strnicmp
318 #define g_strstrip(a) g_strchug (g_strchomp (a))
320 #define g_strcasecmp strcasecmp
321 #define g_ascii_strcasecmp strcasecmp
322 #define g_ascii_strtoull strtoull
323 #define g_strncasecmp strncasecmp
324 #define g_strstrip(a) g_strchug (g_strchomp (a))
328 #define G_STR_DELIMITERS "_-|> <."
339 GString *g_string_new (const gchar *init);
340 GString *g_string_new_len (const gchar *init, gssize len);
341 GString *g_string_sized_new (gsize default_size);
342 gchar *g_string_free (GString *string, gboolean free_segment);
343 GString *g_string_append (GString *string, const gchar *val);
344 void g_string_printf (GString *string, const gchar *format, ...);
345 void g_string_append_printf (GString *string, const gchar *format, ...);
346 void g_string_append_vprintf (GString *string, const gchar *format, va_list args);
347 GString *g_string_append_unichar (GString *string, gunichar c);
348 GString *g_string_append_c (GString *string, gchar c);
349 GString *g_string_append (GString *string, const gchar *val);
350 GString *g_string_append_len (GString *string, const gchar *val, gssize len);
351 GString *g_string_truncate (GString *string, gsize len);
352 GString *g_string_prepend (GString *string, const gchar *val);
354 #define g_string_sprintfa g_string_append_printf
359 typedef struct _GSList GSList;
365 GSList *g_slist_alloc (void);
366 GSList *g_slist_append (GSList *list,
368 GSList *g_slist_prepend (GSList *list,
370 void g_slist_free (GSList *list);
371 void g_slist_free_1 (GSList *list);
372 GSList *g_slist_copy (GSList *list);
373 GSList *g_slist_concat (GSList *list1,
375 void g_slist_foreach (GSList *list,
378 GSList *g_slist_last (GSList *list);
379 GSList *g_slist_find (GSList *list,
381 GSList *g_slist_find_custom (GSList *list,
384 GSList *g_slist_remove (GSList *list,
386 GSList *g_slist_remove_all (GSList *list,
388 GSList *g_slist_reverse (GSList *list);
389 guint g_slist_length (GSList *list);
390 GSList *g_slist_remove_link (GSList *list,
392 GSList *g_slist_delete_link (GSList *list,
394 GSList *g_slist_insert_sorted (GSList *list,
397 GSList *g_slist_insert_before (GSList *list,
400 GSList *g_slist_sort (GSList *list,
402 gint g_slist_index (GSList *list,
404 GSList *g_slist_nth (GSList *list,
406 gpointer g_slist_nth_data (GSList *list,
409 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
412 typedef struct _GList GList;
419 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
420 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
422 GList *g_list_alloc (void);
423 GList *g_list_append (GList *list,
425 GList *g_list_prepend (GList *list,
427 void g_list_free (GList *list);
428 void g_list_free_1 (GList *list);
429 GList *g_list_copy (GList *list);
430 guint g_list_length (GList *list);
431 gint g_list_index (GList *list,
433 GList *g_list_nth (GList *list,
435 gpointer g_list_nth_data (GList *list,
437 GList *g_list_last (GList *list);
438 GList *g_list_concat (GList *list1,
440 void g_list_foreach (GList *list,
443 GList *g_list_first (GList *list);
444 GList *g_list_find (GList *list,
446 GList *g_list_find_custom (GList *list,
449 GList *g_list_remove (GList *list,
451 GList *g_list_reverse (GList *list);
452 GList *g_list_remove_link (GList *list,
454 GList *g_list_delete_link (GList *list,
456 GList *g_list_insert_sorted (GList *list,
459 GList *g_list_insert_before (GList *list,
462 GList *g_list_sort (GList *sort,
469 typedef struct _GByteArray GByteArray;
475 GByteArray *g_byte_array_new (void);
476 GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
477 guint8* g_byte_array_free (GByteArray *array, gboolean free_segment);
483 typedef struct _GArray GArray;
489 GArray *g_array_new (gboolean zero_terminated, gboolean clear_, guint element_size);
490 gchar* g_array_free (GArray *array, gboolean free_segment);
491 GArray *g_array_append_vals (GArray *array, gconstpointer data, guint len);
492 GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer data, guint len);
493 GArray* g_array_remove_index (GArray *array, guint index_);
494 GArray* g_array_remove_index_fast (GArray *array, guint index_);
496 #define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
497 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
498 #define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
504 void g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data);
510 typedef struct _GPtrArray GPtrArray;
516 GPtrArray *g_ptr_array_new (void);
517 GPtrArray *g_ptr_array_sized_new (guint reserved_size);
518 void g_ptr_array_add (GPtrArray *array, gpointer data);
519 gboolean g_ptr_array_remove (GPtrArray *array, gpointer data);
520 gpointer g_ptr_array_remove_index (GPtrArray *array, guint index);
521 gboolean g_ptr_array_remove_fast (GPtrArray *array, gpointer data);
522 gpointer g_ptr_array_remove_index_fast (GPtrArray *array, guint index);
523 void g_ptr_array_sort (GPtrArray *array, GCompareFunc compare_func);
524 void g_ptr_array_sort_with_data (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
525 void g_ptr_array_set_size (GPtrArray *array, gint length);
526 gpointer *g_ptr_array_free (GPtrArray *array, gboolean free_seg);
527 void g_ptr_array_foreach (GPtrArray *array, GFunc func, gpointer user_data);
528 #define g_ptr_array_index(array,index) (array)->pdata[(index)]
539 gpointer g_queue_pop_head (GQueue *queue);
540 void g_queue_push_head (GQueue *queue,
542 void g_queue_push_tail (GQueue *queue,
544 gboolean g_queue_is_empty (GQueue *queue);
545 GQueue *g_queue_new (void);
546 void g_queue_free (GQueue *queue);
547 void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data);
553 #define G_LOG_DOMAIN ((gchar*) 0)
557 G_LOG_FLAG_RECURSION = 1 << 0,
558 G_LOG_FLAG_FATAL = 1 << 1,
560 G_LOG_LEVEL_ERROR = 1 << 2,
561 G_LOG_LEVEL_CRITICAL = 1 << 3,
562 G_LOG_LEVEL_WARNING = 1 << 4,
563 G_LOG_LEVEL_MESSAGE = 1 << 5,
564 G_LOG_LEVEL_INFO = 1 << 6,
565 G_LOG_LEVEL_DEBUG = 1 << 7,
567 G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
570 void g_print (const gchar *format, ...);
571 void g_printerr (const gchar *format, ...);
572 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
573 GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask);
574 void g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
575 void g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
576 void g_assertion_message (const gchar *format, ...) G_GNUC_NORETURN;
578 #ifdef HAVE_C99_SUPPORT
579 /* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
580 #define g_error(format, ...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
581 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
582 #define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
583 #define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
584 #define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
585 #else /* HAVE_C99_SUPPORT */
586 #define g_error(...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
587 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
588 #define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
589 #define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
590 #define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
591 #endif /* ndef HAVE_C99_SUPPORT */
592 #define g_log_set_handler(a,b,c,d)
594 #define G_GNUC_INTERNAL
600 gpointer g_convert_error_quark(void);
604 * Unicode Manipulation: most of this is not used by Mono by default, it is
605 * only used if the old collation code is activated, so this is only the
606 * bare minimum to build.
612 G_UNICODE_UNASSIGNED,
613 G_UNICODE_PRIVATE_USE,
615 G_UNICODE_LOWERCASE_LETTER,
616 G_UNICODE_MODIFIER_LETTER,
617 G_UNICODE_OTHER_LETTER,
618 G_UNICODE_TITLECASE_LETTER,
619 G_UNICODE_UPPERCASE_LETTER,
620 G_UNICODE_COMBINING_MARK,
621 G_UNICODE_ENCLOSING_MARK,
622 G_UNICODE_NON_SPACING_MARK,
623 G_UNICODE_DECIMAL_NUMBER,
624 G_UNICODE_LETTER_NUMBER,
625 G_UNICODE_OTHER_NUMBER,
626 G_UNICODE_CONNECT_PUNCTUATION,
627 G_UNICODE_DASH_PUNCTUATION,
628 G_UNICODE_CLOSE_PUNCTUATION,
629 G_UNICODE_FINAL_PUNCTUATION,
630 G_UNICODE_INITIAL_PUNCTUATION,
631 G_UNICODE_OTHER_PUNCTUATION,
632 G_UNICODE_OPEN_PUNCTUATION,
633 G_UNICODE_CURRENCY_SYMBOL,
634 G_UNICODE_MODIFIER_SYMBOL,
635 G_UNICODE_MATH_SYMBOL,
636 G_UNICODE_OTHER_SYMBOL,
637 G_UNICODE_LINE_SEPARATOR,
638 G_UNICODE_PARAGRAPH_SEPARATOR,
639 G_UNICODE_SPACE_SEPARATOR
642 gunichar g_unichar_toupper (gunichar c);
643 gunichar g_unichar_tolower (gunichar c);
644 gunichar g_unichar_totitle (gunichar c);
645 GUnicodeType g_unichar_type (gunichar c);
646 gboolean g_unichar_isxdigit (gunichar c);
647 gint g_unichar_xdigit_value (gunichar c);
650 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
654 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
658 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
661 #if defined(__GNUC__) && (__GNUC__ > 2)
662 #define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
663 #define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
665 #define G_LIKELY(x) (x)
666 #define G_UNLIKELY(x) (x)
669 #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
670 #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
676 #define G_CONVERT_ERROR g_convert_error_quark()
679 G_CONVERT_ERROR_NO_CONVERSION,
680 G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
681 G_CONVERT_ERROR_FAILED,
682 G_CONVERT_ERROR_PARTIAL_INPUT,
683 G_CONVERT_ERROR_BAD_URI,
684 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
687 gchar *g_utf8_strup (const gchar *str, gssize len);
688 gchar *g_utf8_strdown (const gchar *str, gssize len);
689 gint g_unichar_to_utf8 (gunichar c, gchar *outbuf);
690 gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **error);
691 gchar *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **error);
692 gunichar *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **error);
693 gchar *g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **error);
694 gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **error);
696 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
699 #define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
701 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
707 gchar *g_build_path (const gchar *separator, const gchar *first_element, ...);
708 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
709 gchar *g_path_get_dirname (const gchar *filename);
710 gchar *g_path_get_basename (const char *filename);
711 gchar *g_find_program_in_path (const gchar *program);
712 gchar *g_get_current_dir (void);
713 gboolean g_path_is_absolute (const char *filename);
715 const gchar *g_get_home_dir (void);
716 const gchar *g_get_tmp_dir (void);
717 const gchar *g_get_user_name (void);
718 gchar *g_get_prgname (void);
719 void g_set_prgname (const gchar *prgname);
725 gboolean g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
726 gchar *g_shell_unquote (const gchar *quoted_string, GError **error);
727 gchar *g_shell_quote (const gchar *unquoted_string);
733 G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
734 G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
735 G_SPAWN_SEARCH_PATH = 1 << 2,
736 G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
737 G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
738 G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
739 G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
742 typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
744 gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
745 gboolean g_spawn_async_with_pipes (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
746 gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
752 typedef struct _GTimer GTimer;
754 GTimer *g_timer_new (void);
755 void g_timer_destroy (GTimer *timer);
756 gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
757 void g_timer_stop (GTimer *timer);
758 void g_timer_start (GTimer *timer);
768 void g_get_current_time (GTimeVal *result);
769 void g_usleep (gulong microseconds);
779 G_FILE_ERROR_NAMETOOLONG,
804 G_FILE_TEST_IS_REGULAR = 1 << 0,
805 G_FILE_TEST_IS_SYMLINK = 1 << 1,
806 G_FILE_TEST_IS_DIR = 1 << 2,
807 G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
808 G_FILE_TEST_EXISTS = 1 << 4
812 gboolean g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
813 GFileError g_file_error_from_errno (gint err_no);
814 gint g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
815 gboolean g_file_test (const gchar *filename, GFileTest test);
818 #define g_rename rename
820 #define g_unlink unlink
825 typedef struct _GPatternSpec GPatternSpec;
826 GPatternSpec * g_pattern_spec_new (const gchar *pattern);
827 void g_pattern_spec_free (GPatternSpec *pspec);
828 gboolean g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
833 typedef struct _GDir GDir;
834 GDir *g_dir_open (const gchar *path, guint flags, GError **error);
835 const gchar *g_dir_read_name (GDir *dir);
836 void g_dir_rewind (GDir *dir);
837 void g_dir_close (GDir *dir);
839 int g_mkdir_with_parents (const gchar *pathname, int mode);
840 #define g_mkdir mkdir
845 typedef struct _GMarkupParseContext GMarkupParseContext;
849 G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
850 G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1
854 void (*start_element) (GMarkupParseContext *context,
855 const gchar *element_name,
856 const gchar **attribute_names,
857 const gchar **attribute_values,
861 void (*end_element) (GMarkupParseContext *context,
862 const gchar *element_name,
866 void (*text) (GMarkupParseContext *context,
872 void (*passthrough) (GMarkupParseContext *context,
873 const gchar *passthrough_text,
877 void (*error) (GMarkupParseContext *context,
882 GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
883 GMarkupParseFlags flags,
885 GDestroyNotify user_data_dnotify);
886 void g_markup_parse_context_free (GMarkupParseContext *context);
887 gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
888 const gchar *text, gssize text_len,
890 gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
894 * Character set conversion
897 * Index into the table below with the first byte of a UTF-8 sequence to
898 * get the number of trailing bytes that are supposed to follow it.
899 * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
900 * left as-is for anyone who may want to do such conversion, which was
901 * allowed in earlier algorithms.
903 extern const gchar g_trailingBytesForUTF8[256];
905 gboolean g_get_charset (G_CONST_RETURN char **charset);
906 gchar *g_locale_to_utf8 (const gchar *opsysstring, gssize len,
907 gsize *bytes_read, gsize *bytes_written,
909 gchar *g_locale_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
910 gsize *bytes_written, GError **error);
911 gchar *g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
912 gsize *bytes_written, GError **error);
913 gchar *g_convert (const gchar *str, gssize len,
914 const gchar *to_codeset, const gchar *from_codeset,
915 gsize *bytes_read, gsize *bytes_written, GError **error);
916 gboolean g_utf8_validate (const gchar *str, gssize max_len, const gchar **end);
917 gunichar g_utf8_get_char (const gchar *src);
918 glong g_utf8_strlen (const gchar *str, gssize max);
919 #define g_utf8_next_char(p) p + (g_trailingBytesForUTF8[(guchar)(*p)] + 1)
922 * Empty thread functions, not used by eglib
924 #define g_thread_supported() TRUE
925 #define g_thread_init(x) G_STMT_START { if (x != NULL) { g_error ("No vtable supported in g_thread_init"); } } G_STMT_END
927 #define G_LOCK_DEFINE(name) int name;
928 #define G_LOCK_DEFINE_STATIC(name) static int name;
929 #define G_LOCK_EXTERN(name)
931 #define G_TRYLOCK(name)
932 #define G_UNLOCK(name)
934 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
936 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
937 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
938 ( (((guint32) (x)) << 24)| \
939 ((((guint32) (x)) & 0xff0000) >> 8) | \
940 ((((guint32) (x)) & 0xff00) << 8) | \
941 (((guint32) (x)) >> 24)) )
943 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
944 GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
948 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
949 # define GUINT32_TO_LE(x) (x)
950 # define GUINT64_TO_LE(x) (x)
951 # define GUINT16_TO_LE(x) (x)
952 # define GUINT_TO_LE(x) (x)
953 # define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
954 # define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
955 # define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
956 # define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
957 # define GINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
958 # define GINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
959 # define GINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
961 # define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
962 # define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
963 # define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
964 # define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
965 # define GUINT32_TO_BE(x) (x)
966 # define GUINT16_FROM_BE(x) (x)
967 # define GUINT32_FROM_BE(x) (x)
968 # define GUINT64_FROM_BE(x) (x)
969 # define GINT16_FROM_BE(x) (x)
970 # define GINT32_FROM_BE(x) (x)
971 # define GINT64_FROM_BE(x) (x)
974 #define GINT64_FROM_LE(x) (GUINT64_TO_LE (x))
975 #define GINT32_FROM_LE(x) (GUINT32_TO_LE (x))
976 #define GINT16_FROM_LE(x) (GUINT16_TO_LE (x))
978 #define GUINT32_FROM_LE(x) (GUINT32_TO_LE (x))
979 #define GUINT64_FROM_LE(x) (GUINT64_TO_LE (x))
980 #define GUINT16_FROM_LE(x) (GUINT16_TO_LE (x))
981 #define GUINT_FROM_LE(x) (GUINT_TO_LE (x))
983 #define _EGLIB_MAJOR 2
984 #define _EGLIB_MIDDLE 4
985 #define _EGLIB_MINOR 0
987 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))