13 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
18 #include <eglib-config.h>
19 #ifndef EGLIB_NO_REMAP
20 #include <eglib-remap.h>
24 # define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
30 #define G_BEGIN_DECLS extern "C" {
44 typedef unsigned int guint
;
46 typedef unsigned short gushort
;
48 typedef unsigned long gulong
;
49 typedef void * gpointer
;
50 typedef const void * gconstpointer
;
52 typedef unsigned char guchar
;
57 typedef unsigned __int8 guint8
;
58 typedef __int16 gint16
;
59 typedef unsigned __int16 guint16
;
60 typedef __int32 gint32
;
61 typedef unsigned __int32 guint32
;
62 typedef __int64 gint64
;
63 typedef unsigned __int64 guint64
;
65 typedef double gdouble
;
66 typedef unsigned __int16 gunichar2
;
68 /* Types defined in terms of the stdint.h */
70 typedef uint8_t guint8
;
71 typedef int16_t gint16
;
72 typedef uint16_t guint16
;
73 typedef int32_t gint32
;
74 typedef uint32_t guint32
;
75 typedef int64_t gint64
;
76 typedef uint64_t guint64
;
78 typedef double gdouble
;
79 typedef uint16_t gunichar2
;
87 #define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
92 #define G_MAXINT INT_MAX
93 #define G_MININT INT_MIN
94 #define G_MAXINT32 INT32_MAX
95 #define G_MININT32 INT32_MIN
96 #define G_MININT64 INT64_MIN
97 #define G_MAXINT64 INT64_MAX
99 #define G_LITTLE_ENDIAN 1234
100 #define G_BIG_ENDIAN 4321
101 #define G_STMT_START do
102 #define G_STMT_END while (0)
104 #define G_USEC_PER_SEC 1000000
106 #define ABS(a) ((a) > 0 ? (a) : -(a))
108 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
110 #define EGLIB_STRINGIFY(x) #x
111 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
112 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
114 #define G_CONST_RETURN const
119 void g_free (void *ptr
);
120 static inline gpointer
g_realloc (gpointer obj
, gsize size
) { if (!size
) {g_free (obj
); return 0;} return realloc (obj
, size
);}
121 static inline gpointer
g_malloc (gsize x
) {if (x
) return malloc (x
); else return 0;}
122 static inline gpointer
g_malloc0 (gsize x
) {if (x
) return calloc(1,x
); else return 0;}
123 #define g_try_malloc(x) g_malloc(x)
124 #define g_try_realloc(obj,size) g_realloc((obj),(size))
126 #define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
127 #define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
128 #define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
130 #define g_memmove(dest,src,len) memmove (dest, src, len)
131 #define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
132 #define g_alloca(size) alloca (size)
134 gpointer
g_memdup (gconstpointer mem
, guint byte_size
);
135 static inline gchar
*g_strdup (const gchar
*str
) { if (str
) {return strdup (str
);} return NULL
; }
138 gpointer (*malloc
) (gsize n_bytes
);
139 gpointer (*realloc
) (gpointer mem
, gsize n_bytes
);
140 void (*free
) (gpointer mem
);
141 gpointer (*calloc
) (gsize n_blocks
, gsize n_block_bytes
);
142 gpointer (*try_malloc
) (gsize n_bytes
);
143 gpointer (*try_realloc
) (gpointer mem
, gsize n_bytes
);
146 #define g_mem_set_vtable(x)
152 typedef struct _GMemChunk GMemChunk
;
156 #define g_atexit(func) ((void) atexit (func))
158 const gchar
* g_getenv(const gchar
*variable
);
159 gboolean
g_setenv(const gchar
*variable
, const gchar
*value
, gboolean overwrite
);
160 void g_unsetenv(const gchar
*variable
);
162 gchar
* g_win32_getlocale(void);
165 * Precondition macros
167 #define g_return_if_fail(x) G_STMT_START { if (!(x)) { printf ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
168 #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
173 typedef struct _GHashTable GHashTable
;
174 typedef void (*GFunc
) (gpointer data
, gpointer user_data
);
175 typedef gint (*GCompareFunc
) (gconstpointer a
, gconstpointer b
);
176 typedef gint (*GCompareDataFunc
) (gconstpointer a
, gconstpointer b
, gpointer user_data
);
177 typedef void (*GHFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
178 typedef gboolean (*GHRFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
179 typedef void (*GDestroyNotify
) (gpointer data
);
180 typedef guint (*GHashFunc
) (gconstpointer key
);
181 typedef gboolean (*GEqualFunc
) (gconstpointer a
, gconstpointer b
);
182 typedef void (*GFreeFunc
) (gpointer data
);
184 GHashTable
*g_hash_table_new (GHashFunc hash_func
, GEqualFunc key_equal_func
);
185 GHashTable
*g_hash_table_new_full (GHashFunc hash_func
, GEqualFunc key_equal_func
,
186 GDestroyNotify key_destroy_func
, GDestroyNotify value_destroy_func
);
187 void g_hash_table_insert_replace (GHashTable
*hash
, gpointer key
, gpointer value
, gboolean replace
);
188 guint
g_hash_table_size (GHashTable
*hash
);
189 gpointer
g_hash_table_lookup (GHashTable
*hash
, gconstpointer key
);
190 gboolean
g_hash_table_lookup_extended (GHashTable
*hash
, gconstpointer key
, gpointer
*orig_key
, gpointer
*value
);
191 void g_hash_table_foreach (GHashTable
*hash
, GHFunc func
, gpointer user_data
);
192 gpointer
g_hash_table_find (GHashTable
*hash
, GHRFunc predicate
, gpointer user_data
);
193 gboolean
g_hash_table_remove (GHashTable
*hash
, gconstpointer key
);
194 guint
g_hash_table_foreach_remove (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
195 guint
g_hash_table_foreach_steal (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
196 void g_hash_table_destroy (GHashTable
*hash
);
198 guint
g_spaced_primes_closest (guint x
);
200 #define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
201 #define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
203 gboolean
g_direct_equal (gconstpointer v1
, gconstpointer v2
);
204 guint
g_direct_hash (gconstpointer v1
);
205 gboolean
g_int_equal (gconstpointer v1
, gconstpointer v2
);
206 guint
g_int_hash (gconstpointer v1
);
207 gboolean
g_str_equal (gconstpointer v1
, gconstpointer v2
);
208 guint
g_str_hash (gconstpointer v1
);
210 #define g_assert(x) G_STMT_START { if (!(x)) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); } G_STMT_END
211 #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
217 /* In the real glib, this is a GQuark, but we dont use/need that */
223 void g_clear_error (GError
**error
);
224 void g_error_free (GError
*error
);
225 GError
*g_error_new (gpointer domain
, gint code
, const char *format
, ...);
226 void g_set_error (GError
**err
, gpointer domain
, gint code
, const gchar
*format
, ...);
227 void g_propagate_error (GError
**dest
, GError
*src
);
232 gchar
*g_strdup_printf (const gchar
*format
, ...);
233 gchar
*g_strdup_vprintf (const gchar
*format
, va_list args
);
234 gchar
*g_strndup (const gchar
*str
, gsize n
);
235 const gchar
*g_strerror (gint errnum
);
236 gchar
*g_strndup (const gchar
*str
, gsize n
);
237 void g_strfreev (gchar
**str_array
);
238 gchar
*g_strconcat (const gchar
*first
, ...);
239 gchar
**g_strsplit (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
240 gchar
**g_strsplit_set (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
241 gchar
*g_strreverse (gchar
*str
);
242 gboolean
g_str_has_prefix (const gchar
*str
, const gchar
*prefix
);
243 gboolean
g_str_has_suffix (const gchar
*str
, const gchar
*suffix
);
244 guint
g_strv_length (gchar
**str_array
);
245 gchar
*g_strjoin (const gchar
*separator
, ...);
246 gchar
*g_strjoinv (const gchar
*separator
, gchar
**str_array
);
247 gchar
*g_strchug (gchar
*str
);
248 gchar
*g_strchomp (gchar
*str
);
249 void g_strdown (gchar
*string
);
250 gchar
*g_strnfill (gsize length
, gchar fill_char
);
252 gchar
*g_strdelimit (gchar
*string
, const gchar
*delimiters
, gchar new_delimiter
);
253 gchar
*g_strescape (const gchar
*source
, const gchar
*exceptions
);
255 gchar
*g_filename_to_uri (const gchar
*filename
, const gchar
*hostname
, GError
**error
);
256 gchar
*g_filename_from_uri (const gchar
*uri
, gchar
**hostname
, GError
**error
);
258 gint
g_printf (gchar
const *format
, ...);
259 gint
g_fprintf (FILE *file
, gchar
const *format
, ...);
260 gint
g_sprintf (gchar
*string
, gchar
const *format
, ...);
261 gint
g_snprintf (gchar
*string
, gulong n
, gchar
const *format
, ...);
262 #define g_vprintf vprintf
263 #define g_vfprintf vfprintf
264 #define g_vsprintf vsprintf
265 #define g_vsnprintf vsnprintf
266 #define g_vasprintf vasprintf
268 gsize
g_strlcpy (gchar
*dest
, const gchar
*src
, gsize dest_size
);
270 gchar
g_ascii_tolower (gchar c
);
271 gchar
*g_ascii_strdown (const gchar
*str
, gssize len
);
272 gint
g_ascii_strncasecmp (const gchar
*s1
, const gchar
*s2
, gsize n
);
273 gint
g_ascii_xdigit_value (gchar c
);
274 #define g_ascii_isspace(c) (isspace (c) != 0)
275 #define g_ascii_isalpha(c) (isalpha (c) != 0)
276 #define g_ascii_isprint(c) (isprint (c) != 0)
277 #define g_ascii_isxdigit(c) (isxdigit (c) != 0)
279 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
281 #define g_strcasecmp stricmp
282 #define g_ascii_strcasecmp stricmp
283 #define g_strncasecmp strnicmp
284 #define g_strstrip(a) g_strchug (g_strchomp (a))
286 #define g_strcasecmp strcasecmp
287 #define g_ascii_strcasecmp strcasecmp
288 #define g_strncasecmp strncasecmp
289 #define g_strstrip(a) g_strchug (g_strchomp (a))
293 #define G_STR_DELIMITERS "_-|> <."
304 GString
*g_string_new (const gchar
*init
);
305 GString
*g_string_new_len (const gchar
*init
, gssize len
);
306 GString
*g_string_sized_new (gsize default_size
);
307 gchar
*g_string_free (GString
*string
, gboolean free_segment
);
308 GString
*g_string_append (GString
*string
, const gchar
*val
);
309 void g_string_printf (GString
*string
, const gchar
*format
, ...);
310 void g_string_append_printf (GString
*string
, const gchar
*format
, ...);
311 GString
*g_string_append_c (GString
*string
, gchar c
);
312 GString
*g_string_append (GString
*string
, const gchar
*val
);
313 GString
*g_string_append_len (GString
*string
, const gchar
*val
, gssize len
);
314 GString
*g_string_truncate (GString
*string
, gsize len
);
315 GString
*g_string_prepend (GString
*string
, const gchar
*val
);
317 #define g_string_sprintfa g_string_append_printf
322 typedef struct _GSList GSList
;
328 GSList
*g_slist_alloc (void);
329 GSList
*g_slist_append (GSList
*list
,
331 GSList
*g_slist_prepend (GSList
*list
,
333 void g_slist_free (GSList
*list
);
334 void g_slist_free_1 (GSList
*list
);
335 GSList
*g_slist_copy (GSList
*list
);
336 GSList
*g_slist_concat (GSList
*list1
,
338 void g_slist_foreach (GSList
*list
,
341 GSList
*g_slist_last (GSList
*list
);
342 GSList
*g_slist_find (GSList
*list
,
344 GSList
*g_slist_find_custom (GSList
*list
,
347 GSList
*g_slist_remove (GSList
*list
,
349 GSList
*g_slist_remove_all (GSList
*list
,
351 GSList
*g_slist_reverse (GSList
*list
);
352 guint
g_slist_length (GSList
*list
);
353 GSList
*g_slist_remove_link (GSList
*list
,
355 GSList
*g_slist_delete_link (GSList
*list
,
357 GSList
*g_slist_insert_sorted (GSList
*list
,
360 GSList
*g_slist_insert_before (GSList
*list
,
363 GSList
*g_slist_sort (GSList
*list
,
365 gint
g_slist_index (GSList
*list
,
367 GSList
*g_slist_nth (GSList
*list
,
369 gpointer
g_slist_nth_data (GSList
*list
,
372 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
375 typedef struct _GList GList
;
382 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
383 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
385 GList
*g_list_alloc (void);
386 GList
*g_list_append (GList
*list
,
388 GList
*g_list_prepend (GList
*list
,
390 void g_list_free (GList
*list
);
391 void g_list_free_1 (GList
*list
);
392 GList
*g_list_copy (GList
*list
);
393 guint
g_list_length (GList
*list
);
394 gint
g_list_index (GList
*list
,
396 GList
*g_list_nth (GList
*list
,
398 gpointer
g_list_nth_data (GList
*list
,
400 GList
*g_list_last (GList
*list
);
401 GList
*g_list_concat (GList
*list1
,
403 void g_list_foreach (GList
*list
,
406 GList
*g_list_first (GList
*list
);
407 GList
*g_list_find (GList
*list
,
409 GList
*g_list_find_custom (GList
*list
,
412 GList
*g_list_remove (GList
*list
,
414 GList
*g_list_reverse (GList
*list
);
415 GList
*g_list_remove_link (GList
*list
,
417 GList
*g_list_delete_link (GList
*list
,
419 GList
*g_list_insert_sorted (GList
*list
,
422 GList
*g_list_insert_before (GList
*list
,
425 GList
*g_list_sort (GList
*sort
,
432 typedef struct _GArray GArray
;
438 GArray
*g_array_new (gboolean zero_terminated
, gboolean clear_
, guint element_size
);
439 gchar
* g_array_free (GArray
*array
, gboolean free_segment
);
440 GArray
*g_array_append_vals (GArray
*array
, gconstpointer data
, guint len
);
441 GArray
* g_array_insert_vals (GArray
*array
, guint index_
, gconstpointer data
, guint len
);
442 GArray
* g_array_remove_index (GArray
*array
, guint index_
);
443 GArray
* g_array_remove_index_fast (GArray
*array
, guint index_
);
445 #define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
446 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
447 #define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
453 typedef struct _GPtrArray GPtrArray
;
459 GPtrArray
*g_ptr_array_new (void);
460 GPtrArray
*g_ptr_array_sized_new (guint reserved_size
);
461 void g_ptr_array_add (GPtrArray
*array
, gpointer data
);
462 gboolean
g_ptr_array_remove (GPtrArray
*array
, gpointer data
);
463 gpointer
g_ptr_array_remove_index (GPtrArray
*array
, guint index
);
464 gboolean
g_ptr_array_remove_fast (GPtrArray
*array
, gpointer data
);
465 gpointer
g_ptr_array_remove_index_fast (GPtrArray
*array
, guint index
);
466 void g_ptr_array_sort (GPtrArray
*array
, GCompareFunc compare_func
);
467 void g_ptr_array_sort_with_data (GPtrArray
*array
, GCompareDataFunc compare_func
, gpointer user_data
);
468 void g_ptr_array_set_size (GPtrArray
*array
, gint length
);
469 gpointer
*g_ptr_array_free (GPtrArray
*array
, gboolean free_seg
);
470 void g_ptr_array_foreach (GPtrArray
*array
, GFunc func
, gpointer user_data
);
471 #define g_ptr_array_index(array,index) (array)->pdata[(index)]
482 gpointer
g_queue_pop_head (GQueue
*queue
);
483 void g_queue_push_head (GQueue
*queue
,
485 void g_queue_push_tail (GQueue
*queue
,
487 gboolean
g_queue_is_empty (GQueue
*queue
);
488 GQueue
*g_queue_new (void);
489 void g_queue_free (GQueue
*queue
);
495 #define G_LOG_DOMAIN ((gchar*) 0)
499 G_LOG_FLAG_RECURSION
= 1 << 0,
500 G_LOG_FLAG_FATAL
= 1 << 1,
502 G_LOG_LEVEL_ERROR
= 1 << 2,
503 G_LOG_LEVEL_CRITICAL
= 1 << 3,
504 G_LOG_LEVEL_WARNING
= 1 << 4,
505 G_LOG_LEVEL_MESSAGE
= 1 << 5,
506 G_LOG_LEVEL_INFO
= 1 << 6,
507 G_LOG_LEVEL_DEBUG
= 1 << 7,
509 G_LOG_LEVEL_MASK
= ~(G_LOG_FLAG_RECURSION
| G_LOG_FLAG_FATAL
)
512 void g_print (const gchar
*format
, ...);
513 GLogLevelFlags
g_log_set_always_fatal (GLogLevelFlags fatal_mask
);
514 GLogLevelFlags
g_log_set_fatal_mask (const gchar
*log_domain
, GLogLevelFlags fatal_mask
);
515 void g_logv (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, va_list args
);
516 void g_log (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, ...);
517 void g_assertion_message (const gchar
*format
, ...) G_GNUC_NORETURN
;
519 #ifdef HAVE_C99_SUPPORT
520 #define g_error(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__)
521 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
522 #define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
523 #define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
524 #define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
526 #define g_printerr(format, ...) fprintf (stderr, format, __VA_ARGS__)
528 #define g_error(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__)
529 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
530 #define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
531 #define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
532 #define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
534 #define g_printerr(...) fprintf (stderr, __VA_ARGS__)
536 #define g_log_set_handler(a,b,c,d)
542 gpointer
g_convert_error_quark(void);
546 * Unicode Manipulation: most of this is not used by Mono by default, it is
547 * only used if the old collation code is activated, so this is only the
548 * bare minimum to build.
550 typedef guint32 gunichar
;
555 G_UNICODE_UNASSIGNED
,
556 G_UNICODE_PRIVATE_USE
,
558 G_UNICODE_LOWERCASE_LETTER
,
559 G_UNICODE_MODIFIER_LETTER
,
560 G_UNICODE_OTHER_LETTER
,
561 G_UNICODE_TITLECASE_LETTER
,
562 G_UNICODE_UPPERCASE_LETTER
,
563 G_UNICODE_COMBINING_MARK
,
564 G_UNICODE_ENCLOSING_MARK
,
565 G_UNICODE_NON_SPACING_MARK
,
566 G_UNICODE_DECIMAL_NUMBER
,
567 G_UNICODE_LETTER_NUMBER
,
568 G_UNICODE_OTHER_NUMBER
,
569 G_UNICODE_CONNECT_PUNCTUATION
,
570 G_UNICODE_DASH_PUNCTUATION
,
571 G_UNICODE_CLOSE_PUNCTUATION
,
572 G_UNICODE_FINAL_PUNCTUATION
,
573 G_UNICODE_INITIAL_PUNCTUATION
,
574 G_UNICODE_OTHER_PUNCTUATION
,
575 G_UNICODE_OPEN_PUNCTUATION
,
576 G_UNICODE_CURRENCY_SYMBOL
,
577 G_UNICODE_MODIFIER_SYMBOL
,
578 G_UNICODE_MATH_SYMBOL
,
579 G_UNICODE_OTHER_SYMBOL
,
580 G_UNICODE_LINE_SEPARATOR
,
581 G_UNICODE_PARAGRAPH_SEPARATOR
,
582 G_UNICODE_SPACE_SEPARATOR
585 gunichar
g_unichar_toupper (gunichar c
);
586 gunichar
g_unichar_tolower (gunichar c
);
587 gunichar
g_unichar_totitle (gunichar c
);
588 GUnicodeType
g_unichar_type (gunichar c
);
589 gboolean
g_unichar_isxdigit (gunichar c
);
590 gint
g_unichar_xdigit_value (gunichar c
);
593 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
597 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
601 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
604 /* FIXME: Implement these two for gcc */
605 #define G_LIKELY(x) (x)
606 #define G_UNLIKELY(x) (x)
612 #define G_CONVERT_ERROR g_convert_error_quark()
615 G_CONVERT_ERROR_NO_CONVERSION
,
616 G_CONVERT_ERROR_ILLEGAL_SEQUENCE
,
617 G_CONVERT_ERROR_FAILED
,
618 G_CONVERT_ERROR_PARTIAL_INPUT
,
619 G_CONVERT_ERROR_BAD_URI
,
620 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
623 gchar
* g_utf8_strup (const gchar
*str
, gssize len
);
624 gchar
* g_utf8_strdown (const gchar
*str
, gssize len
);
625 gunichar2
*g_utf8_to_utf16 (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
626 gchar
*g_utf16_to_utf8 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
627 gunichar2
*g_ucs4_to_utf16 (const gunichar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
628 gunichar
*g_utf16_to_ucs4 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
630 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
633 #define u16to8(str) g_utf16_to_utf8(str, (glong)wcslen(str), NULL, NULL, NULL)
635 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
641 gchar
*g_build_path (const gchar
*separator
, const gchar
*first_element
, ...);
642 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
643 gchar
*g_path_get_dirname (const gchar
*filename
);
644 gchar
*g_path_get_basename (const char *filename
);
645 gchar
*g_find_program_in_path (const gchar
*program
);
646 gchar
*g_get_current_dir (void);
647 gboolean
g_path_is_absolute (const char *filename
);
649 const gchar
*g_get_home_dir (void);
650 const gchar
*g_get_tmp_dir (void);
651 const gchar
*g_get_user_name (void);
652 gchar
*g_get_prgname (void);
653 void g_set_prgname (const gchar
*prgname
);
659 gboolean
g_shell_parse_argv (const gchar
*command_line
, gint
*argcp
, gchar
***argvp
, GError
**error
);
660 gchar
*g_shell_unquote (const gchar
*quoted_string
, GError
**error
);
661 gchar
*g_shell_quote (const gchar
*unquoted_string
);
667 G_SPAWN_LEAVE_DESCRIPTORS_OPEN
= 1,
668 G_SPAWN_DO_NOT_REAP_CHILD
= 1 << 1,
669 G_SPAWN_SEARCH_PATH
= 1 << 2,
670 G_SPAWN_STDOUT_TO_DEV_NULL
= 1 << 3,
671 G_SPAWN_STDERR_TO_DEV_NULL
= 1 << 4,
672 G_SPAWN_CHILD_INHERITS_STDIN
= 1 << 5,
673 G_SPAWN_FILE_AND_ARGV_ZERO
= 1 << 6
678 typedef void (*GSpawnChildSetupFunc
) (gpointer user_data
);
680 gboolean
g_spawn_command_line_sync (const gchar
*command_line
, gchar
**standard_output
, gchar
**standard_error
, gint
*exit_status
, GError
**error
);
681 gboolean
g_spawn_async_with_pipes (const gchar
*working_directory
, gchar
**argv
, gchar
**envp
, GSpawnFlags flags
, GSpawnChildSetupFunc child_setup
,
682 gpointer user_data
, GPid
*child_pid
, gint
*standard_input
, gint
*standard_output
, gint
*standard_error
, GError
**error
);
688 typedef struct _GTimer GTimer
;
690 GTimer
*g_timer_new (void);
691 void g_timer_destroy (GTimer
*timer
);
692 gdouble
g_timer_elapsed (GTimer
*timer
, gulong
*microseconds
);
693 void g_timer_stop (GTimer
*timer
);
694 void g_timer_start (GTimer
*timer
);
704 void g_get_current_time (GTimeVal
*result
);
705 void g_usleep (gulong microseconds
);
715 G_FILE_ERROR_NAMETOOLONG
,
740 G_FILE_TEST_IS_REGULAR
= 1 << 0,
741 G_FILE_TEST_IS_SYMLINK
= 1 << 1,
742 G_FILE_TEST_IS_DIR
= 1 << 2,
743 G_FILE_TEST_IS_EXECUTABLE
= 1 << 3,
744 G_FILE_TEST_EXISTS
= 1 << 4
748 gboolean
g_file_get_contents (const gchar
*filename
, gchar
**contents
, gsize
*length
, GError
**error
);
749 GFileError
g_file_error_from_errno (gint err_no
);
750 gint
g_file_open_tmp (const gchar
*tmpl
, gchar
**name_used
, GError
**error
);
751 gboolean
g_file_test (const gchar
*filename
, GFileTest test
);
756 typedef struct _GPatternSpec GPatternSpec
;
757 GPatternSpec
* g_pattern_spec_new (const gchar
*pattern
);
758 void g_pattern_spec_free (GPatternSpec
*pspec
);
759 gboolean
g_pattern_match_string (GPatternSpec
*pspec
, const gchar
*string
);
764 typedef struct _GDir GDir
;
765 GDir
*g_dir_open (const gchar
*path
, guint flags
, GError
**error
);
766 const gchar
*g_dir_read_name (GDir
*dir
);
767 void g_dir_rewind (GDir
*dir
);
768 void g_dir_close (GDir
*dir
);
773 typedef struct _GMarkupParseContext GMarkupParseContext
;
777 G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG
= 1 << 0,
778 G_MARKUP_TREAT_CDATA_AS_TEXT
= 1 << 1
782 void (*start_element
) (GMarkupParseContext
*context
,
783 const gchar
*element_name
,
784 const gchar
**attribute_names
,
785 const gchar
**attribute_values
,
789 void (*end_element
) (GMarkupParseContext
*context
,
790 const gchar
*element_name
,
794 void (*text
) (GMarkupParseContext
*context
,
800 void (*passthrough
) (GMarkupParseContext
*context
,
801 const gchar
*passthrough_text
,
805 void (*error
) (GMarkupParseContext
*context
,
810 GMarkupParseContext
*g_markup_parse_context_new (const GMarkupParser
*parser
,
811 GMarkupParseFlags flags
,
813 GDestroyNotify user_data_dnotify
);
814 void g_markup_parse_context_free (GMarkupParseContext
*context
);
815 gboolean
g_markup_parse_context_parse (GMarkupParseContext
*context
,
816 const gchar
*text
, gssize text_len
,
818 gboolean
g_markup_parse_context_end_parse (GMarkupParseContext
*context
,
822 * Character set conversion
825 * Index into the table below with the first byte of a UTF-8 sequence to
826 * get the number of trailing bytes that are supposed to follow it.
827 * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
828 * left as-is for anyone who may want to do such conversion, which was
829 * allowed in earlier algorithms.
831 extern const gchar g_trailingBytesForUTF8
[256];
833 gboolean
g_get_charset (G_CONST_RETURN
char **charset
);
834 gchar
*g_locale_to_utf8 (const gchar
*opsysstring
, gssize len
,
835 gsize
*bytes_read
, gsize
*bytes_written
,
837 gchar
*g_locale_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
838 gsize
*bytes_written
, GError
**error
);
839 gchar
*g_filename_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
840 gsize
*bytes_written
, GError
**error
);
841 gchar
*g_convert (const gchar
*str
, gssize len
,
842 const gchar
*to_codeset
, const gchar
*from_codeset
,
843 gsize
*bytes_read
, gsize
*bytes_written
, GError
**error
);
844 gboolean
g_utf8_validate (const gchar
*str
, gssize max_len
, const gchar
**end
);
845 gunichar
g_utf8_get_char (const gchar
*src
);
846 glong
g_utf8_strlen (const gchar
*str
, gssize max
);
847 #define g_utf8_next_char(p) p + (g_trailingBytesForUTF8[(guchar)(*p)] + 1)
850 * Empty thread functions, not used by eglib
852 #define g_thread_supported() TRUE
853 #define g_thread_init(x) G_STMT_START { if (x != NULL) { g_error ("No vtable supported in g_thread_init"); } } G_STMT_END
855 #define G_LOCK_DEFINE(name) int name;
856 #define G_LOCK_DEFINE_STATIC(name) static int name;
857 #define G_LOCK_EXTERN(name)
859 #define G_TRYLOCK(name)
860 #define G_UNLOCK(name)
862 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
864 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
865 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
866 ( (((guint32) (x)) << 24)| \
867 ((((guint32) (x)) & 0xff0000) >> 8) | \
868 ((((guint32) (x)) & 0xff00) << 8) | \
869 (((guint32) (x)) >> 24)) )
871 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
872 GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
876 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
877 # define GUINT32_TO_LE(x) (x)
878 # define GUINT64_TO_LE(x) (x)
879 # define GUINT16_TO_LE(x) (x)
880 # define GUINT_TO_LE(x) (x)
881 # define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
882 # define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
884 # define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
885 # define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
886 # define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
887 # define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
888 # define GUINT32_TO_BE(x) (x)
889 # define GUINT32_FROM_BE(x) (x)
892 #define GUINT32_FROM_LE(x) (GUINT32_TO_LE (x))
893 #define GUINT64_FROM_LE(x) (GUINT64_TO_LE (x))
894 #define GUINT16_FROM_LE(x) (GUINT16_TO_LE (x))
895 #define GUINT_FROM_LE(x) (GUINT_TO_LE (x))
897 #define _EGLIB_MAJOR 2
898 #define _EGLIB_MIDDLE 4
899 #define _EGLIB_MINOR 0
901 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))