Canorus 0.0
glib.h
Go to the documentation of this file.
1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
17 */
18
19/*
20 * Modified by the GLib Team and others 1997-1999. See the AUTHORS
21 * file for a list of people on the GLib Team. See the ChangeLog
22 * files for a list of changes. These files are distributed with
23 * GLib at ftp://ftp.gtk.org/pub/gtk/.
24 * Modified: Steve Ratcliffe May 1999. File exists so that pmidi
25 * is not dependant on glib.
26 */
27
28#ifndef __G_LIB_H__
29#define __G_LIB_H__
30
31#include <stdlib.h>
32#include <string.h>
33
34/* system specific config file glibconfig.h provides definitions for
35 * the extrema of many of the standard types. These are:
36 *
37 * G_MINSHORT, G_MAXSHORT
38 * G_MININT, G_MAXINT
39 * G_MINLONG, G_MAXLONG
40 * G_MINFLOAT, G_MAXFLOAT
41 * G_MINDOUBLE, G_MAXDOUBLE
42 *
43 * It also provides the following typedefs:
44 *
45 * gint8, guint8
46 * gint16, guint16
47 * gint32, guint32
48 * gint64, guint64
49 *
50 * It defines the G_BYTE_ORDER symbol to one of G_*_ENDIAN (see later in
51 * this file).
52 *
53 * And it provides a way to store and retrieve a `gint' in/from a `gpointer'.
54 * This is useful to pass an integer instead of a pointer to a callback.
55 *
56 * GINT_TO_POINTER(i), GUINT_TO_POINTER(i)
57 * GPOINTER_TO_INT(p), GPOINTER_TO_UINT(p)
58 *
59 * Finally, it provide the following wrappers to STDC functions:
60 *
61 * g_ATEXIT
62 * To register hooks which are executed on exit().
63 * Usually a wrapper for STDC atexit.
64 *
65 * void *g_memmove(void *dest, const void *src, guint count);
66 * A wrapper for STDC memmove, or an implementation, if memmove doesn't
67 * exist. The prototype looks like the above, give or take a const,
68 * or size_t.
69 */
70
71typedef signed char gint8;
72typedef unsigned char guint8;
73typedef signed short gint16;
74typedef unsigned short guint16;
75typedef signed int gint32;
76typedef unsigned int guint32;
77
78/* include varargs functions for assertment macros
79 */
80#include <stdarg.h>
81
82/* optionally feature DMALLOC memory allocation debugger
83 */
84#ifdef USE_DMALLOC
85#include "dmalloc.h"
86#endif
87
88
89#ifdef NATIVE_WIN32
90
91/* On native Win32, directory separator is the backslash, and search path
92 * separator is the semicolon.
93 */
94#define G_DIR_SEPARATOR '\\'
95#define G_DIR_SEPARATOR_S "\\"
96#define G_SEARCHPATH_SEPARATOR ';'
97#define G_SEARCHPATH_SEPARATOR_S ";"
98
99#else /* !NATIVE_WIN32 */
100
101/* Unix */
102
103#define G_DIR_SEPARATOR '/'
104#define G_DIR_SEPARATOR_S "/"
105#define G_SEARCHPATH_SEPARATOR ':'
106#define G_SEARCHPATH_SEPARATOR_S ":"
107
108#endif /* !NATIVE_WIN32 */
109
110#ifdef __cplusplus
111extern "C" {
112#endif /* __cplusplus */
113
114
115/* Provide definitions for some commonly used macros.
116 * Some of them are only provided if they haven't already
117 * been defined. It is assumed that if they are already
118 * defined then the current definition is correct.
119 */
120#ifndef NULL
121#define NULL ((void*) 0)
122#endif
123
124#ifndef FALSE
125#define FALSE (0)
126#endif
127
128#ifndef TRUE
129#define TRUE (!FALSE)
130#endif
131
132#undef MAX
133#define MAX(a, b) (((a) > (b)) ? (a) : (b))
134
135#undef MIN
136#define MIN(a, b) (((a) < (b)) ? (a) : (b))
137
138#undef ABS
139#define ABS(a) (((a) < 0) ? -(a) : (a))
140
141#undef CLAMP
142#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
143
144
145/* Define G_VA_COPY() to do the right thing for copying va_list variables.
146 * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.
147 */
148#if !defined (G_VA_COPY)
149# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
150# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
151# elif defined (G_VA_COPY_AS_ARRAY)
152# define G_VA_COPY(ap1, ap2) g_memmove ((ap1), (ap2), sizeof (va_list))
153# else /* va_list is a pointer */
154# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2))
155# endif /* va_list is a pointer */
156#endif /* !G_VA_COPY */
157
158
159/* Provide convenience macros for handling structure
160 * fields through their offsets.
161 */
162#define G_STRUCT_OFFSET(struct_type, member) \
163 ((gulong) ((gchar*) &((struct_type*) 0)->member))
164#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
165 ((gpointer) ((gchar*) (struct_p) + (gulong) (struct_offset)))
166#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
167 (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
168
169
170/* inlining hassle. for compilers that don't allow the `inline' keyword,
171 * mostly because of strict ANSI C compliance or dumbness, we try to fall
172 * back to either `__inline__' or `__inline'.
173 * we define G_CAN_INLINE, if the compiler seems to be actually
174 * *capable* to do function inlining, in which case inline function bodys
175 * do make sense. we also define G_INLINE_FUNC to properly export the
176 * function prototypes if no inlining can be performed.
177 * we special case most of the stuff, so inline functions can have a normal
178 * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1.
179 */
180#ifndef G_INLINE_FUNC
181# define G_CAN_INLINE 1
182#endif
183#ifdef G_HAVE_INLINE
184# if defined (__GNUC__) && defined (__STRICT_ANSI__)
185# undef inline
186# define inline __inline__
187# endif
188#else /* !G_HAVE_INLINE */
189# undef inline
190# if defined (G_HAVE___INLINE__)
191# define inline __inline__
192# else /* !inline && !__inline__ */
193# if defined (G_HAVE___INLINE)
194# define inline __inline
195# else /* !inline && !__inline__ && !__inline */
196# define inline /* don't inline, then */
197# ifndef G_INLINE_FUNC
198# undef G_CAN_INLINE
199# endif
200# endif
201# endif
202#endif
203#ifndef G_INLINE_FUNC
204# ifdef __GNUC__
205# ifdef __OPTIMIZE__
206# define G_INLINE_FUNC extern inline
207# else
208# undef G_CAN_INLINE
209# define G_INLINE_FUNC extern
210# endif
211# else /* !__GNUC__ */
212# ifdef G_CAN_INLINE
213# define G_INLINE_FUNC static inline
214# else
215# define G_INLINE_FUNC extern
216# endif
217# endif /* !__GNUC__ */
218#endif /* !G_INLINE_FUNC */
219
220
221/* Provide simple macro statement wrappers (adapted from Perl):
222 * G_STMT_START { statements; } G_STMT_END;
223 * can be used as a single statement, as in
224 * if (x) G_STMT_START { ... } G_STMT_END; else ...
225 *
226 * For gcc we will wrap the statements within `({' and `})' braces.
227 * For SunOS they will be wrapped within `if (1)' and `else (void) 0',
228 * and otherwise within `do' and `while (0)'.
229 */
230#if !(defined (G_STMT_START) && defined (G_STMT_END))
231# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
232# define G_STMT_START (void)(
233# define G_STMT_END )
234# else
235# if (defined (sun) || defined (__sun__))
236# define G_STMT_START if (1)
237# define G_STMT_END else (void)0
238# else
239# define G_STMT_START do
240# define G_STMT_END while (0)
241# endif
242# endif
243#endif
244
245
246/* Provide macros to feature the GCC function attribute.
247 */
248#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
249#define G_GNUC_PRINTF( format_idx, arg_idx ) \
250 __attribute__((format (printf, format_idx, arg_idx)))
251#define G_GNUC_SCANF( format_idx, arg_idx ) \
252 __attribute__((format (scanf, format_idx, arg_idx)))
253#define G_GNUC_FORMAT( arg_idx ) \
254 __attribute__((format_arg (arg_idx)))
255#define G_GNUC_NORETURN \
256 __attribute__((noreturn))
257#define G_GNUC_CONST \
258 __attribute__((const))
259#define G_GNUC_UNUSED \
260 __attribute__((unused))
261#else /* !__GNUC__ */
262#define G_GNUC_PRINTF( format_idx, arg_idx )
263#define G_GNUC_SCANF( format_idx, arg_idx )
264#define G_GNUC_FORMAT( arg_idx )
265#define G_GNUC_NORETURN
266#define G_GNUC_CONST
267#define G_GNUC_UNUSED
268#endif /* !__GNUC__ */
269
270
271/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
272 * macros, so we can refer to them as strings unconditionally.
273 */
274#ifdef __GNUC__
275#define G_GNUC_FUNCTION __FUNCTION__
276#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
277#else /* !__GNUC__ */
278#define G_GNUC_FUNCTION ""
279#define G_GNUC_PRETTY_FUNCTION ""
280#endif /* !__GNUC__ */
281
282/* we try to provide a usefull equivalent for ATEXIT if it is
283 * not defined, but use is actually abandoned. people should
284 * use g_atexit() instead.
285 */
286#ifndef ATEXIT
287# define ATEXIT(proc) g_ATEXIT(proc)
288#else
289# define G_NATIVE_ATEXIT
290#endif /* ATEXIT */
291
292/* Hacker macro to place breakpoints for elected machines.
293 * Actual use is strongly deprecated of course ;)
294 */
295#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
296#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END
297#elif defined (__alpha__) && defined (__GNUC__) && __GNUC__ >= 2
298#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END
299#else /* !__i386__ && !__alpha__ */
300#define G_BREAKPOINT()
301#endif /* __i386__ */
302
303
304/* Provide macros for easily allocating memory. The macros
305 * will cast the allocated memory to the specified type
306 * in order to avoid compiler warnings. (Makes the code neater).
307 */
308
309# define g_new(type, count) \
310 ((type *) malloc ((unsigned) sizeof (type) * (count)))
311# define g_new0(type, count) \
312 ((type *) calloc ((unsigned) sizeof (type) * (count), 1))
313# define g_renew(type, mem, count) \
314 ((type *) realloc (mem, (unsigned) sizeof (type) * (count)))
315
316#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
317 g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
318 sizeof (type), \
319 sizeof (type) * (pre_alloc), \
320 (alloc_type)) \
321)
322#define g_chunk_new(type, chunk) ( \
323 (type *) g_mem_chunk_alloc (chunk) \
324)
325#define g_chunk_new0(type, chunk) ( \
326 (type *) g_mem_chunk_alloc0 (chunk) \
327)
328#define g_chunk_free(mem, mem_chunk) G_STMT_START { \
329 g_mem_chunk_free ((mem_chunk), (mem)); \
330} G_STMT_END
331
332
333#define g_string(x) #x
334
335
336/* Provide macros for error handling. The "assert" macros will
337 * exit on failure. The "return" macros will exit the current
338 * function. Two different definitions are given for the macros
339 * if G_DISABLE_ASSERT is not defined, in order to support gcc's
340 * __PRETTY_FUNCTION__ capability.
341 */
342
343#ifdef G_DISABLE_ASSERT
344
345#define g_assert(expr)
346#define g_assert_not_reached()
347
348#else /* !G_DISABLE_ASSERT */
349
350#ifdef __GNUC__
351
352#define g_assert(expr) G_STMT_START{ \
353 if (!(expr)) \
354 g_log (G_LOG_DOMAIN, \
355 G_LOG_LEVEL_ERROR, \
356 "file %s: line %d (%s): assertion failed: (%s)", \
357 __FILE__, \
358 __LINE__, \
359 __PRETTY_FUNCTION__, \
360 #expr); }G_STMT_END
361
362#define g_assert_not_reached() G_STMT_START{ \
363 g_log (G_LOG_DOMAIN, \
364 G_LOG_LEVEL_ERROR, \
365 "file %s: line %d (%s): should not be reached", \
366 __FILE__, \
367 __LINE__, \
368 __PRETTY_FUNCTION__); }G_STMT_END
369
370#else /* !__GNUC__ */
371
372#define g_assert(expr) G_STMT_START{ \
373 if (!(expr)) \
374 g_log (G_LOG_DOMAIN, \
375 G_LOG_LEVEL_ERROR, \
376 "file %s: line %d: assertion failed: (%s)", \
377 __FILE__, \
378 __LINE__, \
379 #expr); }G_STMT_END
380
381#define g_assert_not_reached() G_STMT_START{ \
382 g_log (G_LOG_DOMAIN, \
383 G_LOG_LEVEL_ERROR, \
384 "file %s: line %d: should not be reached", \
385 __FILE__, \
386 __LINE__); }G_STMT_END
387
388#endif /* __GNUC__ */
389
390#endif /* !G_DISABLE_ASSERT */
391
392
393#ifdef G_DISABLE_CHECKS
394
395#define g_return_if_fail(expr)
396#define g_return_val_if_fail(expr,val)
397
398#else /* !G_DISABLE_CHECKS */
399
400#ifdef __GNUC__
401
402#define g_return_if_fail(expr) G_STMT_START{ \
403 if (!(expr)) \
404 { \
405 g_log (G_LOG_DOMAIN, \
406 G_LOG_LEVEL_CRITICAL, \
407 "file %s: line %d (%s): assertion `%s' failed.", \
408 __FILE__, \
409 __LINE__, \
410 __PRETTY_FUNCTION__, \
411 #expr); \
412 return; \
413 }; }G_STMT_END
414
415#define g_return_val_if_fail(expr,val) G_STMT_START{ \
416 if (!(expr)) \
417 { \
418 g_log (G_LOG_DOMAIN, \
419 G_LOG_LEVEL_CRITICAL, \
420 "file %s: line %d (%s): assertion `%s' failed.", \
421 __FILE__, \
422 __LINE__, \
423 __PRETTY_FUNCTION__, \
424 #expr); \
425 return val; \
426 }; }G_STMT_END
427
428#else /* !__GNUC__ */
429
430#define g_return_if_fail(expr) G_STMT_START{ \
431 if (!(expr)) \
432 { \
433 g_log (G_LOG_DOMAIN, \
434 G_LOG_LEVEL_CRITICAL, \
435 "file %s: line %d: assertion `%s' failed.", \
436 __FILE__, \
437 __LINE__, \
438 #expr); \
439 return; \
440 }; }G_STMT_END
441
442#define g_return_val_if_fail(expr, val) G_STMT_START{ \
443 if (!(expr)) \
444 { \
445 g_log (G_LOG_DOMAIN, \
446 G_LOG_LEVEL_CRITICAL, \
447 "file %s: line %d: assertion `%s' failed.", \
448 __FILE__, \
449 __LINE__, \
450 #expr); \
451 return val; \
452 }; }G_STMT_END
453
454#endif /* !__GNUC__ */
455
456#endif /* !G_DISABLE_CHECKS */
457
458
459/* Provide type definitions for commonly used types.
460 * These are useful because a "gint8" can be adjusted
461 * to be 1 byte (8 bits) on all platforms. Similarly and
462 * more importantly, "gint32" can be adjusted to be
463 * 4 bytes (32 bits) on all platforms.
464 */
465
466typedef char gchar;
467typedef short gshort;
468typedef long glong;
469typedef int gint;
471
472typedef unsigned char guchar;
473typedef unsigned short gushort;
474typedef unsigned long gulong;
475typedef unsigned int guint;
476
477typedef float gfloat;
478typedef double gdouble;
479
480/* HAVE_LONG_DOUBLE doesn't work correctly on all platforms.
481 * Since gldouble isn't used anywhere, just disable it for now */
482
483#if 0
484#ifdef HAVE_LONG_DOUBLE
485typedef long double gldouble;
486#else /* HAVE_LONG_DOUBLE */
487typedef double gldouble;
488#endif /* HAVE_LONG_DOUBLE */
489#endif /* 0 */
490
491typedef void* gpointer;
492typedef const void *gconstpointer;
493
494
498typedef gint32 GTime;
499
500
501/* Portable endian checks and conversions
502 *
503 * glibconfig.h defines G_BYTE_ORDER which expands to one of
504 * the below macros.
505 */
506#define G_LITTLE_ENDIAN 1234
507#define G_BIG_ENDIAN 4321
508#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
509
510
511/* Basic bit swapping functions
512 */
513#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
514 (((guint16) (val) & (guint16) 0x00ffU) << 8) | \
515 (((guint16) (val) & (guint16) 0xff00U) >> 8)))
516#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \
517 (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
518 (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \
519 (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \
520 (((guint32) (val) & (guint32) 0xff000000U) >> 24)))
521
522/* Intel specific stuff for speed
523 */
524#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
525# define GUINT16_SWAP_LE_BE_X86(val) \
526 (__extension__ \
527 ({ register guint16 __v; \
528 if (__builtin_constant_p (val)) \
529 __v = GUINT16_SWAP_LE_BE_CONSTANT (val); \
530 else \
531 __asm__ __const__ ("rorw $8, %w0" \
532 : "=r" (__v) \
533 : "0" ((guint16) (val))); \
534 __v; }))
535# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_X86 (val))
536# if !defined(__i486__) && !defined(__i586__) \
537 && !defined(__pentium__) && !defined(__i686__) && !defined(__pentiumpro__)
538# define GUINT32_SWAP_LE_BE_X86(val) \
539 (__extension__ \
540 ({ register guint32 __v; \
541 if (__builtin_constant_p (val)) \
542 __v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
543 else \
544 __asm__ __const__ ("rorw $8, %w0\n\t" \
545 "rorl $16, %0\n\t" \
546 "rorw $8, %w0" \
547 : "=r" (__v) \
548 : "0" ((guint32) (val))); \
549 __v; }))
550# else /* 486 and higher has bswap */
551# define GUINT32_SWAP_LE_BE_X86(val) \
552 (__extension__ \
553 ({ register guint32 __v; \
554 if (__builtin_constant_p (val)) \
555 __v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
556 else \
557 __asm__ __const__ ("bswap %0" \
558 : "=r" (__v) \
559 : "0" ((guint32) (val))); \
560 __v; }))
561# endif /* processor specific 32-bit stuff */
562# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86 (val))
563#else /* !__i386__ */
564# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
565# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
566#endif /* __i386__ */
567
568#ifdef G_HAVE_GINT64
569# define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \
570 (((guint64) (val) & \
571 (guint64) G_GINT64_CONSTANT(0x00000000000000ffU)) << 56) | \
572 (((guint64) (val) & \
573 (guint64) G_GINT64_CONSTANT(0x000000000000ff00U)) << 40) | \
574 (((guint64) (val) & \
575 (guint64) G_GINT64_CONSTANT(0x0000000000ff0000U)) << 24) | \
576 (((guint64) (val) & \
577 (guint64) G_GINT64_CONSTANT(0x00000000ff000000U)) << 8) | \
578 (((guint64) (val) & \
579 (guint64) G_GINT64_CONSTANT(0x000000ff00000000U)) >> 8) | \
580 (((guint64) (val) & \
581 (guint64) G_GINT64_CONSTANT(0x0000ff0000000000U)) >> 24) | \
582 (((guint64) (val) & \
583 (guint64) G_GINT64_CONSTANT(0x00ff000000000000U)) >> 40) | \
584 (((guint64) (val) & \
585 (guint64) G_GINT64_CONSTANT(0xff00000000000000U)) >> 56)))
586# if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
587# define GUINT64_SWAP_LE_BE_X86(val) \
588 (__extension__ \
589 ({ union { guint64 __ll; \
590 guint32 __l[2]; } __r; \
591 if (__builtin_constant_p (val)) \
592 __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (val); \
593 else \
594 { \
595 union { guint64 __ll; \
596 guint32 __l[2]; } __w; \
597 __w.__ll = ((guint64) val); \
598 __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \
599 __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \
600 } \
601 __r.__ll; }))
602# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86 (val))
603# else /* !__i386__ */
604# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT(val))
605# endif
606#endif
607
608#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val))
609#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val))
610#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \
611 (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
612 (((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
613#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \
614 (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
615 (((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
616
617/* The G*_TO_?E() macros are defined in glibconfig.h.
618 * The transformation is symmetric, so the FROM just maps to the TO.
619 */
620#define GINT16_FROM_LE(val) (GINT16_TO_LE (val))
621#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val))
622#define GINT16_FROM_BE(val) (GINT16_TO_BE (val))
623#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
624#define GINT32_FROM_LE(val) (GINT32_TO_LE (val))
625#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val))
626#define GINT32_FROM_BE(val) (GINT32_TO_BE (val))
627#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val))
628
629#ifdef G_HAVE_GINT64
630#define GINT64_FROM_LE(val) (GINT64_TO_LE (val))
631#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val))
632#define GINT64_FROM_BE(val) (GINT64_TO_BE (val))
633#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val))
634#endif
635
636#define GLONG_FROM_LE(val) (GLONG_TO_LE (val))
637#define GULONG_FROM_LE(val) (GULONG_TO_LE (val))
638#define GLONG_FROM_BE(val) (GLONG_TO_BE (val))
639#define GULONG_FROM_BE(val) (GULONG_TO_BE (val))
640
641#define GINT_FROM_LE(val) (GINT_TO_LE (val))
642#define GUINT_FROM_LE(val) (GUINT_TO_LE (val))
643#define GINT_FROM_BE(val) (GINT_TO_BE (val))
644#define GUINT_FROM_BE(val) (GUINT_TO_BE (val))
645
646
647/* Portable versions of host-network order stuff
648 */
649#define g_ntohl(val) (GUINT32_FROM_BE (val))
650#define g_ntohs(val) (GUINT16_FROM_BE (val))
651#define g_htonl(val) (GUINT32_TO_BE (val))
652#define g_htons(val) (GUINT16_TO_BE (val))
653
654
655/* Glib version.
656 * we prefix variable declarations so they can
657 * properly get exported in windows dlls.
658 */
659#ifdef NATIVE_WIN32
660# ifdef GLIB_COMPILATION
661# define GUTILS_C_VAR __declspec(dllexport)
662# else /* !GLIB_COMPILATION */
663# define GUTILS_C_VAR extern __declspec(dllimport)
664# endif /* !GLIB_COMPILATION */
665#else /* !NATIVE_WIN32 */
666# define GUTILS_C_VAR extern
667#endif /* !NATIVE_WIN32 */
668
674
675#define GLIB_CHECK_VERSION(major,minor,micro) \
676 (GLIB_MAJOR_VERSION > (major) || \
677 (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \
678 (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \
679 GLIB_MICRO_VERSION >= (micro)))
680
681/* Forward declarations of glib types.
682 */
683typedef struct _GAllocator GAllocator;
684typedef struct _GArray GArray;
685typedef struct _GByteArray GByteArray;
686typedef struct _GCache GCache;
687typedef struct _GCompletion GCompletion;
688typedef struct _GData GData;
689typedef struct _GDebugKey GDebugKey;
690typedef struct _GHashTable GHashTable;
691typedef struct _GHook GHook;
692typedef struct _GHookList GHookList;
693typedef struct _GList GList;
694typedef struct _GMemChunk GMemChunk;
695typedef struct _GNode GNode;
696typedef struct _GPtrArray GPtrArray;
697typedef struct _GRelation GRelation;
698typedef struct _GScanner GScanner;
699typedef struct _GScannerConfig GScannerConfig;
700typedef struct _GSList GSList;
701typedef struct _GString GString;
702typedef struct _GStringChunk GStringChunk;
703typedef struct _GTimer GTimer;
704typedef struct _GTree GTree;
705typedef struct _GTuples GTuples;
706typedef union _GTokenValue GTokenValue;
707typedef struct _GIOChannel GIOChannel;
708
709typedef enum
710{
714 G_TRAVERSE_MASK = 0x03
716
717typedef enum
718{
724
725/* Log level shift offset for user defined
726 * log levels (0-7 are used by GLib).
727 */
728#define G_LOG_LEVEL_USER_SHIFT (8)
729
730/* Glib log levels and flags.
731 */
732typedef enum
733{
734 /* log flags */
737
738 /* GLib log levels */
739 G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
745
748
749/* GLib log levels that are considered fatal by default */
750#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
751
752
754typedef gpointer (*GCacheDupFunc) (gpointer value);
755typedef void (*GCacheDestroyFunc) (gpointer value);
757 gconstpointer b);
758typedef gchar* (*GCompletionFunc) (gpointer);
759typedef void (*GDestroyNotify) (gpointer data);
760typedef void (*GDataForeachFunc) (GQuark key_id,
761 gpointer data,
762 gpointer user_data);
763typedef void (*GFunc) (gpointer data,
764 gpointer user_data);
766typedef void (*GFreeFunc) (gpointer data);
767typedef void (*GHFunc) (gpointer key,
768 gpointer value,
769 gpointer user_data);
770typedef gboolean (*GHRFunc) (gpointer key,
771 gpointer value,
772 gpointer user_data);
773typedef gint (*GHookCompareFunc) (GHook *new_hook,
774 GHook *sibling);
775typedef gboolean (*GHookFindFunc) (GHook *hook,
776 gpointer data);
777typedef void (*GHookMarshaller) (GHook *hook,
778 gpointer data);
780 gpointer data);
781typedef void (*GHookFunc) (gpointer data);
783typedef void (*GHookFreeFunc) (GHookList *hook_list,
784 GHook *hook);
785typedef void (*GLogFunc) (const gchar *log_domain,
786 GLogLevelFlags log_level,
787 const gchar *message,
788 gpointer user_data);
790 gpointer data);
791typedef void (*GNodeForeachFunc) (GNode *node,
792 gpointer data);
793typedef gint (*GSearchFunc) (gpointer key,
794 gpointer data);
795typedef void (*GScannerMsgFunc) (GScanner *scanner,
796 gchar *message,
797 gint error);
799 gpointer value,
800 gpointer data);
801typedef void (*GVoidFunc) (void);
802
803
804struct _GList
805{
809};
810
812{
815};
816
818{
821};
822
824{
827};
828
830{
833};
834
836{
839};
840
842{
844};
845
847{
850};
851
852
853/* Doubly linked lists
854 */
858void g_list_free (GList *list);
859void g_list_free_1 (GList *list);
861 gpointer data);
863 gpointer data);
865 gpointer data,
866 gint position);
868 gpointer data,
869 GCompareFunc func);
871 GList *list2);
873 gpointer data);
875 GList *llink);
879 guint n);
881 gpointer data);
883 gpointer data,
884 GCompareFunc func);
886 GList *llink);
888 gpointer data);
893 GFunc func,
894 gpointer user_data);
896 GCompareFunc compare_func);
898 guint n);
899#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
900#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
901
902
903/* Singly linked lists
904 */
908void g_slist_free (GSList *list);
911 gpointer data);
913 gpointer data);
915 gpointer data,
916 gint position);
918 gpointer data,
919 GCompareFunc func);
921 GSList *list2);
923 gpointer data);
925 GSList *llink);
929 guint n);
931 gpointer data);
933 gpointer data,
934 GCompareFunc func);
936 GSList *llink);
938 gpointer data);
942 GFunc func,
943 gpointer user_data);
945 GCompareFunc compare_func);
947 guint n);
948#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
949
950
951/* Hash tables
952 */
954 GCompareFunc key_compare_func);
957 gpointer key,
958 gpointer value);
960 gconstpointer key);
962 gconstpointer key);
964 gconstpointer lookup_key,
965 gpointer *orig_key,
966 gpointer *value);
968void g_hash_table_thaw (GHashTable *hash_table);
970 GHFunc func,
971 gpointer user_data);
973 GHRFunc func,
974 gpointer user_data);
976
977
978/* Caches
979 */
981 GCacheDestroyFunc value_destroy_func,
982 GCacheDupFunc key_dup_func,
983 GCacheDestroyFunc key_destroy_func,
984 GHashFunc hash_key_func,
985 GHashFunc hash_value_func,
986 GCompareFunc key_compare_func);
989 gpointer key);
991 gpointer value);
993 GHFunc func,
994 gpointer user_data);
996 GHFunc func,
997 gpointer user_data);
998
999
1000/* Balanced binary trees
1001 */
1002GTree* g_tree_new (GCompareFunc key_compare_func);
1005 gpointer key,
1006 gpointer value);
1008 gpointer key);
1010 gpointer key);
1012 GTraverseFunc traverse_func,
1013 GTraverseType traverse_type,
1014 gpointer data);
1016 GSearchFunc search_func,
1017 gpointer data);
1020
1021
1022
1023/* N-way tree implementation
1024 */
1026{
1032};
1033
1034#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \
1035 ((GNode*) (node))->prev == NULL && \
1036 ((GNode*) (node))->next == NULL)
1037#define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL)
1038
1045 gint position,
1046 GNode *node);
1048 GNode *sibling,
1049 GNode *node);
1051 GNode *node);
1053 GTraverseFlags flags);
1056 GNode *descendant);
1059 GTraverseType order,
1060 GTraverseFlags flags,
1061 gpointer data);
1062
1063/* convenience macros */
1064#define g_node_append(parent, node) \
1065 g_node_insert_before ((parent), NULL, (node))
1066#define g_node_insert_data(parent, position, data) \
1067 g_node_insert ((parent), (position), g_node_new (data))
1068#define g_node_insert_data_before(parent, sibling, data) \
1069 g_node_insert_before ((parent), (sibling), g_node_new (data))
1070#define g_node_prepend_data(parent, data) \
1071 g_node_prepend ((parent), g_node_new (data))
1072#define g_node_append_data(parent, data) \
1073 g_node_insert_before ((parent), NULL, g_node_new (data))
1074
1075/* traversal function, assumes that `node' is root
1076 * (only traverses `node' and its subtree).
1077 * this function is just a high level interface to
1078 * low level traversal functions, optimized for speed.
1079 */
1081 GTraverseType order,
1082 GTraverseFlags flags,
1083 gint max_depth,
1084 GNodeTraverseFunc func,
1085 gpointer data);
1086
1087/* return the maximum tree height starting with `node', this is an expensive
1088 * operation, since we need to visit all nodes. this could be shortened by
1089 * adding `guint height' to struct _GNode, but then again, this is not very
1090 * often needed, and would make g_node_insert() more time consuming.
1091 */
1093
1095 GTraverseFlags flags,
1096 GNodeForeachFunc func,
1097 gpointer data);
1101 guint n);
1104 GTraverseFlags flags,
1105 gpointer data);
1107 GNode *child);
1109 gpointer data);
1110
1113
1114#define g_node_prev_sibling(node) ((node) ? \
1115 ((GNode*) (node))->prev : NULL)
1116#define g_node_next_sibling(node) ((node) ? \
1117 ((GNode*) (node))->next : NULL)
1118#define g_node_first_child(node) ((node) ? \
1119 ((GNode*) (node))->children : NULL)
1120
1121
1122/* Callback maintenance functions
1123 */
1124#define G_HOOK_FLAG_USER_SHIFT (4)
1125typedef enum
1126{
1129 G_HOOK_FLAG_MASK = 0x0f
1131
1132#define G_HOOK_DEFERRED_DESTROY ((GHookFreeFunc) 0x01)
1133
1135{
1141 GHookFreeFunc hook_free; /* virtual function */
1142 GHookFreeFunc hook_destroy; /* virtual function */
1143};
1144
1146{
1155};
1156
1157#define G_HOOK_ACTIVE(hook) ((((GHook*) hook)->flags & \
1158 G_HOOK_FLAG_ACTIVE) != 0)
1159#define G_HOOK_IN_CALL(hook) ((((GHook*) hook)->flags & \
1160 G_HOOK_FLAG_IN_CALL) != 0)
1161#define G_HOOK_IS_VALID(hook) (((GHook*) hook)->hook_id != 0 && \
1162 G_HOOK_ACTIVE (hook))
1163#define G_HOOK_IS_UNLINKED(hook) (((GHook*) hook)->next == NULL && \
1164 ((GHook*) hook)->prev == NULL && \
1165 ((GHook*) hook)->hook_id == 0 && \
1166 ((GHook*) hook)->ref_count == 0)
1167
1169 guint hook_size);
1172void g_hook_free (GHookList *hook_list,
1173 GHook *hook);
1174void g_hook_ref (GHookList *hook_list,
1175 GHook *hook);
1176void g_hook_unref (GHookList *hook_list,
1177 GHook *hook);
1179 guint hook_id);
1181 GHook *hook);
1182void g_hook_prepend (GHookList *hook_list,
1183 GHook *hook);
1185 GHook *sibling,
1186 GHook *hook);
1188 GHook *hook,
1189 GHookCompareFunc func);
1191 guint hook_id);
1193 gboolean need_valids,
1194 GHookFindFunc func,
1195 gpointer data);
1197 gboolean need_valids,
1198 gpointer data);
1200 gboolean need_valids,
1201 gpointer func);
1203 gboolean need_valids,
1204 gpointer func,
1205 gpointer data);
1206/* return the first valid hook, and increment its reference count */
1208 gboolean may_be_in_call);
1209/* return the next valid hook with incremented reference count, and
1210 * decrement the reference count of the original hook
1211 */
1213 GHook *hook,
1214 gboolean may_be_in_call);
1215
1216/* GHookCompareFunc implementation to insert hooks sorted by their id */
1218 GHook *sibling);
1219
1220/* convenience macros */
1221#define g_hook_append( hook_list, hook ) \
1222 g_hook_insert_before ((hook_list), NULL, (hook))
1223
1224/* invoke all valid hooks with the (*GHookFunc) signature.
1225 */
1227 gboolean may_recurse);
1228/* invoke all valid hooks with the (*GHookCheckFunc) signature,
1229 * and destroy the hook if FALSE is returned.
1230 */
1232 gboolean may_recurse);
1233/* invoke a marshaller on all valid hooks.
1234 */
1236 gboolean may_recurse,
1237 GHookMarshaller marshaller,
1238 gpointer data);
1240 gboolean may_recurse,
1241 GHookCheckMarshaller marshaller,
1242 gpointer data);
1243
1244
1245/* Fatal error handlers.
1246 * g_on_error_query() will prompt the user to either
1247 * [E]xit, [H]alt, [P]roceed or show [S]tack trace.
1248 * g_on_error_stack_trace() invokes gdb, which attaches to the current
1249 * process and shows a stack trace.
1250 * These function may cause different actions on non-unix platforms.
1251 * The prg_name arg is required by gdb to find the executable, if it is
1252 * passed as NULL, g_on_error_query() will try g_get_prgname().
1253 */
1254void g_on_error_query (const gchar *prg_name);
1255void g_on_error_stack_trace (const gchar *prg_name);
1256
1257
1258/* Logging mechanism
1259 */
1260extern const gchar *g_log_domain_glib;
1261guint g_log_set_handler (const gchar *log_domain,
1262 GLogLevelFlags log_levels,
1263 GLogFunc log_func,
1264 gpointer user_data);
1265void g_log_remove_handler (const gchar *log_domain,
1266 guint handler_id);
1267void g_log_default_handler (const gchar *log_domain,
1268 GLogLevelFlags log_level,
1269 const gchar *message,
1270 gpointer unused_data);
1271void g_log (const gchar *log_domain,
1272 GLogLevelFlags log_level,
1273 const gchar *format,
1274 ...) G_GNUC_PRINTF (3, 4);
1275void g_logv (const gchar *log_domain,
1276 GLogLevelFlags log_level,
1277 const gchar *format,
1278 va_list args);
1280 GLogLevelFlags fatal_mask);
1282#ifndef G_LOG_DOMAIN
1283#define G_LOG_DOMAIN ((gchar*) 0)
1284#endif /* G_LOG_DOMAIN */
1285
1286#define g_error(format, args...) g_log (G_LOG_DOMAIN, \
1287 G_LOG_LEVEL_ERROR, \
1288 format, ##args)
1289#define g_message(format, args...) g_log (G_LOG_DOMAIN, \
1290 G_LOG_LEVEL_MESSAGE, \
1291 format, ##args)
1292#define g_warning printf
1293
1294
1295
1296/* Memory allocation and debugging
1297 */
1298#define g_malloc(size) ((gpointer)malloc(size))
1299#define g_malloc0(size) ((gpointer)calloc(size, 1))
1300#define g_realloc(mem,size) ((gpointer)realloc(mem, size))
1301#define g_free(mem) free(mem)
1302
1303
1304void g_mem_profile (void);
1306
1307
1308/* String utility functions that modify a string argument or
1309 * return a constant string that must not be freed.
1310 */
1311#define G_STR_DELIMITERS "_-|> <."
1313 const gchar *delimiters,
1314 gchar new_delimiter);
1316 gchar **endptr);
1320 const gchar *s2);
1322 const gchar *s2,
1323 guint n);
1324void g_strdown (gchar *string);
1325void g_strup (gchar *string);
1326void g_strreverse (gchar *string);
1327/* removes leading spaces */
1329/* removes trailing spaces */
1331/* removes leading & trailing spaces */
1332#define g_strstrip( string ) g_strchomp (g_strchug (string))
1333
1334/* String utility functions that return a newly allocated string which
1335 * ought to be freed from the caller at some point.
1336 */
1337gchar* g_strdup (const gchar *str);
1339 ...) G_GNUC_PRINTF (1, 2);
1341 va_list args);
1343 guint n);
1345 gchar fill_char);
1347 ...); /* NULL terminated */
1349 ...); /* NULL terminated */
1352 guint byte_size);
1353
1354/* NULL terminated string arrays.
1355 * g_strsplit() splits up string into max_tokens tokens at delim and
1356 * returns a newly allocated string array.
1357 * g_strjoinv() concatenates all of str_array's strings, sliding in an
1358 * optional separator, the returned string is newly allocated.
1359 * g_strfreev() frees the array itself and all of its strings.
1360 */
1362 const gchar *delimiter,
1363 gint max_tokens);
1365 gchar **str_array);
1366void g_strfreev (gchar **str_array);
1367
1368
1369
1370/* calculate a string size, guarranteed to fit format + args.
1371 */
1373 va_list args);
1374
1375
1376/* Retrive static string info
1377 */
1383void g_set_prgname (const gchar *prgname);
1384
1385
1386/* Miscellaneous utility functions
1387 */
1389 GDebugKey *keys,
1390 guint nkeys);
1392 gulong n,
1393 gchar const *format,
1394 ...) G_GNUC_PRINTF (3, 4);
1396 gulong n,
1397 gchar const *format,
1398 va_list args);
1400/* Check if a file name is an absolute path */
1402/* In case of absolute paths, skip the root part */
1404
1405/* strings are newly allocated with g_malloc() */
1409
1410
1411/* we use a GLib function as a replacement for ATEXIT, so
1412 * the programmer is not required to check the return value
1413 * (if there is any in the implementation) and doesn't encounter
1414 * missing include files.
1415 */
1417
1418
1419/* Bit tests
1420 */
1422 gint nth_bit);
1423#ifdef G_CAN_INLINE
1426 gint nth_bit)
1427{
1428 do
1429 {
1430 nth_bit++;
1431 if (mask & (1 << (guint) nth_bit))
1432 return nth_bit;
1433 }
1434 while (nth_bit < 32);
1435 return -1;
1436}
1437#endif /* G_CAN_INLINE */
1438
1440 gint nth_bit);
1441#ifdef G_CAN_INLINE
1444 gint nth_bit)
1445{
1446 if (nth_bit < 0)
1447 nth_bit = 32;
1448 do
1449 {
1450 nth_bit--;
1451 if (mask & (1 << (guint) nth_bit))
1452 return nth_bit;
1453 }
1454 while (nth_bit > 0);
1455 return -1;
1456}
1457#endif /* G_CAN_INLINE */
1458
1460#ifdef G_CAN_INLINE
1462g_bit_storage (guint number)
1463{
1464 register guint n_bits = 0;
1465
1466 do
1467 {
1468 n_bits++;
1469 number >>= 1;
1470 }
1471 while (number);
1472 return n_bits;
1473}
1474#endif /* G_CAN_INLINE */
1475
1476/* String Chunks
1477 */
1481 const gchar *string);
1483 const gchar *string);
1484
1485
1486/* Strings
1487 */
1491 gint free_segment);
1493 const gchar *rval);
1495 gint len);
1497 const gchar *val);
1499 gchar c);
1501 const gchar *val);
1503 gchar c);
1505 gint pos,
1506 const gchar *val);
1508 gint pos,
1509 gchar c);
1511 gint pos,
1512 gint len);
1516 const gchar *format,
1517 ...) G_GNUC_PRINTF (2, 3);
1519 const gchar *format,
1520 ...) G_GNUC_PRINTF (2, 3);
1521
1522
1523/* Resizable arrays, remove fills any cleared spot and shortens the
1524 * array, while preserving the order. remove_fast will distort the
1525 * order by moving the last element to the position of the removed
1526 */
1527
1528#define g_array_append_val(a,v) pmidi_array_append_vals (a, &v, 1)
1529#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &v, 1)
1530#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)
1531#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
1532
1534 gboolean clear,
1535 guint element_size);
1537 gboolean free_segment);
1539 gconstpointer data,
1540 guint len);
1542 gconstpointer data,
1543 guint len);
1545 guint index,
1546 gconstpointer data,
1547 guint len);
1549 guint length);
1551 guint index);
1553 guint index);
1554
1555/* Resizable pointer array. This interface is much less complicated
1556 * than the above. Add appends appends a pointer. Remove fills any
1557 * cleared spot and shortens the array. remove_fast will again distort
1558 * order.
1559 */
1560#define g_ptr_array_index(array,index) (array->pdata)[index]
1563 gboolean free_seg);
1565 gint length);
1567 guint index);
1569 guint index);
1571 gpointer data);
1573 gpointer data);
1575 gpointer data);
1576
1577/* Byte arrays, an array of guint8. Implemented as a GArray,
1578 * but type-safe.
1579 */
1580
1583 gboolean free_segment);
1585 const guint8 *data,
1586 guint len);
1588 const guint8 *data,
1589 guint len);
1591 guint length);
1593 guint index);
1595 guint index);
1596
1597#ifdef __cplusplus
1598}
1599#endif /* __cplusplus */
1600
1601#endif /* __G_LIB_H__ */
G_INLINE_FUNC gint g_bit_nth_lsf(guint32 mask, gint nth_bit)
GNode * g_node_get_root(GNode *node)
gpointer g_hash_table_lookup(GHashTable *hash_table, gconstpointer key)
GList * g_list_copy(GList *list)
void g_node_push_allocator(GAllocator *allocator)
void g_on_error_query(const gchar *prg_name)
void g_hash_table_freeze(GHashTable *hash_table)
gchar gchar * g_strdup_vprintf(const gchar *format, va_list args)
GString * g_string_insert(GString *string, gint pos, const gchar *val)
struct _GCache GCache
Definition: glib.h:686
GList * g_list_insert(GList *list, gpointer data, gint position)
gint32 gssize
Definition: glib.h:495
void g_node_traverse(GNode *root, GTraverseType order, GTraverseFlags flags, gint max_depth, GNodeTraverseFunc func, gpointer data)
GUTILS_C_VAR const guint glib_binary_age
Definition: glib.h:673
gint gint g_vsnprintf(gchar *string, gulong n, gchar const *format, va_list args)
struct _GTree GTree
Definition: glib.h:704
void(* GVoidFunc)(void)
Definition: glib.h:801
GString * g_string_assign(GString *lval, const gchar *rval)
gboolean g_hash_table_lookup_extended(GHashTable *hash_table, gconstpointer lookup_key, gpointer *orig_key, gpointer *value)
gint g_list_position(GList *list, GList *llink)
void g_node_unlink(GNode *node)
GSList * g_slist_find(GSList *list, gpointer data)
struct _GTimer GTimer
Definition: glib.h:703
GList * g_list_sort(GList *list, GCompareFunc compare_func)
unsigned int guint32
Definition: glib.h:76
gchar * g_getenv(const gchar *variable)
GTree * g_tree_new(GCompareFunc key_compare_func)
void g_hook_unref(GHookList *hook_list, GHook *hook)
gboolean(* GNodeTraverseFunc)(GNode *node, gpointer data)
Definition: glib.h:789
gboolean(* GHookCheckMarshaller)(GHook *hook, gpointer data)
Definition: glib.h:779
gchar * g_string_chunk_insert_const(GStringChunk *chunk, const gchar *string)
void(* GHookMarshaller)(GHook *hook, gpointer data)
Definition: glib.h:777
GUTILS_C_VAR const guint glib_interface_age
Definition: glib.h:672
guint g_node_n_children(GNode *node)
gchar * g_strdup(const gchar *str)
gchar * g_strchomp(gchar *string)
GTraverseFlags
Definition: glib.h:710
@ G_TRAVERSE_ALL
Definition: glib.h:713
@ G_TRAVERSE_MASK
Definition: glib.h:714
@ G_TRAVERSE_LEAFS
Definition: glib.h:711
@ G_TRAVERSE_NON_LEAFS
Definition: glib.h:712
guint g_hash_table_size(GHashTable *hash_table)
void g_cache_remove(GCache *cache, gpointer value)
void g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value)
GList * g_list_find_custom(GList *list, gpointer data, GCompareFunc func)
gboolean g_hook_destroy(GHookList *hook_list, guint hook_id)
signed short gint16
Definition: glib.h:73
gint g_hook_compare_ids(GHook *new_hook, GHook *sibling)
gchar * g_path_skip_root(gchar *file_name)
void g_node_pop_allocator(void)
GByteArray * g_byte_array_append(GByteArray *array, const guint8 *data, guint len)
gpointer(* GCacheNewFunc)(gpointer key)
Definition: glib.h:753
GCache * g_cache_new(GCacheNewFunc value_new_func, GCacheDestroyFunc value_destroy_func, GCacheDupFunc key_dup_func, GCacheDestroyFunc key_destroy_func, GHashFunc hash_key_func, GHashFunc hash_value_func, GCompareFunc key_compare_func)
GString * g_string_append_c(GString *string, gchar c)
GSList * g_slist_insert_sorted(GSList *list, gpointer data, GCompareFunc func)
void g_hash_table_remove(GHashTable *hash_table, gconstpointer key)
void g_slist_free_1(GSList *list)
void g_tree_traverse(GTree *tree, GTraverseFunc traverse_func, GTraverseType traverse_type, gpointer data)
gchar * g_get_tmp_dir(void)
void g_hash_table_thaw(GHashTable *hash_table)
void pmidi_ptr_array_free(GPtrArray *array, gboolean free_seg)
void g_tree_insert(GTree *tree, gpointer key, gpointer value)
unsigned short guint16
Definition: glib.h:74
gchar * g_get_user_name(void)
struct _GRelation GRelation
Definition: glib.h:697
GList * g_list_find(GList *list, gpointer data)
GSList * g_slist_nth(GSList *list, guint n)
gint gboolean
Definition: glib.h:470
GStringChunk * g_string_chunk_new(gint size)
gint(* GTraverseFunc)(gpointer key, gpointer value, gpointer data)
Definition: glib.h:798
GString * g_string_new(const gchar *init)
guint(* GHashFunc)(gconstpointer key)
Definition: glib.h:765
GSList * g_slist_concat(GSList *list1, GSList *list2)
gchar ** g_strsplit(const gchar *string, const gchar *delimiter, gint max_tokens)
gchar * g_get_real_name(void)
void(* GScannerMsgFunc)(GScanner *scanner, gchar *message, gint error)
Definition: glib.h:795
GSList * g_slist_copy(GSList *list)
gchar * g_basename(const gchar *file_name)
GList * g_list_remove(GList *list, gpointer data)
GHook * g_hook_find(GHookList *hook_list, gboolean need_valids, GHookFindFunc func, gpointer data)
void g_hook_insert_sorted(GHookList *hook_list, GHook *hook, GHookCompareFunc func)
gchar * g_strjoin(const gchar *separator,...)
GSList * g_slist_remove(GSList *list, gpointer data)
void g_node_children_foreach(GNode *node, GTraverseFlags flags, GNodeForeachFunc func, gpointer data)
GNode * g_node_new(gpointer data)
struct _GScannerConfig GScannerConfig
Definition: glib.h:699
gint(* GSearchFunc)(gpointer key, gpointer data)
Definition: glib.h:793
char gchar
Definition: glib.h:466
GSList * g_slist_last(GSList *list)
GNode * g_node_last_child(GNode *node)
gchar * g_strdup_printf(const gchar *format,...) G_GNUC_PRINTF(1
unsigned long gulong
Definition: glib.h:474
guint32 GQuark
Definition: glib.h:497
void g_tree_destroy(GTree *tree)
guint g_parse_debug_string(const gchar *string, GDebugKey *keys, guint nkeys)
GArray * pmidi_array_append_vals(GArray *array, gconstpointer data, guint len)
GList * g_list_alloc(void)
gboolean g_node_is_ancestor(GNode *node, GNode *descendant)
GString * g_string_down(GString *string)
unsigned char guint8
Definition: glib.h:72
guint g_slist_length(GSList *list)
float gfloat
Definition: glib.h:477
GString * g_string_truncate(GString *string, gint len)
void g_cache_destroy(GCache *cache)
void g_hook_list_invoke_check(GHookList *hook_list, gboolean may_recurse)
gchar * g_strnfill(guint length, gchar fill_char)
unsigned char guchar
Definition: glib.h:472
gchar * g_get_home_dir(void)
guint g_hash_table_foreach_remove(GHashTable *hash_table, GHRFunc func, gpointer user_data)
void g_strup(gchar *string)
void(* GNodeForeachFunc)(GNode *node, gpointer data)
Definition: glib.h:791
GNode * g_node_first_sibling(GNode *node)
GNode * g_node_find_child(GNode *node, GTraverseFlags flags, gpointer data)
gpointer g_tree_search(GTree *tree, GSearchFunc search_func, gpointer data)
void g_log(const gchar *log_domain, GLogLevelFlags log_level, const gchar *format,...) G_GNUC_PRINTF(3
gchar * g_strescape(gchar *string)
GList * g_list_nth(GList *list, guint n)
GList * g_list_insert_sorted(GList *list, gpointer data, GCompareFunc func)
GArray * g_array_remove_index_fast(GArray *array, guint index)
GLogLevelFlags g_log_set_fatal_mask(const gchar *log_domain, GLogLevelFlags fatal_mask)
void g_hash_table_foreach(GHashTable *hash_table, GHFunc func, gpointer user_data)
GByteArray * g_byte_array_prepend(GByteArray *array, const guint8 *data, guint len)
GString * g_string_insert_c(GString *string, gint pos, gchar c)
#define G_GNUC_PRINTF(format_idx, arg_idx)
Definition: glib.h:262
GHook * g_hook_first_valid(GHookList *hook_list, gboolean may_be_in_call)
struct _GData GData
Definition: glib.h:688
struct _GIOChannel GIOChannel
Definition: glib.h:707
guint32 gsize
Definition: glib.h:496
GList * g_list_first(GList *list)
gint g_list_index(GList *list, gpointer data)
void g_hook_insert_before(GHookList *hook_list, GHook *sibling, GHook *hook)
gint32 GTime
Definition: glib.h:498
GList * g_list_concat(GList *list1, GList *list2)
GString * g_string_prepend(GString *string, const gchar *val)
void g_mem_profile(void)
void g_hook_list_marshal_check(GHookList *hook_list, gboolean may_recurse, GHookCheckMarshaller marshaller, gpointer data)
GString * g_string_sized_new(guint dfl_size)
void g_list_free_1(GList *list)
void g_slist_free(GSList *list)
void g_string_sprintf(GString *string, const gchar *format,...) G_GNUC_PRINTF(2
gchar * g_get_prgname(void)
GHashTable * g_hash_table_new(GHashFunc hash_func, GCompareFunc key_compare_func)
void g_atexit(GVoidFunc func)
void(* GHookFreeFunc)(GHookList *hook_list, GHook *hook)
Definition: glib.h:783
gpointer(* GCacheDupFunc)(gpointer value)
Definition: glib.h:754
#define GUTILS_C_VAR
Definition: glib.h:666
GByteArray * g_byte_array_remove_index_fast(GByteArray *array, guint index)
GString * g_string_up(GString *string)
void void g_string_sprintfa(GString *string, const gchar *format,...) G_GNUC_PRINTF(2
gboolean g_ptr_array_remove_fast(GPtrArray *array, gpointer data)
void * gpointer
Definition: glib.h:491
void g_tree_remove(GTree *tree, gpointer key)
signed char gint8
Definition: glib.h:71
void g_hook_destroy_link(GHookList *hook_list, GHook *hook)
void g_list_free(GList *list)
GNode * g_node_nth_child(GNode *node, guint n)
void g_slist_push_allocator(GAllocator *allocator)
gchar * g_string_chunk_insert(GStringChunk *chunk, const gchar *string)
guint g_list_length(GList *list)
gint(* GCompareFunc)(gconstpointer a, gconstpointer b)
Definition: glib.h:756
GHook * g_hook_alloc(GHookList *hook_list)
gpointer g_list_nth_data(GList *list, guint n)
GByteArray * g_byte_array_remove_index(GByteArray *array, guint index)
void g_hook_list_init(GHookList *hook_list, guint hook_size)
void g_list_foreach(GList *list, GFunc func, gpointer user_data)
void g_cache_value_foreach(GCache *cache, GHFunc func, gpointer user_data)
void g_hook_ref(GHookList *hook_list, GHook *hook)
GNode * g_node_insert(GNode *parent, gint position, GNode *node)
GList * g_list_append(GList *list, gpointer data)
int gint
Definition: glib.h:469
guint g_log_set_handler(const gchar *log_domain, GLogLevelFlags log_levels, GLogFunc log_func, gpointer user_data)
void(* GHFunc)(gpointer key, gpointer value, gpointer user_data)
Definition: glib.h:767
gboolean g_path_is_absolute(const gchar *file_name)
guint g_node_max_height(GNode *root)
void g_hook_list_marshal(GHookList *hook_list, gboolean may_recurse, GHookMarshaller marshaller, gpointer data)
const void * gconstpointer
Definition: glib.h:492
long glong
Definition: glib.h:468
GHookFlagMask
Definition: glib.h:1126
@ G_HOOK_FLAG_IN_CALL
Definition: glib.h:1128
@ G_HOOK_FLAG_ACTIVE
Definition: glib.h:1127
@ G_HOOK_FLAG_MASK
Definition: glib.h:1129
gdouble g_strtod(const gchar *nptr, gchar **endptr)
gchar * g_strndup(const gchar *str, guint n)
GSList * g_slist_prepend(GSList *list, gpointer data)
struct _GCompletion GCompletion
Definition: glib.h:687
signed int gint32
Definition: glib.h:75
GHook * g_hook_find_func_data(GHookList *hook_list, gboolean need_valids, gpointer func, gpointer data)
GNode * g_node_find(GNode *root, GTraverseType order, GTraverseFlags flags, gpointer data)
GByteArray * g_byte_array_set_size(GByteArray *array, guint length)
GHook * g_hook_get(GHookList *hook_list, guint hook_id)
gint g_strncasecmp(const gchar *s1, const gchar *s2, guint n)
short gshort
Definition: glib.h:467
gint g_slist_position(GSList *list, GSList *llink)
void g_byte_array_free(GByteArray *array, gboolean free_segment)
gpointer g_cache_insert(GCache *cache, gpointer key)
GUTILS_C_VAR const guint glib_major_version
Definition: glib.h:669
void g_on_error_stack_trace(const gchar *prg_name)
GNode * g_node_prepend(GNode *parent, GNode *node)
GString * g_string_append(GString *string, const gchar *val)
gpointer g_slist_nth_data(GSList *list, guint n)
void pmidi_ptr_array_add(GPtrArray *array, gpointer data)
gchar * g_strsignal(gint signum)
gchar * g_get_current_dir(void)
G_INLINE_FUNC gint g_bit_nth_msf(guint32 mask, gint nth_bit)
gchar * g_strconcat(const gchar *string1,...)
void void g_logv(const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
GArray * g_array_remove_index(GArray *array, guint index)
GList * g_list_prepend(GList *list, gpointer data)
guint g_node_n_nodes(GNode *root, GTraverseFlags flags)
gpointer pmidi_ptr_array_remove_index_fast(GPtrArray *array, guint index)
gchar * g_dirname(const gchar *file_name)
gint g_node_child_position(GNode *node, GNode *child)
GLogLevelFlags
Definition: glib.h:733
@ G_LOG_LEVEL_CRITICAL
Definition: glib.h:740
@ G_LOG_LEVEL_INFO
Definition: glib.h:743
@ G_LOG_LEVEL_MESSAGE
Definition: glib.h:742
@ G_LOG_LEVEL_DEBUG
Definition: glib.h:744
@ G_LOG_LEVEL_ERROR
Definition: glib.h:739
@ G_LOG_FLAG_RECURSION
Definition: glib.h:735
@ G_LOG_LEVEL_MASK
Definition: glib.h:746
@ G_LOG_LEVEL_WARNING
Definition: glib.h:741
@ G_LOG_FLAG_FATAL
Definition: glib.h:736
struct _GHashTable GHashTable
Definition: glib.h:690
struct _GMemChunk GMemChunk
Definition: glib.h:694
GArray * g_array_insert_vals(GArray *array, guint index, gconstpointer data, guint len)
void(* GLogFunc)(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition: glib.h:785
gint g_strcasecmp(const gchar *s1, const gchar *s2)
GSList * g_slist_remove_link(GSList *list, GSList *llink)
double gdouble
Definition: glib.h:478
void(* GFunc)(gpointer data, gpointer user_data)
Definition: glib.h:763
GList * g_list_reverse(GList *list)
void g_cache_key_foreach(GCache *cache, GHFunc func, gpointer user_data)
GByteArray * g_byte_array_new(void)
void g_strreverse(gchar *string)
GHook * g_hook_next_valid(GHookList *hook_list, GHook *hook, gboolean may_be_in_call)
void g_hook_list_clear(GHookList *hook_list)
void g_hook_prepend(GHookList *hook_list, GHook *hook)
GLogLevelFlags g_log_set_always_fatal(GLogLevelFlags fatal_mask)
void pmidi_array_free(GArray *array, gboolean free_segment)
void g_ptr_array_set_size(GPtrArray *array, gint length)
void(* GDataForeachFunc)(GQuark key_id, gpointer data, gpointer user_data)
Definition: glib.h:760
GString * g_string_prepend_c(GString *string, gchar c)
void g_hash_table_destroy(GHashTable *hash_table)
GList * g_list_last(GList *list)
gchar * g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delimiter)
GSList * g_slist_sort(GSList *list, GCompareFunc compare_func)
void(* GHookFunc)(gpointer data)
Definition: glib.h:781
void g_set_prgname(const gchar *prgname)
void g_slist_foreach(GSList *list, GFunc func, gpointer user_data)
void g_hook_free(GHookList *hook_list, GHook *hook)
void g_hook_list_invoke(GHookList *hook_list, gboolean may_recurse)
void g_string_chunk_free(GStringChunk *chunk)
unsigned short gushort
Definition: glib.h:473
gchar * g_strjoinv(const gchar *separator, gchar **str_array)
gchar * g_strerror(gint errnum)
GArray * pmidi_array_new(gboolean zero_terminated, gboolean clear, guint element_size)
GTraverseType
Definition: glib.h:718
@ G_POST_ORDER
Definition: glib.h:721
@ G_IN_ORDER
Definition: glib.h:719
@ G_LEVEL_ORDER
Definition: glib.h:722
@ G_PRE_ORDER
Definition: glib.h:720
GString * g_string_erase(GString *string, gint pos, gint len)
guint g_printf_string_upper_bound(const gchar *format, va_list args)
gint g_slist_index(GSList *list, gpointer data)
void(* GDestroyNotify)(gpointer data)
Definition: glib.h:759
GNode * g_node_last_sibling(GNode *node)
GUTILS_C_VAR const guint glib_minor_version
Definition: glib.h:670
gpointer g_memdup(gconstpointer mem, guint byte_size)
struct _GStringChunk GStringChunk
Definition: glib.h:702
GSList * g_slist_insert(GSList *list, gpointer data, gint position)
void(* GCacheDestroyFunc)(gpointer value)
Definition: glib.h:755
GSList * g_slist_find_custom(GSList *list, gpointer data, GCompareFunc func)
union _GTokenValue GTokenValue
Definition: glib.h:706
GArray * g_array_prepend_vals(GArray *array, gconstpointer data, guint len)
gint g_snprintf(gchar *string, gulong n, gchar const *format,...) G_GNUC_PRINTF(3
GPtrArray * pmidi_ptr_array_new(void)
gboolean(* GHookFindFunc)(GHook *hook, gpointer data)
Definition: glib.h:775
void g_strfreev(gchar **str_array)
gpointer g_tree_lookup(GTree *tree, gpointer key)
void g_log_default_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
void g_slist_pop_allocator(void)
void(* GFreeFunc)(gpointer data)
Definition: glib.h:766
GNode * g_node_insert_before(GNode *parent, GNode *sibling, GNode *node)
GHook * g_hook_find_func(GHookList *hook_list, gboolean need_valids, gpointer func)
gpointer g_ptr_array_remove_index(GPtrArray *array, guint index)
GSList * g_slist_append(GSList *list, gpointer data)
GSList * g_slist_alloc(void)
GList * g_list_remove_link(GList *list, GList *llink)
struct _GAllocator GAllocator
Definition: glib.h:683
void g_string_free(GString *string, gint free_segment)
void g_strdown(gchar *string)
unsigned int guint
Definition: glib.h:475
gint(* GHookCompareFunc)(GHook *new_hook, GHook *sibling)
Definition: glib.h:773
GHook * g_hook_find_data(GHookList *hook_list, gboolean need_valids, gpointer data)
G_INLINE_FUNC guint g_bit_storage(guint number)
#define G_INLINE_FUNC
Definition: glib.h:215
GArray * g_array_set_size(GArray *array, guint length)
gboolean g_ptr_array_remove(GPtrArray *array, gpointer data)
void g_mem_check(gpointer mem)
void g_log_remove_handler(const gchar *log_domain, guint handler_id)
const gchar * g_log_domain_glib
guint g_node_depth(GNode *node)
GSList * g_slist_reverse(GSList *list)
gboolean(* GHRFunc)(gpointer key, gpointer value, gpointer user_data)
Definition: glib.h:770
gint g_node_child_index(GNode *node, gpointer data)
gchar * g_strchug(gchar *string)
GUTILS_C_VAR const guint glib_micro_version
Definition: glib.h:671
void g_list_pop_allocator(void)
gint g_tree_nnodes(GTree *tree)
gint g_tree_height(GTree *tree)
void g_node_destroy(GNode *root)
void g_node_reverse_children(GNode *node)
void g_list_push_allocator(GAllocator *allocator)
struct _GScanner GScanner
Definition: glib.h:698
gboolean(* GHookCheckFunc)(gpointer data)
Definition: glib.h:782
Definition: glib.h:824
gchar * data
Definition: glib.h:825
guint len
Definition: glib.h:826
Definition: glib.h:830
guint8 * data
Definition: glib.h:831
guint len
Definition: glib.h:832
Definition: glib.h:847
guint value
Definition: glib.h:849
gchar * key
Definition: glib.h:848
Definition: glib.h:1135
guint seq_id
Definition: glib.h:1136
GHookFreeFunc hook_free
Definition: glib.h:1141
GHook * hooks
Definition: glib.h:1139
guint is_setup
Definition: glib.h:1138
guint hook_size
Definition: glib.h:1137
GHookFreeFunc hook_destroy
Definition: glib.h:1142
GMemChunk * hook_memchunk
Definition: glib.h:1140
Definition: glib.h:1146
GHook * prev
Definition: glib.h:1149
gpointer func
Definition: glib.h:1153
guint hook_id
Definition: glib.h:1151
guint ref_count
Definition: glib.h:1150
guint flags
Definition: glib.h:1152
gpointer data
Definition: glib.h:1147
GDestroyNotify destroy
Definition: glib.h:1154
GHook * next
Definition: glib.h:1148
Definition: glib.h:805
GList * prev
Definition: glib.h:808
GList * next
Definition: glib.h:807
gpointer data
Definition: glib.h:806
Definition: glib.h:1026
GNode * parent
Definition: glib.h:1030
GNode * prev
Definition: glib.h:1029
GNode * next
Definition: glib.h:1028
gpointer data
Definition: glib.h:1027
GNode * children
Definition: glib.h:1031
Definition: glib.h:836
gpointer * pdata
Definition: glib.h:837
guint len
Definition: glib.h:838
Definition: glib.h:812
GSList * next
Definition: glib.h:814
gpointer data
Definition: glib.h:813
Definition: glib.h:818
gchar * str
Definition: glib.h:819
gint len
Definition: glib.h:820
Definition: glib.h:842
guint len
Definition: glib.h:843
#define const
Definition: zconf.h:124