13 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
18 #include <eglib-config.h>
21 # define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
27 #define G_BEGIN_DECLS extern "C" {
41 typedef unsigned int guint
;
43 typedef unsigned short gushort
;
45 typedef unsigned long gulong
;
46 typedef void * gpointer
;
47 typedef const void * gconstpointer
;
49 typedef unsigned char guchar
;
54 typedef unsigned __int8 guint8
;
55 typedef __int16 gint16
;
56 typedef unsigned __int16 guint16
;
57 typedef __int32 gint32
;
58 typedef unsigned __int32 guint32
;
59 typedef __int64 gint64
;
60 typedef unsigned __int64 guint64
;
62 typedef double gdouble
;
63 typedef unsigned __int16 gunichar2
;
65 /* Types defined in terms of the stdint.h */
67 typedef uint8_t guint8
;
68 typedef int16_t gint16
;
69 typedef uint16_t guint16
;
70 typedef int32_t gint32
;
71 typedef uint32_t guint32
;
72 typedef int64_t gint64
;
73 typedef uint64_t guint64
;
75 typedef double gdouble
;
76 typedef uint16_t gunichar2
;
84 #define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
89 #define G_MAXINT INT_MAX
90 #define G_MININT INT_MIN
91 #define G_MAXINT32 INT32_MAX
92 #define G_MININT32 INT32_MIN
93 #define G_MININT64 INT64_MIN
94 #define G_MAXINT64 INT64_MAX
96 #define G_LITTLE_ENDIAN 1234
97 #define G_BIG_ENDIAN 4321
98 #define G_STMT_START do
99 #define G_STMT_END while (0)
101 #define G_USEC_PER_SEC 1000000
103 #define ABS(a) ((a) > 0 ? (a) : -(a))
105 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
107 #define EGLIB_STRINGIFY(x) #x
108 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
109 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
111 #define G_CONST_RETURN const
116 void g_free (void *ptr
);
117 static inline gpointer
g_realloc (gpointer obj
, gsize size
) { if (!size
) {g_free (obj
); return 0;} return realloc (obj
, size
);}
118 static inline gpointer
g_malloc (gsize x
) {if (x
) return malloc (x
); else return 0;}
119 static inline gpointer
g_malloc0 (gsize x
) {if (x
) return calloc(1,x
); else return 0;}
120 #define g_try_malloc(x) g_malloc(x)
121 #define g_try_realloc(obj,size) g_realloc((obj),(size))
123 #define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
124 #define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
125 #define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
127 #define g_memmove(dest,src,len) memmove (dest, src, len)
128 #define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
129 #define g_alloca(size) alloca (size)
131 gpointer
g_memdup (gconstpointer mem
, guint byte_size
);
132 static inline gchar
*g_strdup (const gchar
*str
) { if (str
) {return strdup (str
);} return NULL
; }
135 gpointer (*malloc
) (gsize n_bytes
);
136 gpointer (*realloc
) (gpointer mem
, gsize n_bytes
);
137 void (*free
) (gpointer mem
);
138 gpointer (*calloc
) (gsize n_blocks
, gsize n_block_bytes
);
139 gpointer (*try_malloc
) (gsize n_bytes
);
140 gpointer (*try_realloc
) (gpointer mem
, gsize n_bytes
);
143 #define g_mem_set_vtable(x)
149 typedef struct _GMemChunk GMemChunk
;
153 #define g_atexit(func) ((void) atexit (func))
155 const gchar
* g_getenv(const gchar
*variable
);
156 gboolean
g_setenv(const gchar
*variable
, const gchar
*value
, gboolean overwrite
);
157 void g_unsetenv(const gchar
*variable
);
159 gchar
* g_win32_getlocale(void);
162 * Precondition macros
164 #define g_return_if_fail(x) G_STMT_START { if (!(x)) { printf ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
165 #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
170 typedef struct _GHashTable GHashTable
;
171 typedef void (*GFunc
) (gpointer data
, gpointer user_data
);
172 typedef gint (*GCompareFunc
) (gconstpointer a
, gconstpointer b
);
173 typedef gint (*GCompareDataFunc
) (gconstpointer a
, gconstpointer b
, gpointer user_data
);
174 typedef void (*GHFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
175 typedef gboolean (*GHRFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
176 typedef void (*GDestroyNotify
) (gpointer data
);
177 typedef guint (*GHashFunc
) (gconstpointer key
);
178 typedef gboolean (*GEqualFunc
) (gconstpointer a
, gconstpointer b
);
179 typedef void (*GFreeFunc
) (gpointer data
);
181 GHashTable
*g_hash_table_new (GHashFunc hash_func
, GEqualFunc key_equal_func
);
182 GHashTable
*g_hash_table_new_full (GHashFunc hash_func
, GEqualFunc key_equal_func
,
183 GDestroyNotify key_destroy_func
, GDestroyNotify value_destroy_func
);
184 void g_hash_table_insert_replace (GHashTable
*hash
, gpointer key
, gpointer value
, gboolean replace
);
185 guint
g_hash_table_size (GHashTable
*hash
);
186 gpointer
g_hash_table_lookup (GHashTable
*hash
, gconstpointer key
);
187 gboolean
g_hash_table_lookup_extended (GHashTable
*hash
, gconstpointer key
, gpointer
*orig_key
, gpointer
*value
);
188 void g_hash_table_foreach (GHashTable
*hash
, GHFunc func
, gpointer user_data
);
189 gpointer
g_hash_table_find (GHashTable
*hash
, GHRFunc predicate
, gpointer user_data
);
190 gboolean
g_hash_table_remove (GHashTable
*hash
, gconstpointer key
);
191 guint
g_hash_table_foreach_remove (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
192 guint
g_hash_table_foreach_steal (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
193 void g_hash_table_destroy (GHashTable
*hash
);
195 guint
g_spaced_primes_closest (guint x
);
197 #define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
198 #define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
200 gboolean
g_direct_equal (gconstpointer v1
, gconstpointer v2
);
201 guint
g_direct_hash (gconstpointer v1
);
202 gboolean
g_int_equal (gconstpointer v1
, gconstpointer v2
);
203 guint
g_int_hash (gconstpointer v1
);
204 gboolean
g_str_equal (gconstpointer v1
, gconstpointer v2
);
205 guint
g_str_hash (gconstpointer v1
);
207 #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
208 #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
214 /* In the real glib, this is a GQuark, but we dont use/need that */
220 void g_clear_error (GError
**error
);
221 void g_error_free (GError
*error
);
222 GError
*g_error_new (gpointer domain
, gint code
, const char *format
, ...);
223 void g_set_error (GError
**err
, gpointer domain
, gint code
, const gchar
*format
, ...);
224 void g_propagate_error (GError
**dest
, GError
*src
);
229 gchar
*g_strdup_printf (const gchar
*format
, ...);
230 gchar
*g_strdup_vprintf (const gchar
*format
, va_list args
);
231 gchar
*g_strndup (const gchar
*str
, gsize n
);
232 const gchar
*g_strerror (gint errnum
);
233 gchar
*g_strndup (const gchar
*str
, gsize n
);
234 void g_strfreev (gchar
**str_array
);
235 gchar
*g_strconcat (const gchar
*first
, ...);
236 gchar
**g_strsplit (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
237 gchar
**g_strsplit_set (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
238 gchar
*g_strreverse (gchar
*str
);
239 gboolean
g_str_has_prefix (const gchar
*str
, const gchar
*prefix
);
240 gboolean
g_str_has_suffix (const gchar
*str
, const gchar
*suffix
);
241 guint
g_strv_length (gchar
**str_array
);
242 gchar
*g_strjoin (const gchar
*separator
, ...);
243 gchar
*g_strjoinv (const gchar
*separator
, gchar
**str_array
);
244 gchar
*g_strchug (gchar
*str
);
245 gchar
*g_strchomp (gchar
*str
);
246 void g_strdown (gchar
*string
);
247 gchar
*g_strnfill (gsize length
, gchar fill_char
);
249 gchar
*g_strdelimit (gchar
*string
, const gchar
*delimiters
, gchar new_delimiter
);
250 gchar
*g_strescape (const gchar
*source
, const gchar
*exceptions
);
252 gchar
*g_filename_to_uri (const gchar
*filename
, const gchar
*hostname
, GError
**error
);
253 gchar
*g_filename_from_uri (const gchar
*uri
, gchar
**hostname
, GError
**error
);
255 gint
g_printf (gchar
const *format
, ...);
256 gint
g_fprintf (FILE *file
, gchar
const *format
, ...);
257 gint
g_sprintf (gchar
*string
, gchar
const *format
, ...);
258 gint
g_snprintf (gchar
*string
, gulong n
, gchar
const *format
, ...);
259 #define g_vprintf vprintf
260 #define g_vfprintf vfprintf
261 #define g_vsprintf vsprintf
262 #define g_vsnprintf vsnprintf
263 #define g_vasprintf vasprintf
265 gsize
g_strlcpy (gchar
*dest
, const gchar
*src
, gsize dest_size
);
267 gchar
g_ascii_tolower (gchar c
);
268 gchar
*g_ascii_strdown (const gchar
*str
, gssize len
);
269 gint
g_ascii_strncasecmp (const gchar
*s1
, const gchar
*s2
, gsize n
);
270 gint
g_ascii_xdigit_value (gchar c
);
271 #define g_ascii_isspace(c) (isspace (c) != 0)
272 #define g_ascii_isalpha(c) (isalpha (c) != 0)
273 #define g_ascii_isprint(c) (isprint (c) != 0)
274 #define g_ascii_isxdigit(c) (isxdigit (c) != 0)
276 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
278 #define g_strcasecmp stricmp
279 #define g_ascii_strcasecmp stricmp
280 #define g_strncasecmp strnicmp
281 #define g_strstrip(a) g_strchug (g_strchomp (a))
283 #define g_strcasecmp strcasecmp
284 #define g_ascii_strcasecmp strcasecmp
285 #define g_strncasecmp strncasecmp
286 #define g_strstrip(a) g_strchug (g_strchomp (a))
290 #define G_STR_DELIMITERS "_-|> <."
301 GString
*g_string_new (const gchar
*init
);
302 GString
*g_string_new_len (const gchar
*init
, gssize len
);
303 GString
*g_string_sized_new (gsize default_size
);
304 gchar
*g_string_free (GString
*string
, gboolean free_segment
);
305 GString
*g_string_append (GString
*string
, const gchar
*val
);
306 void g_string_printf (GString
*string
, const gchar
*format
, ...);
307 void g_string_append_printf (GString
*string
, const gchar
*format
, ...);
308 GString
*g_string_append_c (GString
*string
, gchar c
);
309 GString
*g_string_append (GString
*string
, const gchar
*val
);
310 GString
*g_string_append_len (GString
*string
, const gchar
*val
, gssize len
);
311 GString
*g_string_truncate (GString
*string
, gsize len
);
312 GString
*g_string_prepend (GString
*string
, const gchar
*val
);
314 #define g_string_sprintfa g_string_append_printf
319 typedef struct _GSList GSList
;
325 GSList
*g_slist_alloc (void);
326 GSList
*g_slist_append (GSList
*list
,
328 GSList
*g_slist_prepend (GSList
*list
,
330 void g_slist_free (GSList
*list
);
331 void g_slist_free_1 (GSList
*list
);
332 GSList
*g_slist_copy (GSList
*list
);
333 GSList
*g_slist_concat (GSList
*list1
,
335 void g_slist_foreach (GSList
*list
,
338 GSList
*g_slist_last (GSList
*list
);
339 GSList
*g_slist_find (GSList
*list
,
341 GSList
*g_slist_find_custom (GSList
*list
,
344 GSList
*g_slist_remove (GSList
*list
,
346 GSList
*g_slist_remove_all (GSList
*list
,
348 GSList
*g_slist_reverse (GSList
*list
);
349 guint
g_slist_length (GSList
*list
);
350 GSList
*g_slist_remove_link (GSList
*list
,
352 GSList
*g_slist_delete_link (GSList
*list
,
354 GSList
*g_slist_insert_sorted (GSList
*list
,
357 GSList
*g_slist_insert_before (GSList
*list
,
360 GSList
*g_slist_sort (GSList
*list
,
362 gint
g_slist_index (GSList
*list
,
364 GSList
*g_slist_nth (GSList
*list
,
366 gpointer
g_slist_nth_data (GSList
*list
,
369 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
372 typedef struct _GList GList
;
379 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
380 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
382 GList
*g_list_alloc (void);
383 GList
*g_list_append (GList
*list
,
385 GList
*g_list_prepend (GList
*list
,
387 void g_list_free (GList
*list
);
388 void g_list_free_1 (GList
*list
);
389 GList
*g_list_copy (GList
*list
);
390 guint
g_list_length (GList
*list
);
391 gint
g_list_index (GList
*list
,
393 GList
*g_list_nth (GList
*list
,
395 gpointer
g_list_nth_data (GList
*list
,
397 GList
*g_list_last (GList
*list
);
398 GList
*g_list_concat (GList
*list1
,
400 void g_list_foreach (GList
*list
,
403 GList
*g_list_first (GList
*list
);
404 GList
*g_list_find (GList
*list
,
406 GList
*g_list_find_custom (GList
*list
,
409 GList
*g_list_remove (GList
*list
,
411 GList
*g_list_reverse (GList
*list
);
412 GList
*g_list_remove_link (GList
*list
,
414 GList
*g_list_delete_link (GList
*list
,
416 GList
*g_list_insert_sorted (GList
*list
,
419 GList
*g_list_insert_before (GList
*list
,
422 GList
*g_list_sort (GList
*sort
,
429 typedef struct _GArray GArray
;
435 GArray
*g_array_new (gboolean zero_terminated
, gboolean clear_
, guint element_size
);
436 gchar
* g_array_free (GArray
*array
, gboolean free_segment
);
437 GArray
*g_array_append_vals (GArray
*array
, gconstpointer data
, guint len
);
438 GArray
* g_array_insert_vals (GArray
*array
, guint index_
, gconstpointer data
, guint len
);
439 GArray
* g_array_remove_index (GArray
*array
, guint index_
);
440 GArray
* g_array_remove_index_fast (GArray
*array
, guint index_
);
442 #define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
443 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
444 #define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
450 typedef struct _GPtrArray GPtrArray
;
456 GPtrArray
*g_ptr_array_new (void);
457 GPtrArray
*g_ptr_array_sized_new (guint reserved_size
);
458 void g_ptr_array_add (GPtrArray
*array
, gpointer data
);
459 gboolean
g_ptr_array_remove (GPtrArray
*array
, gpointer data
);
460 gpointer
g_ptr_array_remove_index (GPtrArray
*array
, guint index
);
461 gboolean
g_ptr_array_remove_fast (GPtrArray
*array
, gpointer data
);
462 gpointer
g_ptr_array_remove_index_fast (GPtrArray
*array
, guint index
);
463 void g_ptr_array_sort (GPtrArray
*array
, GCompareFunc compare_func
);
464 void g_ptr_array_sort_with_data (GPtrArray
*array
, GCompareDataFunc compare_func
, gpointer user_data
);
465 void g_ptr_array_set_size (GPtrArray
*array
, gint length
);
466 gpointer
*g_ptr_array_free (GPtrArray
*array
, gboolean free_seg
);
467 void g_ptr_array_foreach (GPtrArray
*array
, GFunc func
, gpointer user_data
);
468 #define g_ptr_array_index(array,index) (array)->pdata[(index)]
479 gpointer
g_queue_pop_head (GQueue
*queue
);
480 void g_queue_push_head (GQueue
*queue
,
482 void g_queue_push_tail (GQueue
*queue
,
484 gboolean
g_queue_is_empty (GQueue
*queue
);
485 GQueue
*g_queue_new (void);
486 void g_queue_free (GQueue
*queue
);
492 #define G_LOG_DOMAIN ((gchar*) 0)
496 G_LOG_FLAG_RECURSION
= 1 << 0,
497 G_LOG_FLAG_FATAL
= 1 << 1,
499 G_LOG_LEVEL_ERROR
= 1 << 2,
500 G_LOG_LEVEL_CRITICAL
= 1 << 3,
501 G_LOG_LEVEL_WARNING
= 1 << 4,
502 G_LOG_LEVEL_MESSAGE
= 1 << 5,
503 G_LOG_LEVEL_INFO
= 1 << 6,
504 G_LOG_LEVEL_DEBUG
= 1 << 7,
506 G_LOG_LEVEL_MASK
= ~(G_LOG_FLAG_RECURSION
| G_LOG_FLAG_FATAL
)
509 void g_print (const gchar
*format
, ...);
510 GLogLevelFlags
g_log_set_always_fatal (GLogLevelFlags fatal_mask
);
511 GLogLevelFlags
g_log_set_fatal_mask (const gchar
*log_domain
, GLogLevelFlags fatal_mask
);
512 void g_logv (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, va_list args
);
513 void g_log (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, ...);
514 void g_assertion_message (const gchar
*format
, ...) G_GNUC_NORETURN
;
516 #ifdef HAVE_C99_SUPPORT
517 #define g_error(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__)
518 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
519 #define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
520 #define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
521 #define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
523 #define g_printerr(format, ...) fprintf (stderr, format, __VA_ARGS__)
525 #define g_error(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__)
526 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
527 #define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
528 #define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
529 #define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
531 #define g_printerr(...) fprintf (stderr, __VA_ARGS__)
533 #define g_log_set_handler(a,b,c,d)
539 gpointer
g_convert_error_quark(void);
543 * Unicode Manipulation: most of this is not used by Mono by default, it is
544 * only used if the old collation code is activated, so this is only the
545 * bare minimum to build.
547 typedef guint32 gunichar
;
552 G_UNICODE_UNASSIGNED
,
553 G_UNICODE_PRIVATE_USE
,
555 G_UNICODE_LOWERCASE_LETTER
,
556 G_UNICODE_MODIFIER_LETTER
,
557 G_UNICODE_OTHER_LETTER
,
558 G_UNICODE_TITLECASE_LETTER
,
559 G_UNICODE_UPPERCASE_LETTER
,
560 G_UNICODE_COMBINING_MARK
,
561 G_UNICODE_ENCLOSING_MARK
,
562 G_UNICODE_NON_SPACING_MARK
,
563 G_UNICODE_DECIMAL_NUMBER
,
564 G_UNICODE_LETTER_NUMBER
,
565 G_UNICODE_OTHER_NUMBER
,
566 G_UNICODE_CONNECT_PUNCTUATION
,
567 G_UNICODE_DASH_PUNCTUATION
,
568 G_UNICODE_CLOSE_PUNCTUATION
,
569 G_UNICODE_FINAL_PUNCTUATION
,
570 G_UNICODE_INITIAL_PUNCTUATION
,
571 G_UNICODE_OTHER_PUNCTUATION
,
572 G_UNICODE_OPEN_PUNCTUATION
,
573 G_UNICODE_CURRENCY_SYMBOL
,
574 G_UNICODE_MODIFIER_SYMBOL
,
575 G_UNICODE_MATH_SYMBOL
,
576 G_UNICODE_OTHER_SYMBOL
,
577 G_UNICODE_LINE_SEPARATOR
,
578 G_UNICODE_PARAGRAPH_SEPARATOR
,
579 G_UNICODE_SPACE_SEPARATOR
582 gunichar
g_unichar_toupper (gunichar c
);
583 gunichar
g_unichar_tolower (gunichar c
);
584 gunichar
g_unichar_totitle (gunichar c
);
585 GUnicodeType
g_unichar_type (gunichar c
);
586 gboolean
g_unichar_isxdigit (gunichar c
);
587 gint
g_unichar_xdigit_value (gunichar c
);
590 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
594 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
598 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
601 /* FIXME: Implement these two for gcc */
602 #define G_LIKELY(x) (x)
603 #define G_UNLIKELY(x) (x)
609 #define G_CONVERT_ERROR g_convert_error_quark()
612 G_CONVERT_ERROR_NO_CONVERSION
,
613 G_CONVERT_ERROR_ILLEGAL_SEQUENCE
,
614 G_CONVERT_ERROR_FAILED
,
615 G_CONVERT_ERROR_PARTIAL_INPUT
,
616 G_CONVERT_ERROR_BAD_URI
,
617 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
620 gchar
* g_utf8_strup (const gchar
*str
, gssize len
);
621 gchar
* g_utf8_strdown (const gchar
*str
, gssize len
);
622 gunichar2
*g_utf8_to_utf16 (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
623 gchar
*g_utf16_to_utf8 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
624 gunichar2
*g_ucs4_to_utf16 (const gunichar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
625 gunichar
*g_utf16_to_ucs4 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**error
);
627 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
630 #define u16to8(str) g_utf16_to_utf8(str, (glong)wcslen(str), NULL, NULL, NULL)
632 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
638 gchar
*g_build_path (const gchar
*separator
, const gchar
*first_element
, ...);
639 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
640 gchar
*g_path_get_dirname (const gchar
*filename
);
641 gchar
*g_path_get_basename (const char *filename
);
642 gchar
*g_find_program_in_path (const gchar
*program
);
643 gchar
*g_get_current_dir (void);
644 gboolean
g_path_is_absolute (const char *filename
);
646 const gchar
*g_get_home_dir (void);
647 const gchar
*g_get_tmp_dir (void);
648 const gchar
*g_get_user_name (void);
649 gchar
*g_get_prgname (void);
650 void g_set_prgname (const gchar
*prgname
);
656 gboolean
g_shell_parse_argv (const gchar
*command_line
, gint
*argcp
, gchar
***argvp
, GError
**error
);
657 gchar
*g_shell_unquote (const gchar
*quoted_string
, GError
**error
);
658 gchar
*g_shell_quote (const gchar
*unquoted_string
);
664 G_SPAWN_LEAVE_DESCRIPTORS_OPEN
= 1,
665 G_SPAWN_DO_NOT_REAP_CHILD
= 1 << 1,
666 G_SPAWN_SEARCH_PATH
= 1 << 2,
667 G_SPAWN_STDOUT_TO_DEV_NULL
= 1 << 3,
668 G_SPAWN_STDERR_TO_DEV_NULL
= 1 << 4,
669 G_SPAWN_CHILD_INHERITS_STDIN
= 1 << 5,
670 G_SPAWN_FILE_AND_ARGV_ZERO
= 1 << 6
675 typedef void (*GSpawnChildSetupFunc
) (gpointer user_data
);
677 gboolean
g_spawn_command_line_sync (const gchar
*command_line
, gchar
**standard_output
, gchar
**standard_error
, gint
*exit_status
, GError
**error
);
678 gboolean
g_spawn_async_with_pipes (const gchar
*working_directory
, gchar
**argv
, gchar
**envp
, GSpawnFlags flags
, GSpawnChildSetupFunc child_setup
,
679 gpointer user_data
, GPid
*child_pid
, gint
*standard_input
, gint
*standard_output
, gint
*standard_error
, GError
**error
);
685 typedef struct _GTimer GTimer
;
687 GTimer
*g_timer_new (void);
688 void g_timer_destroy (GTimer
*timer
);
689 gdouble
g_timer_elapsed (GTimer
*timer
, gulong
*microseconds
);
690 void g_timer_stop (GTimer
*timer
);
691 void g_timer_start (GTimer
*timer
);
701 void g_get_current_time (GTimeVal
*result
);
702 void g_usleep (gulong microseconds
);
712 G_FILE_ERROR_NAMETOOLONG
,
737 G_FILE_TEST_IS_REGULAR
= 1 << 0,
738 G_FILE_TEST_IS_SYMLINK
= 1 << 1,
739 G_FILE_TEST_IS_DIR
= 1 << 2,
740 G_FILE_TEST_IS_EXECUTABLE
= 1 << 3,
741 G_FILE_TEST_EXISTS
= 1 << 4
745 gboolean
g_file_get_contents (const gchar
*filename
, gchar
**contents
, gsize
*length
, GError
**error
);
746 GFileError
g_file_error_from_errno (gint err_no
);
747 gint
g_file_open_tmp (const gchar
*tmpl
, gchar
**name_used
, GError
**error
);
748 gboolean
g_file_test (const gchar
*filename
, GFileTest test
);
753 typedef struct _GPatternSpec GPatternSpec
;
754 GPatternSpec
* g_pattern_spec_new (const gchar
*pattern
);
755 void g_pattern_spec_free (GPatternSpec
*pspec
);
756 gboolean
g_pattern_match_string (GPatternSpec
*pspec
, const gchar
*string
);
761 typedef struct _GDir GDir
;
762 GDir
*g_dir_open (const gchar
*path
, guint flags
, GError
**error
);
763 const gchar
*g_dir_read_name (GDir
*dir
);
764 void g_dir_rewind (GDir
*dir
);
765 void g_dir_close (GDir
*dir
);
770 typedef struct _GMarkupParseContext GMarkupParseContext
;
774 G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG
= 1 << 0,
775 G_MARKUP_TREAT_CDATA_AS_TEXT
= 1 << 1
779 void (*start_element
) (GMarkupParseContext
*context
,
780 const gchar
*element_name
,
781 const gchar
**attribute_names
,
782 const gchar
**attribute_values
,
786 void (*end_element
) (GMarkupParseContext
*context
,
787 const gchar
*element_name
,
791 void (*text
) (GMarkupParseContext
*context
,
797 void (*passthrough
) (GMarkupParseContext
*context
,
798 const gchar
*passthrough_text
,
802 void (*error
) (GMarkupParseContext
*context
,
807 GMarkupParseContext
*g_markup_parse_context_new (const GMarkupParser
*parser
,
808 GMarkupParseFlags flags
,
810 GDestroyNotify user_data_dnotify
);
811 void g_markup_parse_context_free (GMarkupParseContext
*context
);
812 gboolean
g_markup_parse_context_parse (GMarkupParseContext
*context
,
813 const gchar
*text
, gssize text_len
,
815 gboolean
g_markup_parse_context_end_parse (GMarkupParseContext
*context
,
819 * Character set conversion
822 * Index into the table below with the first byte of a UTF-8 sequence to
823 * get the number of trailing bytes that are supposed to follow it.
824 * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
825 * left as-is for anyone who may want to do such conversion, which was
826 * allowed in earlier algorithms.
828 extern const gchar g_trailingBytesForUTF8
[256];
830 gboolean
g_get_charset (G_CONST_RETURN
char **charset
);
831 gchar
*g_locale_to_utf8 (const gchar
*opsysstring
, gssize len
,
832 gsize
*bytes_read
, gsize
*bytes_written
,
834 gchar
*g_locale_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
835 gsize
*bytes_written
, GError
**error
);
836 gchar
*g_filename_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
837 gsize
*bytes_written
, GError
**error
);
838 gchar
*g_convert (const gchar
*str
, gssize len
,
839 const gchar
*to_codeset
, const gchar
*from_codeset
,
840 gsize
*bytes_read
, gsize
*bytes_written
, GError
**error
);
841 gboolean
g_utf8_validate (const gchar
*str
, gssize max_len
, const gchar
**end
);
842 gunichar
g_utf8_get_char (const gchar
*src
);
843 glong
g_utf8_strlen (const gchar
*str
, gssize max
);
844 #define g_utf8_next_char(p) p + (g_trailingBytesForUTF8[(guchar)(*p)] + 1)
847 * Empty thread functions, not used by eglib
849 #define g_thread_supported() TRUE
850 #define g_thread_init(x) G_STMT_START { if (x != NULL) { g_error ("No vtable supported in g_thread_init"); } } G_STMT_END
852 #define G_LOCK_DEFINE(name) int name;
853 #define G_LOCK_DEFINE_STATIC(name) static int name;
854 #define G_LOCK_EXTERN(name)
856 #define G_TRYLOCK(name)
857 #define G_UNLOCK(name)
859 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
861 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
862 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
863 ( (((guint32) (x)) << 24)| \
864 ((((guint32) (x)) & 0xff0000) >> 8) | \
865 ((((guint32) (x)) & 0xff00) << 8) | \
866 (((guint32) (x)) >> 24)) )
868 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
869 GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
873 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
874 # define GUINT32_TO_LE(x) (x)
875 # define GUINT64_TO_LE(x) (x)
876 # define GUINT16_TO_LE(x) (x)
877 # define GUINT_TO_LE(x) (x)
878 # define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
879 # define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
881 # define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
882 # define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
883 # define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
884 # define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
885 # define GUINT32_TO_BE(x) (x)
886 # define GUINT32_FROM_BE(x) (x)
889 #define GUINT32_FROM_LE(x) (GUINT32_TO_LE (x))
890 #define GUINT64_FROM_LE(x) (GUINT64_TO_LE (x))
891 #define GUINT16_FROM_LE(x) (GUINT16_TO_LE (x))
892 #define GUINT_FROM_LE(x) (GUINT_TO_LE (x))
894 #define _EGLIB_MAJOR 2
895 #define _EGLIB_MIDDLE 4
896 #define _EGLIB_MINOR 0
898 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))