1 /************************************************************/
2 /* THIS FILE IS GENERATED DO NOT EDIT */
3 /************************************************************/
9 * Calculates the absolute value of @a.
10 * The absolute value is simply the number with any negative sign taken away.
14 * - ABS(10) is also 10.
16 * Returns: the absolute value of @a.
22 * @x: the value to clamp
23 * @low: the minimum value allowed
24 * @high: the maximum value allowed
26 * Ensures that @x is between the limits set by @low and @high. If @low is
27 * greater than @high the result is undefined.
30 * - CLAMP(5, 10, 15) is 10.
31 * - CLAMP(15, 5, 10) is 10.
32 * - CLAMP(20, 15, 25) is 20.
34 * Returns: the value of @x clamped to the range between @low and @high
40 * @Context: a message context, must be a string literal
41 * @String: a message id, must be a string literal
43 * Uses gettext to get the translation for @String. @Context is
44 * used as a context. This is mainly useful for short strings which
45 * may need different translations, depending on the context in which
48 * label1 = C_("Navigation", "Back");
49 * label2 = C_("Body part", "Back");
52 * <note><para>If you are using the C_() macro, you need to make sure
53 * that you pass <option>--keyword=C_:1c,2</option> to xgettext when
54 * extracting messages. Note that this only works with GNU
55 * gettext >= 0.15.</para></note>
57 * Returns: the translated message
65 * Defines the %FALSE value for the #gboolean type.
71 * @data: a pointer to the element data. The data may be moved as
72 * elements are added to the #GArray.
73 * @len: the number of elements in the #GArray not including the
74 * possible terminating zero element.
76 * Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
83 * The GAsyncQueue struct is an opaque data structure which represents
84 * an asynchronous queue. It should only be accessed through the
85 * <function>g_async_queue_*</function> functions.
91 * @data: a pointer to the element data. The data may be moved as
92 * elements are added to the #GByteArray.
93 * @len: the number of elements in the #GByteArray.
95 * The <structname>GByteArray</structname> struct allows access to the
96 * public fields of a <structname>GByteArray</structname>.
103 * A simple refcounted data type representing an immutable byte sequence
104 * from an unspecified origin.
106 * The purpose of a #GBytes is to keep the memory region that it holds
107 * alive for as long as anyone holds a reference to the bytes. When
108 * the last reference count is dropped, the memory is released. Multiple
109 * unrelated callers can use byte data in the #GBytes without coordinating
110 * their activities, resting assured that the byte data will not change or
111 * move while they hold a reference.
113 * A #GBytes can come from many different origins that may have
114 * different procedures for freeing the memory region. Examples are
115 * memory from g_malloc(), from memory slices, from a #GMappedFile or
116 * memory from other allocators.
118 * #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
119 * g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
120 * #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
121 * function to g_tree_new().
123 * The data pointed to by this bytes must not be modified. For a mutable
124 * array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
125 * mutable array for a #GBytes sequence. To create an immutable #GBytes from
126 * a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
135 * @b: a value to compare with.
136 * @user_data: user data to pass to comparison function.
138 * Specifies the type of a comparison function used to compare two
139 * values. The function should return a negative integer if the first
140 * value comes before the second, 0 if they are equal, or a positive
141 * integer if the first value comes after the second.
143 * Returns: negative value if @a < @b; zero if @a = @b; positive
151 * @b: a value to compare with.
153 * Specifies the type of a comparison function used to compare two
154 * values. The function should return a negative integer if the first
155 * value comes before the second, 0 if they are equal, or a positive
156 * integer if the first value comes after the second.
158 * Returns: negative value if @a < @b; zero if @a = @b; positive
166 * The #GCond struct is an opaque data structure that represents a
167 * condition. Threads can block on a #GCond if they find a certain
168 * condition to be false. If other threads change the state of this
169 * condition they signal the #GCond, and that causes the waiting
170 * threads to be woken up.
172 * Consider the following example of a shared variable. One or more
173 * threads can wait for data to be published to the variable and when
174 * another thread publishes the data, it can signal one of the waiting
175 * threads to wake up to collect the data.
179 * Using GCond to block a thread until a condition is satisfied
182 * gpointer current_data = NULL;
187 * push_data (gpointer data)
189 * g_mutex_lock (&data_mutex);
190 * current_data = data;
191 * g_cond_signal (&data_cond);
192 * g_mutex_unlock (&data_mutex);
200 * g_mutex_lock (&data_mutex);
201 * while (!current_data)
202 * g_cond_wait (&data_cond, &data_mutex);
203 * data = current_data;
204 * current_data = NULL;
205 * g_mutex_unlock (&data_mutex);
212 * Whenever a thread calls pop_data() now, it will wait until
213 * current_data is non-%NULL, i.e. until some other thread
214 * has called push_data().
216 * The example shows that use of a condition variable must always be
217 * paired with a mutex. Without the use of a mutex, there would be a
218 * race between the check of <varname>current_data</varname> by the
219 * while loop in <function>pop_data</function> and waiting.
220 * Specifically, another thread could set <varname>pop_data</varname>
221 * after the check, and signal the cond (with nobody waiting on it)
222 * before the first thread goes to sleep. #GCond is specifically useful
223 * for its ability to release the mutex and go to sleep atomically.
225 * It is also important to use the g_cond_wait() and g_cond_wait_until()
226 * functions only inside a loop which checks for the condition to be
227 * true. See g_cond_wait() for an explanation of why the condition may
228 * not be true even after it returns.
230 * If a #GCond is allocated in static storage then it can be used
231 * without initialisation. Otherwise, you should call g_cond_init() on
232 * it and g_cond_clear() when done.
234 * A #GCond should only be accessed via the <function>g_cond_</function>
242 * The #GData struct is an opaque data structure to represent a <link
243 * linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
244 * only be accessed via the following functions.
250 * @key_id: the #GQuark id to identifying the data element.
251 * @data: the data element.
252 * @user_data: user data passed to g_dataset_foreach().
254 * Specifies the type of function passed to g_dataset_foreach(). It is
255 * called with each #GQuark id and associated data element, together
256 * with the @user_data parameter supplied to g_dataset_foreach().
262 * @julian_days: the Julian representation of the date
263 * @julian: this bit is set if @julian_days is valid
264 * @dmy: this is set if @day, @month and @year are valid
265 * @day: the day of the day-month-year representation of the date,
266 * as a number between 1 and 31
267 * @month: the day of the day-month-year representation of the date,
268 * as a number between 1 and 12
269 * @year: the day of the day-month-year representation of the date
271 * Represents a day between January 1, Year 1 and a few thousand years in
272 * the future. None of its members should be accessed directly. If the
273 * <structname>GDate</structname> is obtained from g_date_new(), it will
274 * be safe to mutate but invalid and thus not safe for calendrical
275 * computations. If it's declared on the stack, it will contain garbage
276 * so must be initialized with g_date_clear(). g_date_clear() makes the
277 * date invalid but sane. An invalid date doesn't represent a day, it's
278 * "empty." A date becomes valid after you set it to a Julian day or you
279 * set a day, month, and year.
286 * @G_DATE_MONTH: a month
287 * @G_DATE_YEAR: a year
289 * This enumeration isn't used in the API, but may be useful if you need
290 * to mark a number as a day, month, or year.
297 * Integer representing a day of the month; between 1 and
298 * 31. #G_DATE_BAD_DAY represents an invalid day of the month.
304 * @G_DATE_BAD_MONTH: invalid value
305 * @G_DATE_JANUARY: January
306 * @G_DATE_FEBRUARY: February
307 * @G_DATE_MARCH: March
308 * @G_DATE_APRIL: April
312 * @G_DATE_AUGUST: August
313 * @G_DATE_SEPTEMBER: September
314 * @G_DATE_OCTOBER: October
315 * @G_DATE_NOVEMBER: November
316 * @G_DATE_DECEMBER: December
318 * Enumeration representing a month; values are #G_DATE_JANUARY,
319 * #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
325 * @G_DATE_BAD_WEEKDAY: invalid value
326 * @G_DATE_MONDAY: Monday
327 * @G_DATE_TUESDAY: Tuesday
328 * @G_DATE_WEDNESDAY: Wednesday
329 * @G_DATE_THURSDAY: Thursday
330 * @G_DATE_FRIDAY: Friday
331 * @G_DATE_SATURDAY: Saturday
332 * @G_DATE_SUNDAY: Sunday
334 * Enumeration representing a day of the week; #G_DATE_MONDAY,
335 * #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
342 * Integer representing a year; #G_DATE_BAD_YEAR is the invalid
343 * value. The year must be 1 or higher; negative (BC) years are not
344 * allowed. The year is represented with four digits.
350 * @data: the data element.
352 * Specifies the type of function which is called when a data element
353 * is destroyed. It is passed the pointer to the data element and
354 * should free any memory and resources allocated for it.
361 * An opaque structure representing an opened directory.
367 * @v_double: the double value
369 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
370 * mantissa and exponent of IEEE floats and doubles. These unions are defined
371 * as appropriate for a given platform. IEEE floats and doubles are supported
372 * (used for storage) by at least Intel, PPC and Sparc.
378 * @data: the data to duplicate
379 * @user_data: user data that was specified in g_datalist_id_dup_data()
381 * The type of functions that are used to 'duplicate' an object.
382 * What this means depends on the context, it could just be
383 * incrementing the reference count, if @data is a ref-counted
386 * Returns: a duplicate of data
393 * @b: a value to compare with
395 * Specifies the type of a function used to test two values for
396 * equality. The function should return %TRUE if both values are equal
397 * and %FALSE otherwise.
399 * Returns: %TRUE if @a = @b; %FALSE otherwise
405 * @G_ERR_UNKNOWN: unknown error
406 * @G_ERR_UNEXP_EOF: unexpected end of file
407 * @G_ERR_UNEXP_EOF_IN_STRING: unterminated string constant
408 * @G_ERR_UNEXP_EOF_IN_COMMENT: unterminated comment
409 * @G_ERR_NON_DIGIT_IN_CONST: non-digit character in a number
410 * @G_ERR_DIGIT_RADIX: digit beyond radix in a number
411 * @G_ERR_FLOAT_RADIX: non-decimal floating point number
412 * @G_ERR_FLOAT_MALFORMED: malformed floating point number
414 * The possible errors, used in the @v_error field
415 * of #GTokenValue, when the token is a %G_TOKEN_ERROR.
421 * @G_FILE_ERROR_EXIST: Operation not permitted; only the owner of
422 * the file (or other resource) or processes with special privileges
423 * can perform the operation.
424 * @G_FILE_ERROR_ISDIR: File is a directory; you cannot open a directory
425 * for writing, or create or remove hard links to it.
426 * @G_FILE_ERROR_ACCES: Permission denied; the file permissions do not
427 * allow the attempted operation.
428 * @G_FILE_ERROR_NAMETOOLONG: Filename too long.
429 * @G_FILE_ERROR_NOENT: No such file or directory. This is a "file
430 * doesn't exist" error for ordinary files that are referenced in
431 * contexts where they are expected to already exist.
432 * @G_FILE_ERROR_NOTDIR: A file that isn't a directory was specified when
433 * a directory is required.
434 * @G_FILE_ERROR_NXIO: No such device or address. The system tried to
435 * use the device represented by a file you specified, and it
436 * couldn't find the device. This can mean that the device file was
437 * installed incorrectly, or that the physical device is missing or
438 * not correctly attached to the computer.
439 * @G_FILE_ERROR_NODEV: The underlying file system of the specified file
440 * does not support memory mapping.
441 * @G_FILE_ERROR_ROFS: The directory containing the new link can't be
442 * modified because it's on a read-only file system.
443 * @G_FILE_ERROR_TXTBSY: Text file busy.
444 * @G_FILE_ERROR_FAULT: You passed in a pointer to bad memory.
445 * (GLib won't reliably return this, don't pass in pointers to bad
447 * @G_FILE_ERROR_LOOP: Too many levels of symbolic links were encountered
448 * in looking up a file name. This often indicates a cycle of symbolic
450 * @G_FILE_ERROR_NOSPC: No space left on device; write operation on a
451 * file failed because the disk is full.
452 * @G_FILE_ERROR_NOMEM: No memory available. The system cannot allocate
453 * more virtual memory because its capacity is full.
454 * @G_FILE_ERROR_MFILE: The current process has too many files open and
455 * can't open any more. Duplicate descriptors do count toward this
457 * @G_FILE_ERROR_NFILE: There are too many distinct file openings in the
459 * @G_FILE_ERROR_BADF: Bad file descriptor; for example, I/O on a
460 * descriptor that has been closed or reading from a descriptor open
461 * only for writing (or vice versa).
462 * @G_FILE_ERROR_INVAL: Invalid argument. This is used to indicate
463 * various kinds of problems with passing the wrong argument to a
465 * @G_FILE_ERROR_PIPE: Broken pipe; there is no process reading from the
466 * other end of a pipe. Every library function that returns this
467 * error code also generates a 'SIGPIPE' signal; this signal
468 * terminates the program if not handled or blocked. Thus, your
469 * program will never actually see this code unless it has handled
470 * or blocked 'SIGPIPE'.
471 * @G_FILE_ERROR_AGAIN: Resource temporarily unavailable; the call might
472 * work if you try again later.
473 * @G_FILE_ERROR_INTR: Interrupted function call; an asynchronous signal
474 * occurred and prevented completion of the call. When this
475 * happens, you should try the call again.
476 * @G_FILE_ERROR_IO: Input/output error; usually used for physical read
477 * or write errors. i.e. the disk or other physical device hardware
478 * is returning errors.
479 * @G_FILE_ERROR_PERM: Operation not permitted; only the owner of the
480 * file (or other resource) or processes with special privileges can
481 * perform the operation.
482 * @G_FILE_ERROR_NOSYS: Function not implemented; this indicates that
483 * the system is missing some functionality.
484 * @G_FILE_ERROR_FAILED: Does not correspond to a UNIX error code; this
485 * is the standard "failed for unspecified reason" error code present
486 * in all #GError error code enumerations. Returned if no specific
489 * Values corresponding to @errno codes returned from file operations
490 * on UNIX. Unlike @errno codes, GFileError values are available on
491 * all systems, even Windows. The exact meaning of each code depends
492 * on what sort of file operation you were performing; the UNIX
493 * documentation gives more details. The following error code descriptions
494 * come from the GNU C Library manual, and are under the copyright
497 * It's not very portable to make detailed assumptions about exactly
498 * which errors will be returned from a given operation. Some errors
499 * don't occur on some systems, etc., sometimes there are subtle
500 * differences in when a system will report a given error, etc.
506 * @G_FILE_TEST_IS_REGULAR: %TRUE if the file is a regular file
507 * (not a directory). Note that this test will also return %TRUE
508 * if the tested file is a symlink to a regular file.
509 * @G_FILE_TEST_IS_SYMLINK: %TRUE if the file is a symlink.
510 * @G_FILE_TEST_IS_DIR: %TRUE if the file is a directory.
511 * @G_FILE_TEST_IS_EXECUTABLE: %TRUE if the file is executable.
512 * @G_FILE_TEST_EXISTS: %TRUE if the file exists. It may or may not
515 * A test to perform on a file using g_file_test().
521 * @v_float: the double value
523 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
524 * mantissa and exponent of IEEE floats and doubles. These unions are defined
525 * as appropriate for a given platform. IEEE floats and doubles are supported
526 * (used for storage) by at least Intel, PPC and Sparc.
532 * @G_FORMAT_SIZE_DEFAULT: behave the same as g_format_size()
533 * @G_FORMAT_SIZE_LONG_FORMAT: include the exact number of bytes as part
534 * of the returned string. For example, "45.6 kB (45,612 bytes)".
535 * @G_FORMAT_SIZE_IEC_UNITS: use IEC (base 1024) units with "KiB"-style
536 * suffixes. IEC units should only be used for reporting things with
537 * a strong "power of 2" basis, like RAM sizes or RAID stripe sizes.
538 * Network and storage sizes should be reported in the normal SI units.
540 * Flags to modify the format of the string returned by g_format_size_full().
546 * @data: the element's data.
547 * @user_data: user data passed to g_list_foreach() or
550 * Specifies the type of functions passed to g_list_foreach() and
558 * @value: the value corresponding to the key
559 * @user_data: user data passed to g_hash_table_foreach()
561 * Specifies the type of the function passed to g_hash_table_foreach().
562 * It is called with each key/value pair, together with the @user_data
563 * parameter which is passed to g_hash_table_foreach().
570 * @value: the value associated with the key
571 * @user_data: user data passed to g_hash_table_remove()
573 * Specifies the type of the function passed to
574 * g_hash_table_foreach_remove(). It is called with each key/value
575 * pair, together with the @user_data parameter passed to
576 * g_hash_table_foreach_remove(). It should return %TRUE if the
577 * key/value pair should be removed from the #GHashTable.
579 * Returns: %TRUE if the key/value pair should be removed from the
588 * Specifies the type of the hash function which is passed to
589 * g_hash_table_new() when a #GHashTable is created.
591 * The function is passed a key and should return a #guint hash value.
592 * The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
593 * hash functions which can be used when the key is a #gpointer, #gint*,
594 * and #gchar* respectively.
596 * g_direct_hash() is also the appropriate hash function for keys
597 * of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
599 * <!-- FIXME: Need more here. --> A good hash functions should produce
600 * hash values that are evenly distributed over a fairly large range.
601 * The modulus is taken with the hash table size (a prime number) to
602 * find the 'bucket' to place each key into. The function should also
603 * be very fast, since it is called for each key lookup.
605 * Note that the hash functions provided by GLib have these qualities,
606 * but are not particularly robust against manufactured keys that
607 * cause hash collisions. Therefore, you should consider choosing
608 * a more secure hash function when using a GHashTable with keys
609 * that originate in untrusted data (such as HTTP requests).
610 * Using g_str_hash() in that situation might make your application
611 * vulerable to <ulink url="https://lwn.net/Articles/474912/">Algorithmic Complexity Attacks</ulink>.
613 * The key to choosing a good hash is unpredictability. Even
614 * cryptographic hashes are very easy to find collisions for when the
615 * remainder is taken modulo a somewhat predictable prime number. There
616 * must be an element of randomness that an attacker is unable to guess.
618 * Returns: the hash value corresponding to the key
625 * The #GHashTable struct is an opaque data structure to represent a
626 * <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
627 * accessed via the following functions.
634 * A GHashTableIter structure represents an iterator that can be used
635 * to iterate over the elements of a #GHashTable. GHashTableIter
636 * structures are typically allocated on the stack and then initialized
637 * with g_hash_table_iter_init().
643 * @data: data which is passed to func when this hook is invoked
644 * @next: pointer to the next hook in the list
645 * @prev: pointer to the previous hook in the list
646 * @ref_count: the reference count of this hook
647 * @hook_id: the id of this hook, which is unique within its list
648 * @flags: flags which are set for this hook. See #GHookFlagMask for
650 * @func: the function to call when this hook is invoked. The possible
651 * signatures for this function are #GHookFunc and #GHookCheckFunc
652 * @destroy: the default @finalize_hook function of a #GHookList calls
653 * this member of the hook that is being finalized
655 * The <structname>GHook</structname> struct represents a single hook
656 * function in a #GHookList.
662 * @data: the data field of the #GHook is passed to the hook function here
664 * Defines the type of a hook function that can be invoked
665 * by g_hook_list_invoke_check().
667 * Returns: %FALSE if the #GHook should be destroyed
672 * GHookCheckMarshaller:
674 * @marshal_data: user data
676 * Defines the type of function used by g_hook_list_marshal_check().
678 * Returns: %FALSE if @hook should be destroyed
684 * @new_hook: the #GHook being inserted
685 * @sibling: the #GHook to compare with @new_hook
687 * Defines the type of function used to compare #GHook elements in
688 * g_hook_insert_sorted().
690 * Returns: a value <= 0 if @new_hook should be before @sibling
696 * @hook_list: a #GHookList
697 * @hook: the hook in @hook_list that gets finalized
699 * Defines the type of function to be called when a hook in a
700 * list of hooks gets finalized.
707 * @data: user data passed to g_hook_find_func()
709 * Defines the type of the function passed to g_hook_find().
711 * Returns: %TRUE if the required #GHook has been found
717 * @G_HOOK_FLAG_ACTIVE: set if the hook has not been destroyed
718 * @G_HOOK_FLAG_IN_CALL: set if the hook is currently being run
719 * @G_HOOK_FLAG_MASK: A mask covering all bits reserved for
720 * hook flags; see %G_HOOK_FLAG_USER_SHIFT
722 * Flags used internally in the #GHook implementation.
728 * @data: the data field of the #GHook is passed to the hook function here
730 * Defines the type of a hook function that can be invoked
731 * by g_hook_list_invoke().
737 * @seq_id: the next free #GHook id
738 * @hook_size: the size of the #GHookList elements, in bytes
739 * @is_setup: 1 if the #GHookList has been initialized
740 * @hooks: the first #GHook element in the list
742 * @finalize_hook: the function to call to finalize a #GHook element.
743 * The default behaviour is to call the hooks @destroy function
746 * The <structname>GHookList</structname> struct represents a
747 * list of hook functions.
754 * @marshal_data: user data
756 * Defines the type of function used by g_hook_list_marshal().
762 * @val: a #gint16 value in big-endian byte order
764 * Converts a #gint16 value from big-endian to host byte order.
766 * Returns: @val converted to host byte order
772 * @val: a #gint16 value in little-endian byte order
774 * Converts a #gint16 value from little-endian to host byte order.
776 * Returns: @val converted to host byte order
782 * @val: a #gint16 value in host byte order
784 * Converts a #gint16 value from host byte order to big-endian.
786 * Returns: @val converted to big-endian
792 * @val: a #gint16 value in host byte order
794 * Converts a #gint16 value from host byte order to little-endian.
796 * Returns: @val converted to little-endian
802 * @val: a #gint32 value in big-endian byte order
804 * Converts a #gint32 value from big-endian to host byte order.
806 * Returns: @val converted to host byte order
812 * @val: a #gint32 value in little-endian byte order
814 * Converts a #gint32 value from little-endian to host byte order.
816 * Returns: @val converted to host byte order
822 * @val: a #gint32 value in host byte order
824 * Converts a #gint32 value from host byte order to big-endian.
826 * Returns: @val converted to big-endian
832 * @val: a #gint32 value in host byte order
834 * Converts a #gint32 value from host byte order to little-endian.
836 * Returns: @val converted to little-endian
842 * @val: a #gint64 value in big-endian byte order
844 * Converts a #gint64 value from big-endian to host byte order.
846 * Returns: @val converted to host byte order
852 * @val: a #gint64 value in little-endian byte order
854 * Converts a #gint64 value from little-endian to host byte order.
856 * Returns: @val converted to host byte order
862 * @val: a #gint64 value in host byte order
864 * Converts a #gint64 value from host byte order to big-endian.
866 * Returns: @val converted to big-endian
872 * @val: a #gint64 value in host byte order
874 * Converts a #gint64 value from host byte order to little-endian.
876 * Returns: @val converted to little-endian
882 * @val: a #gint value in big-endian byte order
884 * Converts a #gint value from big-endian to host byte order.
886 * Returns: @val converted to host byte order
892 * @val: a #gint value in little-endian byte order
894 * Converts a #gint value from little-endian to host byte order.
896 * Returns: @val converted to host byte order
902 * @val: a #gint value in host byte order
904 * Converts a #gint value from host byte order to big-endian.
906 * Returns: @val converted to big-endian byte order
912 * @val: a #gint value in host byte order
914 * Converts a #gint value from host byte order to little-endian.
916 * Returns: @val converted to little-endian byte order
922 * @i: integer to stuff into a pointer
924 * Stuffs an integer into a pointer type.
926 * Remember, you may not store pointers in integers. This is not portable
927 * in any way, shape or form. These macros <emphasis>only</emphasis> allow
928 * storing integers in pointers, and only preserve 32 bits of the
929 * integer; values outside the range of a 32-bit integer will be mangled.
936 * A data structure representing an IO Channel. The fields should be
937 * considered private and should only be accessed with the following
944 * @G_IO_CHANNEL_ERROR_FBIG: File too large.
945 * @G_IO_CHANNEL_ERROR_INVAL: Invalid argument.
946 * @G_IO_CHANNEL_ERROR_IO: IO error.
947 * @G_IO_CHANNEL_ERROR_ISDIR: File is a directory.
948 * @G_IO_CHANNEL_ERROR_NOSPC: No space left on device.
949 * @G_IO_CHANNEL_ERROR_NXIO: No such device or address.
950 * @G_IO_CHANNEL_ERROR_OVERFLOW: Value too large for defined datatype.
951 * @G_IO_CHANNEL_ERROR_PIPE: Broken pipe.
952 * @G_IO_CHANNEL_ERROR_FAILED: Some other error.
954 * Error codes returned by #GIOChannel operations.
960 * @G_IO_IN: There is data to read.
961 * @G_IO_OUT: Data can be written (without blocking).
962 * @G_IO_PRI: There is urgent data to read.
963 * @G_IO_ERR: Error condition.
964 * @G_IO_HUP: Hung up (the connection has been broken, usually for
965 * pipes and sockets).
966 * @G_IO_NVAL: Invalid request. The file descriptor is not open.
968 * A bitwise combination representing a condition to watch for on an
975 * @G_IO_ERROR_NONE: no error
976 * @G_IO_ERROR_AGAIN: an EAGAIN error occurred
977 * @G_IO_ERROR_INVAL: an EINVAL error occurred
978 * @G_IO_ERROR_UNKNOWN: another error occurred
980 * #GIOError is only used by the deprecated functions
981 * g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
987 * @G_IO_FLAG_APPEND: turns on append mode, corresponds to <literal>O_APPEND</literal>
988 * (see the documentation of the UNIX open()
990 * @G_IO_FLAG_NONBLOCK: turns on nonblocking mode, corresponds to
991 * <literal>O_NONBLOCK</literal>/<literal>O_NDELAY</literal>
992 * (see the documentation of the UNIX open() syscall).
993 * @G_IO_FLAG_IS_READABLE: indicates that the io channel is readable.
994 * This flag cannot be changed.
995 * @G_IO_FLAG_IS_WRITABLE: indicates that the io channel is writable.
996 * This flag cannot be changed.
997 * @G_IO_FLAG_IS_SEEKABLE: indicates that the io channel is seekable,
998 * i.e. that g_io_channel_seek_position() can
999 * be used on it. This flag cannot be changed.
1000 * @G_IO_FLAG_MASK: the mask that specifies all the valid flags.
1001 * @G_IO_FLAG_GET_MASK: the mask of the flags that are returned from
1002 * g_io_channel_get_flags().
1003 * @G_IO_FLAG_SET_MASK: the mask of the flags that the user can modify
1004 * with g_io_channel_set_flags().
1006 * Specifies properties of a #GIOChannel. Some of the flags can only be
1007 * read with g_io_channel_get_flags(), but not changed with
1008 * g_io_channel_set_flags().
1014 * @source: the #GIOChannel event source
1015 * @condition: the condition which has been satisfied
1016 * @data: user data set in g_io_add_watch() or g_io_add_watch_full()
1018 * Specifies the type of function passed to g_io_add_watch() or
1019 * g_io_add_watch_full(), which is called when the requested condition
1020 * on a #GIOChannel is satisfied.
1022 * Returns: the function should return %FALSE if the event source
1029 * @io_read: reads raw bytes from the channel. This is called from
1030 * various functions such as g_io_channel_read_chars() to
1031 * read raw bytes from the channel. Encoding and buffering
1032 * issues are dealt with at a higher level.
1033 * @io_write: writes raw bytes to the channel. This is called from
1034 * various functions such as g_io_channel_write_chars() to
1035 * write raw bytes to the channel. Encoding and buffering
1036 * issues are dealt with at a higher level.
1037 * @io_seek: (optional) seeks the channel. This is called from
1038 * g_io_channel_seek() on channels that support it.
1039 * @io_close: closes the channel. This is called from
1040 * g_io_channel_close() after flushing the buffers.
1041 * @io_create_watch: creates a watch on the channel. This call
1042 * corresponds directly to g_io_create_watch().
1043 * @io_free: called from g_io_channel_unref() when the channel needs to
1044 * be freed. This function must free the memory associated
1045 * with the channel, including freeing the #GIOChannel
1046 * structure itself. The channel buffers have been flushed
1047 * and possibly @io_close has been called by the time this
1048 * function is called.
1049 * @io_set_flags: sets the #GIOFlags on the channel. This is called
1050 * from g_io_channel_set_flags() with all flags except
1051 * for %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK masked
1053 * @io_get_flags: gets the #GIOFlags for the channel. This function
1054 * need only return the %G_IO_FLAG_APPEND and
1055 * %G_IO_FLAG_NONBLOCK flags; g_io_channel_get_flags()
1056 * automatically adds the others as appropriate.
1058 * A table of functions used to handle different types of #GIOChannel
1065 * @G_IO_STATUS_ERROR: An error occurred.
1066 * @G_IO_STATUS_NORMAL: Success.
1067 * @G_IO_STATUS_EOF: End of file.
1068 * @G_IO_STATUS_AGAIN: Resource temporarily unavailable.
1070 * Stati returned by most of the #GIOFuncs functions.
1077 * The GKeyFile struct contains only private data
1078 * and should not be accessed directly.
1084 * @G_KEY_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was in
1085 * an unknown encoding
1086 * @G_KEY_FILE_ERROR_PARSE: document was ill-formed
1087 * @G_KEY_FILE_ERROR_NOT_FOUND: the file was not found
1088 * @G_KEY_FILE_ERROR_KEY_NOT_FOUND: a requested key was not found
1089 * @G_KEY_FILE_ERROR_GROUP_NOT_FOUND: a requested group was not found
1090 * @G_KEY_FILE_ERROR_INVALID_VALUE: a value could not be parsed
1092 * Error codes returned by key file parsing.
1098 * @G_KEY_FILE_NONE: No flags, default behaviour
1099 * @G_KEY_FILE_KEEP_COMMENTS: Use this flag if you plan to write the
1100 * (possibly modified) contents of the key file back to a file;
1101 * otherwise all comments will be lost when the key file is
1103 * @G_KEY_FILE_KEEP_TRANSLATIONS: Use this flag if you plan to write the
1104 * (possibly modified) contents of the key file back to a file;
1105 * otherwise only the translations for the current language will be
1108 * Flags which influence the parsing.
1113 * GLIB_CHECK_VERSION:
1114 * @major: the major version to check for
1115 * @minor: the minor version to check for
1116 * @micro: the micro version to check for
1118 * Checks the version of the GLib library that is being compiled
1122 * <title>Checking the version of the GLib library</title>
1124 * if (!GLIB_CHECK_VERSION (1, 2, 0))
1125 * g_error ("GLib version 1.2.0 or above is needed");
1129 * See glib_check_version() for a runtime check.
1131 * Returns: %TRUE if the version of the GLib header files
1132 * is the same as or newer than the passed-in version.
1137 * GLIB_DISABLE_DEPRECATION_WARNINGS:
1139 * A macro that should be defined before including the glib.h header.
1140 * If it is defined, no compiler warnings will be produced for uses
1141 * of deprecated GLib APIs.
1146 * GLIB_MAJOR_VERSION:
1148 * The major version number of the GLib library.
1150 * Like #glib_major_version, but from the headers used at
1151 * application compile time, rather than from the library
1152 * linked against at application run time.
1157 * GLIB_MICRO_VERSION:
1159 * The micro version number of the GLib library.
1161 * Like #gtk_micro_version, but from the headers used at
1162 * application compile time, rather than from the library
1163 * linked against at application run time.
1168 * GLIB_MINOR_VERSION:
1170 * The minor version number of the GLib library.
1172 * Like #gtk_minor_version, but from the headers used at
1173 * application compile time, rather than from the library
1174 * linked against at application run time.
1180 * @val: a #glong value in big-endian byte order
1182 * Converts a #glong value from big-endian to the host byte order.
1184 * Returns: @val converted to host byte order
1190 * @val: a #glong value in little-endian byte order
1192 * Converts a #glong value from little-endian to host byte order.
1194 * Returns: @val converted to host byte order
1200 * @val: a #glong value in host byte order
1202 * Converts a #glong value from host byte order to big-endian.
1204 * Returns: @val converted to big-endian byte order
1210 * @val: a #glong value in host byte order
1212 * Converts a #glong value from host byte order to little-endian.
1214 * Returns: @val converted to little-endian
1220 * @data: holds the element's data, which can be a pointer to any kind
1221 * of data, or any integer value using the <link
1222 * linkend="glib-Type-Conversion-Macros">Type Conversion
1224 * @next: contains the link to the next element in the list.
1225 * @prev: contains the link to the previous element in the list.
1227 * The #GList struct is used for each element in a doubly-linked list.
1233 * @log_domain: the log domain of the message
1234 * @log_level: the log level of the message (including the
1235 * fatal and recursion flags)
1236 * @message: the message to process
1237 * @user_data: user data, set in g_log_set_handler()
1239 * Specifies the prototype of log handler functions.
1241 * The default log handler, g_log_default_handler(), automatically appends a
1242 * new-line character to @message when printing it. It is advised that any
1243 * custom log handler functions behave similarly, so that logging calls in user
1244 * code do not need modifying to add a new-line character to the message if the
1245 * log handler is changed.
1251 * @G_LOG_FLAG_RECURSION: internal flag
1252 * @G_LOG_FLAG_FATAL: internal flag
1253 * @G_LOG_LEVEL_ERROR: log level for errors, see g_error().
1254 * This level is also used for messages produced by g_assert().
1255 * @G_LOG_LEVEL_CRITICAL: log level for critical messages, see g_critical().
1256 * This level is also used for messages produced by g_return_if_fail()
1257 * and g_return_val_if_fail().
1258 * @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
1259 * @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
1260 * @G_LOG_LEVEL_INFO: log level for informational messages
1261 * @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
1262 * @G_LOG_LEVEL_MASK: a mask including all log levels
1264 * Flags specifying the level of log messages.
1266 * It is possible to change how GLib treats messages of the various
1267 * levels using g_log_set_handler() and g_log_set_fatal_mask().
1274 * The #GMappedFile represents a file mapping created with
1275 * g_mapped_file_new(). It has only private members and should
1276 * not be accessed directly.
1281 * GMarkupCollectType:
1282 * @G_MARKUP_COLLECT_INVALID: used to terminate the list of attributes
1284 * @G_MARKUP_COLLECT_STRING: collect the string pointer directly from
1285 * the attribute_values[] array. Expects a parameter of type (const
1286 * char **). If %G_MARKUP_COLLECT_OPTIONAL is specified and the
1287 * attribute isn't present then the pointer will be set to %NULL
1288 * @G_MARKUP_COLLECT_STRDUP: as with %G_MARKUP_COLLECT_STRING, but
1289 * expects a parameter of type (char **) and g_strdup()s the
1290 * returned pointer. The pointer must be freed with g_free()
1291 * @G_MARKUP_COLLECT_BOOLEAN: expects a parameter of type (gboolean *)
1292 * and parses the attribute value as a boolean. Sets %FALSE if the
1293 * attribute isn't present. Valid boolean values consist of
1294 * (case-insensitive) "false", "f", "no", "n", "0" and "true", "t",
1296 * @G_MARKUP_COLLECT_TRISTATE: as with %G_MARKUP_COLLECT_BOOLEAN, but
1297 * in the case of a missing attribute a value is set that compares
1298 * equal to neither %FALSE nor %TRUE G_MARKUP_COLLECT_OPTIONAL is
1300 * @G_MARKUP_COLLECT_OPTIONAL: can be bitwise ORed with the other fields.
1301 * If present, allows the attribute not to appear. A default value
1302 * is set depending on what value type is used
1304 * A mixed enumerated type and flags field. You must specify one type
1305 * (string, strdup, boolean, tristate). Additionally, you may optionally
1306 * bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
1308 * It is likely that this enum will be extended in the future to
1309 * support other types.
1316 * The #GMutex struct is an opaque data structure to represent a mutex
1317 * (mutual exclusion). It can be used to protect data against shared
1318 * access. Take for example the following function:
1321 * <title>A function which will not work in a threaded environment</title>
1324 * give_me_next_number (void)
1326 * static int current_number = 0;
1328 * /<!-- -->* now do a very complicated calculation to calculate the new
1329 * * number, this might for example be a random number generator
1331 * current_number = calc_next_number (current_number);
1333 * return current_number;
1338 * It is easy to see that this won't work in a multi-threaded
1339 * application. There current_number must be protected against shared
1340 * access. A #GMutex can be used as a solution to this problem:
1343 * <title>Using GMutex to protected a shared variable</title>
1346 * give_me_next_number (void)
1348 * static GMutex mutex;
1349 * static int current_number = 0;
1352 * g_mutex_lock (&mutex);
1353 * ret_val = current_number = calc_next_number (current_number);
1354 * g_mutex_unlock (&mutex);
1361 * Notice that the #GMutex is not initialised to any particular value.
1362 * Its placement in static storage ensures that it will be initialised
1363 * to all-zeros, which is appropriate.
1365 * If a #GMutex is placed in other contexts (eg: embedded in a struct)
1366 * then it must be explicitly initialised using g_mutex_init().
1368 * A #GMutex should only be accessed via <function>g_mutex_</function>
1375 * @data: contains the actual data of the node.
1376 * @next: points to the node's next sibling (a sibling is another
1377 * #GNode with the same parent).
1378 * @prev: points to the node's previous sibling.
1379 * @parent: points to the parent of the #GNode, or is %NULL if the
1380 * #GNode is the root of the tree.
1381 * @children: points to the first child of the #GNode. The other
1382 * children are accessed by using the @next pointer of each
1385 * The #GNode struct represents one node in a
1386 * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
1393 * @data: user data passed to g_node_children_foreach().
1395 * Specifies the type of function passed to g_node_children_foreach().
1396 * The function is called with each child node, together with the user
1397 * data passed to g_node_children_foreach().
1402 * GNodeTraverseFunc:
1404 * @data: user data passed to g_node_traverse().
1406 * Specifies the type of function passed to g_node_traverse(). The
1407 * function is called with each of the nodes visited, together with the
1408 * user data passed to g_node_traverse(). If the function returns
1409 * %TRUE, then the traversal is stopped.
1411 * Returns: %TRUE to stop the traversal.
1417 * @status: the status of the #GOnce
1418 * @retval: the value returned by the call to the function, if @status
1419 * is %G_ONCE_STATUS_READY
1421 * A #GOnce struct controls a one-time initialization function. Any
1422 * one-time initialization function must have its own unique #GOnce
1431 * @G_ONCE_STATUS_NOTCALLED: the function has not been called yet.
1432 * @G_ONCE_STATUS_PROGRESS: the function call is currently in progress.
1433 * @G_ONCE_STATUS_READY: the function has been called.
1435 * The possible statuses of a one-time initialization function
1436 * controlled by a #GOnce struct.
1444 * @p: pointer containing an integer
1446 * Extracts an integer from a pointer. The integer must have
1447 * been stored in the pointer with GINT_TO_POINTER().
1449 * Remember, you may not store pointers in integers. This is not portable
1450 * in any way, shape or form. These macros <emphasis>only</emphasis> allow
1451 * storing integers in pointers, and only preserve 32 bits of the
1452 * integer; values outside the range of a 32-bit integer will be mangled.
1458 * @p: pointer to extract a #gsize from
1460 * Extracts a #gsize from a pointer. The #gsize must have
1461 * been stored in the pointer with GSIZE_TO_POINTER().
1467 * @p: pointer to extract an unsigned integer from
1469 * Extracts an unsigned integer from a pointer. The integer must have
1470 * been stored in the pointer with GUINT_TO_POINTER().
1477 * A <structname>GPatternSpec</structname> is the 'compiled' form of a
1478 * pattern. This structure is opaque and its fields cannot be accessed
1486 * The #GPrivate struct is an opaque data structure to represent a
1487 * thread-local data key. It is approximately equivalent to the
1488 * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
1489 * TlsSetValue()/TlsGetValue() on Windows.
1491 * If you don't already know why you might want this functionality,
1492 * then you probably don't need it.
1494 * #GPrivate is a very limited resource (as far as 128 per program,
1495 * shared between all libraries). It is also not possible to destroy a
1496 * #GPrivate after it has been used. As such, it is only ever acceptable
1497 * to use #GPrivate in static scope, and even then sparingly so.
1499 * See G_PRIVATE_INIT() for a couple of examples.
1501 * The #GPrivate structure should be considered opaque. It should only
1502 * be accessed via the <function>g_private_</function> functions.
1508 * @pdata: points to the array of pointers, which may be moved when the
1510 * @len: number of pointers in the array.
1512 * Contains the public fields of a pointer array.
1519 * A GQuark is a non-zero integer which uniquely identifies a
1520 * particular string. A GQuark value of zero is associated to %NULL.
1527 * The GRWLock struct is an opaque data structure to represent a
1528 * reader-writer lock. It is similar to a #GMutex in that it allows
1529 * multiple threads to coordinate access to a shared resource.
1531 * The difference to a mutex is that a reader-writer lock discriminates
1532 * between read-only ('reader') and full ('writer') access. While only
1533 * one thread at a time is allowed write access (by holding the 'writer'
1534 * lock via g_rw_lock_writer_lock()), multiple threads can gain
1535 * simultaneous read-only access (by holding the 'reader' lock via
1536 * g_rw_lock_reader_lock()).
1539 * <title>An array with access functions</title>
1545 * my_array_get (guint index)
1547 * gpointer retval = NULL;
1552 * g_rw_lock_reader_lock (&lock);
1553 * if (index < array->len)
1554 * retval = g_ptr_array_index (array, index);
1555 * g_rw_lock_reader_unlock (&lock);
1561 * my_array_set (guint index, gpointer data)
1563 * g_rw_lock_writer_lock (&lock);
1566 * array = g_ptr_array_new (<!-- -->);
1568 * if (index >= array->len)
1569 * g_ptr_array_set_size (array, index+1);
1570 * g_ptr_array_index (array, index) = data;
1572 * g_rw_lock_writer_unlock (&lock);
1576 * This example shows an array which can be accessed by many readers
1577 * (the <function>my_array_get()</function> function) simultaneously,
1578 * whereas the writers (the <function>my_array_set()</function>
1579 * function) will only be allowed once at a time and only if no readers
1580 * currently access the array. This is because of the potentially
1581 * dangerous resizing of the array. Using these functions is fully
1582 * multi-thread safe now.
1586 * If a #GRWLock is allocated in static storage then it can be used
1587 * without initialisation. Otherwise, you should call
1588 * g_rw_lock_init() on it and g_rw_lock_clear() when done.
1590 * A GRWLock should only be accessed with the
1591 * <function>g_rw_lock_</function> functions.
1600 * The #GRand struct is an opaque data structure. It should only be
1601 * accessed through the <function>g_rand_*</function> functions.
1608 * The GRecMutex struct is an opaque data structure to represent a
1609 * recursive mutex. It is similar to a #GMutex with the difference
1610 * that it is possible to lock a GRecMutex multiple times in the same
1611 * thread without deadlock. When doing so, care has to be taken to
1612 * unlock the recursive mutex as often as it has been locked.
1614 * If a #GRecMutex is allocated in static storage then it can be used
1615 * without initialisation. Otherwise, you should call
1616 * g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
1618 * A GRecMutex should only be accessed with the
1619 * <function>g_rec_mutex_</function> functions.
1627 * @val: a #gsize value in big-endian byte order
1629 * Converts a #gsize value from big-endian to the host byte order.
1631 * Returns: @val converted to host byte order
1637 * @val: a #gsize value in little-endian byte order
1639 * Converts a #gsize value from little-endian to host byte order.
1641 * Returns: @val converted to host byte order
1647 * @val: a #gsize value in host byte order
1649 * Converts a #gsize value from host byte order to big-endian.
1651 * Returns: @val converted to big-endian byte order
1657 * @val: a #gsize value in host byte order
1659 * Converts a #gsize value from host byte order to little-endian.
1661 * Returns: @val converted to little-endian
1667 * @s: #gsize to stuff into the pointer
1669 * Stuffs a #gsize into a pointer type.
1675 * @data: holds the element's data, which can be a pointer to any kind
1676 * of data, or any integer value using the <link
1677 * linkend="glib-Type-Conversion-Macros">Type Conversion
1679 * @next: contains the link to the next element in the list.
1681 * The #GSList struct is used for each element in the singly-linked
1688 * @val: a #gssize value in big-endian byte order
1690 * Converts a #gssize value from big-endian to host byte order.
1692 * Returns: @val converted to host byte order
1698 * @val: a #gssize value in little-endian byte order
1700 * Converts a #gssize value from little-endian to host byte order.
1702 * Returns: @val converted to host byte order
1708 * @val: a #gssize value in host byte order
1710 * Converts a #gssize value from host byte order to big-endian.
1712 * Returns: @val converted to big-endian
1718 * @val: a #gssize value in host byte order
1720 * Converts a #gssize value from host byte order to little-endian.
1722 * Returns: @val converted to little-endian
1728 * @user_data: unused
1729 * @max_parse_errors: unused
1730 * @parse_errors: g_scanner_error() increments this field
1731 * @input_name: name of input stream, featured by the default message handler
1732 * @qdata: quarked data
1733 * @config: link into the scanner configuration
1734 * @token: token parsed by the last g_scanner_get_next_token()
1735 * @value: value of the last token from g_scanner_get_next_token()
1736 * @line: line number of the last token from g_scanner_get_next_token()
1737 * @position: char number of the last token from g_scanner_get_next_token()
1738 * @next_token: token parsed by the last g_scanner_peek_next_token()
1739 * @next_value: value of the last token from g_scanner_peek_next_token()
1740 * @next_line: line number of the last token from g_scanner_peek_next_token()
1741 * @next_position: char number of the last token from g_scanner_peek_next_token()
1742 * @msg_handler: handler function for _warn and _error
1744 * The data structure representing a lexical scanner.
1746 * You should set @input_name after creating the scanner, since
1747 * it is used by the default message handler when displaying
1748 * warnings and errors. If you are scanning a file, the filename
1749 * would be a good choice.
1751 * The @user_data and @max_parse_errors fields are not used.
1752 * If you need to associate extra data with the scanner you
1753 * can place them here.
1755 * If you want to use your own message handler you can set the
1756 * @msg_handler field. The type of the message handler function
1757 * is declared by #GScannerMsgFunc.
1763 * @cset_skip_characters: specifies which characters should be skipped
1764 * by the scanner (the default is the whitespace characters: space,
1765 * tab, carriage-return and line-feed).
1766 * @cset_identifier_first: specifies the characters which can start
1767 * identifiers (the default is #G_CSET_a_2_z, "_", and #G_CSET_A_2_Z).
1768 * @cset_identifier_nth: specifies the characters which can be used
1769 * in identifiers, after the first character (the default is
1770 * #G_CSET_a_2_z, "_0123456789", #G_CSET_A_2_Z, #G_CSET_LATINS,
1772 * @cpair_comment_single: specifies the characters at the start and
1773 * end of single-line comments. The default is "#\n" which means
1774 * that single-line comments start with a '#' and continue until
1775 * a '\n' (end of line).
1776 * @case_sensitive: specifies if symbols are case sensitive (the
1777 * default is %FALSE).
1778 * @skip_comment_multi: specifies if multi-line comments are skipped
1779 * and not returned as tokens (the default is %TRUE).
1780 * @skip_comment_single: specifies if single-line comments are skipped
1781 * and not returned as tokens (the default is %TRUE).
1782 * @scan_comment_multi: specifies if multi-line comments are recognized
1783 * (the default is %TRUE).
1784 * @scan_identifier: specifies if identifiers are recognized (the
1785 * default is %TRUE).
1786 * @scan_identifier_1char: specifies if single-character
1787 * identifiers are recognized (the default is %FALSE).
1788 * @scan_identifier_NULL: specifies if %NULL is reported as
1789 * %G_TOKEN_IDENTIFIER_NULL (the default is %FALSE).
1790 * @scan_symbols: specifies if symbols are recognized (the default
1792 * @scan_binary: specifies if binary numbers are recognized (the
1793 * default is %FALSE).
1794 * @scan_octal: specifies if octal numbers are recognized (the
1795 * default is %TRUE).
1796 * @scan_float: specifies if floating point numbers are recognized
1797 * (the default is %TRUE).
1798 * @scan_hex: specifies if hexadecimal numbers are recognized (the
1799 * default is %TRUE).
1800 * @scan_hex_dollar: specifies if '$' is recognized as a prefix for
1801 * hexadecimal numbers (the default is %FALSE).
1802 * @scan_string_sq: specifies if strings can be enclosed in single
1803 * quotes (the default is %TRUE).
1804 * @scan_string_dq: specifies if strings can be enclosed in double
1805 * quotes (the default is %TRUE).
1806 * @numbers_2_int: specifies if binary, octal and hexadecimal numbers
1807 * are reported as #G_TOKEN_INT (the default is %TRUE).
1808 * @int_2_float: specifies if all numbers are reported as %G_TOKEN_FLOAT
1809 * (the default is %FALSE).
1810 * @identifier_2_string: specifies if identifiers are reported as strings
1811 * (the default is %FALSE).
1812 * @char_2_token: specifies if characters are reported by setting
1813 * <literal>token = ch</literal> or as %G_TOKEN_CHAR (the default
1815 * @symbol_2_token: specifies if symbols are reported by setting
1816 * <literal>token = v_symbol</literal> or as %G_TOKEN_SYMBOL (the
1817 * default is %FALSE).
1818 * @scope_0_fallback: specifies if a symbol is searched for in the
1819 * default scope in addition to the current scope (the default is %FALSE).
1820 * @store_int64: use value.v_int64 rather than v_int
1822 * Specifies the #GScanner parser configuration. Most settings can
1823 * be changed during the parsing phase and will affect the lexical
1824 * parsing of the next unpeeked token.
1830 * @scanner: a #GScanner
1831 * @message: the message
1832 * @error: %TRUE if the message signals an error,
1833 * %FALSE if it signals a warning.
1835 * Specifies the type of the message handler function.
1841 * @G_SEEK_CUR: the current position in the file.
1842 * @G_SEEK_SET: the start of the file.
1843 * @G_SEEK_END: the end of the file.
1845 * An enumeration specifying the base position for a
1846 * g_io_channel_seek_position() operation.
1853 * The #GSequence struct is an opaque data type representing a
1854 * <link linkend="glib-Sequences">Sequence</link> data type.
1861 * The #GSequenceIter struct is an opaque data type representing an
1862 * iterator pointing into a #GSequence.
1867 * GSequenceIterCompareFunc:
1868 * @a: a #GSequenceIter
1869 * @b: a #GSequenceIter
1872 * A #GSequenceIterCompareFunc is a function used to compare iterators.
1873 * It must return zero if the iterators compare equal, a negative value
1874 * if @a comes before @b, and a positive value if @b comes before @a.
1876 * Returns: zero if the iterators are equal, a negative value if @a
1877 * comes before @b, and a positive value if @b comes before
1884 * @G_SHELL_ERROR_BAD_QUOTING: Mismatched or otherwise mangled quoting.
1885 * @G_SHELL_ERROR_EMPTY_STRING: String to be parsed was empty.
1886 * @G_SHELL_ERROR_FAILED: Some other error.
1888 * Error codes returned by shell functions.
1895 * A type corresponding to the appropriate struct type for the stat
1896 * system call, depending on the platform and/or compiler being used.
1898 * See g_stat() for more information.
1904 * @str: points to the character data. It may move as text is added.
1905 * The @str field is null-terminated and so
1906 * can be used as an ordinary C string.
1907 * @len: contains the length of the string, not including the
1908 * terminating nul byte.
1909 * @allocated_len: the number of bytes that can be stored in the
1910 * string before it needs to be reallocated. May be larger than @len.
1912 * The GString struct contains the public fields of a GString.
1919 * An opaque data structure representing String Chunks.
1920 * It should only be accessed by using the following functions.
1927 * An opaque structure representing a test case.
1933 * @user_data: the data provided when registering the test
1935 * The type used for test case functions that take an extra pointer
1944 * @G_TEST_DIST: a file that was included in the distribution tarball
1945 * @G_TEST_BUILT: a file that was built on the compiling machine
1947 * The type of file to return the filename for, when used with
1948 * g_test_build_filename().
1950 * These two options correspond rather directly to the 'dist' and
1951 * 'built' terminology that automake uses and are explicitly used to
1952 * distinguish between the 'srcdir' and 'builddir' being separate. All
1953 * files in your project should either be dist (in the
1954 * <literal>DIST_EXTRA</literal> or <literal>dist_schema_DATA</literal>
1955 * sense, in which case they will always be in the srcdir) or built (in
1956 * the <literal>BUILT_SOURCES</literal> sense, in which case they will
1957 * always be in the builddir).
1959 * Note: as a general rule of automake, files that are generated only as
1960 * part of the build-from-git process (but then are distributed with the
1961 * tarball) always go in srcdir (even if doing a srcdir != builddir
1962 * build from git) and are considered as distributed files.
1970 * @fixture: the test fixture
1971 * @user_data: the data provided when registering the test
1973 * The type used for functions that operate on test fixtures. This is
1974 * used for the fixture setup and teardown functions as well as for the
1975 * testcases themselves.
1977 * @user_data is a pointer to the data that was given when registering
1980 * @fixture will be a pointer to the area of memory allocated by the
1981 * test framework, of the size requested. If the requested size was
1982 * zero then @fixture will be equal to @user_data.
1991 * The type used for test case functions.
1998 * GTestSubprocessFlags:
1999 * @G_TEST_SUBPROCESS_INHERIT_STDIN: If this flag is given, the child
2000 * process will inherit the parent's stdin. Otherwise, the child's
2001 * stdin is redirected to <filename>/dev/null</filename>.
2002 * @G_TEST_SUBPROCESS_INHERIT_STDOUT: If this flag is given, the child
2003 * process will inherit the parent's stdout. Otherwise, the child's
2004 * stdout will not be visible, but it will be captured to allow
2005 * later tests with g_test_trap_assert_stdout().
2006 * @G_TEST_SUBPROCESS_INHERIT_STDERR: If this flag is given, the child
2007 * process will inherit the parent's stderr. Otherwise, the child's
2008 * stderr will not be visible, but it will be captured to allow
2009 * later tests with g_test_trap_assert_stderr().
2011 * Flags to pass to g_test_trap_subprocess() to control input and output.
2013 * Note that in contrast with g_test_trap_fork(), the default is to
2014 * not show stdout and stderr.
2021 * An opaque structure representing a test suite.
2027 * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to
2028 * <filename>/dev/null</filename> so it cannot be observed on the
2029 * console during test runs. The actual output is still captured
2030 * though to allow later tests with g_test_trap_assert_stdout().
2031 * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to
2032 * <filename>/dev/null</filename> so it cannot be observed on the
2033 * console during test runs. The actual output is still captured
2034 * though to allow later tests with g_test_trap_assert_stderr().
2035 * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the
2036 * child process is shared with stdin of its parent process.
2037 * It is redirected to <filename>/dev/null</filename> otherwise.
2039 * Test traps are guards around forked tests.
2040 * These flags determine what traps to set.
2042 * Deprecated: #GTestTrapFlags is used only with g_test_trap_fork(),
2043 * which is deprecated. g_test_trap_subprocess() uses
2044 * #GTestTrapSubprocessFlags.
2051 * The #GThread struct represents a running thread. This struct
2052 * is returned by g_thread_new() or g_thread_try_new(). You can
2053 * obtain the #GThread struct representing the current thead by
2054 * calling g_thread_self().
2056 * GThread is refcounted, see g_thread_ref() and g_thread_unref().
2057 * The thread represented by it holds a reference while it is running,
2058 * and g_thread_join() consumes the reference that it is given, so
2059 * it is normally not necessary to manage GThread references
2062 * The structure is opaque -- none of its fields may be directly
2069 * @G_THREAD_ERROR_AGAIN: a thread couldn't be created due to resource
2070 * shortage. Try again later.
2072 * Possible errors of thread related functions.
2078 * @data: data passed to the thread
2080 * Specifies the type of the @func functions passed to g_thread_new()
2081 * or g_thread_try_new().
2083 * Returns: the return value of the thread
2089 * @func: the function to execute in the threads of this pool
2090 * @user_data: the user data for the threads of this pool
2091 * @exclusive: are all threads exclusive to this pool
2093 * The #GThreadPool struct represents a thread pool. It has three
2094 * public read-only members, but the underlying struct is bigger,
2095 * so you must not copy this struct.
2102 * Simply a replacement for <type>time_t</type>. It has been deprecated
2103 * since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
2104 * on 64-bit platforms with a 64-bit <type>time_t</type>.
2105 * Unrelated to #GTimer.
2107 * Note that <type>GTime</type> is defined to always be a 32bit integer,
2108 * unlike <type>time_t</type> which may be 64bit on some systems.
2109 * Therefore, <type>GTime</type> will overflow in the year 2038, and
2110 * you cannot use the address of a <type>GTime</type> variable as argument
2111 * to the UNIX time() function. Instead, do the following:
2116 * time (&ttime);
2117 * gtime = (GTime)ttime;
2125 * @tv_usec: microseconds
2127 * Represents a precise time, with seconds and microseconds.
2128 * Similar to the <structname>struct timeval</structname> returned by
2129 * the gettimeofday() UNIX system call.
2131 * GLib is attempting to unify around the use of 64bit integers to
2132 * represent microsecond-precision time. As such, this type will be
2133 * removed from a future version of GLib.
2140 * #GTimeZone is an opaque structure whose members cannot be accessed
2150 * Opaque datatype that records a start time.
2156 * @G_TOKEN_EOF: the end of the file
2157 * @G_TOKEN_LEFT_PAREN: a '(' character
2158 * @G_TOKEN_LEFT_CURLY: a '{' character
2159 * @G_TOKEN_LEFT_BRACE: a '[' character
2160 * @G_TOKEN_RIGHT_CURLY: a '}' character
2161 * @G_TOKEN_RIGHT_PAREN: a ')' character
2162 * @G_TOKEN_RIGHT_BRACE: a ']' character
2163 * @G_TOKEN_EQUAL_SIGN: a '=' character
2164 * @G_TOKEN_COMMA: a ',' character
2165 * @G_TOKEN_NONE: not a token
2166 * @G_TOKEN_ERROR: an error occurred
2167 * @G_TOKEN_CHAR: a character
2168 * @G_TOKEN_BINARY: a binary integer
2169 * @G_TOKEN_OCTAL: an octal integer
2170 * @G_TOKEN_INT: an integer
2171 * @G_TOKEN_HEX: a hex integer
2172 * @G_TOKEN_FLOAT: a floating point number
2173 * @G_TOKEN_STRING: a string
2174 * @G_TOKEN_SYMBOL: a symbol
2175 * @G_TOKEN_IDENTIFIER: an identifier
2176 * @G_TOKEN_IDENTIFIER_NULL: a null identifier
2177 * @G_TOKEN_COMMENT_SINGLE: one line comment
2178 * @G_TOKEN_COMMENT_MULTI: multi line comment
2180 * The possible types of token returned from each
2181 * g_scanner_get_next_token() call.
2187 * @v_symbol: token symbol value
2188 * @v_identifier: token identifier value
2189 * @v_binary: token binary integer value
2190 * @v_octal: octal integer value
2191 * @v_int: integer value
2192 * @v_int64: 64-bit integer value
2193 * @v_float: floating point value
2194 * @v_hex: hex integer value
2195 * @v_string: string value
2196 * @v_comment: comment value
2197 * @v_char: character value
2198 * @v_error: error value
2200 * A union holding the value of the token.
2206 * @next: pointer to the previous element of the stack,
2207 * gets stored in the first <literal>sizeof (gpointer)</literal>
2208 * bytes of the element
2210 * Each piece of memory that is pushed onto the stack
2211 * is cast to a <structname>GTrashStack*</structname>.
2217 * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has
2218 * been introduced in 2.6, for older version use
2219 * %G_TRAVERSE_LEAFS.
2220 * @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This
2221 * name has been introduced in 2.6, for older
2222 * version use %G_TRAVERSE_NON_LEAFS.
2223 * @G_TRAVERSE_ALL: all nodes should be visited.
2224 * @G_TRAVERSE_MASK: a mask of all traverse flags.
2225 * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
2226 * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
2228 * Specifies which nodes are visited during several of the tree
2229 * functions, including g_node_traverse() and g_node_find().
2235 * @key: a key of a #GTree node.
2236 * @value: the value corresponding to the key.
2237 * @data: user data passed to g_tree_traverse().
2239 * Specifies the type of function passed to g_tree_traverse(). It is
2240 * passed the key and value of each node, together with the @user_data
2241 * parameter passed to g_tree_traverse(). If the function returns
2242 * %TRUE, the traversal is stopped.
2244 * Returns: %TRUE to stop the traversal.
2250 * @G_IN_ORDER: vists a node's left child first, then the node itself,
2251 * then its right child. This is the one to use if you
2252 * want the output sorted according to the compare
2254 * @G_PRE_ORDER: visits a node, then its children.
2255 * @G_POST_ORDER: visits the node's children, then the node itself.
2256 * @G_LEVEL_ORDER: is not implemented for <link
2257 * linkend="glib-Balanced-Binary-Trees">Balanced Binary
2258 * Trees</link>. For <link
2259 * linkend="glib-N-ary-Trees">N-ary Trees</link>, it
2260 * vists the root node first, then its children, then
2261 * its grandchildren, and so on. Note that this is less
2262 * efficient than the other orders.
2264 * Specifies the type of traveral performed by g_tree_traverse(),
2265 * g_node_traverse() and g_node_find().
2272 * The <structname>GTree</structname> struct is an opaque data
2273 * structure representing a <link
2274 * linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
2275 * should be accessed only by using the following functions.
2281 * @val: a #guint16 value in big-endian byte order
2283 * Converts a #guint16 value from big-endian to host byte order.
2285 * Returns: @val converted to host byte order
2291 * @val: a #guint16 value in little-endian byte order
2293 * Converts a #guint16 value from little-endian to host byte order.
2295 * Returns: @val converted to host byte order
2300 * GUINT16_SWAP_BE_PDP:
2301 * @val: a #guint16 value in big-endian or pdp-endian byte order
2303 * Converts a #guint16 value between big-endian and pdp-endian byte order.
2304 * The conversion is symmetric so it can be used both ways.
2306 * Returns: @val converted to the opposite byte order
2311 * GUINT16_SWAP_LE_BE:
2312 * @val: a #guint16 value in little-endian or big-endian byte order
2314 * Converts a #guint16 value between little-endian and big-endian byte order.
2315 * The conversion is symmetric so it can be used both ways.
2317 * Returns: @val converted to the opposite byte order
2322 * GUINT16_SWAP_LE_PDP:
2323 * @val: a #guint16 value in little-endian or pdp-endian byte order
2325 * Converts a #guint16 value between little-endian and pdp-endian byte order.
2326 * The conversion is symmetric so it can be used both ways.
2328 * Returns: @val converted to the opposite byte order
2334 * @val: a #guint16 value in host byte order
2336 * Converts a #guint16 value from host byte order to big-endian.
2338 * Returns: @val converted to big-endian
2344 * @val: a #guint16 value in host byte order
2346 * Converts a #guint16 value from host byte order to little-endian.
2348 * Returns: @val converted to little-endian
2354 * @val: a #guint32 value in big-endian byte order
2356 * Converts a #guint32 value from big-endian to host byte order.
2358 * Returns: @val converted to host byte order
2364 * @val: a #guint32 value in little-endian byte order
2366 * Converts a #guint32 value from little-endian to host byte order.
2368 * Returns: @val converted to host byte order
2373 * GUINT32_SWAP_BE_PDP:
2374 * @val: a #guint32 value in big-endian or pdp-endian byte order
2376 * Converts a #guint32 value between big-endian and pdp-endian byte order.
2377 * The conversion is symmetric so it can be used both ways.
2379 * Returns: @val converted to the opposite byte order
2384 * GUINT32_SWAP_LE_BE:
2385 * @val: a #guint32 value in little-endian or big-endian byte order
2387 * Converts a #guint32 value between little-endian and big-endian byte order.
2388 * The conversion is symmetric so it can be used both ways.
2390 * Returns: @val converted to the opposite byte order
2395 * GUINT32_SWAP_LE_PDP:
2396 * @val: a #guint32 value in little-endian or pdp-endian byte order
2398 * Converts a #guint32 value between little-endian and pdp-endian byte order.
2399 * The conversion is symmetric so it can be used both ways.
2401 * Returns: @val converted to the opposite byte order
2407 * @val: a #guint32 value in host byte order
2409 * Converts a #guint32 value from host byte order to big-endian.
2411 * Returns: @val converted to big-endian
2417 * @val: a #guint32 value in host byte order
2419 * Converts a #guint32 value from host byte order to little-endian.
2421 * Returns: @val converted to little-endian
2427 * @val: a #guint64 value in big-endian byte order
2429 * Converts a #guint64 value from big-endian to host byte order.
2431 * Returns: @val converted to host byte order
2437 * @val: a #guint64 value in little-endian byte order
2439 * Converts a #guint64 value from little-endian to host byte order.
2441 * Returns: @val converted to host byte order
2446 * GUINT64_SWAP_LE_BE:
2447 * @val: a #guint64 value in little-endian or big-endian byte order
2449 * Converts a #guint64 value between little-endian and big-endian byte order.
2450 * The conversion is symmetric so it can be used both ways.
2452 * Returns: @val converted to the opposite byte order
2458 * @val: a #guint64 value in host byte order
2460 * Converts a #guint64 value from host byte order to big-endian.
2462 * Returns: @val converted to big-endian
2468 * @val: a #guint64 value in host byte order
2470 * Converts a #guint64 value from host byte order to little-endian.
2472 * Returns: @val converted to little-endian
2478 * @val: a #guint value in big-endian byte order
2480 * Converts a #guint value from big-endian to host byte order.
2482 * Returns: @val converted to host byte order
2488 * @val: a #guint value in little-endian byte order
2490 * Converts a #guint value from little-endian to host byte order.
2492 * Returns: @val converted to host byte order
2498 * @val: a #guint value in host byte order
2500 * Converts a #guint value from host byte order to big-endian.
2502 * Returns: @val converted to big-endian byte order
2508 * @val: a #guint value in host byte order
2510 * Converts a #guint value from host byte order to little-endian.
2512 * Returns: @val converted to little-endian byte order.
2518 * @u: unsigned integer to stuff into the pointer
2520 * Stuffs an unsigned integer into a pointer type.
2526 * @val: a #gulong value in big-endian byte order
2528 * Converts a #gulong value from big-endian to host byte order.
2530 * Returns: @val converted to host byte order
2536 * @val: a #gulong value in little-endian byte order
2538 * Converts a #gulong value from little-endian to host byte order.
2540 * Returns: @val converted to host byte order
2546 * @val: a #gulong value in host byte order
2548 * Converts a #gulong value from host byte order to big-endian.
2550 * Returns: @val converted to big-endian
2556 * @val: a #gulong value in host byte order
2558 * Converts a #gulong value from host byte order to little-endian.
2560 * Returns: @val converted to little-endian
2567 * #GVariant is an opaque data structure and can only be accessed
2568 * using the following functions.
2577 * A utility type for constructing container-type #GVariant instances.
2579 * This is an opaque structure and may only be accessed using the
2580 * following functions.
2582 * #GVariantBuilder is not threadsafe in any way. Do not attempt to
2583 * access it from more than one thread.
2589 * @G_VARIANT_CLASS_BOOLEAN: The #GVariant is a boolean.
2590 * @G_VARIANT_CLASS_BYTE: The #GVariant is a byte.
2591 * @G_VARIANT_CLASS_INT16: The #GVariant is a signed 16 bit integer.
2592 * @G_VARIANT_CLASS_UINT16: The #GVariant is an unsigned 16 bit integer.
2593 * @G_VARIANT_CLASS_INT32: The #GVariant is a signed 32 bit integer.
2594 * @G_VARIANT_CLASS_UINT32: The #GVariant is an unsigned 32 bit integer.
2595 * @G_VARIANT_CLASS_INT64: The #GVariant is a signed 64 bit integer.
2596 * @G_VARIANT_CLASS_UINT64: The #GVariant is an unsigned 64 bit integer.
2597 * @G_VARIANT_CLASS_HANDLE: The #GVariant is a file handle index.
2598 * @G_VARIANT_CLASS_DOUBLE: The #GVariant is a double precision floating
2600 * @G_VARIANT_CLASS_STRING: The #GVariant is a normal string.
2601 * @G_VARIANT_CLASS_OBJECT_PATH: The #GVariant is a D-Bus object path
2603 * @G_VARIANT_CLASS_SIGNATURE: The #GVariant is a D-Bus signature string.
2604 * @G_VARIANT_CLASS_VARIANT: The #GVariant is a variant.
2605 * @G_VARIANT_CLASS_MAYBE: The #GVariant is a maybe-typed value.
2606 * @G_VARIANT_CLASS_ARRAY: The #GVariant is an array.
2607 * @G_VARIANT_CLASS_TUPLE: The #GVariant is a tuple.
2608 * @G_VARIANT_CLASS_DICT_ENTRY: The #GVariant is a dictionary entry.
2610 * The range of possible top-level types of #GVariant instances.
2617 * GVariantIter: (skip)
2619 * #GVariantIter is an opaque data structure and can only be accessed
2620 * using the following functions.
2625 * GVariantParseError:
2626 * @G_VARIANT_PARSE_ERROR_FAILED: generic error (unused)
2627 * @G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED: a non-basic #GVariantType was given where a basic type was expected
2628 * @G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE: cannot infer the #GVariantType
2629 * @G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED: an indefinite #GVariantType was given where a definite type was expected
2630 * @G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END: extra data after parsing finished
2631 * @G_VARIANT_PARSE_ERROR_INVALID_CHARACTER: invalid character in number or unicode escape
2632 * @G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING: not a valid #GVariant format string
2633 * @G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH: not a valid object path
2634 * @G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE: not a valid type signature
2635 * @G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING: not a valid #GVariant type string
2636 * @G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE: could not find a common type for array entries
2637 * @G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE: the numerical value is out of range of the given type
2638 * @G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG: the numerical value is out of range for any type
2639 * @G_VARIANT_PARSE_ERROR_TYPE_ERROR: cannot parse as variant of the specified type
2640 * @G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN: an unexpected token was encountered
2641 * @G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD: an unknown keyword was encountered
2642 * @G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT: unterminated string constant
2643 * @G_VARIANT_PARSE_ERROR_VALUE_EXPECTED: no value given
2645 * Error codes returned by parsing text-format GVariants.
2650 * G_ASCII_DTOSTR_BUF_SIZE:
2652 * A good size for a buffer to be passed into g_ascii_dtostr().
2653 * It is guaranteed to be enough for all output of that function
2654 * on systems with 64bit IEEE-compatible doubles.
2656 * The typical usage would be something like:
2658 * char buf[G_ASCII_DTOSTR_BUF_SIZE];
2660 * fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
2666 * G_ATOMIC_LOCK_FREE:
2668 * This macro is defined if the atomic operations of GLib are
2669 * implemented using real hardware atomic operations. This means that
2670 * the GLib atomic API can be used between processes and safely mixed
2671 * with other (hardware) atomic APIs.
2673 * If this macro is not defined, the atomic operations may be
2674 * emulated using a mutex. In that case, the GLib atomic operations are
2675 * only atomic relative to themselves and within a single process.
2682 * Used (along with #G_END_DECLS) to bracket header files. If the
2683 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2684 * around the header.
2691 * Specifies one of the possible types of byte order.
2692 * See #G_BYTE_ORDER.
2699 * The host byte order.
2700 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
2701 * #G_PDP_ENDIAN may be added in future.)
2708 * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
2709 * to nothing. By default, the macro expands to <literal>const</literal>.
2710 * The macro should be used in place of <literal>const</literal> for
2711 * functions that return a value that should not be modified. The
2712 * purpose of this macro is to allow us to turn on <literal>const</literal>
2713 * for returned constant strings by default, while allowing programmers
2714 * who find that annoying to turn it off. This macro should only be used
2715 * for return values and for <emphasis>out</emphasis> parameters, it doesn't
2716 * make sense for <emphasis>in</emphasis> parameters.
2718 * Deprecated: 2.30: API providers should replace all existing uses with
2719 * <literal>const</literal> and API consumers should adjust their code
2727 * The set of uppercase ASCII alphabet characters.
2728 * Used for specifying valid identifier characters
2729 * in #GScannerConfig.
2736 * The set of uppercase ISO 8859-1 alphabet characters
2737 * which are not ASCII characters.
2738 * Used for specifying valid identifier characters
2739 * in #GScannerConfig.
2746 * The set of lowercase ISO 8859-1 alphabet characters
2747 * which are not ASCII characters.
2748 * Used for specifying valid identifier characters
2749 * in #GScannerConfig.
2756 * The set of lowercase ASCII alphabet characters.
2757 * Used for specifying valid identifier characters
2758 * in #GScannerConfig.
2765 * Represents an invalid #GDateDay.
2770 * G_DATE_BAD_JULIAN:
2772 * Represents an invalid Julian day number.
2779 * Represents an invalid year.
2785 * @QN: the name to return a #GQuark for
2786 * @q_n: prefix for the function name
2788 * A convenience macro which defines a function returning the
2789 * #GQuark for the name @QN. The function will be named
2790 * @q_n<!-- -->_quark().
2791 * Note that the quark name will be stringified automatically in the
2792 * macro, so you shouldn't use double quotes.
2801 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2802 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2803 * meant to be portable across different compilers and must be placed
2804 * before the function declaration.
2812 * @f: the name of the function that this function was deprecated for
2814 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2815 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2816 * meant to be portable across different compilers and must be placed
2817 * before the function declaration.
2826 * The directory separator character.
2827 * This is '/' on UNIX machines and '\' under Windows.
2832 * G_DIR_SEPARATOR_S:
2834 * The directory separator as a string.
2835 * This is "/" on UNIX machines and "\" under Windows.
2842 * The base of natural logarithms.
2849 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
2850 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2851 * around the header.
2858 * Error domain for file operations. Errors in this domain will
2859 * be from the #GFileError enumeration. See #GError for information
2867 * This is the platform dependent conversion specifier for scanning and
2868 * printing values of type #gint16. It is a string literal, but doesn't
2869 * include the percent-sign, such that you can add precision and length
2870 * modifiers between percent-sign and conversion specifier.
2875 * sscanf ("42", "%" G_GINT16_FORMAT, &in)
2877 * g_print ("%" G_GINT32_FORMAT, out);
2883 * G_GINT16_MODIFIER:
2885 * The platform dependent length modifier for conversion specifiers
2886 * for scanning and printing values of type #gint16 or #guint16. It
2887 * is a string literal, but doesn't include the percent-sign, such
2888 * that you can add precision and length modifiers between percent-sign
2889 * and conversion specifier and append a conversion specifier.
2891 * The following example prints "0x7b";
2893 * gint16 value = 123;
2894 * g_print ("%#" G_GINT16_MODIFIER "x", value);
2904 * This is the platform dependent conversion specifier for scanning
2905 * and printing values of type #gint32. See also #G_GINT16_FORMAT.
2910 * G_GINT32_MODIFIER:
2912 * The platform dependent length modifier for conversion specifiers
2913 * for scanning and printing values of type #gint32 or #guint32. It
2914 * is a string literal. See also #G_GINT16_MODIFIER.
2921 * G_GINT64_CONSTANT:
2922 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
2924 * This macro is used to insert 64-bit integer literals
2925 * into the source code.
2932 * This is the platform dependent conversion specifier for scanning
2933 * and printing values of type #gint64. See also #G_GINT16_FORMAT.
2936 * Some platforms do not support scanning and printing 64 bit integers,
2937 * even though the types are supported. On such platforms #G_GINT64_FORMAT
2938 * is not defined. Note that scanf() may not support 64 bit integers, even
2939 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
2940 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
2947 * G_GINT64_MODIFIER:
2949 * The platform dependent length modifier for conversion specifiers
2950 * for scanning and printing values of type #gint64 or #guint64.
2951 * It is a string literal.
2954 * Some platforms do not support printing 64 bit integers, even
2955 * though the types are supported. On such platforms #G_GINT64_MODIFIER
2966 * This is the platform dependent conversion specifier for scanning
2967 * and printing values of type #gintptr.
2974 * G_GINTPTR_MODIFIER:
2976 * The platform dependent length modifier for conversion specifiers
2977 * for scanning and printing values of type #gintptr or #guintptr.
2978 * It is a string literal.
2985 * G_GNUC_ALLOC_SIZE:
2986 * @x: the index of the argument specifying the allocation size
2988 * Expands to the GNU C <literal>alloc_size</literal> function attribute
2989 * if the compiler is a new enough <command>gcc</command>. This attribute
2990 * tells the compiler that the function returns a pointer to memory of a
2991 * size that is specified by the @x<!-- -->th function parameter.
2993 * Place the attribute after the function declaration, just before the
2996 * See the GNU C documentation for more details.
3003 * G_GNUC_ALLOC_SIZE2:
3004 * @x: the index of the argument specifying one factor of the allocation size
3005 * @y: the index of the argument specifying the second factor of the allocation size
3007 * Expands to the GNU C <literal>alloc_size</literal> function attribute
3008 * if the compiler is a new enough <command>gcc</command>. This attribute
3009 * tells the compiler that the function returns a pointer to memory of a
3010 * size that is specified by the product of two function parameters.
3012 * Place the attribute after the function declaration, just before the
3015 * See the GNU C documentation for more details.
3022 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
3024 * Tells <command>gcc</command> (if it is a new enough version) to
3025 * temporarily stop emitting warnings when functions marked with
3026 * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
3027 * useful for when you have one deprecated function calling another
3028 * one, or when you still have regression tests for deprecated
3031 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
3032 * are not compiling with <literal>-Wdeprecated-declarations</literal>
3033 * then neither macro has any effect.)
3035 * This macro can be used either inside or outside of a function body,
3036 * but must appear on a line by itself.
3045 * Expands to the GNU C <literal>const</literal> function attribute if
3046 * the compiler is <command>gcc</command>. Declaring a function as const
3047 * enables better optimization of calls to the function. A const function
3048 * doesn't examine any values except its parameters, and has no effects
3049 * except its return value.
3051 * Place the attribute after the declaration, just before the semicolon.
3053 * See the GNU C documentation for more details.
3056 * A function that has pointer arguments and examines the data pointed to
3057 * must <emphasis>not</emphasis> be declared const. Likewise, a function
3058 * that calls a non-const function usually must not be const. It doesn't
3059 * make sense for a const function to return void.
3065 * G_GNUC_DEPRECATED:
3067 * Expands to the GNU C <literal>deprecated</literal> attribute if the
3068 * compiler is <command>gcc</command>. It can be used to mark typedefs,
3069 * variables and functions as deprecated. When called with the
3070 * <option>-Wdeprecated-declarations</option> option, the compiler will
3071 * generate warnings when deprecated interfaces are used.
3073 * Place the attribute after the declaration, just before the semicolon.
3075 * See the GNU C documentation for more details.
3082 * G_GNUC_DEPRECATED_FOR:
3083 * @f: the intended replacement for the deprecated symbol,
3084 * such as the name of a function
3086 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
3087 * deprecated symbol if the version of <command>gcc</command> in use is
3088 * new enough to support custom deprecation messages.
3090 * Place the attribute after the declaration, just before the semicolon.
3092 * See the GNU C documentation for more details.
3094 * Note that if @f is a macro, it will be expanded in the warning message.
3095 * You can enclose it in quotes to prevent this. (The quotes will show up
3096 * in the warning, but it's better than showing the macro expansion.)
3103 * G_GNUC_END_IGNORE_DEPRECATIONS:
3105 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
3106 * <command>gcc</command> to begin outputting warnings again
3107 * (assuming those warnings had been enabled to begin with).
3109 * This macro can be used either inside or outside of a function body,
3110 * but must appear on a line by itself.
3119 * Expands to <literal>__extension__</literal> when <command>gcc</command>
3120 * is used as the compiler. This simply tells <command>gcc</command> not
3121 * to warn about the following non-standard code when compiling with the
3122 * <option>-pedantic</option> option.
3128 * @arg_idx: the index of the argument
3130 * Expands to the GNU C <literal>format_arg</literal> function attribute
3131 * if the compiler is <command>gcc</command>. This function attribute
3132 * specifies that a function takes a format string for a printf(),
3133 * scanf(), strftime() or strfmon() style function and modifies it,
3134 * so that the result can be passed to a printf(), scanf(), strftime()
3135 * or strfmon() style function (with the remaining arguments to the
3136 * format function the same as they would have been for the unmodified
3139 * Place the attribute after the function declaration, just before the
3142 * See the GNU C documentation for more details.
3145 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
3153 * Expands to "" on all modern compilers, and to
3154 * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
3157 * Deprecated: 2.16: Use #G_STRFUNC instead
3164 * This attribute can be used for marking library functions as being used
3165 * internally to the library only, which may allow the compiler to handle
3166 * function calls more efficiently. Note that static functions do not need
3167 * to be marked as internal in this way. See the GNU C documentation for
3170 * When using a compiler that supports the GNU C hidden visibility attribute,
3171 * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
3172 * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
3174 * Note that for portability, the attribute should be placed before the
3175 * function declaration. While GCC allows the macro after the declaration,
3176 * Sun Studio does not.
3180 * void _g_log_fallback_handler (const gchar *log_domain,
3181 * GLogLevelFlags log_level,
3182 * const gchar *message,
3183 * gpointer unused_data);
3193 * Expands to the GNU C <literal>malloc</literal> function attribute if the
3194 * compiler is <command>gcc</command>. Declaring a function as malloc enables
3195 * better optimization of the function. A function can have the malloc
3196 * attribute if it returns a pointer which is guaranteed to not alias with
3197 * any other pointer when the function returns (in practice, this means newly
3198 * allocated memory).
3200 * Place the attribute after the declaration, just before the semicolon.
3202 * See the GNU C documentation for more details.
3211 * Expands to the GNU C <literal>may_alias</literal> type attribute
3212 * if the compiler is <command>gcc</command>. Types with this attribute
3213 * will not be subjected to type-based alias analysis, but are assumed
3214 * to alias with any other type, just like char.
3215 * See the GNU C documentation for details.
3224 * Expands to the GNU C <literal>noreturn</literal> function attribute
3225 * if the compiler is <command>gcc</command>. It is used for declaring
3226 * functions which never return. It enables optimization of the function,
3227 * and avoids possible compiler warnings.
3229 * Place the attribute after the declaration, just before the semicolon.
3231 * See the GNU C documentation for more details.
3236 * G_GNUC_NO_INSTRUMENT:
3238 * Expands to the GNU C <literal>no_instrument_function</literal> function
3239 * attribute if the compiler is <command>gcc</command>. Functions with this
3240 * attribute will not be instrumented for profiling, when the compiler is
3241 * called with the <option>-finstrument-functions</option> option.
3243 * Place the attribute after the declaration, just before the semicolon.
3245 * See the GNU C documentation for more details.
3250 * G_GNUC_NULL_TERMINATED:
3252 * Expands to the GNU C <literal>sentinel</literal> function attribute
3253 * if the compiler is <command>gcc</command>, or "" if it isn't. This
3254 * function attribute only applies to variadic functions and instructs
3255 * the compiler to check that the argument list is terminated with an
3258 * Place the attribute after the declaration, just before the semicolon.
3260 * See the GNU C documentation for more details.
3267 * G_GNUC_PRETTY_FUNCTION:
3269 * Expands to "" on all modern compilers, and to
3270 * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
3271 * version 2.x. Don't use it.
3273 * Deprecated: 2.16: Use #G_STRFUNC instead
3279 * @format_idx: the index of the argument corresponding to the
3280 * format string (The arguments are numbered from 1)
3281 * @arg_idx: the index of the first of the format arguments
3283 * Expands to the GNU C <literal>format</literal> function attribute
3284 * if the compiler is <command>gcc</command>. This is used for declaring
3285 * functions which take a variable number of arguments, with the same
3286 * syntax as printf(). It allows the compiler to type-check the arguments
3287 * passed to the function.
3289 * Place the attribute after the function declaration, just before the
3292 * See the GNU C documentation for more details.
3295 * gint g_snprintf (gchar *string,
3297 * gchar const *format,
3298 * ...) G_GNUC_PRINTF (3, 4);
3306 * Expands to the GNU C <literal>pure</literal> function attribute if the
3307 * compiler is <command>gcc</command>. Declaring a function as pure enables
3308 * better optimization of calls to the function. A pure function has no
3309 * effects except its return value and the return value depends only on
3310 * the parameters and/or global variables.
3312 * Place the attribute after the declaration, just before the semicolon.
3314 * See the GNU C documentation for more details.
3320 * @format_idx: the index of the argument corresponding to
3321 * the format string (The arguments are numbered from 1)
3322 * @arg_idx: the index of the first of the format arguments
3324 * Expands to the GNU C <literal>format</literal> function attribute
3325 * if the compiler is <command>gcc</command>. This is used for declaring
3326 * functions which take a variable number of arguments, with the same
3327 * syntax as scanf(). It allows the compiler to type-check the arguments
3328 * passed to the function. See the GNU C documentation for details.
3335 * Expands to the GNU C <literal>unused</literal> function attribute if
3336 * the compiler is <command>gcc</command>. It is used for declaring
3337 * functions and arguments which may never be used. It avoids possible compiler
3340 * For functions, place the attribute after the declaration, just before the
3341 * semicolon. For arguments, place the attribute at the beginning of the
3342 * argument declaration.
3345 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
3346 * gint other_argument) G_GNUC_UNUSED;
3349 * See the GNU C documentation for more details.
3354 * G_GNUC_WARN_UNUSED_RESULT:
3356 * Expands to the GNU C <literal>warn_unused_result</literal> function
3357 * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
3358 * This function attribute makes the compiler emit a warning if the result
3359 * of a function call is ignored.
3361 * Place the attribute after the declaration, just before the semicolon.
3363 * See the GNU C documentation for more details.
3370 * G_GOFFSET_CONSTANT:
3371 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
3373 * This macro is used to insert #goffset 64-bit integer literals
3374 * into the source code.
3376 * See also #G_GINT64_CONSTANT.
3385 * This is the platform dependent conversion specifier for scanning
3386 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
3393 * G_GOFFSET_MODIFIER:
3395 * The platform dependent length modifier for conversion specifiers
3396 * for scanning and printing values of type #goffset. It is a string
3397 * literal. See also #G_GINT64_MODIFIER.
3406 * This is the platform dependent conversion specifier for scanning
3407 * and printing values of type #gsize. See also #G_GINT16_FORMAT.
3416 * The platform dependent length modifier for conversion specifiers
3417 * for scanning and printing values of type #gsize or #gssize. It
3418 * is a string literal.
3427 * This is the platform dependent conversion specifier for scanning
3428 * and printing values of type #gssize. See also #G_GINT16_FORMAT.
3437 * This is the platform dependent conversion specifier for scanning
3438 * and printing values of type #guint16. See also #G_GINT16_FORMAT
3445 * This is the platform dependent conversion specifier for scanning
3446 * and printing values of type #guint32. See also #G_GINT16_FORMAT.
3451 * G_GUINT64_CONSTANT:
3452 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
3454 * This macro is used to insert 64-bit unsigned integer
3455 * literals into the source code.
3464 * This is the platform dependent conversion specifier for scanning
3465 * and printing values of type #guint64. See also #G_GINT16_FORMAT.
3468 * Some platforms do not support scanning and printing 64 bit integers,
3469 * even though the types are supported. On such platforms #G_GUINT64_FORMAT
3470 * is not defined. Note that scanf() may not support 64 bit integers, even
3471 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
3472 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
3479 * G_GUINTPTR_FORMAT:
3481 * This is the platform dependent conversion specifier
3482 * for scanning and printing values of type #guintptr.
3492 * Casts a pointer to a <literal>GHook*</literal>.
3500 * Returns %TRUE if the #GHook is active, which is normally the case
3501 * until the #GHook is destroyed.
3503 * Returns: %TRUE if the #GHook is active
3511 * Gets the flags of a hook.
3516 * G_HOOK_FLAG_USER_SHIFT:
3518 * The position of the first bit which is not reserved for internal
3519 * use be the #GHook implementation, i.e.
3520 * <literal>1 << G_HOOK_FLAG_USER_SHIFT</literal> is the first
3521 * bit which can be used for application-defined flags.
3529 * Returns %TRUE if the #GHook function is currently executing.
3531 * Returns: %TRUE if the #GHook function is currently executing
3536 * G_HOOK_IS_UNLINKED:
3539 * Returns %TRUE if the #GHook is not in a #GHookList.
3541 * Returns: %TRUE if the #GHook is not in a #GHookList
3549 * Returns %TRUE if the #GHook is valid, i.e. it is in a #GHookList,
3550 * it is active and it has not been destroyed.
3552 * Returns: %TRUE if the #GHook is valid
3557 * G_IEEE754_DOUBLE_BIAS:
3559 * The bias by which exponents in double-precision floats are offset.
3564 * G_IEEE754_FLOAT_BIAS:
3566 * The bias by which exponents in single-precision floats are offset.
3573 * This macro is used to export function prototypes so they can be linked
3574 * with an external version when no inlining is performed. The file which
3575 * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
3576 * before including the headers which contain %G_INLINE_FUNC declarations.
3577 * Since inlining is very compiler-dependent using these macros correctly
3578 * is very difficult. Their use is strongly discouraged.
3580 * This macro is often mistaken for a replacement for the inline keyword;
3581 * inline is already declared in a portable manner in the GLib headers
3582 * and can be used normally.
3587 * G_IO_CHANNEL_ERROR:
3589 * Error domain for #GIOChannel operations. Errors in this domain will
3590 * be from the #GIOChannelError enumeration. See #GError for
3591 * information on error domains.
3596 * G_IO_FLAG_IS_WRITEABLE:
3598 * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
3599 * before the spelling was fixed in GLib 2.30. It is kept here for
3600 * compatibility reasons.
3602 * Deprecated: 2.30: Use G_IO_FLAG_IS_WRITABLE instead.
3607 * G_IS_DIR_SEPARATOR:
3610 * Checks whether a character is a directory
3611 * separator. It returns %TRUE for '/' on UNIX
3612 * machines and for '\' or '/' under Windows.
3619 * G_KEY_FILE_DESKTOP_GROUP:
3621 * The name of the main group of a desktop entry file, as defined in the
3622 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
3623 * Entry Specification</ulink>. Consult the specification for more
3624 * details about the meanings of the keys below.
3631 * G_KEY_FILE_DESKTOP_KEY_CATEGORIES:
3633 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3634 * of strings giving the categories in which the desktop entry
3635 * should be shown in a menu.
3642 * G_KEY_FILE_DESKTOP_KEY_COMMENT:
3644 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3645 * string giving the tooltip for the desktop entry.
3652 * G_KEY_FILE_DESKTOP_KEY_EXEC:
3654 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3655 * giving the command line to execute. It is only valid for desktop
3656 * entries with the <literal>Application</literal> type.
3663 * G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME:
3665 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3666 * string giving the generic name of the desktop entry.
3673 * G_KEY_FILE_DESKTOP_KEY_HIDDEN:
3675 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3676 * stating whether the desktop entry has been deleted by the user.
3683 * G_KEY_FILE_DESKTOP_KEY_ICON:
3685 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3686 * string giving the name of the icon to be displayed for the desktop
3694 * G_KEY_FILE_DESKTOP_KEY_MIME_TYPE:
3696 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3697 * of strings giving the MIME types supported by this desktop entry.
3704 * G_KEY_FILE_DESKTOP_KEY_NAME:
3706 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3707 * string giving the specific name of the desktop entry.
3714 * G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN:
3716 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3717 * strings identifying the environments that should not display the
3725 * G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY:
3727 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3728 * stating whether the desktop entry should be shown in menus.
3735 * G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN:
3737 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3738 * strings identifying the environments that should display the
3746 * G_KEY_FILE_DESKTOP_KEY_PATH:
3748 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3749 * containing the working directory to run the program in. It is only
3750 * valid for desktop entries with the <literal>Application</literal> type.
3757 * G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY:
3759 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3760 * stating whether the application supports the <ulink
3761 * url="http://www.freedesktop.org/Standards/startup-notification-spec">Startup
3762 * Notification Protocol Specification</ulink>.
3769 * G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS:
3771 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is string
3772 * identifying the WM class or name hint of a window that the application
3773 * will create, which can be used to emulate Startup Notification with
3774 * older applications.
3781 * G_KEY_FILE_DESKTOP_KEY_TERMINAL:
3783 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3784 * stating whether the program should be run in a terminal window.
3785 * It is only valid for desktop entries with the
3786 * <literal>Application</literal> type.
3793 * G_KEY_FILE_DESKTOP_KEY_TRY_EXEC:
3795 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3796 * giving the file name of a binary on disk used to determine if the
3797 * program is actually installed. It is only valid for desktop entries
3798 * with the <literal>Application</literal> type.
3805 * G_KEY_FILE_DESKTOP_KEY_TYPE:
3807 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3808 * giving the type of the desktop entry. Usually
3809 * #G_KEY_FILE_DESKTOP_TYPE_APPLICATION,
3810 * #G_KEY_FILE_DESKTOP_TYPE_LINK, or
3811 * #G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.
3818 * G_KEY_FILE_DESKTOP_KEY_URL:
3820 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3821 * giving the URL to access. It is only valid for desktop entries
3822 * with the <literal>Link</literal> type.
3829 * G_KEY_FILE_DESKTOP_KEY_VERSION:
3831 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3832 * giving the version of the Desktop Entry Specification used for
3833 * the desktop entry file.
3840 * G_KEY_FILE_DESKTOP_TYPE_APPLICATION:
3842 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3843 * entries representing applications.
3850 * G_KEY_FILE_DESKTOP_TYPE_DIRECTORY:
3852 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3853 * entries representing directories.
3860 * G_KEY_FILE_DESKTOP_TYPE_LINK:
3862 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3863 * entries representing links to documents.
3872 * Error domain for key file parsing. Errors in this domain will
3873 * be from the #GKeyFileError enumeration.
3875 * See #GError for information on error domains.
3881 * @expr: the expression
3883 * Hints the compiler that the expression is likely to evaluate to
3884 * a true value. The compiler may use this information for optimizations.
3887 * if (G_LIKELY (random () != 1))
3888 * g_print ("not one");
3891 * Returns: the value of @expr
3899 * Specifies one of the possible types of byte order.
3900 * See #G_BYTE_ORDER.
3907 * The natural logarithm of 10.
3914 * The natural logarithm of 2.
3920 * @name: the name of the lock
3922 * Works like g_mutex_lock(), but for a lock defined with
3929 * @name: the name of the lock
3931 * The <literal>G_LOCK_*</literal> macros provide a convenient interface to #GMutex.
3932 * #G_LOCK_DEFINE defines a lock. It can appear in any place where
3933 * variable definitions may appear in programs, i.e. in the first block
3934 * of a function or outside of functions. The @name parameter will be
3935 * mangled to get the name of the #GMutex. This means that you
3936 * can use names of existing variables as the parameter - e.g. the name
3937 * of the variable you intend to protect with the lock. Look at our
3938 * <function>give_me_next_number()</function> example using the
3939 * <literal>G_LOCK_*</literal> macros:
3942 * <title>Using the <literal>G_LOCK_*</literal> convenience macros</title>
3944 * G_LOCK_DEFINE (current_number);
3947 * give_me_next_number (void)
3949 * static int current_number = 0;
3952 * G_LOCK (current_number);
3953 * ret_val = current_number = calc_next_number (current_number);
3954 * G_UNLOCK (current_number);
3964 * G_LOCK_DEFINE_STATIC:
3965 * @name: the name of the lock
3967 * This works like #G_LOCK_DEFINE, but it creates a static object.
3973 * @name: the name of the lock
3975 * This declares a lock, that is defined with #G_LOCK_DEFINE in another
3983 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
3990 * Defines the log domain.
3992 * For applications, this is typically left as the default %NULL
3993 * (or "") domain. Libraries should define this so that any messages
3994 * which they log can be differentiated from messages from other
3995 * libraries and application code. But be careful not to define
3996 * it in any public header files.
3998 * For example, GTK+ uses this in its Makefile.am:
4000 * INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
4008 * GLib log levels that are considered fatal by default.
4015 * The maximum value which can be held in a #gdouble.
4022 * The maximum value which can be held in a #gfloat.
4029 * The maximum value which can be held in a #gint.
4036 * The maximum value which can be held in a #gint16.
4045 * The maximum value which can be held in a #gint32.
4054 * The maximum value which can be held in a #gint64.
4061 * The maximum value which can be held in a #gint8.
4070 * The maximum value which can be held in a #glong.
4077 * The maximum value which can be held in a #goffset.
4084 * The maximum value which can be held in a #gshort.
4091 * The maximum value which can be held in a #gsize.
4100 * The maximum value which can be held in a #gssize.
4109 * The maximum value which can be held in a #guint.
4116 * The maximum value which can be held in a #guint16.
4125 * The maximum value which can be held in a #guint32.
4134 * The maximum value which can be held in a #guint64.
4141 * The maximum value which can be held in a #guint8.
4150 * The maximum value which can be held in a #gulong.
4157 * The maximum value which can be held in a #gushort.
4164 * The minimum positive value which can be held in a #gdouble.
4166 * If you are interested in the smallest value which can be held
4167 * in a #gdouble, use -G_MAXDOUBLE.
4174 * The minimum positive value which can be held in a #gfloat.
4176 * If you are interested in the smallest value which can be held
4177 * in a #gfloat, use -G_MAXFLOAT.
4184 * The minimum value which can be held in a #gint.
4191 * The minimum value which can be held in a #gint16.
4200 * The minimum value which can be held in a #gint32.
4209 * The minimum value which can be held in a #gint64.
4216 * The minimum value which can be held in a #gint8.
4225 * The minimum value which can be held in a #glong.
4232 * The minimum value which can be held in a #goffset.
4239 * The minimum value which can be held in a #gshort.
4246 * The minimum value which can be held in a #gssize.
4256 * Determines the number of elements in an array. The array must be
4257 * declared so the compiler knows its size at compile-time; this
4258 * macro will not work on an array allocated on the heap, only static
4259 * arrays or arrays on the stack.
4266 * A #GOnce must be initialized with this macro before it can be used.
4269 * GOnce my_once = G_ONCE_INIT;
4279 * This macro is defined only on BeOS. So you can bracket
4280 * BeOS-specific code in "#ifdef G_OS_BEOS".
4287 * This macro is defined only on UNIX. So you can bracket
4288 * UNIX-specific code in "#ifdef G_OS_UNIX".
4295 * This macro is defined only on Windows. So you can bracket
4296 * Windows-specific code in "#ifdef G_OS_WIN32".
4302 * @identifier1: an identifier
4303 * @identifier2: an identifier
4305 * Yields a new preprocessor pasted identifier
4306 * <code>identifier1identifier2</code> from its expanded
4307 * arguments @identifier1 and @identifier2. For example,
4308 * the following code:
4310 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
4311 * const gchar *name = GET (traveller, name);
4312 * const gchar *quest = GET (traveller, quest);
4313 * GdkColor *favourite = GET (traveller, favourite_colour);
4316 * is transformed by the preprocessor into:
4318 * const gchar *name = traveller_get_name (traveller);
4319 * const gchar *quest = traveller_get_quest (traveller);
4320 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
4330 * Specifies one of the possible types of byte order
4331 * (currently unused). See #G_BYTE_ORDER.
4338 * The value of pi (ratio of circle's circumference to its diameter).
4358 * @notify: a #GDestroyNotify
4360 * A macro to assist with the static initialisation of a #GPrivate.
4362 * This macro is useful for the case that a #GDestroyNotify function
4363 * should be associated the key. This is needed when the key will be
4364 * used to point at memory that should be deallocated when the thread
4367 * Additionally, the #GDestroyNotify will also be called on the previous
4368 * value stored in the key when g_private_replace() is used.
4370 * If no #GDestroyNotify is needed, then use of this macro is not
4371 * required -- if the #GPrivate is declared in static scope then it will
4372 * be properly initialised by default (ie: to all zeros). See the
4376 * static GPrivate name_key = G_PRIVATE_INIT (g_free);
4378 * // return value should not be freed
4380 * get_local_name (void)
4382 * return g_private_get (&name_key);
4386 * set_local_name (const gchar *name)
4388 * g_private_replace (&name_key, g_strdup (name));
4392 * static GPrivate count_key; // no free function
4395 * get_local_count (void)
4397 * return GPOINTER_TO_INT (g_private_get (&count_key));
4401 * set_local_count (gint count)
4403 * g_private_set (&count_key, GINT_TO_POINTER (count));
4412 * G_SEARCHPATH_SEPARATOR:
4414 * The search path separator character.
4415 * This is ':' on UNIX machines and ';' under Windows.
4420 * G_SEARCHPATH_SEPARATOR_S:
4422 * The search path separator as a string.
4423 * This is ":" on UNIX machines and ";" under Windows.
4430 * Error domain for shell functions. Errors in this domain will be from
4431 * the #GShellError enumeration. See #GError for information on error
4439 * The square root of two.
4445 * @expr: a constant expression
4447 * The G_STATIC_ASSERT macro lets the programmer check
4448 * a condition at compile time, the condition needs to
4449 * be compile time computable. The macro can be used in
4450 * any place where a <literal>typedef</literal> is valid.
4453 * A <literal>typedef</literal> is generally allowed in
4454 * exactly the same places that a variable declaration is
4455 * allowed. For this reason, you should not use
4456 * <literal>G_STATIC_ASSERT</literal> in the middle of
4460 * The macro should only be used once per source code line.
4467 * G_STATIC_ASSERT_EXPR:
4468 * @expr: a constant expression
4470 * The G_STATIC_ASSERT_EXPR macro lets the programmer check
4471 * a condition at compile time. The condition needs to be
4472 * compile time computable.
4474 * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
4475 * evaluates to an expression and, as such, can be used in
4476 * the middle of other expressions. Its value should be
4477 * ignored. This can be accomplished by placing it as
4478 * the first argument of a comma expression.
4481 * #define ADD_ONE_TO_INT(x) \
4482 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
4492 * Used within multi-statement macros so that they can be used in places
4493 * where only one statement is expected by the compiler.
4500 * Used within multi-statement macros so that they can be used in places
4501 * where only one statement is expected by the compiler.
4508 * Expands to a string identifying the current function.
4516 * @macro_or_string: a macro or a string
4518 * Accepts a macro or a string and converts it into a string after
4519 * preprocessor argument expansion. For example, the following code:
4523 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
4526 * is transformed by the preprocessor into (code equivalent to):
4529 * const gchar *greeting = "27 today!";
4537 * Expands to a string identifying the current code position.
4543 * @member_type: the type of the struct field
4544 * @struct_p: a pointer to a struct
4545 * @struct_offset: the offset of the field from the start of the struct,
4548 * Returns a member of a structure at a given offset, using the given type.
4550 * Returns: the struct member
4555 * G_STRUCT_MEMBER_P:
4556 * @struct_p: a pointer to a struct
4557 * @struct_offset: the offset from the start of the struct, in bytes
4559 * Returns an untyped pointer to a given offset of a struct.
4561 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
4567 * @struct_type: a structure type, e.g. <structname>GtkWidget</structname>
4568 * @member: a field in the structure, e.g. <structfield>window</structfield>
4570 * Returns the offset, in bytes, of a member of a struct.
4572 * Returns: the offset of @member from the start of @struct_type
4579 * The standard delimiters, used in g_strdelimit().
4586 * The error domain of the GLib thread subsystem.
4592 * @name: the name of the lock
4594 * Works like g_mutex_trylock(), but for a lock defined with
4597 * Returns: %TRUE, if the lock could be locked.
4603 * @maj: the major version that introduced the symbol
4604 * @min: the minor version that introduced the symbol
4606 * This macro can be used to mark a function declaration as unavailable.
4607 * It must be placed before the function declaration. Use of a function
4608 * that has been annotated with this macros will produce a compiler warning.
4616 * @expr: the expression
4618 * Hints the compiler that the expression is unlikely to evaluate to
4619 * a true value. The compiler may use this information for optimizations.
4622 * if (G_UNLIKELY (random () == 1))
4623 * g_print ("a random one");
4626 * Returns: the value of @expr
4633 * @name: the name of the lock
4635 * Works like g_mutex_unlock(), but for a lock defined with
4643 * Number of microseconds in one second (1 million).
4644 * This macro is provided for code readability.
4649 * G_VARIANT_PARSE_ERROR:
4651 * Error domain for GVariant text format parsing. Specific error codes
4652 * are not currently defined for this domain. See #GError for
4653 * information on error domains.
4659 * @ap1: the <type>va_list</type> variable to place a copy of @ap2 in
4660 * @ap2: a <type>va_list</type>
4662 * Portable way to copy <type>va_list</type> variables.
4664 * In order to use this function, you must include
4665 * <filename>string.h</filename> yourself, because this macro may
4666 * use memmove() and GLib does not include <filename>string.h</filename>
4672 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
4673 * @static: empty or "static"
4674 * @dll_name: the name of the (pointer to the) char array where
4675 * the DLL name will be stored. If this is used, you must also
4676 * include <filename>windows.h</filename>. If you need a more
4677 * complex DLL entry point function, you cannot use this
4679 * On Windows, this macro defines a DllMain() function that stores
4680 * the actual DLL name that the code being compiled will be included in.
4682 * On non-Windows platforms, expands to nothing.
4687 * G_WIN32_HAVE_WIDECHAR_API:
4689 * On Windows, this macro defines an expression which evaluates to
4690 * %TRUE if the code is running on a version of Windows where the wide
4691 * character versions of the Win32 API functions, and the wide character
4692 * versions of the C library functions work. (They are always present in
4693 * the DLLs, but don't work on Windows 9x and Me.)
4695 * On non-Windows platforms, it is not defined.
4702 * G_WIN32_IS_NT_BASED:
4704 * On Windows, this macro defines an expression which evaluates to
4705 * %TRUE if the code is running on an NT-based Windows operating system.
4707 * On non-Windows platforms, it is not defined.
4715 * @a: a numeric value
4716 * @b: a numeric value
4718 * Calculates the maximum of @a and @b.
4720 * Returns: the maximum of @a and @b.
4727 * Provided for UNIX emulation on Windows; equivalent to UNIX
4728 * macro %MAXPATHLEN, which is the maximum length of a filename
4729 * (including full path).
4735 * @a: a numeric value
4736 * @b: a numeric value
4738 * Calculates the minimum of @a and @b.
4740 * Returns: the minimum of @a and @b.
4746 * @Context: a message context, must be a string literal
4747 * @String: a message id, must be a string literal
4749 * Only marks a string for translation, with context.
4750 * This is useful in situations where the translated strings can't
4751 * be directly used, e.g. in string array initializers. To get the
4752 * translated string, you should call g_dpgettext2() at runtime.
4756 * static const char *messages[] = {
4757 * NC_("some context", "some very meaningful message"),
4758 * NC_("some context", "and another one")
4760 * const char *string;
4763 * = index > 1 ? g_dpgettext2 (NULL, "some context", "a default message")
4764 * : g_dpgettext2 (NULL, "some context", messages[index]);
4771 * <note><para>If you are using the NC_() macro, you need to make sure
4772 * that you pass <option>--keyword=NC_:1c,2</option> to xgettext when
4773 * extracting messages. Note that this only works with GNU gettext >= 0.15.
4774 * Intltool has support for the NC_() macro since version 0.40.1.
4784 * Defines the standard %NULL pointer.
4790 * @String: the string to be translated
4792 * Only marks a string for translation. This is useful in situations
4793 * where the translated strings can't be directly used, e.g. in string
4794 * array initializers. To get the translated string, call gettext()
4798 * static const char *messages[] = {
4799 * N_("some very meaningful message"),
4800 * N_("and another one")
4802 * const char *string;
4805 * = index > 1 ? _("a default message") : gettext (messages[index]);
4818 * @String: the string to be translated, with a '|'-separated prefix
4819 * which must not be translated
4821 * Like _(), but handles context in message ids. This has the advantage
4822 * that the string can be adorned with a prefix to guarantee uniqueness
4823 * and provide context to the translator.
4825 * One use case given in the gettext manual is GUI translation, where one
4826 * could e.g. disambiguate two "Open" menu entries as "File|Open" and
4827 * "Printer|Open". Another use case is the string "Russian" which may
4828 * have to be translated differently depending on whether it's the name
4829 * of a character set or a language. This could be solved by using
4830 * "charset|Russian" and "language|Russian".
4832 * See the C_() macro for a different way to mark up translatable strings
4835 * <note><para>If you are using the Q_() macro, you need to make sure
4836 * that you pass <option>--keyword=Q_</option> to xgettext when extracting
4837 * messages. If you are using GNU gettext >= 0.15, you can also use
4838 * <option>--keyword=Q_:1g</option> to let xgettext split the context
4839 * string off into a msgctxt line in the po file.</para></note>
4841 * Returns: the translated message
4849 * @short_description: arrays of arbitrary elements which grow
4850 * automatically as elements are added
4852 * Arrays are similar to standard C arrays, except that they grow
4853 * automatically as elements are added.
4855 * Array elements can be of any size (though all elements of one array
4856 * are the same size), and the array can be automatically cleared to
4857 * '0's and zero-terminated.
4859 * To create a new array use g_array_new().
4861 * To add elements to an array, use g_array_append_val(),
4862 * g_array_append_vals(), g_array_prepend_val(), and
4863 * g_array_prepend_vals().
4865 * To access an element of an array, use g_array_index().
4867 * To set the size of an array, use g_array_set_size().
4869 * To free an array, use g_array_free().
4872 * <title>Using a #GArray to store #gint values</title>
4876 * /<!-- -->* We create a new array to store gint values.
4877 * We don't want it zero-terminated or cleared to 0's. *<!-- -->/
4878 * garray = g_array_new (FALSE, FALSE, sizeof (gint));
4879 * for (i = 0; i < 10000; i++)
4880 * g_array_append_val (garray, i);
4881 * for (i = 0; i < 10000; i++)
4882 * if (g_array_index (garray, gint, i) != i)
4883 * g_print ("ERROR: got %d instead of %d\n",
4884 * g_array_index (garray, gint, i), i);
4885 * g_array_free (garray, TRUE);
4892 * SECTION:arrays_byte
4893 * @title: Byte Arrays
4894 * @short_description: arrays of bytes
4896 * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
4897 * of bytes which grow automatically as elements are added.
4899 * To create a new #GByteArray use g_byte_array_new(). To add elements to a
4900 * #GByteArray, use g_byte_array_append(), and g_byte_array_prepend().
4902 * To set the size of a #GByteArray, use g_byte_array_set_size().
4904 * To free a #GByteArray, use g_byte_array_free().
4907 * <title>Using a #GByteArray</title>
4909 * GByteArray *gbarray;
4912 * gbarray = g_byte_array_new (<!-- -->);
4913 * for (i = 0; i < 10000; i++)
4914 * g_byte_array_append (gbarray, (guint8*) "abcd", 4);
4916 * for (i = 0; i < 10000; i++)
4918 * g_assert (gbarray->data[4*i] == 'a');
4919 * g_assert (gbarray->data[4*i+1] == 'b');
4920 * g_assert (gbarray->data[4*i+2] == 'c');
4921 * g_assert (gbarray->data[4*i+3] == 'd');
4924 * g_byte_array_free (gbarray, TRUE);
4928 * See #GBytes if you are interested in an immutable object representing a
4929 * sequence of bytes.
4934 * SECTION:arrays_pointer
4935 * @title: Pointer Arrays
4936 * @short_description: arrays of pointers to any type of data, which
4937 * grow automatically as new elements are added
4939 * Pointer Arrays are similar to Arrays but are used only for storing
4942 * <note><para>If you remove elements from the array, elements at the
4943 * end of the array are moved into the space previously occupied by the
4944 * removed element. This means that you should not rely on the index of
4945 * particular elements remaining the same. You should also be careful
4946 * when deleting elements while iterating over the array.</para></note>
4948 * To create a pointer array, use g_ptr_array_new().
4950 * To add elements to a pointer array, use g_ptr_array_add().
4952 * To remove elements from a pointer array, use g_ptr_array_remove(),
4953 * g_ptr_array_remove_index() or g_ptr_array_remove_index_fast().
4955 * To access an element of a pointer array, use g_ptr_array_index().
4957 * To set the size of a pointer array, use g_ptr_array_set_size().
4959 * To free a pointer array, use g_ptr_array_free().
4962 * <title>Using a #GPtrArray</title>
4964 * GPtrArray *gparray;
4965 * gchar *string1 = "one", *string2 = "two", *string3 = "three";
4967 * gparray = g_ptr_array_new (<!-- -->);
4968 * g_ptr_array_add (gparray, (gpointer) string1);
4969 * g_ptr_array_add (gparray, (gpointer) string2);
4970 * g_ptr_array_add (gparray, (gpointer) string3);
4972 * if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
4973 * g_print ("ERROR: got %p instead of %p\n",
4974 * g_ptr_array_index (gparray, 0), string1);
4976 * g_ptr_array_free (gparray, TRUE);
4983 * SECTION:async_queues
4984 * @title: Asynchronous Queues
4985 * @short_description: asynchronous communication between threads
4986 * @see_also: #GThreadPool
4988 * Often you need to communicate between different threads. In general
4989 * it's safer not to do this by shared memory, but by explicit message
4990 * passing. These messages only make sense asynchronously for
4991 * multi-threaded applications though, as a synchronous operation could
4992 * as well be done in the same thread.
4994 * Asynchronous queues are an exception from most other GLib data
4995 * structures, as they can be used simultaneously from multiple threads
4996 * without explicit locking and they bring their own builtin reference
4997 * counting. This is because the nature of an asynchronous queue is that
4998 * it will always be used by at least 2 concurrent threads.
5000 * For using an asynchronous queue you first have to create one with
5001 * g_async_queue_new(). #GAsyncQueue structs are reference counted,
5002 * use g_async_queue_ref() and g_async_queue_unref() to manage your
5005 * A thread which wants to send a message to that queue simply calls
5006 * g_async_queue_push() to push the message to the queue.
5008 * A thread which is expecting messages from an asynchronous queue
5009 * simply calls g_async_queue_pop() for that queue. If no message is
5010 * available in the queue at that point, the thread is now put to sleep
5011 * until a message arrives. The message will be removed from the queue
5012 * and returned. The functions g_async_queue_try_pop() and
5013 * g_async_queue_timeout_pop() can be used to only check for the presence
5014 * of messages or to only wait a certain time for messages respectively.
5016 * For almost every function there exist two variants, one that locks
5017 * the queue and one that doesn't. That way you can hold the queue lock
5018 * (acquire it with g_async_queue_lock() and release it with
5019 * g_async_queue_unlock()) over multiple queue accessing instructions.
5020 * This can be necessary to ensure the integrity of the queue, but should
5021 * only be used when really necessary, as it can make your life harder
5022 * if used unwisely. Normally you should only use the locking function
5023 * variants (those without the _unlocked suffix).
5025 * In many cases, it may be more convenient to use #GThreadPool when
5026 * you need to distribute work to a set of worker threads instead of
5027 * using #GAsyncQueue manually. #GThreadPool uses a GAsyncQueue
5033 * SECTION:atomic_operations
5034 * @title: Atomic Operations
5035 * @short_description: basic atomic integer and pointer operations
5036 * @see_also: #GMutex
5038 * The following is a collection of compiler macros to provide atomic
5039 * access to integer and pointer-sized values.
5041 * The macros that have 'int' in the name will operate on pointers to
5042 * #gint and #guint. The macros with 'pointer' in the name will operate
5043 * on pointers to any pointer-sized value, including #gsize. There is
5044 * no support for 64bit operations on platforms with 32bit pointers
5045 * because it is not generally possible to perform these operations
5048 * The get, set and exchange operations for integers and pointers
5049 * nominally operate on #gint and #gpointer, respectively. Of the
5050 * arithmetic operations, the 'add' operation operates on (and returns)
5051 * signed integer values (#gint and #gssize) and the 'and', 'or', and
5052 * 'xor' operations operate on (and return) unsigned integer values
5053 * (#guint and #gsize).
5055 * All of the operations act as a full compiler and (where appropriate)
5056 * hardware memory barrier. Acquire and release or producer and
5057 * consumer barrier semantics are not available through this API.
5059 * It is very important that all accesses to a particular integer or
5060 * pointer be performed using only this API and that different sizes of
5061 * operation are not mixed or used on overlapping memory regions. Never
5062 * read or assign directly from or to a value -- always use this API.
5064 * For simple reference counting purposes you should use
5065 * g_atomic_int_inc() and g_atomic_int_dec_and_test(). Other uses that
5066 * fall outside of simple reference counting patterns are prone to
5067 * subtle bugs and occasionally undefined behaviour. It is also worth
5068 * noting that since all of these operations require global
5069 * synchronisation of the entire machine, they can be quite slow. In
5070 * the case of performing multiple atomic operations it can often be
5071 * faster to simply acquire a mutex lock around the critical area,
5072 * perform the operations normally and then release the lock.
5078 * @title: Base64 Encoding
5079 * @short_description: encodes and decodes data in Base64 format
5081 * Base64 is an encoding that allows a sequence of arbitrary bytes to be
5082 * encoded as a sequence of printable ASCII characters. For the definition
5083 * of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
5084 * 1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
5085 * 2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
5088 * GLib supports incremental encoding using g_base64_encode_step() and
5089 * g_base64_encode_close(). Incremental decoding can be done with
5090 * g_base64_decode_step(). To encode or decode data in one go, use
5091 * g_base64_encode() or g_base64_decode(). To avoid memory allocation when
5092 * decoding, you can use g_base64_decode_inplace().
5094 * Support for Base64 encoding has been added in GLib 2.12.
5099 * SECTION:bookmarkfile
5100 * @title: Bookmark file parser
5101 * @short_description: parses files containing bookmarks
5103 * GBookmarkFile lets you parse, edit or create files containing bookmarks
5104 * to URI, along with some meta-data about the resource pointed by the URI
5105 * like its MIME type, the application that is registering the bookmark and
5106 * the icon that should be used to represent the bookmark. The data is stored
5108 * <ulink url="http://www.gnome.org/~ebassi/bookmark-spec">Desktop Bookmark
5109 * Specification</ulink>.
5111 * The syntax of the bookmark files is described in detail inside the Desktop
5112 * Bookmark Specification, here is a quick summary: bookmark files use a
5113 * sub-class of the <ulink url="">XML Bookmark Exchange Language</ulink>
5114 * specification, consisting of valid UTF-8 encoded XML, under the
5115 * <literal>xbel</literal> root element; each bookmark is stored inside a
5116 * <literal>bookmark</literal> element, using its URI: no relative paths can
5117 * be used inside a bookmark file. The bookmark may have a user defined title
5118 * and description, to be used instead of the URI. Under the
5119 * <literal>metadata</literal> element, with its <literal>owner</literal>
5120 * attribute set to <literal>http://freedesktop.org</literal>, is stored the
5121 * meta-data about a resource pointed by its URI. The meta-data consists of
5122 * the resource's MIME type; the applications that have registered a bookmark;
5123 * the groups to which a bookmark belongs to; a visibility flag, used to set
5124 * the bookmark as "private" to the applications and groups that has it
5125 * registered; the URI and MIME type of an icon, to be used when displaying
5126 * the bookmark inside a GUI.
5127 * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../glib/tests/bookmarks.xbel"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]|
5129 * A bookmark file might contain more than one bookmark; each bookmark
5130 * is accessed through its URI.
5132 * The important caveat of bookmark files is that when you add a new
5133 * bookmark you must also add the application that is registering it, using
5134 * g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
5135 * If a bookmark has no applications then it won't be dumped when creating
5136 * the on disk representation, using g_bookmark_file_to_data() or
5137 * g_bookmark_file_to_file().
5139 * The #GBookmarkFile parser was added in GLib 2.12.
5144 * SECTION:byte_order
5145 * @title: Byte Order Macros
5146 * @short_description: a portable way to convert between different byte orders
5148 * These macros provide a portable way to determine the host byte order
5149 * and to convert values between different byte orders.
5151 * The byte order is the order in which bytes are stored to create larger
5152 * data types such as the #gint and #glong values.
5153 * The host byte order is the byte order used on the current machine.
5155 * Some processors store the most significant bytes (i.e. the bytes that
5156 * hold the largest part of the value) first. These are known as big-endian
5157 * processors. Other processors (notably the x86 family) store the most
5158 * significant byte last. These are known as little-endian processors.
5160 * Finally, to complicate matters, some other processors store the bytes in
5161 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
5162 * most significant byte is stored first, then the 4th, then the 1st and
5165 * Obviously there is a problem when these different processors communicate
5166 * with each other, for example over networks or by using binary file formats.
5167 * This is where these macros come in. They are typically used to convert
5168 * values into a byte order which has been agreed on for use when
5169 * communicating between different processors. The Internet uses what is
5170 * known as 'network byte order' as the standard byte order (which is in
5171 * fact the big-endian byte order).
5173 * Note that the byte order conversion macros may evaluate their arguments
5174 * multiple times, thus you should not use them with arguments which have
5181 * @title: Data Checksums
5182 * @short_description: computes the checksum for data
5184 * GLib provides a generic API for computing checksums (or "digests")
5185 * for a sequence of arbitrary bytes, using various hashing algorithms
5186 * like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
5187 * environments and specifications.
5189 * GLib supports incremental checksums using the GChecksum data
5190 * structure, by calling g_checksum_update() as long as there's data
5191 * available and then using g_checksum_get_string() or
5192 * g_checksum_get_digest() to compute the checksum and return it either
5193 * as a string in hexadecimal form, or as a raw sequence of bytes. To
5194 * compute the checksum for binary blobs and NUL-terminated strings in
5195 * one go, use the convenience functions g_compute_checksum_for_data()
5196 * and g_compute_checksum_for_string(), respectively.
5198 * Support for checksums has been added in GLib 2.16
5203 * SECTION:conversions
5204 * @title: Character Set Conversion
5205 * @short_description: convert strings between different character sets
5207 * The g_convert() family of function wraps the functionality of iconv(). In
5208 * addition to pure character set conversions, GLib has functions to deal
5209 * with the extra complications of encodings for file names.
5211 * <refsect2 id="file-name-encodings">
5212 * <title>File Name Encodings</title>
5214 * Historically, Unix has not had a defined encoding for file
5215 * names: a file name is valid as long as it does not have path
5216 * separators in it ("/"). However, displaying file names may
5217 * require conversion: from the character set in which they were
5218 * created, to the character set in which the application
5219 * operates. Consider the Spanish file name
5220 * "<filename>Presentación.sxi</filename>". If the
5221 * application which created it uses ISO-8859-1 for its encoding,
5223 * <programlisting id="filename-iso8859-1">
5224 * Character: P r e s e n t a c i ó n . s x i
5225 * Hex code: 50 72 65 73 65 6e 74 61 63 69 f3 6e 2e 73 78 69
5228 * However, if the application use UTF-8, the actual file name on
5229 * disk would look like this:
5231 * <programlisting id="filename-utf-8">
5232 * Character: P r e s e n t a c i ó n . s x i
5233 * Hex code: 50 72 65 73 65 6e 74 61 63 69 c3 b3 6e 2e 73 78 69
5236 * Glib uses UTF-8 for its strings, and GUI toolkits like GTK+
5237 * that use Glib do the same thing. If you get a file name from
5238 * the file system, for example, from readdir(3) or from g_dir_read_name(),
5239 * and you wish to display the file name to the user, you
5240 * <emphasis>will</emphasis> need to convert it into UTF-8. The
5241 * opposite case is when the user types the name of a file he
5242 * wishes to save: the toolkit will give you that string in
5243 * UTF-8 encoding, and you will need to convert it to the
5244 * character set used for file names before you can create the
5245 * file with open(2) or fopen(3).
5248 * By default, Glib assumes that file names on disk are in UTF-8
5249 * encoding. This is a valid assumption for file systems which
5250 * were created relatively recently: most applications use UTF-8
5251 * encoding for their strings, and that is also what they use for
5252 * the file names they create. However, older file systems may
5253 * still contain file names created in "older" encodings, such as
5254 * ISO-8859-1. In this case, for compatibility reasons, you may
5255 * want to instruct Glib to use that particular encoding for file
5256 * names rather than UTF-8. You can do this by specifying the
5257 * encoding for file names in the <link
5258 * linkend="G_FILENAME_ENCODING"><envar>G_FILENAME_ENCODING</envar></link>
5259 * environment variable. For example, if your installation uses
5260 * ISO-8859-1 for file names, you can put this in your
5261 * <filename>~/.profile</filename>:
5264 * export G_FILENAME_ENCODING=ISO-8859-1
5267 * Glib provides the functions g_filename_to_utf8() and
5268 * g_filename_from_utf8() to perform the necessary conversions. These
5269 * functions convert file names from the encoding specified in
5270 * <envar>G_FILENAME_ENCODING</envar> to UTF-8 and vice-versa.
5271 * <xref linkend="file-name-encodings-diagram"/> illustrates how
5272 * these functions are used to convert between UTF-8 and the
5273 * encoding for file names in the file system.
5275 * <figure id="file-name-encodings-diagram">
5276 * <title>Conversion between File Name Encodings</title>
5277 * <graphic fileref="file-name-encodings.png" format="PNG"/>
5279 * <refsect3 id="file-name-encodings-checklist">
5280 * <title>Checklist for Application Writers</title>
5282 * This section is a practical summary of the detailed
5283 * description above. You can use this as a checklist of
5284 * things to do to make sure your applications process file
5285 * name encodings correctly.
5289 * If you get a file name from the file system from a function
5290 * such as readdir(3) or gtk_file_chooser_get_filename(),
5291 * you do not need to do any conversion to pass that
5292 * file name to functions like open(2), rename(2), or
5293 * fopen(3) — those are "raw" file names which the file
5294 * system understands.
5295 * </para></listitem>
5297 * If you need to display a file name, convert it to UTF-8 first by
5298 * using g_filename_to_utf8(). If conversion fails, display a string like
5299 * "<literal>Unknown file name</literal>". <emphasis>Do not</emphasis>
5300 * convert this string back into the encoding used for file names if you
5301 * wish to pass it to the file system; use the original file name instead.
5302 * For example, the document window of a word processor could display
5303 * "Unknown file name" in its title bar but still let the user save the
5304 * file, as it would keep the raw file name internally. This can happen
5305 * if the user has not set the <envar>G_FILENAME_ENCODING</envar>
5306 * environment variable even though he has files whose names are not
5308 * </para></listitem>
5310 * If your user interface lets the user type a file name for saving or
5311 * renaming, convert it to the encoding used for file names in the file
5312 * system by using g_filename_from_utf8(). Pass the converted file name
5313 * to functions like fopen(3). If conversion fails, ask the user to enter
5314 * a different file name. This can happen if the user types Japanese
5315 * characters when <envar>G_FILENAME_ENCODING</envar> is set to
5316 * <literal>ISO-8859-1</literal>, for example.
5317 * </para></listitem>
5326 * @title: Keyed Data Lists
5327 * @short_description: lists of data elements which are accessible by a
5328 * string or GQuark identifier
5330 * Keyed data lists provide lists of arbitrary data elements which can
5331 * be accessed either with a string or with a #GQuark corresponding to
5334 * The #GQuark methods are quicker, since the strings have to be
5335 * converted to #GQuarks anyway.
5337 * Data lists are used for associating arbitrary data with #GObjects,
5338 * using g_object_set_data() and related functions.
5340 * To create a datalist, use g_datalist_init().
5342 * To add data elements to a datalist use g_datalist_id_set_data(),
5343 * g_datalist_id_set_data_full(), g_datalist_set_data() and
5344 * g_datalist_set_data_full().
5346 * To get data elements from a datalist use g_datalist_id_get_data()
5347 * and g_datalist_get_data().
5349 * To iterate over all data elements in a datalist use
5350 * g_datalist_foreach() (not thread-safe).
5352 * To remove data elements from a datalist use
5353 * g_datalist_id_remove_data() and g_datalist_remove_data().
5355 * To remove all data elements from a datalist, use g_datalist_clear().
5362 * @short_description: associate groups of data elements with
5363 * particular memory locations
5365 * Datasets associate groups of data elements with particular memory
5366 * locations. These are useful if you need to associate data with a
5367 * structure returned from an external library. Since you cannot modify
5368 * the structure, you use its location in memory as the key into a
5369 * dataset, where you can associate any number of data elements with it.
5371 * There are two forms of most of the dataset functions. The first form
5372 * uses strings to identify the data elements associated with a
5373 * location. The second form uses #GQuark identifiers, which are
5374 * created with a call to g_quark_from_string() or
5375 * g_quark_from_static_string(). The second form is quicker, since it
5376 * does not require looking up the string in the hash table of #GQuark
5379 * There is no function to create a dataset. It is automatically
5380 * created as soon as you add elements to it.
5382 * To add data elements to a dataset use g_dataset_id_set_data(),
5383 * g_dataset_id_set_data_full(), g_dataset_set_data() and
5384 * g_dataset_set_data_full().
5386 * To get data elements from a dataset use g_dataset_id_get_data() and
5387 * g_dataset_get_data().
5389 * To iterate over all data elements in a dataset use
5390 * g_dataset_foreach() (not thread-safe).
5392 * To remove data elements from a dataset use
5393 * g_dataset_id_remove_data() and g_dataset_remove_data().
5395 * To destroy a dataset, use g_dataset_destroy().
5401 * @title: Date and Time Functions
5402 * @short_description: calendrical calculations and miscellaneous time stuff
5404 * The #GDate data structure represents a day between January 1, Year 1,
5405 * and sometime a few thousand years in the future (right now it will go
5406 * to the year 65535 or so, but g_date_set_parse() only parses up to the
5407 * year 8000 or so - just count on "a few thousand"). #GDate is meant to
5408 * represent everyday dates, not astronomical dates or historical dates
5409 * or ISO timestamps or the like. It extrapolates the current Gregorian
5410 * calendar forward and backward in time; there is no attempt to change
5411 * the calendar to match time periods or locations. #GDate does not store
5412 * time information; it represents a <emphasis>day</emphasis>.
5414 * The #GDate implementation has several nice features; it is only a
5415 * 64-bit struct, so storing large numbers of dates is very efficient. It
5416 * can keep both a Julian and day-month-year representation of the date,
5417 * since some calculations are much easier with one representation or the
5418 * other. A Julian representation is simply a count of days since some
5419 * fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
5420 * ("Julian" dates in the #GDate API aren't really Julian dates in the
5421 * technical sense; technically, Julian dates count from the start of the
5422 * Julian period, Jan 1, 4713 BC).
5424 * #GDate is simple to use. First you need a "blank" date; you can get a
5425 * dynamically allocated date from g_date_new(), or you can declare an
5426 * automatic variable or array and initialize it to a sane state by
5427 * calling g_date_clear(). A cleared date is sane; it's safe to call
5428 * g_date_set_dmy() and the other mutator functions to initialize the
5429 * value of a cleared date. However, a cleared date is initially
5430 * <emphasis>invalid</emphasis>, meaning that it doesn't represent a day
5431 * that exists. It is undefined to call any of the date calculation
5432 * routines on an invalid date. If you obtain a date from a user or other
5433 * unpredictable source, you should check its validity with the
5434 * g_date_valid() predicate. g_date_valid() is also used to check for
5435 * errors with g_date_set_parse() and other functions that can
5436 * fail. Dates can be invalidated by calling g_date_clear() again.
5438 * <emphasis>It is very important to use the API to access the #GDate
5439 * struct.</emphasis> Often only the day-month-year or only the Julian
5440 * representation is valid. Sometimes neither is valid. Use the API.
5442 * GLib also features #GDateTime which represents a precise time.
5449 * @short_description: a structure representing Date and Time
5450 * @see_also: #GTimeZone
5452 * #GDateTime is a structure that combines a Gregorian date and time
5453 * into a single structure. It provides many conversion and methods to
5454 * manipulate dates and times. Time precision is provided down to
5455 * microseconds and the time can range (proleptically) from 0001-01-01
5456 * 00:00:00 to 9999-12-31 23:59:59.999999. #GDateTime follows POSIX
5457 * time in the sense that it is oblivious to leap seconds.
5459 * #GDateTime is an immutable object; once it has been created it cannot
5460 * be modified further. All modifiers will create a new #GDateTime.
5461 * Nearly all such functions can fail due to the date or time going out
5462 * of range, in which case %NULL will be returned.
5464 * #GDateTime is reference counted: the reference count is increased by calling
5465 * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
5466 * reference count drops to 0, the resources allocated by the #GDateTime
5467 * structure are released.
5469 * Many parts of the API may produce non-obvious results. As an
5470 * example, adding two months to January 31st will yield March 31st
5471 * whereas adding one month and then one month again will yield either
5472 * March 28th or March 29th. Also note that adding 24 hours is not
5473 * always the same as adding one day (since days containing daylight
5474 * savings time transitions are either 23 or 25 hours in length).
5476 * #GDateTime is available since GLib 2.26.
5481 * SECTION:error_reporting
5482 * @Title: Error Reporting
5483 * @Short_description: a system for reporting errors
5485 * GLib provides a standard method of reporting errors from a called
5486 * function to the calling code. (This is the same problem solved by
5487 * exceptions in other languages.) It's important to understand that
5488 * this method is both a <emphasis>data type</emphasis> (the #GError
5489 * object) and a <emphasis>set of rules.</emphasis> If you use #GError
5490 * incorrectly, then your code will not properly interoperate with other
5491 * code that uses #GError, and users of your API will probably get confused.
5493 * First and foremost: <emphasis>#GError should only be used to report
5494 * recoverable runtime errors, never to report programming
5495 * errors.</emphasis> If the programmer has screwed up, then you should
5496 * use g_warning(), g_return_if_fail(), g_assert(), g_error(), or some
5497 * similar facility. (Incidentally, remember that the g_error() function
5498 * should <emphasis>only</emphasis> be used for programming errors, it
5499 * should not be used to print any error reportable via #GError.)
5501 * Examples of recoverable runtime errors are "file not found" or
5502 * "failed to parse input." Examples of programming errors are "NULL
5503 * passed to strcmp()" or "attempted to free the same pointer twice."
5504 * These two kinds of errors are fundamentally different: runtime errors
5505 * should be handled or reported to the user, programming errors should
5506 * be eliminated by fixing the bug in the program. This is why most
5507 * functions in GLib and GTK+ do not use the #GError facility.
5509 * Functions that can fail take a return location for a #GError as their
5510 * last argument. For example:
5512 * gboolean g_file_get_contents (const gchar *filename,
5517 * If you pass a non-%NULL value for the <literal>error</literal>
5518 * argument, it should point to a location where an error can be placed.
5522 * GError *err = NULL;
5523 * g_file_get_contents ("foo.txt", &contents, NULL, &err);
5524 * g_assert ((contents == NULL && err != NULL) || (contents != NULL && err == NULL));
5527 * /* Report error to user, and free error */
5528 * g_assert (contents == NULL);
5529 * fprintf (stderr, "Unable to read file: %s\n", err->message);
5530 * g_error_free (err);
5534 * /* Use file contents */
5535 * g_assert (contents != NULL);
5538 * Note that <literal>err != NULL</literal> in this example is a
5539 * <emphasis>reliable</emphasis> indicator of whether
5540 * g_file_get_contents() failed. Additionally, g_file_get_contents()
5541 * returns a boolean which indicates whether it was successful.
5543 * Because g_file_get_contents() returns %FALSE on failure, if you
5544 * are only interested in whether it failed and don't need to display
5545 * an error message, you can pass %NULL for the <literal>error</literal>
5548 * if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /* ignore errors */
5549 * /* no error occurred */ ;
5551 * /* error */ ;
5554 * The #GError object contains three fields: <literal>domain</literal>
5555 * indicates the module the error-reporting function is located in,
5556 * <literal>code</literal> indicates the specific error that occurred,
5557 * and <literal>message</literal> is a user-readable error message with
5558 * as many details as possible. Several functions are provided to deal
5559 * with an error received from a called function: g_error_matches()
5560 * returns %TRUE if the error matches a given domain and code,
5561 * g_propagate_error() copies an error into an error location (so the
5562 * calling function will receive it), and g_clear_error() clears an
5563 * error location by freeing the error and resetting the location to
5564 * %NULL. To display an error to the user, simply display
5565 * <literal>error->message</literal>, perhaps along with additional
5566 * context known only to the calling function (the file being opened,
5567 * or whatever -- though in the g_file_get_contents() case,
5568 * <literal>error->message</literal> already contains a filename).
5570 * When implementing a function that can report errors, the basic
5571 * tool is g_set_error(). Typically, if a fatal error occurs you
5572 * want to g_set_error(), then return immediately. g_set_error()
5573 * does nothing if the error location passed to it is %NULL.
5574 * Here's an example:
5577 * foo_open_file (GError **error)
5581 * fd = open ("file.txt", O_RDONLY);
5585 * g_set_error (error,
5586 * FOO_ERROR, /* error domain */
5587 * FOO_ERROR_BLAH, /* error code */
5588 * "Failed to open file: %s", /* error message format string */
5589 * g_strerror (errno));
5597 * Things are somewhat more complicated if you yourself call another
5598 * function that can report a #GError. If the sub-function indicates
5599 * fatal errors in some way other than reporting a #GError, such as
5600 * by returning %TRUE on success, you can simply do the following:
5603 * my_function_that_can_fail (GError **err)
5605 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5607 * if (!sub_function_that_can_fail (err))
5609 * /* assert that error was set by the sub-function */
5610 * g_assert (err == NULL || *err != NULL);
5614 * /* otherwise continue, no error occurred */
5615 * g_assert (err == NULL || *err == NULL);
5619 * If the sub-function does not indicate errors other than by
5620 * reporting a #GError, you need to create a temporary #GError
5621 * since the passed-in one may be %NULL. g_propagate_error() is
5622 * intended for use in this case.
5625 * my_function_that_can_fail (GError **err)
5627 * GError *tmp_error;
5629 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5632 * sub_function_that_can_fail (&tmp_error);
5634 * if (tmp_error != NULL)
5636 * /* store tmp_error in err, if err != NULL,
5637 * * otherwise call g_error_free() on tmp_error
5639 * g_propagate_error (err, tmp_error);
5643 * /* otherwise continue, no error occurred */
5647 * Error pileups are always a bug. For example, this code is incorrect:
5650 * my_function_that_can_fail (GError **err)
5652 * GError *tmp_error;
5654 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5657 * sub_function_that_can_fail (&tmp_error);
5658 * other_function_that_can_fail (&tmp_error);
5660 * if (tmp_error != NULL)
5662 * g_propagate_error (err, tmp_error);
5667 * <literal>tmp_error</literal> should be checked immediately after
5668 * sub_function_that_can_fail(), and either cleared or propagated
5669 * upward. The rule is: <emphasis>after each error, you must either
5670 * handle the error, or return it to the calling function</emphasis>.
5671 * Note that passing %NULL for the error location is the equivalent
5672 * of handling an error by always doing nothing about it. So the
5673 * following code is fine, assuming errors in sub_function_that_can_fail()
5674 * are not fatal to my_function_that_can_fail():
5677 * my_function_that_can_fail (GError **err)
5679 * GError *tmp_error;
5681 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5683 * sub_function_that_can_fail (NULL); /* ignore errors */
5686 * other_function_that_can_fail (&tmp_error);
5688 * if (tmp_error != NULL)
5690 * g_propagate_error (err, tmp_error);
5696 * Note that passing %NULL for the error location
5697 * <emphasis>ignores</emphasis> errors; it's equivalent to
5698 * <literal>try { sub_function_that_can_fail (); } catch (...) {}</literal>
5699 * in C++. It does <emphasis>not</emphasis> mean to leave errors
5700 * unhandled; it means to handle them by doing nothing.
5702 * Error domains and codes are conventionally named as follows:
5705 * The error domain is called
5706 * <literal><NAMESPACE>_<MODULE>_ERROR</literal>,
5707 * for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
5709 * #define G_SPAWN_ERROR g_spawn_error_quark ()
5712 * g_spawn_error_quark (void)
5714 * return g_quark_from_static_string ("g-spawn-error-quark");
5717 * </para></listitem>
5719 * The quark function for the error domain is called
5720 * <literal><namespace>_<module>_error_quark</literal>,
5721 * for example g_spawn_error_quark() or g_thread_error_quark().
5722 * </para></listitem>
5724 * The error codes are in an enumeration called
5725 * <literal><Namespace><Module>Error</literal>;
5726 * for example,#GThreadError or #GSpawnError.
5727 * </para></listitem>
5729 * Members of the error code enumeration are called
5730 * <literal><NAMESPACE>_<MODULE>_ERROR_<CODE></literal>,
5731 * for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
5732 * </para></listitem>
5734 * If there's a "generic" or "unknown" error code for unrecoverable
5735 * errors it doesn't make sense to distinguish with specific codes,
5736 * it should be called <literal><NAMESPACE>_<MODULE>_ERROR_FAILED</literal>,
5737 * for example %G_SPAWN_ERROR_FAILED.
5738 * </para></listitem>
5741 * Summary of rules for use of #GError:
5744 * Do not report programming errors via #GError.
5745 * </para></listitem>
5747 * The last argument of a function that returns an error should
5748 * be a location where a #GError can be placed (i.e. "#GError** error").
5749 * If #GError is used with varargs, the #GError** should be the last
5750 * argument before the "...".
5751 * </para></listitem>
5753 * The caller may pass %NULL for the #GError** if they are not interested
5754 * in details of the exact error that occurred.
5755 * </para></listitem>
5757 * If %NULL is passed for the #GError** argument, then errors should
5758 * not be returned to the caller, but your function should still
5759 * abort and return if an error occurs. That is, control flow should
5760 * not be affected by whether the caller wants to get a #GError.
5761 * </para></listitem>
5763 * If a #GError is reported, then your function by definition
5764 * <emphasis>had a fatal failure and did not complete whatever
5765 * it was supposed to do</emphasis>. If the failure was not fatal,
5766 * then you handled it and you should not report it. If it was fatal,
5767 * then you must report it and discontinue whatever you were doing
5769 * </para></listitem>
5771 * If a #GError is reported, out parameters are not guaranteed to
5772 * be set to any defined value.
5773 * </para></listitem>
5775 * A #GError* must be initialized to %NULL before passing its address
5776 * to a function that can report errors.
5777 * </para></listitem>
5779 * "Piling up" errors is always a bug. That is, if you assign a
5780 * new #GError to a #GError* that is non-%NULL, thus overwriting
5781 * the previous error, it indicates that you should have aborted
5782 * the operation instead of continuing. If you were able to continue,
5783 * you should have cleared the previous error with g_clear_error().
5784 * g_set_error() will complain if you pile up errors.
5785 * </para></listitem>
5787 * By convention, if you return a boolean value indicating success
5788 * then %TRUE means success and %FALSE means failure. If %FALSE is
5789 * returned, the error <emphasis>must</emphasis> be set to a non-%NULL
5791 * </para></listitem>
5793 * A %NULL return value is also frequently used to mean that an error
5794 * occurred. You should make clear in your documentation whether %NULL
5795 * is a valid return value in non-error cases; if %NULL is a valid value,
5796 * then users must check whether an error was returned to see if the
5797 * function succeeded.
5798 * </para></listitem>
5800 * When implementing a function that can report errors, you may want
5801 * to add a check at the top of your function that the error return
5802 * location is either %NULL or contains a %NULL error (e.g.
5803 * <literal>g_return_if_fail (error == NULL || *error == NULL);</literal>).
5804 * </para></listitem>
5811 * @title: File Utilities
5812 * @short_description: various file-related functions
5814 * There is a group of functions which wrap the common POSIX functions
5815 * dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(),
5816 * g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these
5817 * wrappers is to make it possible to handle file names with any Unicode
5818 * characters in them on Windows without having to use ifdefs and the
5819 * wide character API in the application code.
5821 * The pathname argument should be in the GLib file name encoding.
5822 * On POSIX this is the actual on-disk encoding which might correspond
5823 * to the locale settings of the process (or the
5824 * <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
5826 * On Windows the GLib file name encoding is UTF-8. Note that the
5827 * Microsoft C library does not use UTF-8, but has separate APIs for
5828 * current system code page and wide characters (UTF-16). The GLib
5829 * wrappers call the wide character API if present (on modern Windows
5830 * systems), otherwise convert to/from the system code page.
5832 * Another group of functions allows to open and read directories
5833 * in the GLib file name encoding. These are g_dir_open(),
5834 * g_dir_read_name(), g_dir_rewind(), g_dir_close().
5839 * SECTION:ghostutils
5840 * @short_description: Internet hostname utilities
5842 * Functions for manipulating internet hostnames; in particular, for
5843 * converting between Unicode and ASCII-encoded forms of
5844 * Internationalized Domain Names (IDNs).
5847 * url="http://www.ietf.org/rfc/rfc3490.txt">Internationalized Domain
5848 * Names for Applications (IDNA)</ulink> standards allow for the use
5849 * of Unicode domain names in applications, while providing
5850 * backward-compatibility with the old ASCII-only DNS, by defining an
5851 * ASCII-Compatible Encoding of any given Unicode name, which can be
5852 * used with non-IDN-aware applications and protocols. (For example,
5853 * "Παν語.org" maps to "xn--4wa8awb4637h.org".)
5859 * @title: Perl-compatible regular expressions
5860 * @short_description: matches strings against regular expressions
5861 * @see_also: <xref linkend="glib-regex-syntax"/>
5863 * The <function>g_regex_*()</function> functions implement regular
5864 * expression pattern matching using syntax and semantics similar to
5865 * Perl regular expression.
5867 * Some functions accept a @start_position argument, setting it differs
5868 * from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
5869 * in the case of a pattern that begins with any kind of lookbehind assertion.
5870 * For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
5871 * in the middle of words. ("\B" matches only if the current position in the
5872 * subject is not a word boundary.) When applied to the string "Mississipi"
5873 * from the fourth byte, namely "issipi", it does not match, because "\B" is
5874 * always false at the start of the subject, which is deemed to be a word
5875 * boundary. However, if the entire string is passed , but with
5876 * @start_position set to 4, it finds the second occurrence of "iss" because
5877 * it is able to look behind the starting point to discover that it is
5878 * preceded by a letter.
5880 * Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
5881 * to these functions must be encoded in UTF-8. The lengths and the positions
5882 * inside the strings are in bytes and not in characters, so, for instance,
5883 * "\xc3\xa0" (i.e. "à") is two bytes long but it is treated as a
5884 * single character. If you set #G_REGEX_RAW the strings can be non-valid
5885 * UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
5886 * bytes and two characters long.
5888 * When matching a pattern, "\n" matches only against a "\n" character in
5889 * the string, and "\r" matches only a "\r" character. To match any newline
5890 * sequence use "\R". This particular group matches either the two-character
5891 * sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
5892 * U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
5893 * CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
5894 * separator, U+2028), or PS (paragraph separator, U+2029).
5896 * The behaviour of the dot, circumflex, and dollar metacharacters are
5897 * affected by newline characters, the default is to recognize any newline
5898 * character (the same characters recognized by "\R"). This can be changed
5899 * with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
5900 * compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
5901 * #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
5902 * #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
5903 * relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
5904 * unescaped "#" outside a character class is encountered. This indicates
5905 * a comment that lasts until after the next newline.
5907 * When setting the %G_REGEX_JAVASCRIPT_COMPAT flag, pattern syntax and pattern
5908 * matching is changed to be compatible with the way that regular expressions
5909 * work in JavaScript. More precisely, a lonely ']' character in the pattern
5910 * is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
5911 * you must use the '\u' escape sequence with 4 hex digits to specify a unicode
5912 * codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
5913 * the specified number of hex digits, they match 'x' and 'u' literally; also
5914 * '\U' always matches 'U' instead of being an error in the pattern. Finally,
5915 * pattern matching is modified so that back references to an unset subpattern
5916 * group produces a match with the empty string instead of an error. See
5917 * <ulink>man:pcreapi(3)</ulink> for more information.
5919 * Creating and manipulating the same #GRegex structure from different
5920 * threads is not a problem as #GRegex does not modify its internal
5921 * state between creation and destruction, on the other hand #GMatchInfo
5922 * is not threadsafe.
5924 * The regular expressions low-level functionalities are obtained through
5925 * the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
5926 * written by Philip Hazel.
5932 * @title: UNIX-specific utilities and integration
5933 * @short_description: pipes, signal handling
5934 * @include: glib-unix.h
5936 * Most of GLib is intended to be portable; in contrast, this set of
5937 * functions is designed for programs which explicitly target UNIX,
5938 * or are using it to build higher level abstractions which would be
5939 * conditionally compiled if the platform matches G_OS_UNIX.
5941 * To use these functions, you must explicitly include the
5942 * "glib-unix.h" header.
5948 * @title: URI Functions
5949 * @short_description: manipulating URIs
5951 * Functions for manipulating Universal Resource Identifiers (URIs) as
5952 * defined by <ulink url="http://www.ietf.org/rfc/rfc3986.txt">
5953 * RFC 3986</ulink>. It is highly recommended that you have read and
5954 * understand RFC 3986 for understanding this API.
5961 * @short_description: strongly typed value datatype
5962 * @see_also: GVariantType
5964 * #GVariant is a variant datatype; it stores a value along with
5965 * information about the type of that value. The range of possible
5966 * values is determined by the type. The type system used by #GVariant
5969 * #GVariant instances always have a type and a value (which are given
5970 * at construction time). The type and value of a #GVariant instance
5971 * can never change other than by the #GVariant itself being
5972 * destroyed. A #GVariant cannot contain a pointer.
5974 * #GVariant is reference counted using g_variant_ref() and
5975 * g_variant_unref(). #GVariant also has floating reference counts --
5976 * see g_variant_ref_sink().
5978 * #GVariant is completely threadsafe. A #GVariant instance can be
5979 * concurrently accessed in any way from any number of threads without
5982 * #GVariant is heavily optimised for dealing with data in serialised
5983 * form. It works particularly well with data located in memory-mapped
5984 * files. It can perform nearly all deserialisation operations in a
5985 * small constant time, usually touching only a single memory page.
5986 * Serialised #GVariant data can also be sent over the network.
5988 * #GVariant is largely compatible with D-Bus. Almost all types of
5989 * #GVariant instances can be sent over D-Bus. See #GVariantType for
5990 * exceptions. (However, #GVariant's serialisation format is not the same
5991 * as the serialisation format of a D-Bus message body: use #GDBusMessage,
5992 * in the gio library, for those.)
5994 * For space-efficiency, the #GVariant serialisation format does not
5995 * automatically include the variant's type or endianness, which must
5996 * either be implied from context (such as knowledge that a particular
5997 * file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
5998 * or supplied out-of-band (for instance, a type and/or endianness
5999 * indicator could be placed at the beginning of a file, network message
6000 * or network stream).
6002 * A #GVariant's size is limited mainly by any lower level operating
6003 * system constraints, such as the number of bits in #gsize. For
6004 * example, it is reasonable to have a 2GB file mapped into memory
6005 * with #GMappedFile, and call g_variant_new_from_data() on it.
6007 * For convenience to C programmers, #GVariant features powerful
6008 * varargs-based value construction and destruction. This feature is
6009 * designed to be embedded in other libraries.
6011 * There is a Python-inspired text language for describing #GVariant
6012 * values. #GVariant includes a printer for this language and a parser
6013 * with type inferencing.
6016 * <title>Memory Use</title>
6018 * #GVariant tries to be quite efficient with respect to memory use.
6019 * This section gives a rough idea of how much memory is used by the
6020 * current implementation. The information here is subject to change
6024 * The memory allocated by #GVariant can be grouped into 4 broad
6025 * purposes: memory for serialised data, memory for the type
6026 * information cache, buffer management memory and memory for the
6027 * #GVariant structure itself.
6029 * <refsect3 id="gvariant-serialised-data-memory">
6030 * <title>Serialised Data Memory</title>
6032 * This is the memory that is used for storing GVariant data in
6033 * serialised form. This is what would be sent over the network or
6034 * what would end up on disk.
6037 * The amount of memory required to store a boolean is 1 byte. 16,
6038 * 32 and 64 bit integers and double precision floating point numbers
6039 * use their "natural" size. Strings (including object path and
6040 * signature strings) are stored with a nul terminator, and as such
6041 * use the length of the string plus 1 byte.
6044 * Maybe types use no space at all to represent the null value and
6045 * use the same amount of space (sometimes plus one byte) as the
6046 * equivalent non-maybe-typed value to represent the non-null case.
6049 * Arrays use the amount of space required to store each of their
6050 * members, concatenated. Additionally, if the items stored in an
6051 * array are not of a fixed-size (ie: strings, other arrays, etc)
6052 * then an additional framing offset is stored for each item. The
6053 * size of this offset is either 1, 2 or 4 bytes depending on the
6054 * overall size of the container. Additionally, extra padding bytes
6055 * are added as required for alignment of child values.
6058 * Tuples (including dictionary entries) use the amount of space
6059 * required to store each of their members, concatenated, plus one
6060 * framing offset (as per arrays) for each non-fixed-sized item in
6061 * the tuple, except for the last one. Additionally, extra padding
6062 * bytes are added as required for alignment of child values.
6065 * Variants use the same amount of space as the item inside of the
6066 * variant, plus 1 byte, plus the length of the type string for the
6067 * item inside the variant.
6070 * As an example, consider a dictionary mapping strings to variants.
6071 * In the case that the dictionary is empty, 0 bytes are required for
6072 * the serialisation.
6075 * If we add an item "width" that maps to the int32 value of 500 then
6076 * we will use 4 byte to store the int32 (so 6 for the variant
6077 * containing it) and 6 bytes for the string. The variant must be
6078 * aligned to 8 after the 6 bytes of the string, so that's 2 extra
6079 * bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
6080 * for the dictionary entry. An additional 1 byte is added to the
6081 * array as a framing offset making a total of 15 bytes.
6084 * If we add another entry, "title" that maps to a nullable string
6085 * that happens to have a value of null, then we use 0 bytes for the
6086 * null value (and 3 bytes for the variant to contain it along with
6087 * its type string) plus 6 bytes for the string. Again, we need 2
6088 * padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
6091 * We now require extra padding between the two items in the array.
6092 * After the 14 bytes of the first item, that's 2 bytes required. We
6093 * now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
6094 * + 2 = 29 bytes to encode the entire two-item dictionary.
6098 * <title>Type Information Cache</title>
6100 * For each GVariant type that currently exists in the program a type
6101 * information structure is kept in the type information cache. The
6102 * type information structure is required for rapid deserialisation.
6105 * Continuing with the above example, if a #GVariant exists with the
6106 * type "a{sv}" then a type information struct will exist for
6107 * "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
6108 * will share the same type information. Additionally, all
6109 * single-digit types are stored in read-only static memory and do
6110 * not contribute to the writable memory footprint of a program using
6114 * Aside from the type information structures stored in read-only
6115 * memory, there are two forms of type information. One is used for
6116 * container types where there is a single element type: arrays and
6117 * maybe types. The other is used for container types where there
6118 * are multiple element types: tuples and dictionary entries.
6121 * Array type info structures are 6 * sizeof (void *), plus the
6122 * memory required to store the type string itself. This means that
6123 * on 32bit systems, the cache entry for "a{sv}" would require 30
6124 * bytes of memory (plus malloc overhead).
6127 * Tuple type info structures are 6 * sizeof (void *), plus 4 *
6128 * sizeof (void *) for each item in the tuple, plus the memory
6129 * required to store the type string itself. A 2-item tuple, for
6130 * example, would have a type information structure that consumed
6131 * writable memory in the size of 14 * sizeof (void *) (plus type
6132 * string) This means that on 32bit systems, the cache entry for
6133 * "{sv}" would require 61 bytes of memory (plus malloc overhead).
6136 * This means that in total, for our "a{sv}" example, 91 bytes of
6137 * type information would be allocated.
6140 * The type information cache, additionally, uses a #GHashTable to
6141 * store and lookup the cached items and stores a pointer to this
6142 * hash table in static storage. The hash table is freed when there
6143 * are zero items in the type cache.
6146 * Although these sizes may seem large it is important to remember
6147 * that a program will probably only have a very small number of
6148 * different types of values in it and that only one type information
6149 * structure is required for many different values of the same type.
6153 * <title>Buffer Management Memory</title>
6155 * #GVariant uses an internal buffer management structure to deal
6156 * with the various different possible sources of serialised data
6157 * that it uses. The buffer is responsible for ensuring that the
6158 * correct call is made when the data is no longer in use by
6159 * #GVariant. This may involve a g_free() or a g_slice_free() or
6160 * even g_mapped_file_unref().
6163 * One buffer management structure is used for each chunk of
6164 * serialised data. The size of the buffer management structure is 4
6165 * * (void *). On 32bit systems, that's 16 bytes.
6169 * <title>GVariant structure</title>
6171 * The size of a #GVariant structure is 6 * (void *). On 32 bit
6172 * systems, that's 24 bytes.
6175 * #GVariant structures only exist if they are explicitly created
6176 * with API calls. For example, if a #GVariant is constructed out of
6177 * serialised data for the example given above (with the dictionary)
6178 * then although there are 9 individual values that comprise the
6179 * entire dictionary (two keys, two values, two variants containing
6180 * the values, two dictionary entries, plus the dictionary itself),
6181 * only 1 #GVariant instance exists -- the one referring to the
6185 * If calls are made to start accessing the other values then
6186 * #GVariant instances will exist for those values only for as long
6187 * as they are in use (ie: until you call g_variant_unref()). The
6188 * type information is shared. The serialised data and the buffer
6189 * management structure for that serialised data is shared by the
6194 * <title>Summary</title>
6196 * To put the entire example together, for our dictionary mapping
6197 * strings to variants (with two entries, as given above), we are
6198 * using 91 bytes of memory for type information, 29 byes of memory
6199 * for the serialised data, 16 bytes for buffer management and 24
6200 * bytes for the #GVariant instance, or a total of 160 bytes, plus
6201 * malloc overhead. If we were to use g_variant_get_child_value() to
6202 * access the two dictionary entries, we would use an additional 48
6203 * bytes. If we were to have other dictionaries of the same type, we
6204 * would use more memory for the serialised data and buffer
6205 * management for those dictionaries, but the type information would
6214 * SECTION:gvarianttype
6215 * @title: GVariantType
6216 * @short_description: introduction to the GVariant type system
6217 * @see_also: #GVariantType, #GVariant
6219 * This section introduces the GVariant type system. It is based, in
6220 * large part, on the D-Bus type system, with two major changes and some minor
6221 * lifting of restrictions. The <ulink
6222 * url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
6223 * specification</ulink>, therefore, provides a significant amount of
6224 * information that is useful when working with GVariant.
6226 * The first major change with respect to the D-Bus type system is the
6227 * introduction of maybe (or "nullable") types. Any type in GVariant can be
6228 * converted to a maybe type, in which case, "nothing" (or "null") becomes a
6229 * valid value. Maybe types have been added by introducing the
6230 * character "<literal>m</literal>" to type strings.
6232 * The second major change is that the GVariant type system supports the
6233 * concept of "indefinite types" -- types that are less specific than
6234 * the normal types found in D-Bus. For example, it is possible to speak
6235 * of "an array of any type" in GVariant, where the D-Bus type system
6236 * would require you to speak of "an array of integers" or "an array of
6237 * strings". Indefinite types have been added by introducing the
6238 * characters "<literal>*</literal>", "<literal>?</literal>" and
6239 * "<literal>r</literal>" to type strings.
6241 * Finally, all arbitrary restrictions relating to the complexity of
6242 * types are lifted along with the restriction that dictionary entries
6243 * may only appear nested inside of arrays.
6245 * Just as in D-Bus, GVariant types are described with strings ("type
6246 * strings"). Subject to the differences mentioned above, these strings
6247 * are of the same form as those found in DBus. Note, however: D-Bus
6248 * always works in terms of messages and therefore individual type
6249 * strings appear nowhere in its interface. Instead, "signatures"
6250 * are a concatenation of the strings of the type of each argument in a
6251 * message. GVariant deals with single values directly so GVariant type
6252 * strings always describe the type of exactly one value. This means
6253 * that a D-Bus signature string is generally not a valid GVariant type
6254 * string -- except in the case that it is the signature of a message
6255 * containing exactly one argument.
6257 * An indefinite type is similar in spirit to what may be called an
6258 * abstract type in other type systems. No value can exist that has an
6259 * indefinite type as its type, but values can exist that have types
6260 * that are subtypes of indefinite types. That is to say,
6261 * g_variant_get_type() will never return an indefinite type, but
6262 * calling g_variant_is_of_type() with an indefinite type may return
6263 * %TRUE. For example, you cannot have a value that represents "an
6264 * array of no particular type", but you can have an "array of integers"
6265 * which certainly matches the type of "an array of no particular type",
6266 * since "array of integers" is a subtype of "array of no particular
6269 * This is similar to how instances of abstract classes may not
6270 * directly exist in other type systems, but instances of their
6271 * non-abstract subtypes may. For example, in GTK, no object that has
6272 * the type of #GtkBin can exist (since #GtkBin is an abstract class),
6273 * but a #GtkWindow can certainly be instantiated, and you would say
6274 * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
6277 * A detailed description of GVariant type strings is given here:
6279 * <refsect2 id='gvariant-typestrings'>
6280 * <title>GVariant Type Strings</title>
6282 * A GVariant type string can be any of the following:
6287 * any basic type string (listed below)
6292 * "<literal>v</literal>", "<literal>r</literal>" or
6293 * "<literal>*</literal>"
6298 * one of the characters '<literal>a</literal>' or
6299 * '<literal>m</literal>', followed by another type string
6304 * the character '<literal>(</literal>', followed by a concatenation
6305 * of zero or more other type strings, followed by the character
6306 * '<literal>)</literal>'
6311 * the character '<literal>{</literal>', followed by a basic type
6312 * string (see below), followed by another type string, followed by
6313 * the character '<literal>}</literal>'
6318 * A basic type string describes a basic type (as per
6319 * g_variant_type_is_basic()) and is always a single
6320 * character in length. The valid basic type strings are
6321 * "<literal>b</literal>", "<literal>y</literal>",
6322 * "<literal>n</literal>", "<literal>q</literal>",
6323 * "<literal>i</literal>", "<literal>u</literal>",
6324 * "<literal>x</literal>", "<literal>t</literal>",
6325 * "<literal>h</literal>", "<literal>d</literal>",
6326 * "<literal>s</literal>", "<literal>o</literal>",
6327 * "<literal>g</literal>" and "<literal>?</literal>".
6330 * The above definition is recursive to arbitrary depth.
6331 * "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
6332 * are both valid type strings, as is
6333 * "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
6336 * The meaning of each of the characters is as follows:
6344 * <emphasis role='strong'>Character</emphasis>
6349 * <emphasis role='strong'>Meaning</emphasis>
6356 * <literal>b</literal>
6361 * the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
6368 * <literal>y</literal>
6373 * the type string of %G_VARIANT_TYPE_BYTE; a byte.
6380 * <literal>n</literal>
6385 * the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
6393 * <literal>q</literal>
6398 * the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
6406 * <literal>i</literal>
6411 * the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
6419 * <literal>u</literal>
6424 * the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
6432 * <literal>x</literal>
6437 * the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
6445 * <literal>t</literal>
6450 * the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
6458 * <literal>h</literal>
6463 * the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
6464 * value that, by convention, is used as an index into an array
6465 * of file descriptors that are sent alongside a D-Bus message.
6472 * <literal>d</literal>
6477 * the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
6478 * floating point value.
6485 * <literal>s</literal>
6490 * the type string of %G_VARIANT_TYPE_STRING; a string.
6497 * <literal>o</literal>
6502 * the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
6503 * the form of a D-Bus object path.
6510 * <literal>g</literal>
6515 * the type string of %G_VARIANT_TYPE_STRING; a string in the
6516 * form of a D-Bus type signature.
6523 * <literal>?</literal>
6528 * the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
6529 * that is a supertype of any of the basic types.
6536 * <literal>v</literal>
6541 * the type string of %G_VARIANT_TYPE_VARIANT; a container type
6542 * that contain any other type of value.
6549 * <literal>a</literal>
6554 * used as a prefix on another type string to mean an array of
6555 * that type; the type string "<literal>ai</literal>", for
6556 * example, is the type of an array of 32 bit signed integers.
6563 * <literal>m</literal>
6568 * used as a prefix on another type string to mean a "maybe", or
6569 * "nullable", version of that type; the type string
6570 * "<literal>ms</literal>", for example, is the type of a value
6571 * that maybe contains a string, or maybe contains nothing.
6578 * <literal>()</literal>
6583 * used to enclose zero or more other concatenated type strings
6584 * to create a tuple type; the type string
6585 * "<literal>(is)</literal>", for example, is the type of a pair
6586 * of an integer and a string.
6593 * <literal>r</literal>
6598 * the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
6599 * that is a supertype of any tuple type, regardless of the
6607 * <literal>{}</literal>
6612 * used to enclose a basic type string concatenated with another
6613 * type string to create a dictionary entry type, which usually
6614 * appears inside of an array to form a dictionary; the type
6615 * string "<literal>a{sd}</literal>", for example, is the type of
6616 * a dictionary that maps strings to double precision floating
6620 * The first type (the basic type) is the key type and the second
6621 * type is the value type. The reason that the first type is
6622 * restricted to being a basic type is so that it can easily be
6630 * <literal>*</literal>
6635 * the type string of %G_VARIANT_TYPE_ANY; the indefinite type
6636 * that is a supertype of all types. Note that, as with all type
6637 * strings, this character represents exactly one type. It
6638 * cannot be used inside of tuples to mean "any number of items".
6646 * Any type string of a container that contains an indefinite type is,
6647 * itself, an indefinite type. For example, the type string
6648 * "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
6649 * an indefinite type that is a supertype of every array type.
6650 * "<literal>(*s)</literal>" is a supertype of all tuples that
6651 * contain exactly two items where the second item is a string.
6654 * "<literal>a{?*}</literal>" is an indefinite type that is a
6655 * supertype of all arrays containing dictionary entries where the key
6656 * is any basic type and the value is any type at all. This is, by
6657 * definition, a dictionary, so this type string corresponds to
6658 * %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
6659 * the key of a dictionary entry must be a basic type,
6660 * "<literal>{**}</literal>" is not a valid type string.
6667 * SECTION:hash_tables
6668 * @title: Hash Tables
6669 * @short_description: associations between keys and values so that
6670 * given a key the value can be found quickly
6672 * A #GHashTable provides associations between keys and values which is
6673 * optimized so that given a key, the associated value can be found
6676 * Note that neither keys nor values are copied when inserted into the
6677 * #GHashTable, so they must exist for the lifetime of the #GHashTable.
6678 * This means that the use of static strings is OK, but temporary
6679 * strings (i.e. those created in buffers and those returned by GTK+
6680 * widgets) should be copied with g_strdup() before being inserted.
6682 * If keys or values are dynamically allocated, you must be careful to
6683 * ensure that they are freed when they are removed from the
6684 * #GHashTable, and also when they are overwritten by new insertions
6685 * into the #GHashTable. It is also not advisable to mix static strings
6686 * and dynamically-allocated strings in a #GHashTable, because it then
6687 * becomes difficult to determine whether the string should be freed.
6689 * To create a #GHashTable, use g_hash_table_new().
6691 * To insert a key and value into a #GHashTable, use
6692 * g_hash_table_insert().
6694 * To lookup a value corresponding to a given key, use
6695 * g_hash_table_lookup() and g_hash_table_lookup_extended().
6697 * g_hash_table_lookup_extended() can also be used to simply
6698 * check if a key is present in the hash table.
6700 * To remove a key and value, use g_hash_table_remove().
6702 * To call a function for each key and value pair use
6703 * g_hash_table_foreach() or use a iterator to iterate over the
6704 * key/value pairs in the hash table, see #GHashTableIter.
6706 * To destroy a #GHashTable use g_hash_table_destroy().
6708 * A common use-case for hash tables is to store information about a
6709 * set of keys, without associating any particular value with each
6710 * key. GHashTable optimizes one way of doing so: If you store only
6711 * key-value pairs where key == value, then GHashTable does not
6712 * allocate memory to store the values, which can be a considerable
6713 * space saving, if your set is large. The functions
6714 * g_hash_table_add() and g_hash_table_contains() are designed to be
6715 * used when using #GHashTable this way.
6721 * @title: Secure HMAC Digests
6722 * @short_description: computes the HMAC for data
6724 * HMACs should be used when producing a cookie or hash based on data
6725 * and a key. Simple mechanisms for using SHA1 and other algorithms to
6726 * digest a key and data together are vulnerable to various security
6727 * issues. <ulink url="http://en.wikipedia.org/wiki/HMAC">HMAC</ulink>
6728 * uses algorithms like SHA1 in a secure way to produce a digest of a
6731 * Both the key and data are arbitrary byte arrays of bytes or characters.
6733 * Support for HMAC Digests has been added in GLib 2.30.
6739 * @title: Hook Functions
6740 * @short_description: support for manipulating lists of hook functions
6742 * The #GHookList, #GHook and their related functions provide support for
6743 * lists of hook functions. Functions can be added and removed from the lists,
6744 * and the list of hook functions can be invoked.
6750 * @title: Internationalization
6751 * @short_description: gettext support macros
6752 * @see_also: the gettext manual
6754 * GLib doesn't force any particular localization method upon its users.
6755 * But since GLib itself is localized using the gettext() mechanism, it seems
6756 * natural to offer the de-facto standard gettext() support macros in an
6759 * In order to use these macros in an application, you must include
6760 * <filename>glib/gi18n.h</filename>. For use in a library, you must include
6761 * <filename>glib/gi18n-lib.h</filename> <emphasis>after</emphasis> defining
6762 * the GETTEXT_PACKAGE macro suitably for your library:
6764 * #define GETTEXT_PACKAGE "gtk20"
6765 * #include <glib/gi18n-lib.h>
6767 * For an application, note that you also have to call bindtextdomain(),
6768 * bind_textdomain_codeset(), textdomain() and setlocale() early on in your
6769 * main() to make gettext() work.
6771 * For a library, you only have to call bindtextdomain() and
6772 * bind_textdomain_codeset() in your initialization function. If your library
6773 * doesn't have an initialization function, you can call the functions before
6774 * the first translated message.
6776 * The gettext manual covers details of how to set up message extraction
6782 * SECTION:iochannels
6783 * @title: IO Channels
6784 * @short_description: portable support for using files, pipes and
6786 * @see_also: <para> <variablelist> <varlistentry>
6787 * <term>g_io_add_watch(), g_io_add_watch_full(),
6788 * g_source_remove()</term> <listitem><para> Convenience
6789 * functions for creating #GIOChannel instances and adding
6790 * them to the <link linkend="glib-The-Main-Event-Loop">main
6791 * event loop</link>. </para></listitem> </varlistentry>
6792 * </variablelist> </para>
6794 * The #GIOChannel data type aims to provide a portable method for
6795 * using file descriptors, pipes, and sockets, and integrating them
6796 * into the <link linkend="glib-The-Main-Event-Loop">main event
6797 * loop</link>. Currently full support is available on UNIX platforms,
6798 * support for Windows is only partially complete.
6800 * To create a new #GIOChannel on UNIX systems use
6801 * g_io_channel_unix_new(). This works for plain file descriptors,
6802 * pipes and sockets. Alternatively, a channel can be created for a
6803 * file in a system independent manner using g_io_channel_new_file().
6805 * Once a #GIOChannel has been created, it can be used in a generic
6806 * manner with the functions g_io_channel_read_chars(),
6807 * g_io_channel_write_chars(), g_io_channel_seek_position(), and
6808 * g_io_channel_shutdown().
6810 * To add a #GIOChannel to the <link
6811 * linkend="glib-The-Main-Event-Loop">main event loop</link> use
6812 * g_io_add_watch() or g_io_add_watch_full(). Here you specify which
6813 * events you are interested in on the #GIOChannel, and provide a
6814 * function to be called whenever these events occur.
6816 * #GIOChannel instances are created with an initial reference count of
6817 * 1. g_io_channel_ref() and g_io_channel_unref() can be used to
6818 * increment or decrement the reference count respectively. When the
6819 * reference count falls to 0, the #GIOChannel is freed. (Though it
6820 * isn't closed automatically, unless it was created using
6821 * g_io_channel_new_file().) Using g_io_add_watch() or
6822 * g_io_add_watch_full() increments a channel's reference count.
6824 * The new functions g_io_channel_read_chars(),
6825 * g_io_channel_read_line(), g_io_channel_read_line_string(),
6826 * g_io_channel_read_to_end(), g_io_channel_write_chars(),
6827 * g_io_channel_seek_position(), and g_io_channel_flush() should not be
6828 * mixed with the deprecated functions g_io_channel_read(),
6829 * g_io_channel_write(), and g_io_channel_seek() on the same channel.
6835 * @title: Key-value file parser
6836 * @short_description: parses .ini-like config files
6838 * #GKeyFile lets you parse, edit or create files containing groups of
6839 * key-value pairs, which we call <firstterm>key files</firstterm> for
6840 * lack of a better name. Several freedesktop.org specifications use
6841 * key files now, e.g the
6842 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6843 * Entry Specification</ulink> and the
6844 * <ulink url="http://freedesktop.org/Standards/icon-theme-spec">Icon
6845 * Theme Specification</ulink>.
6847 * The syntax of key files is described in detail in the
6848 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6849 * Entry Specification</ulink>, here is a quick summary: Key files
6850 * consists of groups of key-value pairs, interspersed with comments.
6853 * # this is just an example
6854 * # there can be comments before the first group
6858 * Name=Key File Example\tthis value shows\nescaping
6860 * # localized strings are stored in multiple key-value pairs
6863 * Welcome[fr_FR]=Bonjour
6865 * Welcome[be@latin]=Hello
6869 * Numbers=2;20;-200;0
6871 * Booleans=true;false;true;true
6874 * Lines beginning with a '#' and blank lines are considered comments.
6876 * Groups are started by a header line containing the group name enclosed
6877 * in '[' and ']', and ended implicitly by the start of the next group or
6878 * the end of the file. Each key-value pair must be contained in a group.
6880 * Key-value pairs generally have the form <literal>key=value</literal>,
6881 * with the exception of localized strings, which have the form
6882 * <literal>key[locale]=value</literal>, with a locale identifier of the
6883 * form <literal>lang_COUNTRY@MODIFIER</literal> where
6884 * <literal>COUNTRY</literal> and <literal>MODIFIER</literal> are optional.
6885 * Space before and after the '=' character are ignored. Newline, tab,
6886 * carriage return and backslash characters in value are escaped as \n,
6887 * \t, \r, and \\, respectively. To preserve leading spaces in values,
6888 * these can also be escaped as \s.
6890 * Key files can store strings (possibly with localized variants), integers,
6891 * booleans and lists of these. Lists are separated by a separator character,
6892 * typically ';' or ','. To use the list separator character in a value in
6893 * a list, it has to be escaped by prefixing it with a backslash.
6895 * This syntax is obviously inspired by the .ini files commonly met
6896 * on Windows, but there are some important differences:
6898 * <listitem>.ini files use the ';' character to begin comments,
6899 * key files use the '#' character.</listitem>
6900 * <listitem>Key files do not allow for ungrouped keys meaning only
6901 * comments can precede the first group.</listitem>
6902 * <listitem>Key files are always encoded in UTF-8.</listitem>
6903 * <listitem>Key and Group names are case-sensitive. For example, a
6904 * group called <literal>[GROUP]</literal> is a different from
6905 * <literal>[group]</literal>.</listitem>
6906 * <listitem>.ini files don't have a strongly typed boolean entry type,
6907 * they only have GetProfileInt(). In key files, only
6908 * <literal>true</literal> and <literal>false</literal> (in lower case)
6909 * are allowed.</listitem>
6912 * Note that in contrast to the
6913 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6914 * Entry Specification</ulink>, groups in key files may contain the same
6915 * key multiple times; the last entry wins. Key files may also contain
6916 * multiple groups with the same name; they are merged together.
6917 * Another difference is that keys and group names in key files are not
6918 * restricted to ASCII characters.
6923 * SECTION:linked_lists_double
6924 * @title: Doubly-Linked Lists
6925 * @short_description: linked lists that can be iterated over in both directions
6927 * The #GList structure and its associated functions provide a standard
6928 * doubly-linked list data structure.
6930 * Each element in the list contains a piece of data, together with
6931 * pointers which link to the previous and next elements in the list.
6932 * Using these pointers it is possible to move through the list in both
6933 * directions (unlike the <link
6934 * linkend="glib-Singly-Linked-Lists">Singly-Linked Lists</link> which
6935 * only allows movement through the list in the forward direction).
6937 * The data contained in each element can be either integer values, by
6938 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6939 * Conversion Macros</link>, or simply pointers to any type of data.
6941 * List elements are allocated from the <link
6942 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6943 * efficient than allocating elements individually.
6945 * Note that most of the #GList functions expect to be passed a pointer
6946 * to the first element in the list. The functions which insert
6947 * elements return the new start of the list, which may have changed.
6949 * There is no function to create a #GList. %NULL is considered to be
6950 * the empty list so you simply set a #GList* to %NULL.
6952 * To add elements, use g_list_append(), g_list_prepend(),
6953 * g_list_insert() and g_list_insert_sorted().
6955 * To remove elements, use g_list_remove().
6957 * To find elements in the list use g_list_first(), g_list_last(),
6958 * g_list_next(), g_list_previous(), g_list_nth(), g_list_nth_data(),
6959 * g_list_find() and g_list_find_custom().
6961 * To find the index of an element use g_list_position() and
6964 * To call a function for each element in the list use g_list_foreach().
6966 * To free the entire list, use g_list_free().
6971 * SECTION:linked_lists_single
6972 * @title: Singly-Linked Lists
6973 * @short_description: linked lists that can be iterated in one direction
6975 * The #GSList structure and its associated functions provide a
6976 * standard singly-linked list data structure.
6978 * Each element in the list contains a piece of data, together with a
6979 * pointer which links to the next element in the list. Using this
6980 * pointer it is possible to move through the list in one direction
6981 * only (unlike the <link
6982 * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
6983 * allow movement in both directions).
6985 * The data contained in each element can be either integer values, by
6986 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6987 * Conversion Macros</link>, or simply pointers to any type of data.
6989 * List elements are allocated from the <link
6990 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6991 * efficient than allocating elements individually.
6993 * Note that most of the #GSList functions expect to be passed a
6994 * pointer to the first element in the list. The functions which insert
6995 * elements return the new start of the list, which may have changed.
6997 * There is no function to create a #GSList. %NULL is considered to be
6998 * the empty list so you simply set a #GSList* to %NULL.
7000 * To add elements, use g_slist_append(), g_slist_prepend(),
7001 * g_slist_insert() and g_slist_insert_sorted().
7003 * To remove elements, use g_slist_remove().
7005 * To find elements in the list use g_slist_last(), g_slist_next(),
7006 * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
7007 * g_slist_find_custom().
7009 * To find the index of an element use g_slist_position() and
7012 * To call a function for each element in the list use
7013 * g_slist_foreach().
7015 * To free the entire list, use g_slist_free().
7021 * @title: Standard Macros
7022 * @short_description: commonly-used macros
7024 * These macros provide a few commonly-used features.
7029 * SECTION:macros_misc
7030 * @title: Miscellaneous Macros
7031 * @short_description: specialized macros which are not used often
7033 * These macros provide more specialized features which are not
7034 * needed so often by application programmers.
7040 * @title: The Main Event Loop
7041 * @short_description: manages all available sources of events
7043 * The main event loop manages all the available sources of events for
7044 * GLib and GTK+ applications. These events can come from any number of
7045 * different types of sources such as file descriptors (plain files,
7046 * pipes or sockets) and timeouts. New types of event sources can also
7047 * be added using g_source_attach().
7049 * To allow multiple independent sets of sources to be handled in
7050 * different threads, each source is associated with a #GMainContext.
7051 * A GMainContext can only be running in a single thread, but
7052 * sources can be added to it and removed from it from other threads.
7054 * Each event source is assigned a priority. The default priority,
7055 * #G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
7056 * Values greater than 0 denote lower priorities. Events from high priority
7057 * sources are always processed before events from lower priority sources.
7059 * Idle functions can also be added, and assigned a priority. These will
7060 * be run whenever no events with a higher priority are ready to be processed.
7062 * The #GMainLoop data type represents a main event loop. A GMainLoop is
7063 * created with g_main_loop_new(). After adding the initial event sources,
7064 * g_main_loop_run() is called. This continuously checks for new events from
7065 * each of the event sources and dispatches them. Finally, the processing of
7066 * an event from one of the sources leads to a call to g_main_loop_quit() to
7067 * exit the main loop, and g_main_loop_run() returns.
7069 * It is possible to create new instances of #GMainLoop recursively.
7070 * This is often used in GTK+ applications when showing modal dialog
7071 * boxes. Note that event sources are associated with a particular
7072 * #GMainContext, and will be checked and dispatched for all main
7073 * loops associated with that GMainContext.
7075 * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
7076 * gtk_main_quit() and gtk_events_pending().
7078 * <refsect2><title>Creating new source types</title>
7079 * <para>One of the unusual features of the #GMainLoop functionality
7080 * is that new types of event source can be created and used in
7081 * addition to the builtin type of event source. A new event source
7082 * type is used for handling GDK events. A new source type is created
7083 * by <firstterm>deriving</firstterm> from the #GSource structure.
7084 * The derived type of source is represented by a structure that has
7085 * the #GSource structure as a first element, and other elements specific
7086 * to the new source type. To create an instance of the new source type,
7087 * call g_source_new() passing in the size of the derived structure and
7088 * a table of functions. These #GSourceFuncs determine the behavior of
7089 * the new source type.</para>
7090 * <para>New source types basically interact with the main context
7091 * in two ways. Their prepare function in #GSourceFuncs can set a timeout
7092 * to determine the maximum amount of time that the main loop will sleep
7093 * before checking the source again. In addition, or as well, the source
7094 * can add file descriptors to the set that the main context checks using
7095 * g_source_add_poll().</para>
7097 * <refsect2><title>Customizing the main loop iteration</title>
7098 * <para>Single iterations of a #GMainContext can be run with
7099 * g_main_context_iteration(). In some cases, more detailed control
7100 * of exactly how the details of the main loop work is desired, for
7101 * instance, when integrating the #GMainLoop with an external main loop.
7102 * In such cases, you can call the component functions of
7103 * g_main_context_iteration() directly. These functions are
7104 * g_main_context_prepare(), g_main_context_query(),
7105 * g_main_context_check() and g_main_context_dispatch().</para>
7106 * <para>The operation of these functions can best be seen in terms
7107 * of a state diagram, as shown in <xref linkend="mainloop-states"/>.</para>
7108 * <figure id="mainloop-states"><title>States of a Main Context</title>
7109 * <graphic fileref="mainloop-states.gif" format="GIF"></graphic>
7113 * On Unix, the GLib mainloop is incompatible with fork(). Any program
7114 * using the mainloop must either exec() or exit() from the child
7115 * without returning to the mainloop.
7121 * @Title: Simple XML Subset Parser
7122 * @Short_description: parses a subset of XML
7123 * @See_also: <ulink url="http://www.w3.org/TR/REC-xml/">XML
7124 * Specification</ulink>
7126 * The "GMarkup" parser is intended to parse a simple markup format
7127 * that's a subset of XML. This is a small, efficient, easy-to-use
7128 * parser. It should not be used if you expect to interoperate with
7129 * other applications generating full-scale XML. However, it's very
7130 * useful for application data files, config files, etc. where you
7131 * know your application will be the only one writing the file.
7132 * Full-scale XML parsers should be able to parse the subset used by
7133 * GMarkup, so you can easily migrate to full-scale XML at a later
7134 * time if the need arises.
7136 * GMarkup is not guaranteed to signal an error on all invalid XML;
7137 * the parser may accept documents that an XML parser would not.
7138 * However, XML documents which are not well-formed<footnote
7139 * id="wellformed">Being wellformed is a weaker condition than being
7140 * valid. See the <ulink url="http://www.w3.org/TR/REC-xml/">XML
7141 * specification</ulink> for definitions of these terms.</footnote>
7142 * are not considered valid GMarkup documents.
7144 * Simplifications to XML include:
7146 * <listitem>Only UTF-8 encoding is allowed</listitem>
7147 * <listitem>No user-defined entities</listitem>
7148 * <listitem>Processing instructions, comments and the doctype declaration
7149 * are "passed through" but are not interpreted in any way</listitem>
7150 * <listitem>No DTD or validation.</listitem>
7153 * The markup format does support:
7155 * <listitem>Elements</listitem>
7156 * <listitem>Attributes</listitem>
7157 * <listitem>5 standard entities:
7158 * <literal>&amp; &lt; &gt; &quot; &apos;</literal>
7160 * <listitem>Character references</listitem>
7161 * <listitem>Sections marked as CDATA</listitem>
7168 * @Short_Description: general memory-handling
7169 * @Title: Memory Allocation
7171 * These functions provide support for allocating and freeing memory.
7174 * If any call to allocate memory fails, the application is terminated.
7175 * This also means that there is no need to check if the call succeeded.
7179 * It's important to match g_malloc() with g_free(), plain malloc() with free(),
7180 * and (if you're using C++) new with delete and new[] with delete[]. Otherwise
7181 * bad things can happen, since these allocators may use different memory
7182 * pools (and new/delete call constructors and destructors). See also
7183 * g_mem_set_vtable().
7189 * SECTION:memory_slices
7190 * @title: Memory Slices
7191 * @short_description: efficient way to allocate groups of equal-sized
7194 * Memory slices provide a space-efficient and multi-processing scalable
7195 * way to allocate equal-sized pieces of memory, just like the original
7196 * #GMemChunks (from GLib 2.8), while avoiding their excessive
7197 * memory-waste, scalability and performance problems.
7199 * To achieve these goals, the slice allocator uses a sophisticated,
7200 * layered design that has been inspired by Bonwick's slab allocator
7202 * <ulink url="http://citeseer.ist.psu.edu/bonwick94slab.html">[Bonwick94]</ulink> Jeff Bonwick, The slab allocator: An object-caching kernel
7203 * memory allocator. USENIX 1994, and
7204 * <ulink url="http://citeseer.ist.psu.edu/bonwick01magazines.html">[Bonwick01]</ulink> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
7205 * slab allocator to many cpu's and arbitrary resources. USENIX 2001
7206 * </para></footnote>.
7207 * It uses posix_memalign() to optimize allocations of many equally-sized
7208 * chunks, and has per-thread free lists (the so-called magazine layer)
7209 * to quickly satisfy allocation requests of already known structure sizes.
7210 * This is accompanied by extra caching logic to keep freed memory around
7211 * for some time before returning it to the system. Memory that is unused
7212 * due to alignment constraints is used for cache colorization (random
7213 * distribution of chunk addresses) to improve CPU cache utilization. The
7214 * caching layer of the slice allocator adapts itself to high lock contention
7215 * to improve scalability.
7217 * The slice allocator can allocate blocks as small as two pointers, and
7218 * unlike malloc(), it does not reserve extra space per block. For large block
7219 * sizes, g_slice_new() and g_slice_alloc() will automatically delegate to the
7220 * system malloc() implementation. For newly written code it is recommended
7221 * to use the new <literal>g_slice</literal> API instead of g_malloc() and
7222 * friends, as long as objects are not resized during their lifetime and the
7223 * object size used at allocation time is still available when freeing.
7226 * <title>Using the slice allocator</title>
7228 * gchar *mem[10000];
7231 * /* Allocate 10000 blocks. */
7232 * for (i = 0; i < 10000; i++)
7234 * mem[i] = g_slice_alloc (50);
7236 * /* Fill in the memory with some junk. */
7237 * for (j = 0; j < 50; j++)
7238 * mem[i][j] = i * j;
7241 * /* Now free all of the blocks. */
7242 * for (i = 0; i < 10000; i++)
7244 * g_slice_free1 (50, mem[i]);
7246 * </programlisting></example>
7249 * <title>Using the slice allocator with data structures</title>
7251 * GRealArray *array;
7253 * /* Allocate one block, using the g_slice_new() macro. */
7254 * array = g_slice_new (GRealArray);
7256 * /* We can now use array just like a normal pointer to a structure. */
7257 * array->data = NULL;
7260 * array->zero_terminated = (zero_terminated ? 1 : 0);
7261 * array->clear = (clear ? 1 : 0);
7262 * array->elt_size = elt_size;
7264 * /* We can free the block, so it can be reused. */
7265 * g_slice_free (GRealArray, array);
7266 * </programlisting></example>
7272 * @title: Message Logging
7273 * @short_description: versatile support for logging messages
7274 * with different levels of importance
7276 * These functions provide support for logging error messages
7277 * or messages used for debugging.
7279 * There are several built-in levels of messages, defined in
7280 * #GLogLevelFlags. These can be extended with user-defined levels.
7285 * SECTION:misc_utils
7286 * @title: Miscellaneous Utility Functions
7287 * @short_description: a selection of portable utility functions
7289 * These are portable utility functions.
7295 * @title: Numerical Definitions
7296 * @short_description: mathematical constants, and floating point decomposition
7298 * GLib offers mathematical constants such as #G_PI for the value of pi;
7299 * many platforms have these in the C library, but some don't, the GLib
7300 * versions always exist.
7302 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
7303 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
7304 * defined as appropriate for a given platform. IEEE floats and doubles are
7305 * supported (used for storage) by at least Intel, PPC and Sparc. See
7306 * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
7307 * for more information about IEEE number formats.
7313 * @Short_description: parses commandline options
7314 * @Title: Commandline option parser
7316 * The GOption commandline parser is intended to be a simpler replacement
7317 * for the popt library. It supports short and long commandline options,
7318 * as shown in the following example:
7320 * <literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
7322 * The example demonstrates a number of features of the GOption
7323 * commandline parser
7324 * <itemizedlist><listitem><para>
7325 * Options can be single letters, prefixed by a single dash. Multiple
7326 * short options can be grouped behind a single dash.
7327 * </para></listitem><listitem><para>
7328 * Long options are prefixed by two consecutive dashes.
7329 * </para></listitem><listitem><para>
7330 * Options can have an extra argument, which can be a number, a string or
7331 * a filename. For long options, the extra argument can be appended with
7332 * an equals sign after the option name, which is useful if the extra
7333 * argument starts with a dash, which would otherwise cause it to be
7334 * interpreted as another option.
7335 * </para></listitem><listitem><para>
7336 * Non-option arguments are returned to the application as rest arguments.
7337 * </para></listitem><listitem><para>
7338 * An argument consisting solely of two dashes turns off further parsing,
7339 * any remaining arguments (even those starting with a dash) are returned
7340 * to the application as rest arguments.
7341 * </para></listitem></itemizedlist>
7343 * Another important feature of GOption is that it can automatically
7344 * generate nicely formatted help output. Unless it is explicitly turned
7345 * off with g_option_context_set_help_enabled(), GOption will recognize
7346 * the <option>--help</option>, <option>-?</option>,
7347 * <option>--help-all</option> and
7348 * <option>--help-</option><replaceable>groupname</replaceable> options
7349 * (where <replaceable>groupname</replaceable> is the name of a
7350 * #GOptionGroup) and write a text similar to the one shown in the
7351 * following example to stdout.
7353 * <informalexample><screen>
7355 * testtreemodel [OPTION...] - test tree model performance
7358 * -h, --help Show help options
7359 * --help-all Show all help options
7360 * --help-gtk Show GTK+ Options
7362 * Application Options:
7363 * -r, --repeats=N Average over N repetitions
7364 * -m, --max-size=M Test up to 2^M items
7365 * --display=DISPLAY X display to use
7366 * -v, --verbose Be verbose
7367 * -b, --beep Beep when done
7368 * --rand Randomize the data
7369 * </screen></informalexample>
7371 * GOption groups options in #GOptionGroup<!-- -->s, which makes it easy to
7372 * incorporate options from multiple sources. The intended use for this is
7373 * to let applications collect option groups from the libraries it uses,
7374 * add them to their #GOptionContext, and parse all options by a single call
7375 * to g_option_context_parse(). See gtk_get_option_group() for an example.
7377 * If an option is declared to be of type string or filename, GOption takes
7378 * care of converting it to the right encoding; strings are returned in
7379 * UTF-8, filenames are returned in the GLib filename encoding. Note that
7380 * this only works if setlocale() has been called before
7381 * g_option_context_parse().
7383 * Here is a complete example of setting up GOption to parse the example
7384 * commandline above and produce the example help output.
7386 * <informalexample><programlisting>
7387 * static gint repeats = 2;
7388 * static gint max_size = 8;
7389 * static gboolean verbose = FALSE;
7390 * static gboolean beep = FALSE;
7391 * static gboolean rand = FALSE;
7393 * static GOptionEntry entries[] =
7395 * { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" },
7396 * { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" },
7397 * { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
7398 * { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
7399 * { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL },
7404 * main (int argc, char *argv[])
7406 * GError *error = NULL;
7407 * GOptionContext *context;
7409 * context = g_option_context_new ("- test tree model performance");
7410 * g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
7411 * g_option_context_add_group (context, gtk_get_option_group (TRUE));
7412 * if (!g_option_context_parse (context, &argc, &argv, &error))
7414 * g_print ("option parsing failed: %s\n", error->message);
7421 * </programlisting></informalexample>
7427 * @title: Glob-style pattern matching
7428 * @short_description: matches strings against patterns containing '*'
7429 * (wildcard) and '?' (joker)
7431 * The <function>g_pattern_match*</function> functions match a string
7432 * against a pattern containing '*' and '?' wildcards with similar
7433 * semantics as the standard glob() function: '*' matches an arbitrary,
7434 * possibly empty, string, '?' matches an arbitrary character.
7436 * Note that in contrast to glob(), the '/' character
7437 * <emphasis>can</emphasis> be matched by the wildcards, there are no
7438 * '[...]' character ranges and '*' and '?' can
7439 * <emphasis>not</emphasis> be escaped to include them literally in a
7442 * When multiple strings must be matched against the same pattern, it
7443 * is better to compile the pattern to a #GPatternSpec using
7444 * g_pattern_spec_new() and use g_pattern_match_string() instead of
7445 * g_pattern_match_simple(). This avoids the overhead of repeated
7446 * pattern compilation.
7453 * @short_description: a 2-way association between a string and a
7454 * unique integer identifier
7456 * Quarks are associations between strings and integer identifiers.
7457 * Given either the string or the #GQuark identifier it is possible to
7458 * retrieve the other.
7460 * Quarks are used for both <link
7461 * linkend="glib-Datasets">Datasets</link> and <link
7462 * linkend="glib-Keyed-Data-Lists">Keyed Data Lists</link>.
7464 * To create a new quark from a string, use g_quark_from_string() or
7465 * g_quark_from_static_string().
7467 * To find the string corresponding to a given #GQuark, use
7468 * g_quark_to_string().
7470 * To find the #GQuark corresponding to a given string, use
7471 * g_quark_try_string().
7473 * Another use for the string pool maintained for the quark functions
7474 * is string interning, using g_intern_string() or
7475 * g_intern_static_string(). An interned string is a canonical
7476 * representation for a string. One important advantage of interned
7477 * strings is that they can be compared for equality by a simple
7478 * pointer comparison, rather than using strcmp().
7484 * @Title: Double-ended Queues
7485 * @Short_description: double-ended queue data structure
7487 * The #GQueue structure and its associated functions provide a standard
7488 * queue data structure. Internally, GQueue uses the same data structure
7489 * as #GList to store elements.
7491 * The data contained in each element can be either integer values, by
7492 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
7493 * Conversion Macros</link>, or simply pointers to any type of data.
7495 * To create a new GQueue, use g_queue_new().
7497 * To initialize a statically-allocated GQueue, use #G_QUEUE_INIT or
7500 * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
7501 * g_queue_push_tail() and g_queue_push_tail_link().
7503 * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
7505 * To free the entire queue, use g_queue_free().
7510 * SECTION:random_numbers
7511 * @title: Random Numbers
7512 * @short_description: pseudo-random number generator
7514 * The following functions allow you to use a portable, fast and good
7515 * pseudo-random number generator (PRNG).
7517 * <warning><para>Do not use this API for cryptographic purposes such as key
7518 * generation, nonces, salts or one-time pads.</para></warning>
7520 * This PRNG is suitable for non-cryptographic use such as in games
7521 * (shuffling a card deck, generating levels), generating data for a
7522 * test suite, etc. If you need random data for cryptographic
7523 * purposes, it is recommended to use platform-specific APIs such as
7524 * <literal>/dev/random</literal> on Unix, or CryptGenRandom() on
7527 * GRand uses the Mersenne Twister PRNG, which was originally
7528 * developed by Makoto Matsumoto and Takuji Nishimura. Further
7529 * information can be found at <ulink
7530 * url="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
7531 * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</ulink>.
7533 * If you just need a random number, you simply call the
7534 * <function>g_random_*</function> functions, which will create a
7535 * globally used #GRand and use the according
7536 * <function>g_rand_*</function> functions internally. Whenever you
7537 * need a stream of reproducible random numbers, you better create a
7538 * #GRand yourself and use the <function>g_rand_*</function> functions
7539 * directly, which will also be slightly faster. Initializing a #GRand
7540 * with a certain seed will produce exactly the same series of random
7541 * numbers on all platforms. This can thus be used as a seed for e.g.
7544 * The <function>g_rand*_range</function> functions will return high
7545 * quality equally distributed random numbers, whereas for example the
7546 * <literal>(g_random_int()%max)</literal> approach often
7547 * doesn't yield equally distributed numbers.
7549 * GLib changed the seeding algorithm for the pseudo-random number
7550 * generator Mersenne Twister, as used by
7551 * <structname>GRand</structname> and <structname>GRandom</structname>.
7552 * This was necessary, because some seeds would yield very bad
7553 * pseudo-random streams. Also the pseudo-random integers generated by
7554 * <function>g_rand*_int_range()</function> will have a slightly better
7555 * equal distribution with the new version of GLib.
7557 * The original seeding and generation algorithms, as found in GLib
7558 * 2.0.x, can be used instead of the new ones by setting the
7559 * environment variable <envar>G_RANDOM_VERSION</envar> to the value of
7560 * '2.0'. Use the GLib-2.0 algorithms only if you have sequences of
7561 * numbers generated with Glib-2.0 that you need to reproduce exactly.
7567 * @title: Lexical Scanner
7568 * @short_description: a general purpose lexical scanner
7570 * The #GScanner and its associated functions provide a
7571 * general purpose lexical scanner.
7578 * @short_description: scalable lists
7580 * The #GSequence data structure has the API of a list, but is
7581 * implemented internally with a balanced binary tree. This means that
7582 * it is possible to maintain a sorted list of n elements in time O(n
7583 * log n). The data contained in each element can be either integer
7584 * values, by using of the <link
7585 * linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
7586 * or simply pointers to any type of data.
7588 * A #GSequence is accessed through <firstterm>iterators</firstterm>,
7589 * represented by a #GSequenceIter. An iterator represents a position
7590 * between two elements of the sequence. For example, the
7591 * <firstterm>begin</firstterm> iterator represents the gap immediately
7592 * before the first element of the sequence, and the
7593 * <firstterm>end</firstterm> iterator represents the gap immediately
7594 * after the last element. In an empty sequence, the begin and end
7595 * iterators are the same.
7597 * Some methods on #GSequence operate on ranges of items. For example
7598 * g_sequence_foreach_range() will call a user-specified function on
7599 * each element with the given range. The range is delimited by the
7600 * gaps represented by the passed-in iterators, so if you pass in the
7601 * begin and end iterators, the range in question is the entire
7604 * The function g_sequence_get() is used with an iterator to access the
7605 * element immediately following the gap that the iterator represents.
7606 * The iterator is said to <firstterm>point</firstterm> to that element.
7608 * Iterators are stable across most operations on a #GSequence. For
7609 * example an iterator pointing to some element of a sequence will
7610 * continue to point to that element even after the sequence is sorted.
7611 * Even moving an element to another sequence using for example
7612 * g_sequence_move_range() will not invalidate the iterators pointing
7613 * to it. The only operation that will invalidate an iterator is when
7614 * the element it points to is removed from any sequence.
7620 * @title: Shell-related Utilities
7621 * @short_description: shell-like commandline handling
7627 * @Short_description: process launching
7628 * @Title: Spawning Processes
7633 * SECTION:string_chunks
7634 * @title: String Chunks
7635 * @short_description: efficient storage of groups of strings
7637 * String chunks are used to store groups of strings. Memory is
7638 * allocated in blocks, and as strings are added to the #GStringChunk
7639 * they are copied into the next free position in a block. When a block
7640 * is full a new block is allocated.
7642 * When storing a large number of strings, string chunks are more
7643 * efficient than using g_strdup() since fewer calls to malloc() are
7644 * needed, and less memory is wasted in memory allocation overheads.
7646 * By adding strings with g_string_chunk_insert_const() it is also
7647 * possible to remove duplicates.
7649 * To create a new #GStringChunk use g_string_chunk_new().
7651 * To add strings to a #GStringChunk use g_string_chunk_insert().
7653 * To add strings to a #GStringChunk, but without duplicating strings
7654 * which are already in the #GStringChunk, use
7655 * g_string_chunk_insert_const().
7657 * To free the entire #GStringChunk use g_string_chunk_free(). It is
7658 * not possible to free individual strings.
7663 * SECTION:string_utils
7664 * @title: String Utility Functions
7665 * @short_description: various string-related functions
7667 * This section describes a number of utility functions for creating,
7668 * duplicating, and manipulating strings.
7670 * Note that the functions g_printf(), g_fprintf(), g_sprintf(),
7671 * g_snprintf(), g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf()
7672 * are declared in the header <filename>gprintf.h</filename> which is
7673 * <emphasis>not</emphasis> included in <filename>glib.h</filename>
7674 * (otherwise using <filename>glib.h</filename> would drag in
7675 * <filename>stdio.h</filename>), so you'll have to explicitly include
7676 * <literal><glib/gprintf.h></literal> in order to use the GLib
7677 * printf() functions.
7679 * <para id="string-precision">While you may use the printf() functions
7680 * to format UTF-8 strings, notice that the precision of a
7681 * <literal>%Ns</literal> parameter is interpreted as the
7682 * number of <emphasis>bytes</emphasis>, not <emphasis>characters</emphasis>
7683 * to print. On top of that, the GNU libc implementation of the printf()
7684 * functions has the "feature" that it checks that the string given for
7685 * the <literal>%Ns</literal> parameter consists of a whole number
7686 * of characters in the current encoding. So, unless you are sure you are
7687 * always going to be in an UTF-8 locale or your know your text is restricted
7688 * to ASCII, avoid using <literal>%Ns</literal>. If your intention is
7689 * to format strings for a certain number of columns, then
7690 * <literal>%Ns</literal> is not a correct solution anyway, since it
7691 * fails to take wide characters (see g_unichar_iswide()) into account.
7699 * @short_description: text buffers which grow automatically
7702 * A #GString is an object that handles the memory management of a C
7703 * string for you. The emphasis of #GString is on text, typically
7704 * UTF-8. Crucially, the "str" member of a #GString is guaranteed to
7705 * have a trailing nul character, and it is therefore always safe to
7706 * call functions such as strchr() or g_strdup() on it.
7708 * However, a #GString can also hold arbitrary binary data, because it
7709 * has a "len" member, which includes any possible embedded nul
7710 * characters in the data. Conceptually then, #GString is like a
7711 * #GByteArray with the addition of many convenience methods for text,
7712 * and a guaranteed nul terminator.
7719 * @short_description: a test framework
7720 * @see_also: <link linkend="gtester">gtester</link>,
7721 * <link linkend="gtester-report">gtester-report</link>
7723 * GLib provides a framework for writing and maintaining unit tests
7724 * in parallel to the code they are testing. The API is designed according
7725 * to established concepts found in the other test frameworks (JUnit, NUnit,
7726 * RUnit), which in turn is based on smalltalk unit testing concepts.
7730 * <term>Test case</term>
7731 * <listitem>Tests (test methods) are grouped together with their
7732 * fixture into test cases.</listitem>
7735 * <term>Fixture</term>
7736 * <listitem>A test fixture consists of fixture data and setup and
7737 * teardown methods to establish the environment for the test
7738 * functions. We use fresh fixtures, i.e. fixtures are newly set
7739 * up and torn down around each test invocation to avoid dependencies
7740 * between tests.</listitem>
7743 * <term>Test suite</term>
7744 * <listitem>Test cases can be grouped into test suites, to allow
7745 * subsets of the available tests to be run. Test suites can be
7746 * grouped into other test suites as well.</listitem>
7749 * The API is designed to handle creation and registration of test suites
7750 * and test cases implicitly. A simple call like
7752 * g_test_add_func ("/misc/assertions", test_assertions);
7754 * creates a test suite called "misc" with a single test case named
7755 * "assertions", which consists of running the test_assertions function.
7757 * In addition to the traditional g_assert(), the test framework provides
7758 * an extended set of assertions for string and numerical comparisons:
7759 * g_assert_cmpfloat(), g_assert_cmpint(), g_assert_cmpuint(),
7760 * g_assert_cmphex(), g_assert_cmpstr(). The advantage of these variants
7761 * over plain g_assert() is that the assertion messages can be more
7762 * elaborate, and include the values of the compared entities.
7764 * GLib ships with two utilities called gtester and gtester-report to
7765 * facilitate running tests and producing nicely formatted test reports.
7770 * SECTION:thread_pools
7771 * @title: Thread Pools
7772 * @short_description: pools of threads to execute work concurrently
7773 * @see_also: #GThread
7775 * Sometimes you wish to asynchronously fork out the execution of work
7776 * and continue working in your own thread. If that will happen often,
7777 * the overhead of starting and destroying a thread each time might be
7778 * too high. In such cases reusing already started threads seems like a
7779 * good idea. And it indeed is, but implementing this can be tedious
7782 * Therefore GLib provides thread pools for your convenience. An added
7783 * advantage is, that the threads can be shared between the different
7784 * subsystems of your program, when they are using GLib.
7786 * To create a new thread pool, you use g_thread_pool_new().
7787 * It is destroyed by g_thread_pool_free().
7789 * If you want to execute a certain task within a thread pool,
7790 * you call g_thread_pool_push().
7792 * To get the current number of running threads you call
7793 * g_thread_pool_get_num_threads(). To get the number of still
7794 * unprocessed tasks you call g_thread_pool_unprocessed(). To control
7795 * the maximal number of threads for a thread pool, you use
7796 * g_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().
7798 * Finally you can control the number of unused threads, that are kept
7799 * alive by GLib for future use. The current number can be fetched with
7800 * g_thread_pool_get_num_unused_threads(). The maximal number can be
7801 * controlled by g_thread_pool_get_max_unused_threads() and
7802 * g_thread_pool_set_max_unused_threads(). All currently unused threads
7803 * can be stopped by calling g_thread_pool_stop_unused_threads().
7810 * @short_description: portable support for threads, mutexes, locks,
7811 * conditions and thread private data
7812 * @see_also: #GThreadPool, #GAsyncQueue
7814 * Threads act almost like processes, but unlike processes all threads
7815 * of one process share the same memory. This is good, as it provides
7816 * easy communication between the involved threads via this shared
7817 * memory, and it is bad, because strange things (so called
7818 * "Heisenbugs") might happen if the program is not carefully designed.
7819 * In particular, due to the concurrent nature of threads, no
7820 * assumptions on the order of execution of code running in different
7821 * threads can be made, unless order is explicitly forced by the
7822 * programmer through synchronization primitives.
7824 * The aim of the thread-related functions in GLib is to provide a
7825 * portable means for writing multi-threaded software. There are
7826 * primitives for mutexes to protect the access to portions of memory
7827 * (#GMutex, #GRecMutex and #GRWLock). There is a facility to use
7828 * individual bits for locks (g_bit_lock()). There are primitives
7829 * for condition variables to allow synchronization of threads (#GCond).
7830 * There are primitives for thread-private data - data that every
7831 * thread has a private instance of (#GPrivate). There are facilities
7832 * for one-time initialization (#GOnce, g_once_init_enter()). Finally,
7833 * there are primitives to create and manage threads (#GThread).
7835 * The GLib threading system used to be initialized with g_thread_init().
7836 * This is no longer necessary. Since version 2.32, the GLib threading
7837 * system is automatically initialized at the start of your program,
7838 * and all thread-creation functions and synchronization primitives
7839 * are available right away.
7841 * Note that it is not safe to assume that your program has no threads
7842 * even if you don't call g_thread_new() yourself. GLib and GIO can
7843 * and will create threads for their own purposes in some cases, such
7844 * as when using g_unix_signal_source_new() or when using GDBus.
7846 * Originally, UNIX did not have threads, and therefore some traditional
7847 * UNIX APIs are problematic in threaded programs. Some notable examples
7851 * C library functions that return data in statically allocated
7852 * buffers, such as strtok() or strerror(). For many of these,
7853 * there are thread-safe variants with a _r suffix, or you can
7854 * look at corresponding GLib APIs (like g_strsplit() or g_strerror()).
7857 * setenv() and unsetenv() manipulate the process environment in
7858 * a not thread-safe way, and may interfere with getenv() calls
7859 * in other threads. Note that getenv() calls may be
7860 * <quote>hidden</quote> behind other APIs. For example, GNU gettext()
7861 * calls getenv() under the covers. In general, it is best to treat
7862 * the environment as readonly. If you absolutely have to modify the
7863 * environment, do it early in main(), when no other threads are around yet.
7866 * setlocale() changes the locale for the entire process, affecting
7867 * all threads. Temporary changes to the locale are often made to
7868 * change the behavior of string scanning or formatting functions
7869 * like scanf() or printf(). GLib offers a number of string APIs
7870 * (like g_ascii_formatd() or g_ascii_strtod()) that can often be
7871 * used as an alternative. Or you can use the uselocale() function
7872 * to change the locale only for the current thread.
7875 * fork() only takes the calling thread into the child's copy of the
7876 * process image. If other threads were executing in critical
7877 * sections they could have left mutexes locked which could easily
7878 * cause deadlocks in the new child. For this reason, you should
7879 * call exit() or exec() as soon as possible in the child and only
7880 * make signal-safe library calls before that.
7883 * daemon() uses fork() in a way contrary to what is described
7884 * above. It should not be used with GLib programs.
7888 * GLib itself is internally completely thread-safe (all global data is
7889 * automatically locked), but individual data structure instances are
7890 * not automatically locked for performance reasons. For example,
7891 * you must coordinate accesses to the same #GHashTable from multiple
7892 * threads. The two notable exceptions from this rule are #GMainLoop
7893 * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
7894 * need no further application-level locking to be accessed from
7895 * multiple threads. Most refcounting functions such as g_object_ref()
7896 * are also thread-safe.
7903 * @short_description: keep track of elapsed time
7905 * #GTimer records a start time, and counts microseconds elapsed since
7906 * that time. This is done somewhat differently on different platforms,
7907 * and can be tricky to get exactly right, so #GTimer provides a
7908 * portable/convenient interface.
7915 * @short_description: a structure representing a time zone
7916 * @see_also: #GDateTime
7918 * #GTimeZone is a structure that represents a time zone, at no
7919 * particular point in time. It is refcounted and immutable.
7921 * A time zone contains a number of intervals. Each interval has
7922 * an abbreviation to describe it, an offet to UTC and a flag indicating
7923 * if the daylight savings time is in effect during that interval. A
7924 * time zone always has at least one interval -- interval 0.
7926 * Every UTC time is contained within exactly one interval, but a given
7927 * local time may be contained within zero, one or two intervals (due to
7928 * incontinuities associated with daylight savings time).
7930 * An interval may refer to a specific period of time (eg: the duration
7931 * of daylight savings time during 2010) or it may refer to many periods
7932 * of time that share the same properties (eg: all periods of daylight
7933 * savings time). It is also possible (usually for political reasons)
7934 * that some properties (like the abbreviation) change between intervals
7935 * without other properties changing.
7937 * #GTimeZone is available since GLib 2.26.
7942 * SECTION:trash_stack
7943 * @title: Trash Stacks
7944 * @short_description: maintain a stack of unused allocated memory chunks
7946 * A #GTrashStack is an efficient way to keep a stack of unused allocated
7947 * memory chunks. Each memory chunk is required to be large enough to hold
7948 * a #gpointer. This allows the stack to be maintained without any space
7949 * overhead, since the stack pointers can be stored inside the memory chunks.
7951 * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
7952 * is a perfectly valid empty stack.
7957 * SECTION:trees-binary
7958 * @title: Balanced Binary Trees
7959 * @short_description: a sorted collection of key/value pairs optimized
7960 * for searching and traversing in order
7962 * The #GTree structure and its associated functions provide a sorted
7963 * collection of key/value pairs optimized for searching and traversing
7966 * To create a new #GTree use g_tree_new().
7968 * To insert a key/value pair into a #GTree use g_tree_insert().
7970 * To lookup the value corresponding to a given key, use
7971 * g_tree_lookup() and g_tree_lookup_extended().
7973 * To find out the number of nodes in a #GTree, use g_tree_nnodes(). To
7974 * get the height of a #GTree, use g_tree_height().
7976 * To traverse a #GTree, calling a function for each node visited in
7977 * the traversal, use g_tree_foreach().
7979 * To remove a key/value pair use g_tree_remove().
7981 * To destroy a #GTree, use g_tree_destroy().
7986 * SECTION:trees-nary
7987 * @title: N-ary Trees
7988 * @short_description: trees of data with any number of branches
7990 * The #GNode struct and its associated functions provide a N-ary tree
7991 * data structure, where nodes in the tree can contain arbitrary data.
7993 * To create a new tree use g_node_new().
7995 * To insert a node into a tree use g_node_insert(),
7996 * g_node_insert_before(), g_node_append() and g_node_prepend().
7998 * To create a new node and insert it into a tree use
7999 * g_node_insert_data(), g_node_insert_data_after(),
8000 * g_node_insert_data_before(), g_node_append_data()
8001 * and g_node_prepend_data().
8003 * To reverse the children of a node use g_node_reverse_children().
8005 * To find a node use g_node_get_root(), g_node_find(),
8006 * g_node_find_child(), g_node_child_index(), g_node_child_position(),
8007 * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
8008 * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
8009 * or g_node_last_sibling().
8011 * To get information about a node or tree use G_NODE_IS_LEAF(),
8012 * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
8013 * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
8015 * To traverse a tree, calling a function for each node visited in the
8016 * traversal, use g_node_traverse() or g_node_children_foreach().
8018 * To remove a node or subtree from a tree use g_node_unlink() or
8024 * SECTION:type_conversion
8025 * @title: Type Conversion Macros
8026 * @short_description: portably storing integers in pointer variables
8028 * Many times GLib, GTK+, and other libraries allow you to pass "user
8029 * data" to a callback, in the form of a void pointer. From time to time
8030 * you want to pass an integer instead of a pointer. You could allocate
8031 * an integer, with something like:
8033 * int *ip = g_new (int, 1);
8036 * But this is inconvenient, and it's annoying to have to free the
8037 * memory at some later time.
8039 * Pointers are always at least 32 bits in size (on all platforms GLib
8040 * intends to support). Thus you can store at least 32-bit integer values
8041 * in a pointer value. Naively, you might try this, but it's incorrect:
8048 * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
8049 * The problem is that on some systems you need to do this:
8053 * p = (void*) (long) 42;
8054 * i = (int) (long) p;
8056 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
8057 * to do the right thing on the every platform.
8059 * <warning><para>You may not store pointers in integers. This is not
8060 * portable in any way, shape or form. These macros <emphasis>only</emphasis>
8061 * allow storing integers in pointers, and only preserve 32 bits of the
8062 * integer; values outside the range of a 32-bit integer will be mangled.
8069 * @title: Basic Types
8070 * @short_description: standard GLib types, defined for ease-of-use
8073 * GLib defines a number of commonly used types, which can be divided
8075 * - New types which are not part of standard C (but are defined in
8076 * various C standard library header files) - #gboolean, #gsize,
8077 * #gssize, #goffset, #gintptr, #guintptr.
8078 * - Integer types which are guaranteed to be the same size across
8079 * all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
8080 * #guint32, #gint64, #guint64.
8081 * - Types which are easier to use than their standard C counterparts -
8082 * #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
8083 * - Types which correspond exactly to standard C types, but are
8084 * included for completeness - #gchar, #gint, #gshort, #glong,
8085 * #gfloat, #gdouble.
8087 * GLib also defines macros for the limits of some of the standard
8088 * integer and floating point types, as well as macros for suitable
8089 * printf() formats for these types.
8095 * @Title: Unicode Manipulation
8096 * @Short_description: functions operating on Unicode characters and
8098 * @See_also: g_locale_to_utf8(), g_locale_from_utf8()
8100 * This section describes a number of functions for dealing with
8101 * Unicode characters and strings. There are analogues of the
8102 * traditional <filename>ctype.h</filename> character classification
8103 * and case conversion functions, UTF-8 analogues of some string utility
8104 * functions, functions to perform normalization, case conversion and
8105 * collation on UTF-8 strings and finally functions to convert between
8106 * the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
8108 * The implementations of the Unicode functions in GLib are based
8109 * on the Unicode Character Data tables, which are available from
8110 * <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
8111 * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
8112 * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
8113 * GLib 2.30 supports Unicode 6.0.
8119 * @Title: Version Information
8120 * @Short_description: variables and functions to check the GLib version
8122 * GLib provides version information, primarily useful in configure
8123 * checks for builds that have a configure script. Applications will
8124 * not typically use the features described here.
8126 * The GLib headers annotate deprecated APIs in a way that produces
8127 * compiler warnings if these deprecated APIs are used. The warnings
8128 * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
8129 * before including the glib.h header.
8131 * GLib also provides support for building applications against
8132 * defined subsets of deprecated or new GLib APIs. Define the macro
8133 * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
8134 * you want to receive warnings about deprecated APIs. Define the
8135 * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
8136 * GLib whose API you want to use.
8142 * @Title: Message Output and Debugging Functions
8143 * @Short_description: functions to output messages and help debug applications
8145 * These functions provide support for outputting messages.
8147 * The <function>g_return</function> family of macros (g_return_if_fail(),
8148 * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached())
8149 * should only be used for programming errors, a typical use case is
8150 * checking for invalid parameters at the beginning of a public function.
8151 * They should not be used if you just mean "if (error) return", they
8152 * should only be used if you mean "if (bug in program) return".
8153 * The program behavior is generally considered undefined after one
8154 * of these checks fails. They are not intended for normal control
8155 * flow, only to give a perhaps-helpful warning before giving up.
8161 * @title: Windows Compatibility Functions
8162 * @short_description: UNIX emulation on Windows
8164 * These functions provide some level of UNIX emulation on the
8165 * Windows platform. If your application really needs the POSIX
8166 * APIs, we suggest you try the Cygwin project.
8173 * Defines the %TRUE value for the #gboolean type.
8179 * @String: the string to be translated
8181 * Marks a string for translation, gets replaced with the translated string
8189 * _glib_get_locale_dir:
8191 * Return the path to the share\locale or lib\locale subfolder of the
8192 * GLib installation folder. The path is in the system codepage. We
8193 * have to use system codepage as bindtextdomain() doesn't have a
8200 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
8201 * @mode: as in access()
8203 * A wrapper for the POSIX access() function. This function is used to
8204 * test a pathname for one or several of read, write or execute
8205 * permissions, or just existence.
8207 * On Windows, the file protection mechanism is not at all POSIX-like,
8208 * and the underlying function in the C library only checks the
8209 * FAT-style READONLY attribute, and does not look at the ACL of a
8210 * file at all. This function is this in practise almost useless on
8211 * Windows. Software that needs to handle file permissions on Windows
8212 * more exactly should use the Win32 API.
8214 * See your C library manual for more details about access().
8216 * Returns: zero if the pathname refers to an existing file system
8217 * object that has all the tested permissions, or -1 otherwise or on
8224 * g_array_append_val:
8226 * @v: the value to append to the #GArray.
8228 * Adds the value on to the end of the array. The array will grow in
8229 * size automatically if necessary.
8231 * <note><para>g_array_append_val() is a macro which uses a reference
8232 * to the value parameter @v. This means that you cannot use it with
8233 * literal values such as "27". You must use variables.</para></note>
8235 * Returns: the #GArray.
8240 * g_array_append_vals:
8241 * @array: a #GArray.
8242 * @data: a pointer to the elements to append to the end of the array.
8243 * @len: the number of elements to append.
8245 * Adds @len elements onto the end of the array.
8247 * Returns: the #GArray.
8253 * @array: a #GArray.
8254 * @free_segment: if %TRUE the actual element data is freed as well.
8256 * Frees the memory allocated for the #GArray. If @free_segment is
8257 * %TRUE it frees the memory block holding the elements as well and
8258 * also each element if @array has a @element_free_func set. Pass
8259 * %FALSE if you want to free the #GArray wrapper but preserve the
8260 * underlying array for use elsewhere. If the reference count of @array
8261 * is greater than one, the #GArray wrapper is preserved but the size
8262 * of @array will be set to zero.
8264 * <note><para>If array elements contain dynamically-allocated memory,
8265 * they should be freed separately.</para></note>
8267 * Returns: the element data if @free_segment is %FALSE, otherwise
8268 * %NULL. The element data should be freed using g_free().
8273 * g_array_get_element_size:
8274 * @array: A #GArray.
8276 * Gets the size of the elements in @array.
8278 * Returns: Size of each element, in bytes.
8286 * @t: the type of the elements.
8287 * @i: the index of the element to return.
8289 * Returns the element of a #GArray at the given index. The return
8290 * value is cast to the given type.
8293 * <title>Getting a pointer to an element in a #GArray</title>
8295 * EDayViewEvent *event;
8296 * /<!-- -->* This gets a pointer to the 4th element
8297 * in the array of EDayViewEvent structs. *<!-- -->/
8298 * event = &g_array_index (events, EDayViewEvent, 3);
8302 * Returns: the element of the #GArray at the index given by @i.
8307 * g_array_insert_val:
8309 * @i: the index to place the element at.
8310 * @v: the value to insert into the array.
8312 * Inserts an element into an array at the given index.
8314 * <note><para>g_array_insert_val() is a macro which uses a reference
8315 * to the value parameter @v. This means that you cannot use it with
8316 * literal values such as "27". You must use variables.</para></note>
8318 * Returns: the #GArray.
8323 * g_array_insert_vals:
8324 * @array: a #GArray.
8325 * @index_: the index to place the elements at.
8326 * @data: a pointer to the elements to insert.
8327 * @len: the number of elements to insert.
8329 * Inserts @len elements into a #GArray at the given index.
8331 * Returns: the #GArray.
8337 * @zero_terminated: %TRUE if the array should have an extra element at
8338 * the end which is set to 0.
8339 * @clear_: %TRUE if #GArray elements should be automatically cleared
8340 * to 0 when they are allocated.
8341 * @element_size: the size of each element in bytes.
8343 * Creates a new #GArray with a reference count of 1.
8345 * Returns: the new #GArray.
8350 * g_array_prepend_val:
8352 * @v: the value to prepend to the #GArray.
8354 * Adds the value on to the start of the array. The array will grow in
8355 * size automatically if necessary.
8357 * This operation is slower than g_array_append_val() since the
8358 * existing elements in the array have to be moved to make space for
8361 * <note><para>g_array_prepend_val() is a macro which uses a reference
8362 * to the value parameter @v. This means that you cannot use it with
8363 * literal values such as "27". You must use variables.</para></note>
8365 * Returns: the #GArray.
8370 * g_array_prepend_vals:
8371 * @array: a #GArray.
8372 * @data: a pointer to the elements to prepend to the start of the
8374 * @len: the number of elements to prepend.
8376 * Adds @len elements onto the start of the array.
8378 * This operation is slower than g_array_append_vals() since the
8379 * existing elements in the array have to be moved to make space for
8382 * Returns: the #GArray.
8388 * @array: A #GArray.
8390 * Atomically increments the reference count of @array by one. This
8391 * function is MT-safe and may be called from any thread.
8393 * Returns: The passed in #GArray.
8399 * g_array_remove_index:
8400 * @array: a #GArray.
8401 * @index_: the index of the element to remove.
8403 * Removes the element at the given index from a #GArray. The following
8404 * elements are moved down one place.
8406 * Returns: the #GArray.
8411 * g_array_remove_index_fast:
8412 * @array: a @GArray.
8413 * @index_: the index of the element to remove.
8415 * Removes the element at the given index from a #GArray. The last
8416 * element in the array is used to fill in the space, so this function
8417 * does not preserve the order of the #GArray. But it is faster than
8418 * g_array_remove_index().
8420 * Returns: the #GArray.
8425 * g_array_remove_range:
8426 * @array: a @GArray.
8427 * @index_: the index of the first element to remove.
8428 * @length: the number of elements to remove.
8430 * Removes the given number of elements starting at the given index
8431 * from a #GArray. The following elements are moved to close the gap.
8433 * Returns: the #GArray.
8439 * g_array_set_clear_func:
8441 * @clear_func: a function to clear an element of @array
8443 * Sets a function to clear an element of @array.
8445 * The @clear_func will be called when an element in the array
8446 * data segment is removed and when the array is freed and data
8447 * segment is deallocated as well.
8449 * Note that in contrast with other uses of #GDestroyNotify
8450 * functions, @clear_func is expected to clear the contents of
8451 * the array element it is given, but not free the element itself.
8459 * @array: a #GArray.
8460 * @length: the new size of the #GArray.
8462 * Sets the size of the array, expanding it if necessary. If the array
8463 * was created with @clear_ set to %TRUE, the new elements are set to 0.
8465 * Returns: the #GArray.
8470 * g_array_sized_new:
8471 * @zero_terminated: %TRUE if the array should have an extra element at
8472 * the end with all bits cleared.
8473 * @clear_: %TRUE if all bits in the array should be cleared to 0 on
8475 * @element_size: size of each element in the array.
8476 * @reserved_size: number of elements preallocated.
8478 * Creates a new #GArray with @reserved_size elements preallocated and
8479 * a reference count of 1. This avoids frequent reallocation, if you
8480 * are going to add many elements to the array. Note however that the
8481 * size of the array is still 0.
8483 * Returns: the new #GArray.
8489 * @array: a #GArray.
8490 * @compare_func: comparison function.
8492 * Sorts a #GArray using @compare_func which should be a qsort()-style
8493 * comparison function (returns less than zero for first arg is less
8494 * than second arg, zero for equal, greater zero if first arg is
8495 * greater than second arg).
8497 * This is guaranteed to be a stable sort since version 2.32.
8502 * g_array_sort_with_data:
8503 * @array: a #GArray.
8504 * @compare_func: comparison function.
8505 * @user_data: data to pass to @compare_func.
8507 * Like g_array_sort(), but the comparison function receives an extra
8508 * user data argument.
8510 * This is guaranteed to be a stable sort since version 2.32.
8512 * There used to be a comment here about making the sort stable by
8513 * using the addresses of the elements in the comparison function.
8514 * This did not actually work, so any such code should be removed.
8520 * @array: A #GArray.
8522 * Atomically decrements the reference count of @array by one. If the
8523 * reference count drops to 0, all memory allocated by the array is
8524 * released. This function is MT-safe and may be called from any
8532 * g_ascii_digit_value:
8533 * @c: an ASCII character.
8535 * Determines the numeric value of a character as a decimal
8536 * digit. Differs from g_unichar_digit_value() because it takes
8537 * a char, so there's no worry about sign extension if characters
8540 * Returns: If @c is a decimal digit (according to
8541 * g_ascii_isdigit()), its numeric value. Otherwise, -1.
8547 * @buffer: A buffer to place the resulting string in
8548 * @buf_len: The length of the buffer.
8549 * @d: The #gdouble to convert
8551 * Converts a #gdouble to a string, using the '.' as
8554 * This functions generates enough precision that converting
8555 * the string back using g_ascii_strtod() gives the same machine-number
8556 * (on machines with IEEE compatible 64bit doubles). It is
8557 * guaranteed that the size of the resulting string will never
8558 * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
8560 * Returns: The pointer to the buffer with the converted string.
8566 * @buffer: A buffer to place the resulting string in
8567 * @buf_len: The length of the buffer.
8568 * @format: The printf()-style format to use for the
8569 * code to use for converting.
8570 * @d: The #gdouble to convert
8572 * Converts a #gdouble to a string, using the '.' as
8573 * decimal point. To format the number you pass in
8574 * a printf()-style format string. Allowed conversion
8575 * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
8577 * If you just want to want to serialize the value into a
8578 * string, use g_ascii_dtostr().
8580 * Returns: The pointer to the buffer with the converted string.
8588 * Determines whether a character is alphanumeric.
8590 * Unlike the standard C library isalnum() function, this only
8591 * recognizes standard ASCII letters and ignores the locale,
8592 * returning %FALSE for all non-ASCII characters. Also, unlike
8593 * the standard library function, this takes a <type>char</type>,
8594 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8595 * cast to #guchar before passing a possibly non-ASCII character in.
8597 * Returns: %TRUE if @c is an ASCII alphanumeric character
8605 * Determines whether a character is alphabetic (i.e. a letter).
8607 * Unlike the standard C library isalpha() function, this only
8608 * recognizes standard ASCII letters and ignores the locale,
8609 * returning %FALSE for all non-ASCII characters. Also, unlike
8610 * the standard library function, this takes a <type>char</type>,
8611 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8612 * cast to #guchar before passing a possibly non-ASCII character in.
8614 * Returns: %TRUE if @c is an ASCII alphabetic character
8622 * Determines whether a character is a control character.
8624 * Unlike the standard C library iscntrl() function, this only
8625 * recognizes standard ASCII control characters and ignores the
8626 * locale, returning %FALSE for all non-ASCII characters. Also,
8627 * unlike the standard library function, this takes a <type>char</type>,
8628 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8629 * cast to #guchar before passing a possibly non-ASCII character in.
8631 * Returns: %TRUE if @c is an ASCII control character.
8639 * Determines whether a character is digit (0-9).
8641 * Unlike the standard C library isdigit() function, this takes
8642 * a <type>char</type>, not an <type>int</type>, so don't call it
8643 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a possibly
8644 * non-ASCII character in.
8646 * Returns: %TRUE if @c is an ASCII digit.
8654 * Determines whether a character is a printing character and not a space.
8656 * Unlike the standard C library isgraph() function, this only
8657 * recognizes standard ASCII characters and ignores the locale,
8658 * returning %FALSE for all non-ASCII characters. Also, unlike
8659 * the standard library function, this takes a <type>char</type>,
8660 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8661 * to cast to #guchar before passing a possibly non-ASCII character in.
8663 * Returns: %TRUE if @c is an ASCII printing character other than space.
8671 * Determines whether a character is an ASCII lower case letter.
8673 * Unlike the standard C library islower() function, this only
8674 * recognizes standard ASCII letters and ignores the locale,
8675 * returning %FALSE for all non-ASCII characters. Also, unlike
8676 * the standard library function, this takes a <type>char</type>,
8677 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8678 * to worry about casting to #guchar before passing a possibly
8679 * non-ASCII character in.
8681 * Returns: %TRUE if @c is an ASCII lower case letter
8689 * Determines whether a character is a printing character.
8691 * Unlike the standard C library isprint() function, this only
8692 * recognizes standard ASCII characters and ignores the locale,
8693 * returning %FALSE for all non-ASCII characters. Also, unlike
8694 * the standard library function, this takes a <type>char</type>,
8695 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8696 * to cast to #guchar before passing a possibly non-ASCII character in.
8698 * Returns: %TRUE if @c is an ASCII printing character.
8706 * Determines whether a character is a punctuation character.
8708 * Unlike the standard C library ispunct() function, this only
8709 * recognizes standard ASCII letters and ignores the locale,
8710 * returning %FALSE for all non-ASCII characters. Also, unlike
8711 * the standard library function, this takes a <type>char</type>,
8712 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8713 * cast to #guchar before passing a possibly non-ASCII character in.
8715 * Returns: %TRUE if @c is an ASCII punctuation character.
8723 * Determines whether a character is a white-space character.
8725 * Unlike the standard C library isspace() function, this only
8726 * recognizes standard ASCII white-space and ignores the locale,
8727 * returning %FALSE for all non-ASCII characters. Also, unlike
8728 * the standard library function, this takes a <type>char</type>,
8729 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8730 * cast to #guchar before passing a possibly non-ASCII character in.
8732 * Returns: %TRUE if @c is an ASCII white-space character
8740 * Determines whether a character is an ASCII upper case letter.
8742 * Unlike the standard C library isupper() function, this only
8743 * recognizes standard ASCII letters and ignores the locale,
8744 * returning %FALSE for all non-ASCII characters. Also, unlike
8745 * the standard library function, this takes a <type>char</type>,
8746 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8747 * worry about casting to #guchar before passing a possibly non-ASCII
8750 * Returns: %TRUE if @c is an ASCII upper case letter
8758 * Determines whether a character is a hexadecimal-digit character.
8760 * Unlike the standard C library isxdigit() function, this takes
8761 * a <type>char</type>, not an <type>int</type>, so don't call it
8762 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a
8763 * possibly non-ASCII character in.
8765 * Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
8770 * g_ascii_strcasecmp:
8771 * @s1: string to compare with @s2.
8772 * @s2: string to compare with @s1.
8774 * Compare two strings, ignoring the case of ASCII characters.
8776 * Unlike the BSD strcasecmp() function, this only recognizes standard
8777 * ASCII letters and ignores the locale, treating all non-ASCII
8778 * bytes as if they are not letters.
8780 * This function should be used only on strings that are known to be
8781 * in encodings where the bytes corresponding to ASCII letters always
8782 * represent themselves. This includes UTF-8 and the ISO-8859-*
8783 * charsets, but not for instance double-byte encodings like the
8784 * Windows Codepage 932, where the trailing bytes of double-byte
8785 * characters include all ASCII letters. If you compare two CP932
8786 * strings using this function, you will get false matches.
8788 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
8789 * or a positive value if @s1 > @s2.
8796 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8798 * Converts all upper case ASCII letters to lower case ASCII letters.
8800 * Returns: a newly-allocated string, with all the upper case
8801 * characters in @str converted to lower case, with
8802 * semantics that exactly match g_ascii_tolower(). (Note
8803 * that this is unlike the old g_strdown(), which modified
8804 * the string in place.)
8809 * g_ascii_strncasecmp:
8810 * @s1: string to compare with @s2.
8811 * @s2: string to compare with @s1.
8812 * @n: number of characters to compare.
8814 * Compare @s1 and @s2, ignoring the case of ASCII characters and any
8815 * characters after the first @n in each string.
8817 * Unlike the BSD strcasecmp() function, this only recognizes standard
8818 * ASCII letters and ignores the locale, treating all non-ASCII
8819 * characters as if they are not letters.
8821 * The same warning as in g_ascii_strcasecmp() applies: Use this
8822 * function only on strings known to be in encodings where bytes
8823 * corresponding to ASCII letters always represent themselves.
8825 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
8826 * or a positive value if @s1 > @s2.
8832 * @nptr: the string to convert to a numeric value.
8833 * @endptr: if non-%NULL, it returns the character after
8834 * the last character used in the conversion.
8836 * Converts a string to a #gdouble value.
8838 * This function behaves like the standard strtod() function
8839 * does in the C locale. It does this without actually changing
8840 * the current locale, since that would not be thread-safe.
8841 * A limitation of the implementation is that this function
8842 * will still accept localized versions of infinities and NANs.
8844 * This function is typically used when reading configuration
8845 * files or other non-user input that should be locale independent.
8846 * To handle input from the user you should normally use the
8847 * locale-sensitive system strtod() function.
8849 * To convert from a #gdouble to a string in a locale-insensitive
8850 * way, use g_ascii_dtostr().
8852 * If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
8853 * is returned (according to the sign of the value), and <literal>ERANGE</literal> is
8854 * stored in <literal>errno</literal>. If the correct value would cause underflow,
8855 * zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8857 * This function resets <literal>errno</literal> before calling strtod() so that
8858 * you can reliably detect overflow and underflow.
8860 * Returns: the #gdouble value.
8866 * @nptr: the string to convert to a numeric value.
8867 * @endptr: if non-%NULL, it returns the character after
8868 * the last character used in the conversion.
8869 * @base: to be used for the conversion, 2..36 or 0
8871 * Converts a string to a #gint64 value.
8872 * This function behaves like the standard strtoll() function
8873 * does in the C locale. It does this without actually
8874 * changing the current locale, since that would not be
8877 * This function is typically used when reading configuration
8878 * files or other non-user input that should be locale independent.
8879 * To handle input from the user you should normally use the
8880 * locale-sensitive system strtoll() function.
8882 * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
8883 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8884 * If the base is outside the valid range, zero is returned, and
8885 * <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
8886 * string conversion fails, zero is returned, and @endptr returns @nptr
8887 * (if @endptr is non-%NULL).
8889 * Returns: the #gint64 value or zero on error.
8896 * @nptr: the string to convert to a numeric value.
8897 * @endptr: if non-%NULL, it returns the character after
8898 * the last character used in the conversion.
8899 * @base: to be used for the conversion, 2..36 or 0
8901 * Converts a string to a #guint64 value.
8902 * This function behaves like the standard strtoull() function
8903 * does in the C locale. It does this without actually
8904 * changing the current locale, since that would not be
8907 * This function is typically used when reading configuration
8908 * files or other non-user input that should be locale independent.
8909 * To handle input from the user you should normally use the
8910 * locale-sensitive system strtoull() function.
8912 * If the correct value would cause overflow, %G_MAXUINT64
8913 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8914 * If the base is outside the valid range, zero is returned, and
8915 * <literal>EINVAL</literal> is stored in <literal>errno</literal>.
8916 * If the string conversion fails, zero is returned, and @endptr returns
8917 * @nptr (if @endptr is non-%NULL).
8919 * Returns: the #guint64 value or zero on error.
8927 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8929 * Converts all lower case ASCII letters to upper case ASCII letters.
8931 * Returns: a newly allocated string, with all the lower case
8932 * characters in @str converted to upper case, with
8933 * semantics that exactly match g_ascii_toupper(). (Note
8934 * that this is unlike the old g_strup(), which modified
8935 * the string in place.)
8941 * @c: any character.
8943 * Convert a character to ASCII lower case.
8945 * Unlike the standard C library tolower() function, this only
8946 * recognizes standard ASCII letters and ignores the locale, returning
8947 * all non-ASCII characters unchanged, even if they are lower case
8948 * letters in a particular character set. Also unlike the standard
8949 * library function, this takes and returns a char, not an int, so
8950 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8951 * before passing a possibly non-ASCII character in.
8953 * Returns: the result of converting @c to lower case.
8954 * If @c is not an ASCII upper case letter,
8955 * @c is returned unchanged.
8961 * @c: any character.
8963 * Convert a character to ASCII upper case.
8965 * Unlike the standard C library toupper() function, this only
8966 * recognizes standard ASCII letters and ignores the locale, returning
8967 * all non-ASCII characters unchanged, even if they are upper case
8968 * letters in a particular character set. Also unlike the standard
8969 * library function, this takes and returns a char, not an int, so
8970 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8971 * before passing a possibly non-ASCII character in.
8973 * Returns: the result of converting @c to upper case.
8974 * If @c is not an ASCII lower case letter,
8975 * @c is returned unchanged.
8980 * g_ascii_xdigit_value:
8981 * @c: an ASCII character.
8983 * Determines the numeric value of a character as a hexidecimal
8984 * digit. Differs from g_unichar_xdigit_value() because it takes
8985 * a char, so there's no worry about sign extension if characters
8988 * Returns: If @c is a hex digit (according to
8989 * g_ascii_isxdigit()), its numeric value. Otherwise, -1.
8995 * @expr: the expression to check
8997 * Debugging macro to terminate the application if the assertion
8998 * fails. If the assertion fails (i.e. the expression is not true),
8999 * an error message is logged and the application is terminated.
9001 * The macro can be turned off in final releases of code by defining
9002 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
9007 * g_assert_cmpfloat:
9008 * @n1: an floating point number
9009 * @cmp: The comparison operator to use.
9010 * One of ==, !=, <, >, <=, >=.
9011 * @n2: another floating point number
9013 * Debugging macro to compare two floating point numbers.
9015 * The effect of <literal>g_assert_cmpfloat (n1, op, n2)</literal> is
9016 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9017 * of this macro is that it can produce a message that includes the
9018 * actual values of @n1 and @n2.
9026 * @n1: an unsigned integer
9027 * @cmp: The comparison operator to use.
9028 * One of ==, !=, <, >, <=, >=.
9029 * @n2: another unsigned integer
9031 * Debugging macro to compare to unsigned integers.
9033 * This is a variant of g_assert_cmpuint() that displays the numbers
9034 * in hexadecimal notation in the message.
9043 * @cmp: The comparison operator to use.
9044 * One of ==, !=, <, >, <=, >=.
9045 * @n2: another integer
9047 * Debugging macro to compare two integers.
9049 * The effect of <literal>g_assert_cmpint (n1, op, n2)</literal> is
9050 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9051 * of this macro is that it can produce a message that includes the
9052 * actual values of @n1 and @n2.
9060 * @s1: a string (may be %NULL)
9061 * @cmp: The comparison operator to use.
9062 * One of ==, !=, <, >, <=, >=.
9063 * @s2: another string (may be %NULL)
9065 * Debugging macro to compare two strings. If the comparison fails,
9066 * an error message is logged and the application is either terminated
9067 * or the testcase marked as failed.
9068 * The strings are compared using g_strcmp0().
9070 * The effect of <literal>g_assert_cmpstr (s1, op, s2)</literal> is
9071 * the same as <literal>g_assert_true (g_strcmp0 (s1, s2) op 0)</literal>.
9072 * The advantage of this macro is that it can produce a message that
9073 * includes the actual values of @s1 and @s2.
9076 * g_assert_cmpstr (mystring, ==, "fubar");
9085 * @n1: an unsigned integer
9086 * @cmp: The comparison operator to use.
9087 * One of ==, !=, <, >, <=, >=.
9088 * @n2: another unsigned integer
9090 * Debugging macro to compare two unsigned integers.
9092 * The effect of <literal>g_assert_cmpuint (n1, op, n2)</literal> is
9093 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9094 * of this macro is that it can produce a message that includes the
9095 * actual values of @n1 and @n2.
9103 * @err: a #GError, possibly %NULL
9104 * @dom: the expected error domain (a #GQuark)
9105 * @c: the expected error code
9107 * Debugging macro to check that a method has returned
9108 * the correct #GError.
9110 * The effect of <literal>g_assert_error (err, dom, c)</literal> is
9111 * the same as <literal>g_assert_true (err != NULL && err->domain
9112 * == dom && err->code == c)</literal>. The advantage of this
9113 * macro is that it can produce a message that includes the incorrect
9114 * error message and code.
9116 * This can only be used to test for a specific error. If you want to
9117 * test that @err is set, but don't care what it's set to, just use
9118 * <literal>g_assert (err != NULL)</literal>
9126 * @expr: the expression to check
9128 * Debugging macro to check an expression is false.
9130 * If the assertion fails (i.e. the expression is not false),
9131 * an error message is logged and the application is either
9132 * terminated or the testcase marked as failed.
9134 * See g_test_set_nonfatal_assertions().
9141 * g_assert_no_error:
9142 * @err: a #GError, possibly %NULL
9144 * Debugging macro to check that a #GError is not set.
9146 * The effect of <literal>g_assert_no_error (err)</literal> is
9147 * the same as <literal>g_assert_true (err == NULL)</literal>. The advantage
9148 * of this macro is that it can produce a message that includes
9149 * the error message and code.
9156 * g_assert_not_reached:
9158 * Debugging macro to terminate the application if it is ever
9159 * reached. If it is reached, an error message is logged and the
9160 * application is terminated.
9162 * The macro can be turned off in final releases of code by defining
9163 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
9169 * @expr: the expression to check
9171 * Debugging macro to check an expression is %NULL.
9173 * If the assertion fails (i.e. the expression is not %NULL),
9174 * an error message is logged and the application is either
9175 * terminated or the testcase marked as failed.
9177 * See g_test_set_nonfatal_assertions().
9185 * @expr: the expression to check
9187 * Debugging macro to check that an expression is true.
9189 * If the assertion fails (i.e. the expression is not true),
9190 * an error message is logged and the application is either
9191 * terminated or the testcase marked as failed.
9193 * See g_test_set_nonfatal_assertions().
9200 * g_async_queue_length:
9201 * @queue: a #GAsyncQueue.
9203 * Returns the length of the queue.
9205 * Actually this function returns the number of data items in
9206 * the queue minus the number of waiting threads, so a negative
9207 * value means waiting threads, and a positive value means available
9208 * entries in the @queue. A return value of 0 could mean n entries
9209 * in the queue and n threads waiting. This can happen due to locking
9210 * of the queue or due to scheduling.
9212 * Returns: the length of the @queue
9217 * g_async_queue_length_unlocked:
9218 * @queue: a #GAsyncQueue
9220 * Returns the length of the queue.
9222 * Actually this function returns the number of data items in
9223 * the queue minus the number of waiting threads, so a negative
9224 * value means waiting threads, and a positive value means available
9225 * entries in the @queue. A return value of 0 could mean n entries
9226 * in the queue and n threads waiting. This can happen due to locking
9227 * of the queue or due to scheduling.
9229 * This function must be called while holding the @queue's lock.
9231 * Returns: the length of the @queue.
9236 * g_async_queue_lock:
9237 * @queue: a #GAsyncQueue
9239 * Acquires the @queue's lock. If another thread is already
9240 * holding the lock, this call will block until the lock
9241 * becomes available.
9243 * Call g_async_queue_unlock() to drop the lock again.
9245 * While holding the lock, you can only call the
9246 * <function>g_async_queue_*_unlocked()</function> functions
9247 * on @queue. Otherwise, deadlock may occur.
9252 * g_async_queue_new:
9254 * Creates a new asynchronous queue.
9256 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
9261 * g_async_queue_new_full:
9262 * @item_free_func: function to free queue elements
9264 * Creates a new asynchronous queue and sets up a destroy notify
9265 * function that is used to free any remaining queue items when
9266 * the queue is destroyed after the final unref.
9268 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
9274 * g_async_queue_pop:
9275 * @queue: a #GAsyncQueue
9277 * Pops data from the @queue. If @queue is empty, this function
9278 * blocks until data becomes available.
9280 * Returns: data from the queue
9285 * g_async_queue_pop_unlocked:
9286 * @queue: a #GAsyncQueue
9288 * Pops data from the @queue. If @queue is empty, this function
9289 * blocks until data becomes available.
9291 * This function must be called while holding the @queue's lock.
9293 * Returns: data from the queue.
9298 * g_async_queue_push:
9299 * @queue: a #GAsyncQueue
9300 * @data: @data to push into the @queue
9302 * Pushes the @data into the @queue. @data must not be %NULL.
9307 * g_async_queue_push_sorted:
9308 * @queue: a #GAsyncQueue
9309 * @data: the @data to push into the @queue
9310 * @func: the #GCompareDataFunc is used to sort @queue
9311 * @user_data: user data passed to @func.
9313 * Inserts @data into @queue using @func to determine the new
9316 * This function requires that the @queue is sorted before pushing on
9317 * new elements, see g_async_queue_sort().
9319 * This function will lock @queue before it sorts the queue and unlock
9320 * it when it is finished.
9322 * For an example of @func see g_async_queue_sort().
9329 * g_async_queue_push_sorted_unlocked:
9330 * @queue: a #GAsyncQueue
9331 * @data: the @data to push into the @queue
9332 * @func: the #GCompareDataFunc is used to sort @queue
9333 * @user_data: user data passed to @func.
9335 * Inserts @data into @queue using @func to determine the new
9338 * The sort function @func is passed two elements of the @queue.
9339 * It should return 0 if they are equal, a negative value if the
9340 * first element should be higher in the @queue or a positive value
9341 * if the first element should be lower in the @queue than the second
9344 * This function requires that the @queue is sorted before pushing on
9345 * new elements, see g_async_queue_sort().
9347 * This function must be called while holding the @queue's lock.
9349 * For an example of @func see g_async_queue_sort().
9356 * g_async_queue_push_unlocked:
9357 * @queue: a #GAsyncQueue
9358 * @data: @data to push into the @queue
9360 * Pushes the @data into the @queue. @data must not be %NULL.
9362 * This function must be called while holding the @queue's lock.
9367 * g_async_queue_ref:
9368 * @queue: a #GAsyncQueue
9370 * Increases the reference count of the asynchronous @queue by 1.
9371 * You do not need to hold the lock to call this function.
9373 * Returns: the @queue that was passed in (since 2.6)
9378 * g_async_queue_ref_unlocked:
9379 * @queue: a #GAsyncQueue
9381 * Increases the reference count of the asynchronous @queue by 1.
9383 * Deprecated: 2.8: Reference counting is done atomically.
9384 * so g_async_queue_ref() can be used regardless of the @queue's
9390 * g_async_queue_sort:
9391 * @queue: a #GAsyncQueue
9392 * @func: the #GCompareDataFunc is used to sort @queue
9393 * @user_data: user data passed to @func
9395 * Sorts @queue using @func.
9397 * The sort function @func is passed two elements of the @queue.
9398 * It should return 0 if they are equal, a negative value if the
9399 * first element should be higher in the @queue or a positive value
9400 * if the first element should be lower in the @queue than the second
9403 * This function will lock @queue before it sorts the queue and unlock
9404 * it when it is finished.
9406 * If you were sorting a list of priority numbers to make sure the
9407 * lowest priority would be at the top of the queue, you could use:
9412 * id1 = GPOINTER_TO_INT (element1);
9413 * id2 = GPOINTER_TO_INT (element2);
9415 * return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
9423 * g_async_queue_sort_unlocked:
9424 * @queue: a #GAsyncQueue
9425 * @func: the #GCompareDataFunc is used to sort @queue
9426 * @user_data: user data passed to @func
9428 * Sorts @queue using @func.
9430 * The sort function @func is passed two elements of the @queue.
9431 * It should return 0 if they are equal, a negative value if the
9432 * first element should be higher in the @queue or a positive value
9433 * if the first element should be lower in the @queue than the second
9436 * This function must be called while holding the @queue's lock.
9443 * g_async_queue_timed_pop:
9444 * @queue: a #GAsyncQueue
9445 * @end_time: a #GTimeVal, determining the final time
9447 * Pops data from the @queue. If the queue is empty, blocks until
9448 * @end_time or until data becomes available.
9450 * If no data is received before @end_time, %NULL is returned.
9452 * To easily calculate @end_time, a combination of g_get_current_time()
9453 * and g_time_val_add() can be used.
9455 * Returns: data from the queue or %NULL, when no data is
9456 * received before @end_time.
9457 * Deprecated: use g_async_queue_timeout_pop().
9462 * g_async_queue_timed_pop_unlocked:
9463 * @queue: a #GAsyncQueue
9464 * @end_time: a #GTimeVal, determining the final time
9466 * Pops data from the @queue. If the queue is empty, blocks until
9467 * @end_time or until data becomes available.
9469 * If no data is received before @end_time, %NULL is returned.
9471 * To easily calculate @end_time, a combination of g_get_current_time()
9472 * and g_time_val_add() can be used.
9474 * This function must be called while holding the @queue's lock.
9476 * Returns: data from the queue or %NULL, when no data is
9477 * received before @end_time.
9478 * Deprecated: use g_async_queue_timeout_pop_unlocked().
9483 * g_async_queue_timeout_pop:
9484 * @queue: a #GAsyncQueue
9485 * @timeout: the number of microseconds to wait
9487 * Pops data from the @queue. If the queue is empty, blocks for
9488 * @timeout microseconds, or until data becomes available.
9490 * If no data is received before the timeout, %NULL is returned.
9492 * Returns: data from the queue or %NULL, when no data is
9493 * received before the timeout.
9498 * g_async_queue_timeout_pop_unlocked:
9499 * @queue: a #GAsyncQueue
9500 * @timeout: the number of microseconds to wait
9502 * Pops data from the @queue. If the queue is empty, blocks for
9503 * @timeout microseconds, or until data becomes available.
9505 * If no data is received before the timeout, %NULL is returned.
9507 * This function must be called while holding the @queue's lock.
9509 * Returns: data from the queue or %NULL, when no data is
9510 * received before the timeout.
9515 * g_async_queue_try_pop:
9516 * @queue: a #GAsyncQueue
9518 * Tries to pop data from the @queue. If no data is available,
9519 * %NULL is returned.
9521 * Returns: data from the queue or %NULL, when no data is
9522 * available immediately.
9527 * g_async_queue_try_pop_unlocked:
9528 * @queue: a #GAsyncQueue
9530 * Tries to pop data from the @queue. If no data is available,
9531 * %NULL is returned.
9533 * This function must be called while holding the @queue's lock.
9535 * Returns: data from the queue or %NULL, when no data is
9536 * available immediately.
9541 * g_async_queue_unlock:
9542 * @queue: a #GAsyncQueue
9544 * Releases the queue's lock.
9546 * Calling this function when you have not acquired
9547 * the with g_async_queue_lock() leads to undefined
9553 * g_async_queue_unref:
9554 * @queue: a #GAsyncQueue.
9556 * Decreases the reference count of the asynchronous @queue by 1.
9558 * If the reference count went to 0, the @queue will be destroyed
9559 * and the memory allocated will be freed. So you are not allowed
9560 * to use the @queue afterwards, as it might have disappeared.
9561 * You do not need to hold the lock to call this function.
9566 * g_async_queue_unref_and_unlock:
9567 * @queue: a #GAsyncQueue
9569 * Decreases the reference count of the asynchronous @queue by 1
9570 * and releases the lock. This function must be called while holding
9571 * the @queue's lock. If the reference count went to 0, the @queue
9572 * will be destroyed and the memory allocated will be freed.
9574 * Deprecated: 2.8: Reference counting is done atomically.
9575 * so g_async_queue_unref() can be used regardless of the @queue's
9582 * @func: (scope async): the function to call on normal program termination.
9584 * Specifies a function to be called at normal program termination.
9586 * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
9587 * macro that maps to a call to the atexit() function in the C
9588 * library. This means that in case the code that calls g_atexit(),
9589 * i.e. atexit(), is in a DLL, the function will be called when the
9590 * DLL is detached from the program. This typically makes more sense
9591 * than that the function is called when the GLib DLL is detached,
9592 * which happened earlier when g_atexit() was a function in the GLib
9595 * The behaviour of atexit() in the context of dynamically loaded
9596 * modules is not formally specified and varies wildly.
9598 * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
9599 * loaded module which is unloaded before the program terminates might
9600 * well cause a crash at program exit.
9602 * Some POSIX systems implement atexit() like Windows, and have each
9603 * dynamically loaded module maintain an own atexit chain that is
9604 * called when the module is unloaded.
9606 * On other POSIX systems, before a dynamically loaded module is
9607 * unloaded, the registered atexit functions (if any) residing in that
9608 * module are called, regardless where the code that registered them
9609 * resided. This is presumably the most robust approach.
9611 * As can be seen from the above, for portability it's best to avoid
9612 * calling g_atexit() (or atexit()) except in the main executable of a
9615 * Deprecated: 2.32: It is best to avoid g_atexit().
9621 * @atomic: a pointer to a #gint or #guint
9622 * @val: the value to add
9624 * Atomically adds @val to the value of @atomic.
9626 * Think of this operation as an atomic version of
9627 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9629 * This call acts as a full compiler and hardware memory barrier.
9631 * Before version 2.30, this function did not return a value
9632 * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
9634 * Returns: the value of @atomic before the add, signed
9641 * @atomic: a pointer to a #gint or #guint
9642 * @val: the value to 'and'
9644 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9645 * storing the result back in @atomic.
9647 * This call acts as a full compiler and hardware memory barrier.
9649 * Think of this operation as an atomic version of
9650 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9652 * Returns: the value of @atomic before the operation, unsigned
9658 * g_atomic_int_compare_and_exchange:
9659 * @atomic: a pointer to a #gint or #guint
9660 * @oldval: the value to compare with
9661 * @newval: the value to conditionally replace with
9663 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9664 * If @atomic was not equal to @oldval then no change occurs.
9666 * This compare and exchange is done atomically.
9668 * Think of this operation as an atomic version of
9669 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9671 * This call acts as a full compiler and hardware memory barrier.
9673 * Returns: %TRUE if the exchange took place
9679 * g_atomic_int_dec_and_test:
9680 * @atomic: a pointer to a #gint or #guint
9682 * Decrements the value of @atomic by 1.
9684 * Think of this operation as an atomic version of
9685 * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
9687 * This call acts as a full compiler and hardware memory barrier.
9689 * Returns: %TRUE if the resultant value is zero
9695 * g_atomic_int_exchange_and_add:
9696 * @atomic: a pointer to a #gint
9697 * @val: the value to add
9699 * This function existed before g_atomic_int_add() returned the prior
9700 * value of the integer (which it now does). It is retained only for
9701 * compatibility reasons. Don't use this function in new code.
9703 * Returns: the value of @atomic before the add, signed
9705 * Deprecated: 2.30: Use g_atomic_int_add() instead.
9711 * @atomic: a pointer to a #gint or #guint
9713 * Gets the current value of @atomic.
9715 * This call acts as a full compiler and hardware
9716 * memory barrier (before the get).
9718 * Returns: the value of the integer
9725 * @atomic: a pointer to a #gint or #guint
9727 * Increments the value of @atomic by 1.
9729 * Think of this operation as an atomic version of
9730 * <literal>{ *@atomic += 1; }</literal>
9732 * This call acts as a full compiler and hardware memory barrier.
9740 * @atomic: a pointer to a #gint or #guint
9741 * @val: the value to 'or'
9743 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9744 * storing the result back in @atomic.
9746 * Think of this operation as an atomic version of
9747 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9749 * This call acts as a full compiler and hardware memory barrier.
9751 * Returns: the value of @atomic before the operation, unsigned
9758 * @atomic: a pointer to a #gint or #guint
9759 * @newval: a new value to store
9761 * Sets the value of @atomic to @newval.
9763 * This call acts as a full compiler and hardware
9764 * memory barrier (after the set).
9772 * @atomic: a pointer to a #gint or #guint
9773 * @val: the value to 'xor'
9775 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9776 * storing the result back in @atomic.
9778 * Think of this operation as an atomic version of
9779 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9781 * This call acts as a full compiler and hardware memory barrier.
9783 * Returns: the value of @atomic before the operation, unsigned
9789 * g_atomic_pointer_add:
9790 * @atomic: a pointer to a #gpointer-sized value
9791 * @val: the value to add
9793 * Atomically adds @val to the value of @atomic.
9795 * Think of this operation as an atomic version of
9796 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9798 * This call acts as a full compiler and hardware memory barrier.
9800 * Returns: the value of @atomic before the add, signed
9806 * g_atomic_pointer_and:
9807 * @atomic: a pointer to a #gpointer-sized value
9808 * @val: the value to 'and'
9810 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9811 * storing the result back in @atomic.
9813 * Think of this operation as an atomic version of
9814 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9816 * This call acts as a full compiler and hardware memory barrier.
9818 * Returns: the value of @atomic before the operation, unsigned
9824 * g_atomic_pointer_compare_and_exchange:
9825 * @atomic: a pointer to a #gpointer-sized value
9826 * @oldval: the value to compare with
9827 * @newval: the value to conditionally replace with
9829 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9830 * If @atomic was not equal to @oldval then no change occurs.
9832 * This compare and exchange is done atomically.
9834 * Think of this operation as an atomic version of
9835 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9837 * This call acts as a full compiler and hardware memory barrier.
9839 * Returns: %TRUE if the exchange took place
9845 * g_atomic_pointer_get:
9846 * @atomic: a pointer to a #gpointer-sized value
9848 * Gets the current value of @atomic.
9850 * This call acts as a full compiler and hardware
9851 * memory barrier (before the get).
9853 * Returns: the value of the pointer
9859 * g_atomic_pointer_or:
9860 * @atomic: a pointer to a #gpointer-sized value
9861 * @val: the value to 'or'
9863 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9864 * storing the result back in @atomic.
9866 * Think of this operation as an atomic version of
9867 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9869 * This call acts as a full compiler and hardware memory barrier.
9871 * Returns: the value of @atomic before the operation, unsigned
9877 * g_atomic_pointer_set:
9878 * @atomic: a pointer to a #gpointer-sized value
9879 * @newval: a new value to store
9881 * Sets the value of @atomic to @newval.
9883 * This call acts as a full compiler and hardware
9884 * memory barrier (after the set).
9891 * g_atomic_pointer_xor:
9892 * @atomic: a pointer to a #gpointer-sized value
9893 * @val: the value to 'xor'
9895 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9896 * storing the result back in @atomic.
9898 * Think of this operation as an atomic version of
9899 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9901 * This call acts as a full compiler and hardware memory barrier.
9903 * Returns: the value of @atomic before the operation, unsigned
9910 * @text: zero-terminated string with base64 text to decode
9911 * @out_len: (out): The length of the decoded data is written here
9913 * Decode a sequence of Base-64 encoded text into binary data. Note
9914 * that the returned binary data is not necessarily zero-terminated,
9915 * so it should not be used as a character string.
9917 * Returns: (transfer full) (array length=out_len) (element-type guint8):
9918 * newly allocated buffer containing the binary data
9919 * that @text represents. The returned buffer must
9920 * be freed with g_free().
9926 * g_base64_decode_inplace:
9927 * @text: (inout) (array length=out_len) (element-type guint8): zero-terminated
9928 * string with base64 text to decode
9929 * @out_len: (inout): The length of the decoded data is written here
9931 * Decode a sequence of Base-64 encoded text into binary data
9932 * by overwriting the input data.
9934 * Returns: (transfer none): The binary data that @text responds. This pointer
9935 * is the same as the input @text.
9941 * g_base64_decode_step:
9942 * @in: (array length=len) (element-type guint8): binary input data
9943 * @len: max length of @in data to decode
9944 * @out: (out) (array) (element-type guint8): output buffer
9945 * @state: (inout): Saved state between steps, initialize to 0
9946 * @save: (inout): Saved state between steps, initialize to 0
9948 * Incrementally decode a sequence of binary data from its Base-64 stringified
9949 * representation. By calling this function multiple times you can convert
9950 * data in chunks to avoid having to have the full encoded data in memory.
9952 * The output buffer must be large enough to fit all the data that will
9953 * be written to it. Since base64 encodes 3 bytes in 4 chars you need
9954 * at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
9957 * Returns: The number of bytes of output that was written
9964 * @data: (array length=len) (element-type guint8): the binary data to encode
9965 * @len: the length of @data
9967 * Encode a sequence of binary data into its Base-64 stringified
9970 * Returns: (transfer full): a newly allocated, zero-terminated Base-64
9971 * encoded string representing @data. The returned string must
9972 * be freed with g_free().
9978 * g_base64_encode_close:
9979 * @break_lines: whether to break long lines
9980 * @out: (out) (array) (element-type guint8): pointer to destination buffer
9981 * @state: (inout): Saved state from g_base64_encode_step()
9982 * @save: (inout): Saved state from g_base64_encode_step()
9984 * Flush the status from a sequence of calls to g_base64_encode_step().
9986 * The output buffer must be large enough to fit all the data that will
9987 * be written to it. It will need up to 4 bytes, or up to 5 bytes if
9988 * line-breaking is enabled.
9990 * Returns: The number of bytes of output that was written
9996 * g_base64_encode_step:
9997 * @in: (array length=len) (element-type guint8): the binary data to encode
9998 * @len: the length of @in
9999 * @break_lines: whether to break long lines
10000 * @out: (out) (array) (element-type guint8): pointer to destination buffer
10001 * @state: (inout): Saved state between steps, initialize to 0
10002 * @save: (inout): Saved state between steps, initialize to 0
10004 * Incrementally encode a sequence of binary data into its Base-64 stringified
10005 * representation. By calling this function multiple times you can convert
10006 * data in chunks to avoid having to have the full encoded data in memory.
10008 * When all of the data has been converted you must call
10009 * g_base64_encode_close() to flush the saved state.
10011 * The output buffer must be large enough to fit all the data that will
10012 * be written to it. Due to the way base64 encodes you will need
10013 * at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
10014 * non-zero state). If you enable line-breaking you will need at least:
10015 * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
10017 * @break_lines is typically used when putting base64-encoded data in emails.
10018 * It breaks the lines at 72 columns instead of putting all of the text on
10019 * the same line. This avoids problems with long lines in the email system.
10020 * Note however that it breaks the lines with <literal>LF</literal>
10021 * characters, not <literal>CR LF</literal> sequences, so the result cannot
10022 * be passed directly to SMTP or certain other protocols.
10024 * Returns: The number of bytes of output that was written
10031 * @file_name: the name of the file
10033 * Gets the name of the file without any leading directory
10034 * components. It returns a pointer into the given file name
10037 * Returns: the name of the file without any leading
10038 * directory components
10039 * Deprecated: 2.2: Use g_path_get_basename() instead, but notice
10040 * that g_path_get_basename() allocates new memory for the
10041 * returned string, unlike this function which returns a pointer
10042 * into the argument.
10048 * @address: a pointer to an integer
10049 * @lock_bit: a bit value between 0 and 31
10051 * Sets the indicated @lock_bit in @address. If the bit is already
10052 * set, this call will block until g_bit_unlock() unsets the
10053 * corresponding bit.
10055 * Attempting to lock on two different bits within the same integer is
10056 * not supported and will very probably cause deadlocks.
10058 * The value of the bit that is set is (1u << @bit). If @bit is not
10059 * between 0 and 31 then the result is undefined.
10061 * This function accesses @address atomically. All other accesses to
10062 * @address must be atomic in order for this function to work
10071 * @mask: a #gulong containing flags
10072 * @nth_bit: the index of the bit to start the search from
10074 * Find the position of the first bit set in @mask, searching
10075 * from (but not including) @nth_bit upwards. Bits are numbered
10076 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
10077 * usually). To start searching from the 0th bit, set @nth_bit to -1.
10079 * Returns: the index of the first bit set which is higher than @nth_bit
10085 * @mask: a #gulong containing flags
10086 * @nth_bit: the index of the bit to start the search from
10088 * Find the position of the first bit set in @mask, searching
10089 * from (but not including) @nth_bit downwards. Bits are numbered
10090 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
10091 * usually). To start searching from the last bit, set @nth_bit to
10092 * -1 or GLIB_SIZEOF_LONG * 8.
10094 * Returns: the index of the first bit set which is lower than @nth_bit
10100 * @number: a #guint
10102 * Gets the number of bits used to hold @number,
10103 * e.g. if @number is 4, 3 bits are needed.
10105 * Returns: the number of bits used to hold @number
10111 * @address: a pointer to an integer
10112 * @lock_bit: a bit value between 0 and 31
10114 * Sets the indicated @lock_bit in @address, returning %TRUE if
10115 * successful. If the bit is already set, returns %FALSE immediately.
10117 * Attempting to lock on two different bits within the same integer is
10120 * The value of the bit that is set is (1u << @bit). If @bit is not
10121 * between 0 and 31 then the result is undefined.
10123 * This function accesses @address atomically. All other accesses to
10124 * @address must be atomic in order for this function to work
10127 * Returns: %TRUE if the lock was acquired
10134 * @address: a pointer to an integer
10135 * @lock_bit: a bit value between 0 and 31
10137 * Clears the indicated @lock_bit in @address. If another thread is
10138 * currently blocked in g_bit_lock() on this same bit then it will be
10141 * This function accesses @address atomically. All other accesses to
10142 * @address must be atomic in order for this function to work
10150 * g_bookmark_file_add_application:
10151 * @bookmark: a #GBookmarkFile
10152 * @uri: a valid URI
10153 * @name: (allow-none): the name of the application registering the bookmark
10155 * @exec: (allow-none): command line to be used to launch the bookmark or %NULL
10157 * Adds the application with @name and @exec to the list of
10158 * applications that have registered a bookmark for @uri into
10161 * Every bookmark inside a #GBookmarkFile must have at least an
10162 * application registered. Each application must provide a name, a
10163 * command line useful for launching the bookmark, the number of times
10164 * the bookmark has been registered by the application and the last
10165 * time the application registered this bookmark.
10167 * If @name is %NULL, the name of the application will be the
10168 * same returned by g_get_application_name(); if @exec is %NULL, the
10169 * command line will be a composition of the program name as
10170 * returned by g_get_prgname() and the "\%u" modifier, which will be
10171 * expanded to the bookmark's URI.
10173 * This function will automatically take care of updating the
10174 * registrations count and timestamping in case an application
10175 * with the same @name had already registered a bookmark for
10176 * @uri inside @bookmark.
10178 * If no bookmark for @uri is found, one is created.
10185 * g_bookmark_file_add_group:
10186 * @bookmark: a #GBookmarkFile
10187 * @uri: a valid URI
10188 * @group: the group name to be added
10190 * Adds @group to the list of groups to which the bookmark for @uri
10193 * If no bookmark for @uri is found then it is created.
10200 * g_bookmark_file_free:
10201 * @bookmark: a #GBookmarkFile
10203 * Frees a #GBookmarkFile.
10210 * g_bookmark_file_get_added:
10211 * @bookmark: a #GBookmarkFile
10212 * @uri: a valid URI
10213 * @error: return location for a #GError, or %NULL
10215 * Gets the time the bookmark for @uri was added to @bookmark
10217 * In the event the URI cannot be found, -1 is returned and
10218 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10220 * Returns: a timestamp
10226 * g_bookmark_file_get_app_info:
10227 * @bookmark: a #GBookmarkFile
10228 * @uri: a valid URI
10229 * @name: an application's name
10230 * @exec: (allow-none) (out): return location for the command line of the application, or %NULL
10231 * @count: (allow-none) (out): return location for the registration count, or %NULL
10232 * @stamp: (allow-none) (out): return location for the last registration time, or %NULL
10233 * @error: return location for a #GError, or %NULL
10235 * Gets the registration informations of @app_name for the bookmark for
10236 * @uri. See g_bookmark_file_set_app_info() for more informations about
10237 * the returned data.
10239 * The string returned in @app_exec must be freed.
10241 * In the event the URI cannot be found, %FALSE is returned and
10242 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
10243 * event that no application with name @app_name has registered a bookmark
10244 * for @uri, %FALSE is returned and error is set to
10245 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
10246 * the command line fails, an error of the #G_SHELL_ERROR domain is
10247 * set and %FALSE is returned.
10249 * Returns: %TRUE on success.
10255 * g_bookmark_file_get_applications:
10256 * @bookmark: a #GBookmarkFile
10257 * @uri: a valid URI
10258 * @length: (allow-none) (out): return location of the length of the returned list, or %NULL
10259 * @error: return location for a #GError, or %NULL
10261 * Retrieves the names of the applications that have registered the
10262 * bookmark for @uri.
10264 * In the event the URI cannot be found, %NULL is returned and
10265 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10267 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings.
10268 * Use g_strfreev() to free it.
10274 * g_bookmark_file_get_description:
10275 * @bookmark: a #GBookmarkFile
10276 * @uri: a valid URI
10277 * @error: return location for a #GError, or %NULL
10279 * Retrieves the description of the bookmark for @uri.
10281 * In the event the URI cannot be found, %NULL is returned and
10282 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10284 * Returns: a newly allocated string or %NULL if the specified
10285 * URI cannot be found.
10291 * g_bookmark_file_get_groups:
10292 * @bookmark: a #GBookmarkFile
10293 * @uri: a valid URI
10294 * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10295 * @error: return location for a #GError, or %NULL
10297 * Retrieves the list of group names of the bookmark for @uri.
10299 * In the event the URI cannot be found, %NULL is returned and
10300 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10302 * The returned array is %NULL terminated, so @length may optionally
10305 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of group names.
10306 * Use g_strfreev() to free it.
10312 * g_bookmark_file_get_icon:
10313 * @bookmark: a #GBookmarkFile
10314 * @uri: a valid URI
10315 * @href: (allow-none) (out): return location for the icon's location or %NULL
10316 * @mime_type: (allow-none) (out): return location for the icon's MIME type or %NULL
10317 * @error: return location for a #GError or %NULL
10319 * Gets the icon of the bookmark for @uri.
10321 * In the event the URI cannot be found, %FALSE is returned and
10322 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10324 * Returns: %TRUE if the icon for the bookmark for the URI was found.
10325 * You should free the returned strings.
10331 * g_bookmark_file_get_is_private:
10332 * @bookmark: a #GBookmarkFile
10333 * @uri: a valid URI
10334 * @error: return location for a #GError, or %NULL
10336 * Gets whether the private flag of the bookmark for @uri is set.
10338 * In the event the URI cannot be found, %FALSE is returned and
10339 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
10340 * event that the private flag cannot be found, %FALSE is returned and
10341 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10343 * Returns: %TRUE if the private flag is set, %FALSE otherwise.
10349 * g_bookmark_file_get_mime_type:
10350 * @bookmark: a #GBookmarkFile
10351 * @uri: a valid URI
10352 * @error: return location for a #GError, or %NULL
10354 * Retrieves the MIME type of the resource pointed by @uri.
10356 * In the event the URI cannot be found, %NULL is returned and
10357 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
10358 * event that the MIME type cannot be found, %NULL is returned and
10359 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10361 * Returns: a newly allocated string or %NULL if the specified
10362 * URI cannot be found.
10368 * g_bookmark_file_get_modified:
10369 * @bookmark: a #GBookmarkFile
10370 * @uri: a valid URI
10371 * @error: return location for a #GError, or %NULL
10373 * Gets the time when the bookmark for @uri was last modified.
10375 * In the event the URI cannot be found, -1 is returned and
10376 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10378 * Returns: a timestamp
10384 * g_bookmark_file_get_size:
10385 * @bookmark: a #GBookmarkFile
10387 * Gets the number of bookmarks inside @bookmark.
10389 * Returns: the number of bookmarks
10395 * g_bookmark_file_get_title:
10396 * @bookmark: a #GBookmarkFile
10397 * @uri: (allow-none): a valid URI or %NULL
10398 * @error: return location for a #GError, or %NULL
10400 * Returns the title of the bookmark for @uri.
10402 * If @uri is %NULL, the title of @bookmark is returned.
10404 * In the event the URI cannot be found, %NULL is returned and
10405 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10407 * Returns: a newly allocated string or %NULL if the specified
10408 * URI cannot be found.
10414 * g_bookmark_file_get_uris:
10415 * @bookmark: a #GBookmarkFile
10416 * @length: (allow-none) (out): return location for the number of returned URIs, or %NULL
10418 * Returns all URIs of the bookmarks in the bookmark file @bookmark.
10419 * The array of returned URIs will be %NULL-terminated, so @length may
10420 * optionally be %NULL.
10422 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings.
10423 * Use g_strfreev() to free it.
10429 * g_bookmark_file_get_visited:
10430 * @bookmark: a #GBookmarkFile
10431 * @uri: a valid URI
10432 * @error: return location for a #GError, or %NULL
10434 * Gets the time the bookmark for @uri was last visited.
10436 * In the event the URI cannot be found, -1 is returned and
10437 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10439 * Returns: a timestamp.
10445 * g_bookmark_file_has_application:
10446 * @bookmark: a #GBookmarkFile
10447 * @uri: a valid URI
10448 * @name: the name of the application
10449 * @error: return location for a #GError or %NULL
10451 * Checks whether the bookmark for @uri inside @bookmark has been
10452 * registered by application @name.
10454 * In the event the URI cannot be found, %FALSE is returned and
10455 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10457 * Returns: %TRUE if the application @name was found
10463 * g_bookmark_file_has_group:
10464 * @bookmark: a #GBookmarkFile
10465 * @uri: a valid URI
10466 * @group: the group name to be searched
10467 * @error: return location for a #GError, or %NULL
10469 * Checks whether @group appears in the list of groups to which
10470 * the bookmark for @uri belongs to.
10472 * In the event the URI cannot be found, %FALSE is returned and
10473 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10475 * Returns: %TRUE if @group was found.
10481 * g_bookmark_file_has_item:
10482 * @bookmark: a #GBookmarkFile
10483 * @uri: a valid URI
10485 * Looks whether the desktop bookmark has an item with its URI set to @uri.
10487 * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise
10493 * g_bookmark_file_load_from_data:
10494 * @bookmark: an empty #GBookmarkFile struct
10495 * @data: desktop bookmarks loaded in memory
10496 * @length: the length of @data in bytes
10497 * @error: return location for a #GError, or %NULL
10499 * Loads a bookmark file from memory into an empty #GBookmarkFile
10500 * structure. If the object cannot be created then @error is set to a
10501 * #GBookmarkFileError.
10503 * Returns: %TRUE if a desktop bookmark could be loaded.
10509 * g_bookmark_file_load_from_data_dirs:
10510 * @bookmark: a #GBookmarkFile
10511 * @file: a relative path to a filename to open and parse
10512 * @full_path: (allow-none): return location for a string containing the full path
10513 * of the file, or %NULL
10514 * @error: return location for a #GError, or %NULL
10516 * This function looks for a desktop bookmark file named @file in the
10517 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
10518 * loads the file into @bookmark and returns the file's full path in
10519 * @full_path. If the file could not be loaded then an %error is
10520 * set to either a #GFileError or #GBookmarkFileError.
10522 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
10528 * g_bookmark_file_load_from_file:
10529 * @bookmark: an empty #GBookmarkFile struct
10530 * @filename: the path of a filename to load, in the GLib file name encoding
10531 * @error: return location for a #GError, or %NULL
10533 * Loads a desktop bookmark file into an empty #GBookmarkFile structure.
10534 * If the file could not be loaded then @error is set to either a #GFileError
10535 * or #GBookmarkFileError.
10537 * Returns: %TRUE if a desktop bookmark file could be loaded
10543 * g_bookmark_file_move_item:
10544 * @bookmark: a #GBookmarkFile
10545 * @old_uri: a valid URI
10546 * @new_uri: (allow-none): a valid URI, or %NULL
10547 * @error: return location for a #GError or %NULL
10549 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any
10550 * existing bookmark for @new_uri will be overwritten. If @new_uri is
10551 * %NULL, then the bookmark is removed.
10553 * In the event the URI cannot be found, %FALSE is returned and
10554 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10556 * Returns: %TRUE if the URI was successfully changed
10562 * g_bookmark_file_new:
10564 * Creates a new empty #GBookmarkFile object.
10566 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
10567 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
10570 * Returns: an empty #GBookmarkFile
10576 * g_bookmark_file_remove_application:
10577 * @bookmark: a #GBookmarkFile
10578 * @uri: a valid URI
10579 * @name: the name of the application
10580 * @error: return location for a #GError or %NULL
10582 * Removes application registered with @name from the list of applications
10583 * that have registered a bookmark for @uri inside @bookmark.
10585 * In the event the URI cannot be found, %FALSE is returned and
10586 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10587 * In the event that no application with name @app_name has registered
10588 * a bookmark for @uri, %FALSE is returned and error is set to
10589 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
10591 * Returns: %TRUE if the application was successfully removed.
10597 * g_bookmark_file_remove_group:
10598 * @bookmark: a #GBookmarkFile
10599 * @uri: a valid URI
10600 * @group: the group name to be removed
10601 * @error: return location for a #GError, or %NULL
10603 * Removes @group from the list of groups to which the bookmark
10604 * for @uri belongs to.
10606 * In the event the URI cannot be found, %FALSE is returned and
10607 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10608 * In the event no group was defined, %FALSE is returned and
10609 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10611 * Returns: %TRUE if @group was successfully removed.
10617 * g_bookmark_file_remove_item:
10618 * @bookmark: a #GBookmarkFile
10619 * @uri: a valid URI
10620 * @error: return location for a #GError, or %NULL
10622 * Removes the bookmark for @uri from the bookmark file @bookmark.
10624 * Returns: %TRUE if the bookmark was removed successfully.
10630 * g_bookmark_file_set_added:
10631 * @bookmark: a #GBookmarkFile
10632 * @uri: a valid URI
10633 * @added: a timestamp or -1 to use the current time
10635 * Sets the time the bookmark for @uri was added into @bookmark.
10637 * If no bookmark for @uri is found then it is created.
10644 * g_bookmark_file_set_app_info:
10645 * @bookmark: a #GBookmarkFile
10646 * @uri: a valid URI
10647 * @name: an application's name
10648 * @exec: an application's command line
10649 * @count: the number of registrations done for this application
10650 * @stamp: the time of the last registration for this application
10651 * @error: return location for a #GError or %NULL
10653 * Sets the meta-data of application @name inside the list of
10654 * applications that have registered a bookmark for @uri inside
10657 * You should rarely use this function; use g_bookmark_file_add_application()
10658 * and g_bookmark_file_remove_application() instead.
10660 * @name can be any UTF-8 encoded string used to identify an
10662 * @exec can have one of these two modifiers: "\%f", which will
10663 * be expanded as the local file name retrieved from the bookmark's
10664 * URI; "\%u", which will be expanded as the bookmark's URI.
10665 * The expansion is done automatically when retrieving the stored
10666 * command line using the g_bookmark_file_get_app_info() function.
10667 * @count is the number of times the application has registered the
10668 * bookmark; if is < 0, the current registration count will be increased
10669 * by one, if is 0, the application with @name will be removed from
10670 * the list of registered applications.
10671 * @stamp is the Unix time of the last registration; if it is -1, the
10672 * current time will be used.
10674 * If you try to remove an application by setting its registration count to
10675 * zero, and no bookmark for @uri is found, %FALSE is returned and
10676 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
10677 * in the event that no application @name has registered a bookmark
10678 * for @uri, %FALSE is returned and error is set to
10679 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
10680 * for @uri is found, one is created.
10682 * Returns: %TRUE if the application's meta-data was successfully
10689 * g_bookmark_file_set_description:
10690 * @bookmark: a #GBookmarkFile
10691 * @uri: (allow-none): a valid URI or %NULL
10692 * @description: a string
10694 * Sets @description as the description of the bookmark for @uri.
10696 * If @uri is %NULL, the description of @bookmark is set.
10698 * If a bookmark for @uri cannot be found then it is created.
10705 * g_bookmark_file_set_groups:
10706 * @bookmark: a #GBookmarkFile
10707 * @uri: an item's URI
10708 * @groups: (allow-none): an array of group names, or %NULL to remove all groups
10709 * @length: number of group name values in @groups
10711 * Sets a list of group names for the item with URI @uri. Each previously
10712 * set group name list is removed.
10714 * If @uri cannot be found then an item for it is created.
10721 * g_bookmark_file_set_icon:
10722 * @bookmark: a #GBookmarkFile
10723 * @uri: a valid URI
10724 * @href: (allow-none): the URI of the icon for the bookmark, or %NULL
10725 * @mime_type: the MIME type of the icon for the bookmark
10727 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
10728 * the currently set icon. @href can either be a full URL for the icon
10729 * file or the icon name following the Icon Naming specification.
10731 * If no bookmark for @uri is found one is created.
10738 * g_bookmark_file_set_is_private:
10739 * @bookmark: a #GBookmarkFile
10740 * @uri: a valid URI
10741 * @is_private: %TRUE if the bookmark should be marked as private
10743 * Sets the private flag of the bookmark for @uri.
10745 * If a bookmark for @uri cannot be found then it is created.
10752 * g_bookmark_file_set_mime_type:
10753 * @bookmark: a #GBookmarkFile
10754 * @uri: a valid URI
10755 * @mime_type: a MIME type
10757 * Sets @mime_type as the MIME type of the bookmark for @uri.
10759 * If a bookmark for @uri cannot be found then it is created.
10766 * g_bookmark_file_set_modified:
10767 * @bookmark: a #GBookmarkFile
10768 * @uri: a valid URI
10769 * @modified: a timestamp or -1 to use the current time
10771 * Sets the last time the bookmark for @uri was last modified.
10773 * If no bookmark for @uri is found then it is created.
10775 * The "modified" time should only be set when the bookmark's meta-data
10776 * was actually changed. Every function of #GBookmarkFile that
10777 * modifies a bookmark also changes the modification time, except for
10778 * g_bookmark_file_set_visited().
10785 * g_bookmark_file_set_title:
10786 * @bookmark: a #GBookmarkFile
10787 * @uri: (allow-none): a valid URI or %NULL
10788 * @title: a UTF-8 encoded string
10790 * Sets @title as the title of the bookmark for @uri inside the
10791 * bookmark file @bookmark.
10793 * If @uri is %NULL, the title of @bookmark is set.
10795 * If a bookmark for @uri cannot be found then it is created.
10802 * g_bookmark_file_set_visited:
10803 * @bookmark: a #GBookmarkFile
10804 * @uri: a valid URI
10805 * @visited: a timestamp or -1 to use the current time
10807 * Sets the time the bookmark for @uri was last visited.
10809 * If no bookmark for @uri is found then it is created.
10811 * The "visited" time should only be set if the bookmark was launched,
10812 * either using the command line retrieved by g_bookmark_file_get_app_info()
10813 * or by the default application for the bookmark's MIME type, retrieved
10814 * using g_bookmark_file_get_mime_type(). Changing the "visited" time
10815 * does not affect the "modified" time.
10822 * g_bookmark_file_to_data:
10823 * @bookmark: a #GBookmarkFile
10824 * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10825 * @error: return location for a #GError, or %NULL
10827 * This function outputs @bookmark as a string.
10829 * Returns: a newly allocated string holding
10830 * the contents of the #GBookmarkFile
10836 * g_bookmark_file_to_file:
10837 * @bookmark: a #GBookmarkFile
10838 * @filename: path of the output file
10839 * @error: return location for a #GError, or %NULL
10841 * This function outputs @bookmark into a file. The write process is
10842 * guaranteed to be atomic by using g_file_set_contents() internally.
10844 * Returns: %TRUE if the file was successfully written.
10850 * g_build_filename:
10851 * @first_element: the first element in the path
10852 * @...: remaining elements in path, terminated by %NULL
10854 * Creates a filename from a series of elements using the correct
10855 * separator for filenames.
10857 * On Unix, this function behaves identically to <literal>g_build_path
10858 * (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
10860 * On Windows, it takes into account that either the backslash
10861 * (<literal>\</literal> or slash (<literal>/</literal>) can be used
10862 * as separator in filenames, but otherwise behaves as on Unix. When
10863 * file pathname separators need to be inserted, the one that last
10864 * previously occurred in the parameters (reading from left to right)
10867 * No attempt is made to force the resulting filename to be an absolute
10868 * path. If the first element is a relative path, the result will
10869 * be a relative path.
10871 * Returns: a newly-allocated string that must be freed with g_free().
10876 * g_build_filenamev:
10877 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10879 * Behaves exactly like g_build_filename(), but takes the path elements
10880 * as a string array, instead of varargs. This function is mainly
10881 * meant for language bindings.
10883 * Returns: a newly-allocated string that must be freed with g_free().
10890 * @separator: a string used to separator the elements of the path.
10891 * @first_element: the first element in the path
10892 * @...: remaining elements in path, terminated by %NULL
10894 * Creates a path from a series of elements using @separator as the
10895 * separator between elements. At the boundary between two elements,
10896 * any trailing occurrences of separator in the first element, or
10897 * leading occurrences of separator in the second element are removed
10898 * and exactly one copy of the separator is inserted.
10900 * Empty elements are ignored.
10902 * The number of leading copies of the separator on the result is
10903 * the same as the number of leading copies of the separator on
10904 * the first non-empty element.
10906 * The number of trailing copies of the separator on the result is
10907 * the same as the number of trailing copies of the separator on
10908 * the last non-empty element. (Determination of the number of
10909 * trailing copies is done without stripping leading copies, so
10910 * if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
10911 * has 1 trailing copy.)
10913 * However, if there is only a single non-empty element, and there
10914 * are no characters in that element not part of the leading or
10915 * trailing separators, then the result is exactly the original value
10918 * Other than for determination of the number of leading and trailing
10919 * copies of the separator, elements consisting only of copies
10920 * of the separator are ignored.
10922 * Returns: a newly-allocated string that must be freed with g_free().
10928 * @separator: a string used to separator the elements of the path.
10929 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10931 * Behaves exactly like g_build_path(), but takes the path elements
10932 * as a string array, instead of varargs. This function is mainly
10933 * meant for language bindings.
10935 * Returns: a newly-allocated string that must be freed with g_free().
10941 * g_byte_array_append:
10942 * @array: a #GByteArray.
10943 * @data: the byte data to be added.
10944 * @len: the number of bytes to add.
10946 * Adds the given bytes to the end of the #GByteArray. The array will
10947 * grow in size automatically if necessary.
10949 * Returns: the #GByteArray.
10954 * g_byte_array_free:
10955 * @array: a #GByteArray.
10956 * @free_segment: if %TRUE the actual byte data is freed as well.
10958 * Frees the memory allocated by the #GByteArray. If @free_segment is
10959 * %TRUE it frees the actual byte data. If the reference count of
10960 * @array is greater than one, the #GByteArray wrapper is preserved but
10961 * the size of @array will be set to zero.
10963 * Returns: the element data if @free_segment is %FALSE, otherwise
10964 * %NULL. The element data should be freed using g_free().
10969 * g_byte_array_free_to_bytes:
10970 * @array: (transfer full): a #GByteArray
10972 * Transfers the data from the #GByteArray into a new immutable #GBytes.
10974 * The #GByteArray is freed unless the reference count of @array is greater
10975 * than one, the #GByteArray wrapper is preserved but the size of @array
10976 * will be set to zero.
10978 * This is identical to using g_bytes_new_take() and g_byte_array_free()
10982 * Returns: (transfer full): a new immutable #GBytes representing same byte
10983 * data that was in the array
10988 * g_byte_array_new:
10990 * Creates a new #GByteArray with a reference count of 1.
10992 * Returns: (transfer full): the new #GByteArray.
10997 * g_byte_array_new_take:
10998 * @data: (transfer full) (array length=len): byte data for the array
10999 * @len: length of @data
11001 * Create byte array containing the data. The data will be owned by the array
11002 * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
11005 * Returns: (transfer full): a new #GByteArray
11010 * g_byte_array_prepend:
11011 * @array: a #GByteArray.
11012 * @data: the byte data to be added.
11013 * @len: the number of bytes to add.
11015 * Adds the given data to the start of the #GByteArray. The array will
11016 * grow in size automatically if necessary.
11018 * Returns: the #GByteArray.
11023 * g_byte_array_ref:
11024 * @array: A #GByteArray.
11026 * Atomically increments the reference count of @array by one. This
11027 * function is MT-safe and may be called from any thread.
11029 * Returns: The passed in #GByteArray.
11035 * g_byte_array_remove_index:
11036 * @array: a #GByteArray.
11037 * @index_: the index of the byte to remove.
11039 * Removes the byte at the given index from a #GByteArray. The
11040 * following bytes are moved down one place.
11042 * Returns: the #GByteArray.
11047 * g_byte_array_remove_index_fast:
11048 * @array: a #GByteArray.
11049 * @index_: the index of the byte to remove.
11051 * Removes the byte at the given index from a #GByteArray. The last
11052 * element in the array is used to fill in the space, so this function
11053 * does not preserve the order of the #GByteArray. But it is faster
11054 * than g_byte_array_remove_index().
11056 * Returns: the #GByteArray.
11061 * g_byte_array_remove_range:
11062 * @array: a @GByteArray.
11063 * @index_: the index of the first byte to remove.
11064 * @length: the number of bytes to remove.
11066 * Removes the given number of bytes starting at the given index from a
11067 * #GByteArray. The following elements are moved to close the gap.
11069 * Returns: the #GByteArray.
11075 * g_byte_array_set_size:
11076 * @array: a #GByteArray.
11077 * @length: the new size of the #GByteArray.
11079 * Sets the size of the #GByteArray, expanding it if necessary.
11081 * Returns: the #GByteArray.
11086 * g_byte_array_sized_new:
11087 * @reserved_size: number of bytes preallocated.
11089 * Creates a new #GByteArray with @reserved_size bytes preallocated.
11090 * This avoids frequent reallocation, if you are going to add many
11091 * bytes to the array. Note however that the size of the array is still
11094 * Returns: the new #GByteArray.
11099 * g_byte_array_sort:
11100 * @array: a #GByteArray.
11101 * @compare_func: comparison function.
11103 * Sorts a byte array, using @compare_func which should be a
11104 * qsort()-style comparison function (returns less than zero for first
11105 * arg is less than second arg, zero for equal, greater than zero if
11106 * first arg is greater than second arg).
11108 * If two array elements compare equal, their order in the sorted array
11109 * is undefined. If you want equal elements to keep their order (i.e.
11110 * you want a stable sort) you can write a comparison function that,
11111 * if two elements would otherwise compare equal, compares them by
11117 * g_byte_array_sort_with_data:
11118 * @array: a #GByteArray.
11119 * @compare_func: comparison function.
11120 * @user_data: data to pass to @compare_func.
11122 * Like g_byte_array_sort(), but the comparison function takes an extra
11123 * user data argument.
11128 * g_byte_array_unref:
11129 * @array: A #GByteArray.
11131 * Atomically decrements the reference count of @array by one. If the
11132 * reference count drops to 0, all memory allocated by the array is
11133 * released. This function is MT-safe and may be called from any
11142 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
11143 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
11145 * Compares the two #GBytes values.
11147 * This function can be used to sort GBytes instances in lexographical order.
11149 * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is
11150 * greater, and zero if bytes2 is equal to bytes1
11157 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
11158 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
11160 * Compares the two #GBytes values being pointed to and returns
11161 * %TRUE if they are equal.
11163 * This function can be passed to g_hash_table_new() as the @key_equal_func
11164 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
11166 * Returns: %TRUE if the two keys match.
11172 * g_bytes_get_data:
11173 * @bytes: a #GBytes
11174 * @size: (out) (allow-none): location to return size of byte data
11176 * Get the byte data in the #GBytes. This data should not be modified.
11178 * This function will always return the same pointer for a given #GBytes.
11180 * Returns: (transfer none) (array length=size) (type guint8): a pointer to the
11187 * g_bytes_get_size:
11188 * @bytes: a #GBytes
11190 * Get the size of the byte data in the #GBytes.
11192 * This function will always return the same value for a given #GBytes.
11194 * Returns: the size
11201 * @bytes: (type GLib.Bytes): a pointer to a #GBytes key
11203 * Creates an integer hash code for the byte data in the #GBytes.
11205 * This function can be passed to g_hash_table_new() as the @key_equal_func
11206 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
11208 * Returns: a hash value corresponding to the key.
11215 * @data: (transfer none) (array length=size) (element-type guint8):
11216 * the data to be used for the bytes
11217 * @size: the size of @data
11219 * Creates a new #GBytes from @data.
11223 * Returns: (transfer full): a new #GBytes
11229 * g_bytes_new_from_bytes:
11230 * @bytes: a #GBytes
11231 * @offset: offset which subsection starts at
11232 * @length: length of subsection
11234 * Creates a #GBytes which is a subsection of another #GBytes. The @offset +
11235 * @length may not be longer than the size of @bytes.
11237 * A reference to @bytes will be held by the newly created #GBytes until
11238 * the byte data is no longer needed.
11240 * Returns: (transfer full): a new #GBytes
11246 * g_bytes_new_static: (skip)
11247 * @data: (transfer full) (array length=size) (element-type guint8):
11248 * the data to be used for the bytes
11249 * @size: the size of @data
11251 * Creates a new #GBytes from static data.
11253 * @data must be static (ie: never modified or freed).
11255 * Returns: (transfer full): a new #GBytes
11261 * g_bytes_new_take:
11262 * @data: (transfer full) (array length=size) (element-type guint8):
11263 * the data to be used for the bytes
11264 * @size: the size of @data
11266 * Creates a new #GBytes from @data.
11268 * After this call, @data belongs to the bytes and may no longer be
11269 * modified by the caller. g_free() will be called on @data when the
11270 * bytes is no longer in use. Because of this @data must have been created by
11271 * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
11272 * functions that wrap these calls (such as g_new(), g_strdup(), etc).
11274 * For creating #GBytes with memory from other allocators, see
11275 * g_bytes_new_with_free_func().
11277 * Returns: (transfer full): a new #GBytes
11283 * g_bytes_new_with_free_func:
11284 * @data: (array length=size): the data to be used for the bytes
11285 * @size: the size of @data
11286 * @free_func: the function to call to release the data
11287 * @user_data: data to pass to @free_func
11289 * Creates a #GBytes from @data.
11291 * When the last reference is dropped, @free_func will be called with the
11292 * @user_data argument.
11294 * @data must not be modified after this call is made until @free_func has
11295 * been called to indicate that the bytes is no longer in use.
11297 * Returns: (transfer full): a new #GBytes
11304 * @bytes: a #GBytes
11306 * Increase the reference count on @bytes.
11308 * Returns: the #GBytes
11315 * @bytes: (allow-none): a #GBytes
11317 * Releases a reference on @bytes. This may result in the bytes being
11325 * g_bytes_unref_to_array:
11326 * @bytes: (transfer full): a #GBytes
11328 * Unreferences the bytes, and returns a new mutable #GByteArray containing
11329 * the same byte data.
11331 * As an optimization, the byte data is transferred to the array without copying
11332 * if this was the last reference to bytes and bytes was created with
11333 * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
11334 * other cases the data is copied.
11336 * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
11342 * g_bytes_unref_to_data:
11343 * @bytes: (transfer full): a #GBytes
11344 * @size: location to place the length of the returned data
11346 * Unreferences the bytes, and returns a pointer the same byte data
11349 * As an optimization, the byte data is returned without copying if this was
11350 * the last reference to bytes and bytes was created with g_bytes_new(),
11351 * g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
11354 * Returns: (transfer full): a pointer to the same byte data, which should
11355 * be freed with g_free()
11362 * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
11364 * A wrapper for the POSIX chdir() function. The function changes the
11365 * current directory of the process to @path.
11367 * See your C library manual for more details about chdir().
11369 * Returns: 0 on success, -1 if an error occurred.
11376 * @checksum: the #GChecksum to copy
11378 * Copies a #GChecksum. If @checksum has been closed, by calling
11379 * g_checksum_get_string() or g_checksum_get_digest(), the copied
11380 * checksum will be closed as well.
11382 * Returns: the copy of the passed #GChecksum. Use g_checksum_free()
11383 * when finished using it.
11390 * @checksum: a #GChecksum
11392 * Frees the memory allocated for @checksum.
11399 * g_checksum_get_digest: (skip)
11400 * @checksum: a #GChecksum
11401 * @buffer: output buffer
11402 * @digest_len: an inout parameter. The caller initializes it to the size of @buffer.
11403 * After the call it contains the length of the digest.
11405 * Gets the digest from @checksum as a raw binary vector and places it
11406 * into @buffer. The size of the digest depends on the type of checksum.
11408 * Once this function has been called, the #GChecksum is closed and can
11409 * no longer be updated with g_checksum_update().
11416 * g_checksum_get_string:
11417 * @checksum: a #GChecksum
11419 * Gets the digest as an hexadecimal string.
11421 * Once this function has been called the #GChecksum can no longer be
11422 * updated with g_checksum_update().
11424 * The hexadecimal characters will be lower case.
11426 * Returns: the hexadecimal representation of the checksum. The
11427 * returned string is owned by the checksum and should not be modified
11435 * @checksum_type: the desired type of checksum
11437 * Creates a new #GChecksum, using the checksum algorithm @checksum_type.
11438 * If the @checksum_type is not known, %NULL is returned.
11439 * A #GChecksum can be used to compute the checksum, or digest, of an
11440 * arbitrary binary blob, using different hashing algorithms.
11442 * A #GChecksum works by feeding a binary blob through g_checksum_update()
11443 * until there is data to be checked; the digest can then be extracted
11444 * using g_checksum_get_string(), which will return the checksum as a
11445 * hexadecimal string; or g_checksum_get_digest(), which will return a
11446 * vector of raw bytes. Once either g_checksum_get_string() or
11447 * g_checksum_get_digest() have been called on a #GChecksum, the checksum
11448 * will be closed and it won't be possible to call g_checksum_update()
11451 * Returns: (transfer full): the newly created #GChecksum, or %NULL.
11452 * Use g_checksum_free() to free the memory allocated by it.
11458 * g_checksum_reset:
11459 * @checksum: the #GChecksum to reset
11461 * Resets the state of the @checksum back to its initial state.
11468 * g_checksum_type_get_length:
11469 * @checksum_type: a #GChecksumType
11471 * Gets the length in bytes of digests of type @checksum_type
11473 * Returns: the checksum length, or -1 if @checksum_type is
11480 * g_checksum_update:
11481 * @checksum: a #GChecksum
11482 * @data: (array length=length) (element-type guint8): buffer used to compute the checksum
11483 * @length: size of the buffer, or -1 if it is a null-terminated string.
11485 * Feeds @data into an existing #GChecksum. The checksum must still be
11486 * open, that is g_checksum_get_string() or g_checksum_get_digest() must
11487 * not have been called on @checksum.
11494 * g_child_watch_add:
11495 * @pid: process id to watch. On POSIX the pid of a child process. On
11496 * Windows a handle for a process (which doesn't have to be a child).
11497 * @function: function to call
11498 * @data: data to pass to @function
11500 * Sets a function to be called when the child indicated by @pid
11501 * exits, at a default priority, #G_PRIORITY_DEFAULT.
11503 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11504 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11505 * the spawn function for the child watching to work.
11507 * Note that on platforms where #GPid must be explicitly closed
11508 * (see g_spawn_close_pid()) @pid must not be closed while the
11509 * source is still active. Typically, you will want to call
11510 * g_spawn_close_pid() in the callback function for the source.
11512 * GLib supports only a single callback per process id.
11514 * This internally creates a main loop source using
11515 * g_child_watch_source_new() and attaches it to the main loop context
11516 * using g_source_attach(). You can do these steps manually if you
11517 * need greater control.
11519 * Returns: the ID (greater than 0) of the event source.
11525 * g_child_watch_add_full: (rename-to g_child_watch_add)
11526 * @priority: the priority of the idle source. Typically this will be in the
11527 * range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
11528 * @pid: process to watch. On POSIX the pid of a child process. On
11529 * Windows a handle for a process (which doesn't have to be a child).
11530 * @function: function to call
11531 * @data: data to pass to @function
11532 * @notify: (allow-none): function to call when the idle is removed, or %NULL
11534 * Sets a function to be called when the child indicated by @pid
11535 * exits, at the priority @priority.
11537 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11538 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11539 * the spawn function for the child watching to work.
11541 * In many programs, you will want to call g_spawn_check_exit_status()
11542 * in the callback to determine whether or not the child exited
11545 * Also, note that on platforms where #GPid must be explicitly closed
11546 * (see g_spawn_close_pid()) @pid must not be closed while the source
11547 * is still active. Typically, you should invoke g_spawn_close_pid()
11548 * in the callback function for the source.
11550 * GLib supports only a single callback per process id.
11552 * This internally creates a main loop source using
11553 * g_child_watch_source_new() and attaches it to the main loop context
11554 * using g_source_attach(). You can do these steps manually if you
11555 * need greater control.
11557 * Returns: the ID (greater than 0) of the event source.
11563 * g_child_watch_source_new:
11564 * @pid: process to watch. On POSIX the pid of a child process. On
11565 * Windows a handle for a process (which doesn't have to be a child).
11567 * Creates a new child_watch source.
11569 * The source will not initially be associated with any #GMainContext
11570 * and must be added to one with g_source_attach() before it will be
11573 * Note that child watch sources can only be used in conjunction with
11574 * <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
11577 * Note that on platforms where #GPid must be explicitly closed
11578 * (see g_spawn_close_pid()) @pid must not be closed while the
11579 * source is still active. Typically, you will want to call
11580 * g_spawn_close_pid() in the callback function for the source.
11582 * Note further that using g_child_watch_source_new() is not
11583 * compatible with calling <literal>waitpid</literal> with a
11584 * nonpositive first argument in the application. Calling waitpid()
11585 * for individual pids will still work fine.
11587 * Returns: the newly-created child watch source
11594 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11595 * @mode: as in chmod()
11597 * A wrapper for the POSIX chmod() function. The chmod() function is
11598 * used to set the permissions of a file system object.
11600 * On Windows the file protection mechanism is not at all POSIX-like,
11601 * and the underlying chmod() function in the C library just sets or
11602 * clears the FAT-style READONLY attribute. It does not touch any
11603 * ACL. Software that needs to manage file permissions on Windows
11604 * exactly should use the Win32 API.
11606 * See your C library manual for more details about chmod().
11608 * Returns: zero if the operation succeeded, -1 on error.
11615 * @err: a #GError return location
11617 * If @err is %NULL, does nothing. If @err is non-%NULL,
11618 * calls g_error_free() on *@err and sets *@err to %NULL.
11623 * g_clear_pointer: (skip)
11624 * @pp: a pointer to a variable, struct member etc. holding a pointer
11625 * @destroy: a function to which a gpointer can be passed, to destroy *@pp
11627 * Clears a reference to a variable.
11629 * @pp must not be %NULL.
11631 * If the reference is %NULL then this function does nothing.
11632 * Otherwise, the variable is destroyed using @destroy and the
11633 * pointer is set to %NULL.
11635 * This function is threadsafe and modifies the pointer atomically,
11636 * using memory barriers where needed.
11638 * A macro is also included that allows this function to be used without
11647 * @fd: A file descriptor
11648 * @error: a #GError
11650 * This wraps the close() call; in case of error, %errno will be
11651 * preserved, but the error will also be stored as a #GError in @error.
11653 * Besides using #GError, there is another major reason to prefer this
11654 * function over the call provided by the system; on Unix, it will
11655 * attempt to correctly handle %EINTR, which has platform-specific
11663 * g_compute_checksum_for_bytes:
11664 * @checksum_type: a #GChecksumType
11665 * @data: binary blob to compute the digest of
11667 * Computes the checksum for a binary @data. This is a
11668 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11669 * and g_checksum_free().
11671 * The hexadecimal string returned will be in lower case.
11673 * Returns: the digest of the binary data as a string in hexadecimal.
11674 * The returned string should be freed with g_free() when done using it.
11680 * g_compute_checksum_for_data:
11681 * @checksum_type: a #GChecksumType
11682 * @data: (array length=length) (element-type guint8): binary blob to compute the digest of
11683 * @length: length of @data
11685 * Computes the checksum for a binary @data of @length. This is a
11686 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11687 * and g_checksum_free().
11689 * The hexadecimal string returned will be in lower case.
11691 * Returns: the digest of the binary data as a string in hexadecimal.
11692 * The returned string should be freed with g_free() when done using it.
11698 * g_compute_checksum_for_string:
11699 * @checksum_type: a #GChecksumType
11700 * @str: the string to compute the checksum of
11701 * @length: the length of the string, or -1 if the string is null-terminated.
11703 * Computes the checksum of a string.
11705 * The hexadecimal string returned will be in lower case.
11707 * Returns: the checksum as a hexadecimal string. The returned string
11708 * should be freed with g_free() when done using it.
11714 * g_compute_hmac_for_data:
11715 * @digest_type: a #GChecksumType to use for the HMAC
11716 * @key: (array length=key_len): the key to use in the HMAC
11717 * @key_len: the length of the key
11718 * @data: binary blob to compute the HMAC of
11719 * @length: length of @data
11721 * Computes the HMAC for a binary @data of @length. This is a
11722 * convenience wrapper for g_hmac_new(), g_hmac_get_string()
11723 * and g_hmac_unref().
11725 * The hexadecimal string returned will be in lower case.
11727 * Returns: the HMAC of the binary data as a string in hexadecimal.
11728 * The returned string should be freed with g_free() when done using it.
11734 * g_compute_hmac_for_string:
11735 * @digest_type: a #GChecksumType to use for the HMAC
11736 * @key: (array length=key_len): the key to use in the HMAC
11737 * @key_len: the length of the key
11738 * @str: the string to compute the HMAC for
11739 * @length: the length of the string, or -1 if the string is nul-terminated
11741 * Computes the HMAC for a string.
11743 * The hexadecimal string returned will be in lower case.
11745 * Returns: the HMAC as a hexadecimal string.
11746 * The returned string should be freed with g_free()
11747 * when done using it.
11753 * g_cond_broadcast:
11756 * If threads are waiting for @cond, all of them are unblocked.
11757 * If no threads are waiting for @cond, this function has no effect.
11758 * It is good practice to lock the same mutex as the waiting threads
11759 * while calling this function, though not required.
11765 * @cond: an initialised #GCond
11767 * Frees the resources allocated to a #GCond with g_cond_init().
11769 * This function should not be used with a #GCond that has been
11770 * statically allocated.
11772 * Calling g_cond_clear() for a #GCond on which threads are
11773 * blocking leads to undefined behaviour.
11781 * @cond: an uninitialized #GCond
11783 * Initialises a #GCond so that it can be used.
11785 * This function is useful to initialise a #GCond that has been
11786 * allocated as part of a larger structure. It is not necessary to
11787 * initialise a #GCond that has been statically allocated.
11789 * To undo the effect of g_cond_init() when a #GCond is no longer
11790 * needed, use g_cond_clear().
11792 * Calling g_cond_init() on an already-initialised #GCond leads
11793 * to undefined behaviour.
11803 * If threads are waiting for @cond, at least one of them is unblocked.
11804 * If no threads are waiting for @cond, this function has no effect.
11805 * It is good practice to hold the same lock as the waiting thread
11806 * while calling this function, though not required.
11813 * @mutex: a #GMutex that is currently locked
11815 * Atomically releases @mutex and waits until @cond is signalled.
11816 * When this function returns, @mutex is locked again and owned by the
11819 * When using condition variables, it is possible that a spurious wakeup
11820 * may occur (ie: g_cond_wait() returns even though g_cond_signal() was
11821 * not called). It's also possible that a stolen wakeup may occur.
11822 * This is when g_cond_signal() is called, but another thread acquires
11823 * @mutex before this thread and modifies the state of the program in
11824 * such a way that when g_cond_wait() is able to return, the expected
11825 * condition is no longer met.
11827 * For this reason, g_cond_wait() must always be used in a loop. See
11828 * the documentation for #GCond for a complete example.
11833 * g_cond_wait_until:
11835 * @mutex: a #GMutex that is currently locked
11836 * @end_time: the monotonic time to wait until
11838 * Waits until either @cond is signalled or @end_time has passed.
11840 * As with g_cond_wait() it is possible that a spurious or stolen wakeup
11841 * could occur. For that reason, waiting on a condition variable should
11842 * always be in a loop, based on an explicitly-checked predicate.
11844 * %TRUE is returned if the condition variable was signalled (or in the
11845 * case of a spurious wakeup). %FALSE is returned if @end_time has
11848 * The following code shows how to correctly perform a timed wait on a
11849 * condition variable (extended the example presented in the
11850 * documentation for #GCond):
11854 * pop_data_timed (void)
11859 * g_mutex_lock (&data_mutex);
11861 * end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
11862 * while (!current_data)
11863 * if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
11865 * // timeout has passed.
11866 * g_mutex_unlock (&data_mutex);
11870 * // there is data for us
11871 * data = current_data;
11872 * current_data = NULL;
11874 * g_mutex_unlock (&data_mutex);
11880 * Notice that the end time is calculated once, before entering the
11881 * loop and reused. This is the motivation behind the use of absolute
11882 * time on this API -- if a relative time of 5 seconds were passed
11883 * directly to the call and a spurious wakeup occurred, the program would
11884 * have to start over waiting again (which would lead to a total wait
11885 * time of more than 5 seconds).
11887 * Returns: %TRUE on a signal, %FALSE on a timeout
11894 * @str: the string to convert
11895 * @len: the length of the string, or -1 if the string is
11896 * nul-terminated<footnote id="nul-unsafe">
11898 * Note that some encodings may allow nul bytes to
11899 * occur inside strings. In that case, using -1 for
11900 * the @len parameter is unsafe.
11903 * @to_codeset: name of character set into which to convert @str
11904 * @from_codeset: character set of @str.
11905 * @bytes_read: (out): location to store the number of bytes in the
11906 * input string that were successfully converted, or %NULL.
11907 * Even if the conversion was successful, this may be
11908 * less than @len if there were partial characters
11909 * at the end of the input. If the error
11910 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
11911 * stored will the byte offset after the last valid
11913 * @bytes_written: (out): the number of bytes stored in the output buffer (not
11914 * including the terminating nul).
11915 * @error: location to store the error occurring, or %NULL to ignore
11916 * errors. Any of the errors in #GConvertError may occur.
11918 * Converts a string from one character set to another.
11920 * Note that you should use g_iconv() for streaming
11921 * conversions<footnoteref linkend="streaming-state"/>.
11923 * Returns: If the conversion was successful, a newly allocated
11924 * nul-terminated string, which must be freed with
11925 * g_free(). Otherwise %NULL and @error will be set.
11930 * g_convert_with_fallback:
11931 * @str: the string to convert
11932 * @len: the length of the string, or -1 if the string is
11933 * nul-terminated<footnoteref linkend="nul-unsafe"/>.
11934 * @to_codeset: name of character set into which to convert @str
11935 * @from_codeset: character set of @str.
11936 * @fallback: UTF-8 string to use in place of character not
11937 * present in the target encoding. (The string must be
11938 * representable in the target encoding).
11939 * If %NULL, characters not in the target encoding will
11940 * be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.
11941 * @bytes_read: location to store the number of bytes in the
11942 * input string that were successfully converted, or %NULL.
11943 * Even if the conversion was successful, this may be
11944 * less than @len if there were partial characters
11945 * at the end of the input.
11946 * @bytes_written: the number of bytes stored in the output buffer (not
11947 * including the terminating nul).
11948 * @error: location to store the error occurring, or %NULL to ignore
11949 * errors. Any of the errors in #GConvertError may occur.
11951 * Converts a string from one character set to another, possibly
11952 * including fallback sequences for characters not representable
11953 * in the output. Note that it is not guaranteed that the specification
11954 * for the fallback sequences in @fallback will be honored. Some
11955 * systems may do an approximate conversion from @from_codeset
11956 * to @to_codeset in their iconv() functions,
11957 * in which case GLib will simply return that approximate conversion.
11959 * Note that you should use g_iconv() for streaming
11960 * conversions<footnoteref linkend="streaming-state"/>.
11962 * Returns: If the conversion was successful, a newly allocated
11963 * nul-terminated string, which must be freed with
11964 * g_free(). Otherwise %NULL and @error will be set.
11969 * g_convert_with_iconv:
11970 * @str: the string to convert
11971 * @len: the length of the string, or -1 if the string is
11972 * nul-terminated<footnoteref linkend="nul-unsafe"/>.
11973 * @converter: conversion descriptor from g_iconv_open()
11974 * @bytes_read: location to store the number of bytes in the
11975 * input string that were successfully converted, or %NULL.
11976 * Even if the conversion was successful, this may be
11977 * less than @len if there were partial characters
11978 * at the end of the input. If the error
11979 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
11980 * stored will the byte offset after the last valid
11982 * @bytes_written: the number of bytes stored in the output buffer (not
11983 * including the terminating nul).
11984 * @error: location to store the error occurring, or %NULL to ignore
11985 * errors. Any of the errors in #GConvertError may occur.
11987 * Converts a string from one character set to another.
11989 * Note that you should use g_iconv() for streaming
11990 * conversions<footnote id="streaming-state">
11992 * Despite the fact that @byes_read can return information about partial
11993 * characters, the <literal>g_convert_...</literal> functions
11994 * are not generally suitable for streaming. If the underlying converter
11995 * being used maintains internal state, then this won't be preserved
11996 * across successive calls to g_convert(), g_convert_with_iconv() or
11997 * g_convert_with_fallback(). (An example of this is the GNU C converter
11998 * for CP1255 which does not emit a base character until it knows that
11999 * the next character is not a mark that could combine with the base
12004 * Returns: If the conversion was successful, a newly allocated
12005 * nul-terminated string, which must be freed with
12006 * g_free(). Otherwise %NULL and @error will be set.
12012 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
12013 * @mode: as in creat()
12015 * A wrapper for the POSIX creat() function. The creat() function is
12016 * used to convert a pathname into a file descriptor, creating a file
12019 * On POSIX systems file descriptors are implemented by the operating
12020 * system. On Windows, it's the C library that implements creat() and
12021 * file descriptors. The actual Windows API for opening files is
12022 * different, see MSDN documentation for CreateFile(). The Win32 API
12023 * uses file handles, which are more randomish integers, not small
12024 * integers like file descriptors.
12026 * Because file descriptors are specific to the C library on Windows,
12027 * the file descriptor returned by this function makes sense only to
12028 * functions in the same C library. Thus if the GLib-using code uses a
12029 * different C library than GLib does, the file descriptor returned by
12030 * this function cannot be passed to C library functions like write()
12033 * See your C library manual for more details about creat().
12035 * Returns: a new file descriptor, or -1 if an error occurred. The
12036 * return value can be used exactly like the return value from creat().
12043 * @...: format string, followed by parameters to insert
12044 * into the format string (as with printf())
12046 * Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
12047 * It's more or less application-defined what constitutes
12048 * a critical vs. a regular warning. You could call
12049 * g_log_set_always_fatal() to make critical warnings exit
12050 * the program, then use g_critical() for fatal errors, for
12053 * You can also make critical warnings fatal at runtime by
12054 * setting the <envar>G_DEBUG</envar> environment variable (see
12055 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
12057 * If g_log_default_handler() is used as the log handler function, a new-line
12058 * character will automatically be appended to @..., and need not be entered
12064 * g_datalist_clear:
12065 * @datalist: a datalist.
12067 * Frees all the data elements of the datalist.
12068 * The data elements' destroy functions are called
12069 * if they have been set.
12074 * g_datalist_foreach:
12075 * @datalist: a datalist.
12076 * @func: the function to call for each data element.
12077 * @user_data: user data to pass to the function.
12079 * Calls the given function for each data element of the datalist. The
12080 * function is called with each data element's #GQuark id and data,
12081 * together with the given @user_data parameter. Note that this
12082 * function is NOT thread-safe. So unless @datalist can be protected
12083 * from any modifications during invocation of this function, it should
12089 * g_datalist_get_data:
12090 * @datalist: a datalist.
12091 * @key: the string identifying a data element.
12093 * Gets a data element, using its string identifier. This is slower than
12094 * g_datalist_id_get_data() because it compares strings.
12096 * Returns: the data element, or %NULL if it is not found.
12101 * g_datalist_get_flags:
12102 * @datalist: pointer to the location that holds a list
12104 * Gets flags values packed in together with the datalist.
12105 * See g_datalist_set_flags().
12107 * Returns: the flags of the datalist
12113 * g_datalist_id_dup_data:
12114 * @datalist: location of a datalist
12115 * @key_id: the #GQuark identifying a data element
12116 * @dup_func: (allow-none): function to duplicate the old value
12117 * @user_data: (allow-none): passed as user_data to @dup_func
12119 * This is a variant of g_datalist_id_get_data() which
12120 * returns a 'duplicate' of the value. @dup_func defines the
12121 * meaning of 'duplicate' in this context, it could e.g.
12122 * take a reference on a ref-counted object.
12124 * If the @key_id is not set in the datalist then @dup_func
12125 * will be called with a %NULL argument.
12127 * Note that @dup_func is called while the datalist is locked, so it
12128 * is not allowed to read or modify the datalist.
12130 * This function can be useful to avoid races when multiple
12131 * threads are using the same datalist and the same key.
12133 * Returns: the result of calling @dup_func on the value
12134 * associated with @key_id in @datalist, or %NULL if not set.
12135 * If @dup_func is %NULL, the value is returned unmodified.
12141 * g_datalist_id_get_data:
12142 * @datalist: a datalist.
12143 * @key_id: the #GQuark identifying a data element.
12145 * Retrieves the data element corresponding to @key_id.
12147 * Returns: the data element, or %NULL if it is not found.
12152 * g_datalist_id_remove_data:
12154 * @q: the #GQuark identifying the data element.
12156 * Removes an element, using its #GQuark identifier.
12161 * g_datalist_id_remove_no_notify:
12162 * @datalist: a datalist.
12163 * @key_id: the #GQuark identifying a data element.
12165 * Removes an element, without calling its destroy notification
12168 * Returns: the data previously stored at @key_id, or %NULL if none.
12173 * g_datalist_id_replace_data:
12174 * @datalist: location of a datalist
12175 * @key_id: the #GQuark identifying a data element
12176 * @oldval: (allow-none): the old value to compare against
12177 * @newval: (allow-none): the new value to replace it with
12178 * @destroy: (allow-none): destroy notify for the new value
12179 * @old_destroy: (allow-none): destroy notify for the existing value
12181 * Compares the member that is associated with @key_id in
12182 * @datalist to @oldval, and if they are the same, replace
12183 * @oldval with @newval.
12185 * This is like a typical atomic compare-and-exchange
12186 * operation, for a member of @datalist.
12188 * If the previous value was replaced then ownership of the
12189 * old value (@oldval) is passed to the caller, including
12190 * the registred destroy notify for it (passed out in @old_destroy).
12191 * Its up to the caller to free this as he wishes, which may
12192 * or may not include using @old_destroy as sometimes replacement
12193 * should not destroy the object in the normal way.
12195 * Returns: %TRUE if the existing value for @key_id was replaced
12196 * by @newval, %FALSE otherwise.
12202 * g_datalist_id_set_data:
12204 * @q: the #GQuark to identify the data element.
12205 * @d: (allow-none): the data element, or %NULL to remove any previous element
12206 * corresponding to @q.
12208 * Sets the data corresponding to the given #GQuark id. Any previous
12209 * data with the same key is removed, and its destroy function is
12215 * g_datalist_id_set_data_full:
12216 * @datalist: a datalist.
12217 * @key_id: the #GQuark to identify the data element.
12218 * @data: (allow-none): the data element or %NULL to remove any previous element
12219 * corresponding to @key_id.
12220 * @destroy_func: the function to call when the data element is
12221 * removed. This function will be called with the data
12222 * element and can be used to free any memory allocated
12223 * for it. If @data is %NULL, then @destroy_func must
12226 * Sets the data corresponding to the given #GQuark id, and the
12227 * function to be called when the element is removed from the datalist.
12228 * Any previous data with the same key is removed, and its destroy
12229 * function is called.
12235 * @datalist: a pointer to a pointer to a datalist.
12237 * Resets the datalist to %NULL. It does not free any memory or call
12238 * any destroy functions.
12243 * g_datalist_remove_data:
12245 * @k: the string identifying the data element.
12247 * Removes an element using its string identifier. The data element's
12248 * destroy function is called if it has been set.
12253 * g_datalist_remove_no_notify:
12255 * @k: the string identifying the data element.
12257 * Removes an element, without calling its destroy notifier.
12262 * g_datalist_set_data:
12264 * @k: the string to identify the data element.
12265 * @d: (allow-none): the data element, or %NULL to remove any previous element
12266 * corresponding to @k.
12268 * Sets the data element corresponding to the given string identifier.
12273 * g_datalist_set_data_full:
12275 * @k: the string to identify the data element.
12276 * @d: (allow-none): the data element, or %NULL to remove any previous element
12277 * corresponding to @k.
12278 * @f: the function to call when the data element is removed. This
12279 * function will be called with the data element and can be used to
12280 * free any memory allocated for it. If @d is %NULL, then @f must
12283 * Sets the data element corresponding to the given string identifier,
12284 * and the function to be called when the data element is removed.
12289 * g_datalist_set_flags:
12290 * @datalist: pointer to the location that holds a list
12291 * @flags: the flags to turn on. The values of the flags are
12292 * restricted by %G_DATALIST_FLAGS_MASK (currently
12293 * 3; giving two possible boolean flags).
12294 * A value for @flags that doesn't fit within the mask is
12297 * Turns on flag values for a data list. This function is used
12298 * to keep a small number of boolean flags in an object with
12299 * a data list without using any additional space. It is
12300 * not generally useful except in circumstances where space
12301 * is very tight. (It is used in the base #GObject type, for
12309 * g_datalist_unset_flags:
12310 * @datalist: pointer to the location that holds a list
12311 * @flags: the flags to turn off. The values of the flags are
12312 * restricted by %G_DATALIST_FLAGS_MASK (currently
12313 * 3: giving two possible boolean flags).
12314 * A value for @flags that doesn't fit within the mask is
12317 * Turns off flag values for a data list. See g_datalist_unset_flags()
12324 * g_dataset_destroy:
12325 * @dataset_location: the location identifying the dataset.
12327 * Destroys the dataset, freeing all memory allocated, and calling any
12328 * destroy functions set for data elements.
12333 * g_dataset_foreach:
12334 * @dataset_location: the location identifying the dataset.
12335 * @func: the function to call for each data element.
12336 * @user_data: user data to pass to the function.
12338 * Calls the given function for each data element which is associated
12339 * with the given location. Note that this function is NOT thread-safe.
12340 * So unless @datalist can be protected from any modifications during
12341 * invocation of this function, it should not be called.
12346 * g_dataset_get_data:
12347 * @l: the location identifying the dataset.
12348 * @k: the string identifying the data element.
12350 * Gets the data element corresponding to a string.
12352 * Returns: the data element corresponding to the string, or %NULL if
12358 * g_dataset_id_get_data:
12359 * @dataset_location: the location identifying the dataset.
12360 * @key_id: the #GQuark id to identify the data element.
12362 * Gets the data element corresponding to a #GQuark.
12364 * Returns: the data element corresponding to the #GQuark, or %NULL if
12370 * g_dataset_id_remove_data:
12371 * @l: the location identifying the dataset.
12372 * @k: the #GQuark id identifying the data element.
12374 * Removes a data element from a dataset. The data element's destroy
12375 * function is called if it has been set.
12380 * g_dataset_id_remove_no_notify:
12381 * @dataset_location: the location identifying the dataset.
12382 * @key_id: the #GQuark ID identifying the data element.
12384 * Removes an element, without calling its destroy notification
12387 * Returns: the data previously stored at @key_id, or %NULL if none.
12392 * g_dataset_id_set_data:
12393 * @l: the location identifying the dataset.
12394 * @k: the #GQuark id to identify the data element.
12395 * @d: the data element.
12397 * Sets the data element associated with the given #GQuark id. Any
12398 * previous data with the same key is removed, and its destroy function
12404 * g_dataset_id_set_data_full:
12405 * @dataset_location: the location identifying the dataset.
12406 * @key_id: the #GQuark id to identify the data element.
12407 * @data: the data element.
12408 * @destroy_func: the function to call when the data element is
12409 * removed. This function will be called with the data
12410 * element and can be used to free any memory allocated
12413 * Sets the data element associated with the given #GQuark id, and also
12414 * the function to call when the data element is destroyed. Any
12415 * previous data with the same key is removed, and its destroy function
12421 * g_dataset_remove_data:
12422 * @l: the location identifying the dataset.
12423 * @k: the string identifying the data element.
12425 * Removes a data element corresponding to a string. Its destroy
12426 * function is called if it has been set.
12431 * g_dataset_remove_no_notify:
12432 * @l: the location identifying the dataset.
12433 * @k: the string identifying the data element.
12435 * Removes an element, without calling its destroy notifier.
12440 * g_dataset_set_data:
12441 * @l: the location identifying the dataset.
12442 * @k: the string to identify the data element.
12443 * @d: the data element.
12445 * Sets the data corresponding to the given string identifier.
12450 * g_dataset_set_data_full:
12451 * @l: the location identifying the dataset.
12452 * @k: the string to identify the data element.
12453 * @d: the data element.
12454 * @f: the function to call when the data element is removed. This
12455 * function will be called with the data element and can be used to
12456 * free any memory allocated for it.
12458 * Sets the data corresponding to the given string identifier, and the
12459 * function to call when the data element is destroyed.
12465 * @date: a #GDate to increment
12466 * @n_days: number of days to move the date forward
12468 * Increments a date some number of days.
12469 * To move forward by weeks, add weeks*7 days.
12470 * The date must be valid.
12475 * g_date_add_months:
12476 * @date: a #GDate to increment
12477 * @n_months: number of months to move forward
12479 * Increments a date by some number of months.
12480 * If the day of the month is greater than 28,
12481 * this routine may change the day of the month
12482 * (because the destination month may not have
12483 * the current day in it). The date must be valid.
12488 * g_date_add_years:
12489 * @date: a #GDate to increment
12490 * @n_years: number of years to move forward
12492 * Increments a date by some number of years.
12493 * If the date is February 29, and the destination
12494 * year is not a leap year, the date will be changed
12495 * to February 28. The date must be valid.
12501 * @date: a #GDate to clamp
12502 * @min_date: minimum accepted value for @date
12503 * @max_date: maximum accepted value for @date
12505 * If @date is prior to @min_date, sets @date equal to @min_date.
12506 * If @date falls after @max_date, sets @date equal to @max_date.
12507 * Otherwise, @date is unchanged.
12508 * Either of @min_date and @max_date may be %NULL.
12509 * All non-%NULL dates must be valid.
12515 * @date: pointer to one or more dates to clear
12516 * @n_dates: number of dates to clear
12518 * Initializes one or more #GDate structs to a sane but invalid
12519 * state. The cleared dates will not represent an existing date, but will
12520 * not contain garbage. Useful to init a date declared on the stack.
12521 * Validity can be tested with g_date_valid().
12527 * @lhs: first date to compare
12528 * @rhs: second date to compare
12530 * qsort()-style comparison function for dates.
12531 * Both dates must be valid.
12533 * Returns: 0 for equal, less than zero if @lhs is less than @rhs,
12534 * greater than zero if @lhs is greater than @rhs
12539 * g_date_days_between:
12540 * @date1: the first date
12541 * @date2: the second date
12543 * Computes the number of days between two dates.
12544 * If @date2 is prior to @date1, the returned value is negative.
12545 * Both dates must be valid.
12547 * Returns: the number of days between @date1 and @date2
12553 * @date: a #GDate to free
12555 * Frees a #GDate returned from g_date_new().
12561 * @date: a #GDate to extract the day of the month from
12563 * Returns the day of the month. The date must be valid.
12565 * Returns: day of the month
12570 * g_date_get_day_of_year:
12571 * @date: a #GDate to extract day of year from
12573 * Returns the day of the year, where Jan 1 is the first day of the
12574 * year. The date must be valid.
12576 * Returns: day of the year
12581 * g_date_get_days_in_month:
12585 * Returns the number of days in a month, taking leap
12586 * years into account.
12588 * Returns: number of days in @month during the @year
12593 * g_date_get_iso8601_week_of_year:
12594 * @date: a valid #GDate
12596 * Returns the week of the year, where weeks are interpreted according
12599 * Returns: ISO 8601 week number of the year.
12605 * g_date_get_julian:
12606 * @date: a #GDate to extract the Julian day from
12608 * Returns the Julian day or "serial number" of the #GDate. The
12609 * Julian day is simply the number of days since January 1, Year 1; i.e.,
12610 * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
12611 * etc. The date must be valid.
12613 * Returns: Julian day
12618 * g_date_get_monday_week_of_year:
12621 * Returns the week of the year, where weeks are understood to start on
12622 * Monday. If the date is before the first Monday of the year, return
12623 * 0. The date must be valid.
12625 * Returns: week of the year
12630 * g_date_get_monday_weeks_in_year:
12633 * Returns the number of weeks in the year, where weeks
12634 * are taken to start on Monday. Will be 52 or 53. The
12635 * date must be valid. (Years always have 52 7-day periods,
12636 * plus 1 or 2 extra days depending on whether it's a leap
12637 * year. This function is basically telling you how many
12638 * Mondays are in the year, i.e. there are 53 Mondays if
12639 * one of the extra days happens to be a Monday.)
12641 * Returns: number of Mondays in the year
12646 * g_date_get_month:
12647 * @date: a #GDate to get the month from
12649 * Returns the month of the year. The date must be valid.
12651 * Returns: month of the year as a #GDateMonth
12656 * g_date_get_sunday_week_of_year:
12659 * Returns the week of the year during which this date falls, if weeks
12660 * are understood to being on Sunday. The date must be valid. Can return
12661 * 0 if the day is before the first Sunday of the year.
12663 * Returns: week number
12668 * g_date_get_sunday_weeks_in_year:
12669 * @year: year to count weeks in
12671 * Returns the number of weeks in the year, where weeks
12672 * are taken to start on Sunday. Will be 52 or 53. The
12673 * date must be valid. (Years always have 52 7-day periods,
12674 * plus 1 or 2 extra days depending on whether it's a leap
12675 * year. This function is basically telling you how many
12676 * Sundays are in the year, i.e. there are 53 Sundays if
12677 * one of the extra days happens to be a Sunday.)
12679 * Returns: the number of weeks in @year
12684 * g_date_get_weekday:
12687 * Returns the day of the week for a #GDate. The date must be valid.
12689 * Returns: day of the week as a #GDateWeekday.
12697 * Returns the year of a #GDate. The date must be valid.
12699 * Returns: year in which the date falls
12704 * g_date_is_first_of_month:
12705 * @date: a #GDate to check
12707 * Returns %TRUE if the date is on the first of a month.
12708 * The date must be valid.
12710 * Returns: %TRUE if the date is the first of the month
12715 * g_date_is_last_of_month:
12716 * @date: a #GDate to check
12718 * Returns %TRUE if the date is the last day of the month.
12719 * The date must be valid.
12721 * Returns: %TRUE if the date is the last day of the month
12726 * g_date_is_leap_year:
12727 * @year: year to check
12729 * Returns %TRUE if the year is a leap year.
12730 * <footnote><para>For the purposes of this function,
12731 * leap year is every year divisible by 4 unless that year
12732 * is divisible by 100. If it is divisible by 100 it would
12733 * be a leap year only if that year is also divisible
12734 * by 400.</para></footnote>
12736 * Returns: %TRUE if the year is a leap year
12743 * Allocates a #GDate and initializes
12744 * it to a sane state. The new date will
12745 * be cleared (as if you'd called g_date_clear()) but invalid (it won't
12746 * represent an existing day). Free the return value with g_date_free().
12748 * Returns: a newly-allocated #GDate
12754 * @day: day of the month
12755 * @month: month of the year
12758 * Like g_date_new(), but also sets the value of the date. Assuming the
12759 * day-month-year triplet you pass in represents an existing day, the
12760 * returned date will be valid.
12762 * Returns: a newly-allocated #GDate initialized with @day, @month, and @year
12767 * g_date_new_julian:
12768 * @julian_day: days since January 1, Year 1
12770 * Like g_date_new(), but also sets the value of the date. Assuming the
12771 * Julian day number you pass in is valid (greater than 0, less than an
12772 * unreasonably large number), the returned date will be valid.
12774 * Returns: a newly-allocated #GDate initialized with @julian_day
12780 * @date1: the first date
12781 * @date2: the second date
12783 * Checks if @date1 is less than or equal to @date2,
12784 * and swap the values if this is not the case.
12793 * Sets the day of the month for a #GDate. If the resulting
12794 * day-month-year triplet is invalid, the date will be invalid.
12805 * Sets the value of a #GDate from a day, month, and year.
12806 * The day-month-year triplet must be valid; if you aren't
12807 * sure it is, call g_date_valid_dmy() to check before you
12813 * g_date_set_julian:
12815 * @julian_date: Julian day number (days since January 1, Year 1)
12817 * Sets the value of a #GDate from a Julian day number.
12822 * g_date_set_month:
12824 * @month: month to set
12826 * Sets the month of the year for a #GDate. If the resulting
12827 * day-month-year triplet is invalid, the date will be invalid.
12832 * g_date_set_parse:
12833 * @date: a #GDate to fill in
12834 * @str: string to parse
12836 * Parses a user-inputted string @str, and try to figure out what date it
12837 * represents, taking the <link linkend="setlocale">current locale</link>
12838 * into account. If the string is successfully parsed, the date will be
12839 * valid after the call. Otherwise, it will be invalid. You should check
12840 * using g_date_valid() to see whether the parsing succeeded.
12842 * This function is not appropriate for file formats and the like; it
12843 * isn't very precise, and its exact behavior varies with the locale.
12844 * It's intended to be a heuristic routine that guesses what the user
12845 * means by a given string (and it does work pretty well in that
12853 * @time_: #GTime value to set.
12855 * Sets the value of a date from a #GTime value.
12856 * The time to date conversion is done using the user's current timezone.
12858 * Deprecated: 2.10: Use g_date_set_time_t() instead.
12863 * g_date_set_time_t:
12865 * @timet: <type>time_t</type> value to set
12867 * Sets the value of a date to the date corresponding to a time
12868 * specified as a time_t. The time to date conversion is done using
12869 * the user's current timezone.
12871 * To set the value of a date to the current day, you could write:
12873 * g_date_set_time_t (date, time (NULL));
12881 * g_date_set_time_val:
12883 * @timeval: #GTimeVal value to set
12885 * Sets the value of a date from a #GTimeVal value. Note that the
12886 * @tv_usec member is ignored, because #GDate can't make use of the
12887 * additional precision.
12889 * The time to date conversion is done using the user's current timezone.
12898 * @year: year to set
12900 * Sets the year for a #GDate. If the resulting day-month-year
12901 * triplet is invalid, the date will be invalid.
12907 * @s: destination buffer
12908 * @slen: buffer size
12909 * @format: format string
12910 * @date: valid #GDate
12912 * Generates a printed representation of the date, in a
12913 * <link linkend="setlocale">locale</link>-specific way.
12914 * Works just like the platform's C library strftime() function,
12915 * but only accepts date-related formats; time-related formats
12916 * give undefined results. Date must be valid. Unlike strftime()
12917 * (which uses the locale encoding), works on a UTF-8 format
12918 * string and stores a UTF-8 result.
12920 * This function does not provide any conversion specifiers in
12921 * addition to those implemented by the platform's C library.
12922 * For example, don't expect that using g_date_strftime() would
12923 * make the \%F provided by the C99 strftime() work on Windows
12924 * where the C library only complies to C89.
12926 * Returns: number of characters written to the buffer, or 0 the buffer was too small
12931 * g_date_subtract_days:
12932 * @date: a #GDate to decrement
12933 * @n_days: number of days to move
12935 * Moves a date some number of days into the past.
12936 * To move by weeks, just move by weeks*7 days.
12937 * The date must be valid.
12942 * g_date_subtract_months:
12943 * @date: a #GDate to decrement
12944 * @n_months: number of months to move
12946 * Moves a date some number of months into the past.
12947 * If the current day of the month doesn't exist in
12948 * the destination month, the day of the month
12949 * may change. The date must be valid.
12954 * g_date_subtract_years:
12955 * @date: a #GDate to decrement
12956 * @n_years: number of years to move
12958 * Moves a date some number of years into the past.
12959 * If the current day doesn't exist in the destination
12960 * year (i.e. it's February 29 and you move to a non-leap-year)
12961 * then the day is changed to February 29. The date
12968 * @datetime: a #GDateTime
12969 * @timespan: a #GTimeSpan
12971 * Creates a copy of @datetime and adds the specified timespan to the copy.
12973 * Returns: the newly created #GDateTime which should be freed with
12974 * g_date_time_unref().
12980 * g_date_time_add_days:
12981 * @datetime: a #GDateTime
12982 * @days: the number of days
12984 * Creates a copy of @datetime and adds the specified number of days to the
12985 * copy. Add negative values to subtract days.
12987 * Returns: the newly created #GDateTime which should be freed with
12988 * g_date_time_unref().
12994 * g_date_time_add_full:
12995 * @datetime: a #GDateTime
12996 * @years: the number of years to add
12997 * @months: the number of months to add
12998 * @days: the number of days to add
12999 * @hours: the number of hours to add
13000 * @minutes: the number of minutes to add
13001 * @seconds: the number of seconds to add
13003 * Creates a new #GDateTime adding the specified values to the current date and
13004 * time in @datetime. Add negative values to subtract.
13006 * Returns: the newly created #GDateTime that should be freed with
13007 * g_date_time_unref().
13013 * g_date_time_add_hours:
13014 * @datetime: a #GDateTime
13015 * @hours: the number of hours to add
13017 * Creates a copy of @datetime and adds the specified number of hours.
13018 * Add negative values to subtract hours.
13020 * Returns: the newly created #GDateTime which should be freed with
13021 * g_date_time_unref().
13027 * g_date_time_add_minutes:
13028 * @datetime: a #GDateTime
13029 * @minutes: the number of minutes to add
13031 * Creates a copy of @datetime adding the specified number of minutes.
13032 * Add negative values to subtract minutes.
13034 * Returns: the newly created #GDateTime which should be freed with
13035 * g_date_time_unref().
13041 * g_date_time_add_months:
13042 * @datetime: a #GDateTime
13043 * @months: the number of months
13045 * Creates a copy of @datetime and adds the specified number of months to the
13046 * copy. Add negative values to subtract months.
13048 * Returns: the newly created #GDateTime which should be freed with
13049 * g_date_time_unref().
13055 * g_date_time_add_seconds:
13056 * @datetime: a #GDateTime
13057 * @seconds: the number of seconds to add
13059 * Creates a copy of @datetime and adds the specified number of seconds.
13060 * Add negative values to subtract seconds.
13062 * Returns: the newly created #GDateTime which should be freed with
13063 * g_date_time_unref().
13069 * g_date_time_add_weeks:
13070 * @datetime: a #GDateTime
13071 * @weeks: the number of weeks
13073 * Creates a copy of @datetime and adds the specified number of weeks to the
13074 * copy. Add negative values to subtract weeks.
13076 * Returns: the newly created #GDateTime which should be freed with
13077 * g_date_time_unref().
13083 * g_date_time_add_years:
13084 * @datetime: a #GDateTime
13085 * @years: the number of years
13087 * Creates a copy of @datetime and adds the specified number of years to the
13088 * copy. Add negative values to subtract years.
13090 * Returns: the newly created #GDateTime which should be freed with
13091 * g_date_time_unref().
13097 * g_date_time_compare:
13098 * @dt1: first #GDateTime to compare
13099 * @dt2: second #GDateTime to compare
13101 * A comparison function for #GDateTimes that is suitable
13102 * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
13104 * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater
13111 * g_date_time_difference:
13112 * @end: a #GDateTime
13113 * @begin: a #GDateTime
13115 * Calculates the difference in time between @end and @begin. The
13116 * #GTimeSpan that is returned is effectively @end - @begin (ie:
13117 * positive if the first parameter is larger).
13119 * Returns: the difference between the two #GDateTime, as a time
13120 * span expressed in microseconds.
13126 * g_date_time_equal:
13127 * @dt1: a #GDateTime
13128 * @dt2: a #GDateTime
13130 * Checks to see if @dt1 and @dt2 are equal.
13132 * Equal here means that they represent the same moment after converting
13133 * them to the same time zone.
13135 * Returns: %TRUE if @dt1 and @dt2 are equal
13141 * g_date_time_format:
13142 * @datetime: A #GDateTime
13143 * @format: a valid UTF-8 string, containing the format for the
13146 * Creates a newly allocated string representing the requested @format.
13148 * The format strings understood by this function are a subset of the
13149 * strftime() format language as specified by C99. The \%D, \%U and \%W
13150 * conversions are not supported, nor is the 'E' modifier. The GNU
13151 * extensions \%k, \%l, \%s and \%P are supported, however, as are the
13152 * '0', '_' and '-' modifiers.
13154 * In contrast to strftime(), this function always produces a UTF-8
13155 * string, regardless of the current locale. Note that the rendering of
13156 * many formats is locale-dependent and may not match the strftime()
13159 * The following format specifiers are supported:
13162 * <varlistentry><term>
13163 * <literal>\%a</literal>:
13164 * </term><listitem><simpara>
13165 * the abbreviated weekday name according to the current locale
13166 * </simpara></listitem></varlistentry>
13167 * <varlistentry><term>
13168 * <literal>\%A</literal>:
13169 * </term><listitem><simpara>
13170 * the full weekday name according to the current locale
13171 * </simpara></listitem></varlistentry>
13172 * <varlistentry><term>
13173 * <literal>\%b</literal>:
13174 * </term><listitem><simpara>
13175 * the abbreviated month name according to the current locale
13176 * </simpara></listitem></varlistentry>
13177 * <varlistentry><term>
13178 * <literal>\%B</literal>:
13179 * </term><listitem><simpara>
13180 * the full month name according to the current locale
13181 * </simpara></listitem></varlistentry>
13182 * <varlistentry><term>
13183 * <literal>\%c</literal>:
13184 * </term><listitem><simpara>
13185 * the preferred date and time representation for the current locale
13186 * </simpara></listitem></varlistentry>
13187 * <varlistentry><term>
13188 * <literal>\%C</literal>:
13189 * </term><listitem><simpara>
13190 * The century number (year/100) as a 2-digit integer (00-99)
13191 * </simpara></listitem></varlistentry>
13192 * <varlistentry><term>
13193 * <literal>\%d</literal>:
13194 * </term><listitem><simpara>
13195 * the day of the month as a decimal number (range 01 to 31)
13196 * </simpara></listitem></varlistentry>
13197 * <varlistentry><term>
13198 * <literal>\%e</literal>:
13199 * </term><listitem><simpara>
13200 * the day of the month as a decimal number (range 1 to 31)
13201 * </simpara></listitem></varlistentry>
13202 * <varlistentry><term>
13203 * <literal>\%F</literal>:
13204 * </term><listitem><simpara>
13205 * equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
13207 * </simpara></listitem></varlistentry>
13208 * <varlistentry><term>
13209 * <literal>\%g</literal>:
13210 * </term><listitem><simpara>
13211 * the last two digits of the ISO 8601 week-based year as a decimal
13212 * number (00-99). This works well with \%V and \%u.
13213 * </simpara></listitem></varlistentry>
13214 * <varlistentry><term>
13215 * <literal>\%G</literal>:
13216 * </term><listitem><simpara>
13217 * the ISO 8601 week-based year as a decimal number. This works well
13218 * with \%V and \%u.
13219 * </simpara></listitem></varlistentry>
13220 * <varlistentry><term>
13221 * <literal>\%h</literal>:
13222 * </term><listitem><simpara>
13223 * equivalent to <literal>\%b</literal>
13224 * </simpara></listitem></varlistentry>
13225 * <varlistentry><term>
13226 * <literal>\%H</literal>:
13227 * </term><listitem><simpara>
13228 * the hour as a decimal number using a 24-hour clock (range 00 to
13230 * </simpara></listitem></varlistentry>
13231 * <varlistentry><term>
13232 * <literal>\%I</literal>:
13233 * </term><listitem><simpara>
13234 * the hour as a decimal number using a 12-hour clock (range 01 to
13236 * </simpara></listitem></varlistentry>
13237 * <varlistentry><term>
13238 * <literal>\%j</literal>:
13239 * </term><listitem><simpara>
13240 * the day of the year as a decimal number (range 001 to 366)
13241 * </simpara></listitem></varlistentry>
13242 * <varlistentry><term>
13243 * <literal>\%k</literal>:
13244 * </term><listitem><simpara>
13245 * the hour (24-hour clock) as a decimal number (range 0 to 23);
13246 * single digits are preceded by a blank
13247 * </simpara></listitem></varlistentry>
13248 * <varlistentry><term>
13249 * <literal>\%l</literal>:
13250 * </term><listitem><simpara>
13251 * the hour (12-hour clock) as a decimal number (range 1 to 12);
13252 * single digits are preceded by a blank
13253 * </simpara></listitem></varlistentry>
13254 * <varlistentry><term>
13255 * <literal>\%m</literal>:
13256 * </term><listitem><simpara>
13257 * the month as a decimal number (range 01 to 12)
13258 * </simpara></listitem></varlistentry>
13259 * <varlistentry><term>
13260 * <literal>\%M</literal>:
13261 * </term><listitem><simpara>
13262 * the minute as a decimal number (range 00 to 59)
13263 * </simpara></listitem></varlistentry>
13264 * <varlistentry><term>
13265 * <literal>\%p</literal>:
13266 * </term><listitem><simpara>
13267 * either "AM" or "PM" according to the given time value, or the
13268 * corresponding strings for the current locale. Noon is treated as
13269 * "PM" and midnight as "AM".
13270 * </simpara></listitem></varlistentry>
13271 * <varlistentry><term>
13272 * <literal>\%P</literal>:
13273 * </term><listitem><simpara>
13274 * like \%p but lowercase: "am" or "pm" or a corresponding string for
13275 * the current locale
13276 * </simpara></listitem></varlistentry>
13277 * <varlistentry><term>
13278 * <literal>\%r</literal>:
13279 * </term><listitem><simpara>
13280 * the time in a.m. or p.m. notation
13281 * </simpara></listitem></varlistentry>
13282 * <varlistentry><term>
13283 * <literal>\%R</literal>:
13284 * </term><listitem><simpara>
13285 * the time in 24-hour notation (<literal>\%H:\%M</literal>)
13286 * </simpara></listitem></varlistentry>
13287 * <varlistentry><term>
13288 * <literal>\%s</literal>:
13289 * </term><listitem><simpara>
13290 * the number of seconds since the Epoch, that is, since 1970-01-01
13292 * </simpara></listitem></varlistentry>
13293 * <varlistentry><term>
13294 * <literal>\%S</literal>:
13295 * </term><listitem><simpara>
13296 * the second as a decimal number (range 00 to 60)
13297 * </simpara></listitem></varlistentry>
13298 * <varlistentry><term>
13299 * <literal>\%t</literal>:
13300 * </term><listitem><simpara>
13302 * </simpara></listitem></varlistentry>
13303 * <varlistentry><term>
13304 * <literal>\%T</literal>:
13305 * </term><listitem><simpara>
13306 * the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
13307 * </simpara></listitem></varlistentry>
13308 * <varlistentry><term>
13309 * <literal>\%u</literal>:
13310 * </term><listitem><simpara>
13311 * the ISO 8601 standard day of the week as a decimal, range 1 to 7,
13312 * Monday being 1. This works well with \%G and \%V.
13313 * </simpara></listitem></varlistentry>
13314 * <varlistentry><term>
13315 * <literal>\%V</literal>:
13316 * </term><listitem><simpara>
13317 * the ISO 8601 standard week number of the current year as a decimal
13318 * number, range 01 to 53, where week 1 is the first week that has at
13319 * least 4 days in the new year. See g_date_time_get_week_of_year().
13320 * This works well with \%G and \%u.
13321 * </simpara></listitem></varlistentry>
13322 * <varlistentry><term>
13323 * <literal>\%w</literal>:
13324 * </term><listitem><simpara>
13325 * the day of the week as a decimal, range 0 to 6, Sunday being 0.
13326 * This is not the ISO 8601 standard format -- use \%u instead.
13327 * </simpara></listitem></varlistentry>
13328 * <varlistentry><term>
13329 * <literal>\%x</literal>:
13330 * </term><listitem><simpara>
13331 * the preferred date representation for the current locale without
13333 * </simpara></listitem></varlistentry>
13334 * <varlistentry><term>
13335 * <literal>\%X</literal>:
13336 * </term><listitem><simpara>
13337 * the preferred time representation for the current locale without
13339 * </simpara></listitem></varlistentry>
13340 * <varlistentry><term>
13341 * <literal>\%y</literal>:
13342 * </term><listitem><simpara>
13343 * the year as a decimal number without the century
13344 * </simpara></listitem></varlistentry>
13345 * <varlistentry><term>
13346 * <literal>\%Y</literal>:
13347 * </term><listitem><simpara>
13348 * the year as a decimal number including the century
13349 * </simpara></listitem></varlistentry>
13350 * <varlistentry><term>
13351 * <literal>\%z</literal>:
13352 * </term><listitem><simpara>
13353 * the time zone as an offset from UTC (+hhmm)
13354 * </simpara></listitem></varlistentry>
13355 * <varlistentry><term>
13356 * <literal>\%:z</literal>:
13357 * </term><listitem><simpara>
13358 * the time zone as an offset from UTC (+hh:mm). This is a gnulib strftime extension. Since: 2.38
13359 * </simpara></listitem></varlistentry>
13360 * <varlistentry><term>
13361 * <literal>\%::z</literal>:
13362 * </term><listitem><simpara>
13363 * the time zone as an offset from UTC (+hh:mm:ss). This is a gnulib strftime extension. Since: 2.38
13364 * </simpara></listitem></varlistentry>
13365 * <varlistentry><term>
13366 * <literal>\%:::z</literal>:
13367 * </term><listitem><simpara>
13368 * the time zone as an offset from UTC, with : to necessary precision
13369 * (e.g., -04, +05:30). This is a gnulib strftime extension. Since: 2.38
13370 * </simpara></listitem></varlistentry>
13371 * <varlistentry><term>
13372 * <literal>\%Z</literal>:
13373 * </term><listitem><simpara>
13374 * the time zone or name or abbreviation
13375 * </simpara></listitem></varlistentry>
13376 * <varlistentry><term>
13377 * <literal>\%\%</literal>:
13378 * </term><listitem><simpara>
13379 * a literal <literal>\%</literal> character
13380 * </simpara></listitem></varlistentry>
13383 * Some conversion specifications can be modified by preceding the
13384 * conversion specifier by one or more modifier characters. The
13385 * following modifiers are supported for many of the numeric
13391 * Use alternative numeric symbols, if the current locale
13398 * Pad a numeric result with spaces.
13399 * This overrides the default padding for the specifier.
13405 * Do not pad a numeric result.
13406 * This overrides the default padding for the specifier.
13412 * Pad a numeric result with zeros.
13413 * This overrides the default padding for the specifier.
13418 * Returns: a newly allocated string formatted to the requested format
13419 * or %NULL in the case that there was an error. The string
13420 * should be freed with g_free().
13426 * g_date_time_get_day_of_month:
13427 * @datetime: a #GDateTime
13429 * Retrieves the day of the month represented by @datetime in the gregorian
13432 * Returns: the day of the month
13438 * g_date_time_get_day_of_week:
13439 * @datetime: a #GDateTime
13441 * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
13442 * Monday, 2 is Tuesday... 7 is Sunday).
13444 * Returns: the day of the week
13450 * g_date_time_get_day_of_year:
13451 * @datetime: a #GDateTime
13453 * Retrieves the day of the year represented by @datetime in the Gregorian
13456 * Returns: the day of the year
13462 * g_date_time_get_hour:
13463 * @datetime: a #GDateTime
13465 * Retrieves the hour of the day represented by @datetime
13467 * Returns: the hour of the day
13473 * g_date_time_get_microsecond:
13474 * @datetime: a #GDateTime
13476 * Retrieves the microsecond of the date represented by @datetime
13478 * Returns: the microsecond of the second
13484 * g_date_time_get_minute:
13485 * @datetime: a #GDateTime
13487 * Retrieves the minute of the hour represented by @datetime
13489 * Returns: the minute of the hour
13495 * g_date_time_get_month:
13496 * @datetime: a #GDateTime
13498 * Retrieves the month of the year represented by @datetime in the Gregorian
13501 * Returns: the month represented by @datetime
13507 * g_date_time_get_second:
13508 * @datetime: a #GDateTime
13510 * Retrieves the second of the minute represented by @datetime
13512 * Returns: the second represented by @datetime
13518 * g_date_time_get_seconds:
13519 * @datetime: a #GDateTime
13521 * Retrieves the number of seconds since the start of the last minute,
13522 * including the fractional part.
13524 * Returns: the number of seconds
13530 * g_date_time_get_timezone_abbreviation:
13531 * @datetime: a #GDateTime
13533 * Determines the time zone abbreviation to be used at the time and in
13534 * the time zone of @datetime.
13536 * For example, in Toronto this is currently "EST" during the winter
13537 * months and "EDT" during the summer months when daylight savings
13538 * time is in effect.
13540 * Returns: (transfer none): the time zone abbreviation. The returned
13541 * string is owned by the #GDateTime and it should not be
13542 * modified or freed
13548 * g_date_time_get_utc_offset:
13549 * @datetime: a #GDateTime
13551 * Determines the offset to UTC in effect at the time and in the time
13552 * zone of @datetime.
13554 * The offset is the number of microseconds that you add to UTC time to
13555 * arrive at local time for the time zone (ie: negative numbers for time
13556 * zones west of GMT, positive numbers for east).
13558 * If @datetime represents UTC time, then the offset is always zero.
13560 * Returns: the number of microseconds that should be added to UTC to
13561 * get the local time
13567 * g_date_time_get_week_numbering_year:
13568 * @datetime: a #GDateTime
13570 * Returns the ISO 8601 week-numbering year in which the week containing
13573 * This function, taken together with g_date_time_get_week_of_year() and
13574 * g_date_time_get_day_of_week() can be used to determine the full ISO
13575 * week date on which @datetime falls.
13577 * This is usually equal to the normal Gregorian year (as returned by
13578 * g_date_time_get_year()), except as detailed below:
13580 * For Thursday, the week-numbering year is always equal to the usual
13581 * calendar year. For other days, the number is such that every day
13582 * within a complete week (Monday to Sunday) is contained within the
13583 * same week-numbering year.
13585 * For Monday, Tuesday and Wednesday occurring near the end of the year,
13586 * this may mean that the week-numbering year is one greater than the
13587 * calendar year (so that these days have the same week-numbering year
13588 * as the Thursday occurring early in the next year).
13590 * For Friday, Saturaday and Sunday occurring near the start of the year,
13591 * this may mean that the week-numbering year is one less than the
13592 * calendar year (so that these days have the same week-numbering year
13593 * as the Thursday occurring late in the previous year).
13595 * An equivalent description is that the week-numbering year is equal to
13596 * the calendar year containing the majority of the days in the current
13597 * week (Monday to Sunday).
13599 * Note that January 1 0001 in the proleptic Gregorian calendar is a
13600 * Monday, so this function never returns 0.
13602 * Returns: the ISO 8601 week-numbering year for @datetime
13608 * g_date_time_get_week_of_year:
13609 * @datetime: a #GDateTime
13611 * Returns the ISO 8601 week number for the week containing @datetime.
13612 * The ISO 8601 week number is the same for every day of the week (from
13613 * Moday through Sunday). That can produce some unusual results
13614 * (described below).
13616 * The first week of the year is week 1. This is the week that contains
13617 * the first Thursday of the year. Equivalently, this is the first week
13618 * that has more than 4 of its days falling within the calendar year.
13620 * The value 0 is never returned by this function. Days contained
13621 * within a year but occurring before the first ISO 8601 week of that
13622 * year are considered as being contained in the last week of the
13623 * previous year. Similarly, the final days of a calendar year may be
13624 * considered as being part of the first ISO 8601 week of the next year
13625 * if 4 or more days of that week are contained within the new year.
13627 * Returns: the ISO 8601 week number for @datetime.
13633 * g_date_time_get_year:
13634 * @datetime: A #GDateTime
13636 * Retrieves the year represented by @datetime in the Gregorian calendar.
13638 * Returns: the year represented by @datetime
13644 * g_date_time_get_ymd:
13645 * @datetime: a #GDateTime.
13646 * @year: (out) (allow-none): the return location for the gregorian year, or %NULL.
13647 * @month: (out) (allow-none): the return location for the month of the year, or %NULL.
13648 * @day: (out) (allow-none): the return location for the day of the month, or %NULL.
13650 * Retrieves the Gregorian day, month, and year of a given #GDateTime.
13657 * g_date_time_hash:
13658 * @datetime: a #GDateTime
13660 * Hashes @datetime into a #guint, suitable for use within #GHashTable.
13662 * Returns: a #guint containing the hash
13668 * g_date_time_is_daylight_savings:
13669 * @datetime: a #GDateTime
13671 * Determines if daylight savings time is in effect at the time and in
13672 * the time zone of @datetime.
13674 * Returns: %TRUE if daylight savings time is in effect
13681 * @tz: a #GTimeZone
13682 * @year: the year component of the date
13683 * @month: the month component of the date
13684 * @day: the day component of the date
13685 * @hour: the hour component of the date
13686 * @minute: the minute component of the date
13687 * @seconds: the number of seconds past the minute
13689 * Creates a new #GDateTime corresponding to the given date and time in
13690 * the time zone @tz.
13692 * The @year must be between 1 and 9999, @month between 1 and 12 and @day
13693 * between 1 and 28, 29, 30 or 31 depending on the month and the year.
13695 * @hour must be between 0 and 23 and @minute must be between 0 and 59.
13697 * @seconds must be at least 0.0 and must be strictly less than 60.0.
13698 * It will be rounded down to the nearest microsecond.
13700 * If the given time is not representable in the given time zone (for
13701 * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
13702 * time) then the time will be rounded up to the nearest existing time
13703 * (in this case, 03:00). If this matters to you then you should verify
13704 * the return value for containing the same as the numbers you gave.
13706 * In the case that the given time is ambiguous in the given time zone
13707 * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
13708 * savings time) then the time falling within standard (ie:
13709 * non-daylight) time is taken.
13711 * It not considered a programmer error for the values to this function
13712 * to be out of range, but in the case that they are, the function will
13715 * You should release the return value by calling g_date_time_unref()
13716 * when you are done with it.
13718 * Returns: a new #GDateTime, or %NULL
13724 * g_date_time_new_from_timeval_local:
13727 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
13730 * The time contained in a #GTimeVal is always stored in the form of
13731 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
13732 * local time offset.
13734 * This call can fail (returning %NULL) if @tv represents a time outside
13735 * of the supported range of #GDateTime.
13737 * You should release the return value by calling g_date_time_unref()
13738 * when you are done with it.
13740 * Returns: a new #GDateTime, or %NULL
13746 * g_date_time_new_from_timeval_utc:
13749 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
13751 * The time contained in a #GTimeVal is always stored in the form of
13752 * seconds elapsed since 1970-01-01 00:00:00 UTC.
13754 * This call can fail (returning %NULL) if @tv represents a time outside
13755 * of the supported range of #GDateTime.
13757 * You should release the return value by calling g_date_time_unref()
13758 * when you are done with it.
13760 * Returns: a new #GDateTime, or %NULL
13766 * g_date_time_new_from_unix_local:
13767 * @t: the Unix time
13769 * Creates a #GDateTime corresponding to the given Unix time @t in the
13772 * Unix time is the number of seconds that have elapsed since 1970-01-01
13773 * 00:00:00 UTC, regardless of the local time offset.
13775 * This call can fail (returning %NULL) if @t represents a time outside
13776 * of the supported range of #GDateTime.
13778 * You should release the return value by calling g_date_time_unref()
13779 * when you are done with it.
13781 * Returns: a new #GDateTime, or %NULL
13787 * g_date_time_new_from_unix_utc:
13788 * @t: the Unix time
13790 * Creates a #GDateTime corresponding to the given Unix time @t in UTC.
13792 * Unix time is the number of seconds that have elapsed since 1970-01-01
13795 * This call can fail (returning %NULL) if @t represents a time outside
13796 * of the supported range of #GDateTime.
13798 * You should release the return value by calling g_date_time_unref()
13799 * when you are done with it.
13801 * Returns: a new #GDateTime, or %NULL
13807 * g_date_time_new_local:
13808 * @year: the year component of the date
13809 * @month: the month component of the date
13810 * @day: the day component of the date
13811 * @hour: the hour component of the date
13812 * @minute: the minute component of the date
13813 * @seconds: the number of seconds past the minute
13815 * Creates a new #GDateTime corresponding to the given date and time in
13816 * the local time zone.
13818 * This call is equivalent to calling g_date_time_new() with the time
13819 * zone returned by g_time_zone_new_local().
13821 * Returns: a #GDateTime, or %NULL
13827 * g_date_time_new_now:
13828 * @tz: a #GTimeZone
13830 * Creates a #GDateTime corresponding to this exact instant in the given
13831 * time zone @tz. The time is as accurate as the system allows, to a
13832 * maximum accuracy of 1 microsecond.
13834 * This function will always succeed unless the system clock is set to
13835 * truly insane values (or unless GLib is still being used after the
13838 * You should release the return value by calling g_date_time_unref()
13839 * when you are done with it.
13841 * Returns: a new #GDateTime, or %NULL
13847 * g_date_time_new_now_local:
13849 * Creates a #GDateTime corresponding to this exact instant in the local
13852 * This is equivalent to calling g_date_time_new_now() with the time
13853 * zone returned by g_time_zone_new_local().
13855 * Returns: a new #GDateTime, or %NULL
13861 * g_date_time_new_now_utc:
13863 * Creates a #GDateTime corresponding to this exact instant in UTC.
13865 * This is equivalent to calling g_date_time_new_now() with the time
13866 * zone returned by g_time_zone_new_utc().
13868 * Returns: a new #GDateTime, or %NULL
13874 * g_date_time_new_utc:
13875 * @year: the year component of the date
13876 * @month: the month component of the date
13877 * @day: the day component of the date
13878 * @hour: the hour component of the date
13879 * @minute: the minute component of the date
13880 * @seconds: the number of seconds past the minute
13882 * Creates a new #GDateTime corresponding to the given date and time in
13885 * This call is equivalent to calling g_date_time_new() with the time
13886 * zone returned by g_time_zone_new_utc().
13888 * Returns: a #GDateTime, or %NULL
13895 * @datetime: a #GDateTime
13897 * Atomically increments the reference count of @datetime by one.
13899 * Returns: the #GDateTime with the reference count increased
13905 * g_date_time_to_local:
13906 * @datetime: a #GDateTime
13908 * Creates a new #GDateTime corresponding to the same instant in time as
13909 * @datetime, but in the local time zone.
13911 * This call is equivalent to calling g_date_time_to_timezone() with the
13912 * time zone returned by g_time_zone_new_local().
13914 * Returns: the newly created #GDateTime
13920 * g_date_time_to_timeval:
13921 * @datetime: a #GDateTime
13922 * @tv: a #GTimeVal to modify
13924 * Stores the instant in time that @datetime represents into @tv.
13926 * The time contained in a #GTimeVal is always stored in the form of
13927 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
13928 * zone associated with @datetime.
13930 * On systems where 'long' is 32bit (ie: all 32bit systems and all
13931 * Windows systems), a #GTimeVal is incapable of storing the entire
13932 * range of values that #GDateTime is capable of expressing. On those
13933 * systems, this function returns %FALSE to indicate that the time is
13936 * On systems where 'long' is 64bit, this function never fails.
13938 * Returns: %TRUE if successful, else %FALSE
13944 * g_date_time_to_timezone:
13945 * @datetime: a #GDateTime
13946 * @tz: the new #GTimeZone
13948 * Create a new #GDateTime corresponding to the same instant in time as
13949 * @datetime, but in the time zone @tz.
13951 * This call can fail in the case that the time goes out of bounds. For
13952 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
13953 * Greenwich will fail (due to the year 0 being out of range).
13955 * You should release the return value by calling g_date_time_unref()
13956 * when you are done with it.
13958 * Returns: a new #GDateTime, or %NULL
13964 * g_date_time_to_unix:
13965 * @datetime: a #GDateTime
13967 * Gives the Unix time corresponding to @datetime, rounding down to the
13970 * Unix time is the number of seconds that have elapsed since 1970-01-01
13971 * 00:00:00 UTC, regardless of the time zone associated with @datetime.
13973 * Returns: the Unix time corresponding to @datetime
13979 * g_date_time_to_utc:
13980 * @datetime: a #GDateTime
13982 * Creates a new #GDateTime corresponding to the same instant in time as
13983 * @datetime, but in UTC.
13985 * This call is equivalent to calling g_date_time_to_timezone() with the
13986 * time zone returned by g_time_zone_new_utc().
13988 * Returns: the newly created #GDateTime
13994 * g_date_time_unref:
13995 * @datetime: a #GDateTime
13997 * Atomically decrements the reference count of @datetime by one.
13999 * When the reference count reaches zero, the resources allocated by
14000 * @datetime are freed
14007 * g_date_to_struct_tm:
14008 * @date: a #GDate to set the <structname>struct tm</structname> from
14009 * @tm: <structname>struct tm</structname> to fill
14011 * Fills in the date-related bits of a <structname>struct tm</structname>
14012 * using the @date value. Initializes the non-date parts with something
14013 * sane but meaningless.
14019 * @date: a #GDate to check
14021 * Returns %TRUE if the #GDate represents an existing day. The date must not
14022 * contain garbage; it should have been initialized with g_date_clear()
14023 * if it wasn't allocated by one of the g_date_new() variants.
14025 * Returns: Whether the date is valid
14030 * g_date_valid_day:
14031 * @day: day to check
14033 * Returns %TRUE if the day of the month is valid (a day is valid if it's
14034 * between 1 and 31 inclusive).
14036 * Returns: %TRUE if the day is valid
14041 * g_date_valid_dmy:
14046 * Returns %TRUE if the day-month-year triplet forms a valid, existing day
14047 * in the range of days #GDate understands (Year 1 or later, no more than
14048 * a few thousand years in the future).
14050 * Returns: %TRUE if the date is a valid one
14055 * g_date_valid_julian:
14056 * @julian_date: Julian day to check
14058 * Returns %TRUE if the Julian day is valid. Anything greater than zero
14059 * is basically a valid Julian, though there is a 32-bit limit.
14061 * Returns: %TRUE if the Julian day is valid
14066 * g_date_valid_month:
14069 * Returns %TRUE if the month value is valid. The 12 #GDateMonth
14070 * enumeration values are the only valid months.
14072 * Returns: %TRUE if the month is valid
14077 * g_date_valid_weekday:
14078 * @weekday: weekday
14080 * Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
14081 * values are the only valid weekdays.
14083 * Returns: %TRUE if the weekday is valid
14088 * g_date_valid_year:
14091 * Returns %TRUE if the year is valid. Any year greater than 0 is valid,
14092 * though there is a 16-bit limit to what #GDate will understand.
14094 * Returns: %TRUE if the year is valid
14100 * @domain: (allow-none): the translation domain to use, or %NULL to use
14101 * the domain set with textdomain()
14102 * @msgid: message to translate
14103 * @category: a locale category
14105 * This is a variant of g_dgettext() that allows specifying a locale
14106 * category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
14107 * more information about how this functions differs from calling
14108 * dcgettext() directly.
14110 * Returns: the translated string for the given locale category
14117 * @...: format string, followed by parameters to insert
14118 * into the format string (as with printf())
14120 * A convenience function/macro to log a debug message.
14122 * If g_log_default_handler() is used as the log handler function, a new-line
14123 * character will automatically be appended to @..., and need not be entered
14132 * @domain: (allow-none): the translation domain to use, or %NULL to use
14133 * the domain set with textdomain()
14134 * @msgid: message to translate
14136 * This function is a wrapper of dgettext() which does not translate
14137 * the message if the default domain as set with textdomain() has no
14138 * translations for the current locale.
14140 * The advantage of using this function over dgettext() proper is that
14141 * libraries using this function (like GTK+) will not use translations
14142 * if the application using the library does not have translations for
14143 * the current locale. This results in a consistent English-only
14144 * interface instead of one having partial translations. For this
14145 * feature to work, the call to textdomain() and setlocale() should
14146 * precede any g_dgettext() invocations. For GTK+, it means calling
14147 * textdomain() before gtk_init or its variants.
14149 * This function disables translations if and only if upon its first
14150 * call all the following conditions hold:
14152 * <listitem>@domain is not %NULL</listitem>
14153 * <listitem>textdomain() has been called to set a default text domain</listitem>
14154 * <listitem>there is no translations available for the default text domain
14155 * and the current locale</listitem>
14156 * <listitem>current locale is not "C" or any English locales (those
14157 * starting with "en_")</listitem>
14160 * Note that this behavior may not be desired for example if an application
14161 * has its untranslated messages in a language other than English. In those
14162 * cases the application should call textdomain() after initializing GTK+.
14164 * Applications should normally not use this function directly,
14165 * but use the _() macro for translations.
14167 * Returns: The translated string
14174 * @dir: a #GDir* created by g_dir_open()
14176 * Closes the directory and deallocates all related resources.
14182 * @tmpl: (type filename) (allow-none): Template for directory name,
14183 * as in g_mkdtemp(), basename only, or %NULL for a default template
14184 * @error: return location for a #GError
14186 * Creates a subdirectory in the preferred directory for temporary
14187 * files (as returned by g_get_tmp_dir()).
14189 * @tmpl should be a string in the GLib file name encoding containing
14190 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14191 * However, unlike these functions, the template should only be a
14192 * basename, no directory components are allowed. If template is
14193 * %NULL, a default template is used.
14195 * Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
14196 * modified, and might thus be a read-only literal string.
14198 * Returns: (type filename): The actual name used. This string
14199 * should be freed with g_free() when not needed any longer and is
14200 * is in the GLib file name encoding. In case of errors, %NULL is
14201 * returned and @error will be set.
14208 * @path: the path to the directory you are interested in. On Unix
14209 * in the on-disk encoding. On Windows in UTF-8
14210 * @flags: Currently must be set to 0. Reserved for future use.
14211 * @error: return location for a #GError, or %NULL.
14212 * If non-%NULL, an error will be set if and only if
14213 * g_dir_open() fails.
14215 * Opens a directory for reading. The names of the files in the
14216 * directory can then be retrieved using g_dir_read_name(). Note
14217 * that the ordering is not defined.
14219 * Returns: a newly allocated #GDir on success, %NULL on failure.
14220 * If non-%NULL, you must free the result with g_dir_close()
14221 * when you are finished with it.
14227 * @dir: a #GDir* created by g_dir_open()
14229 * Retrieves the name of another entry in the directory, or %NULL.
14230 * The order of entries returned from this function is not defined,
14231 * and may vary by file system or other operating-system dependent
14234 * %NULL may also be returned in case of errors. On Unix, you can
14235 * check <literal>errno</literal> to find out if %NULL was returned
14236 * because of an error.
14238 * On Unix, the '.' and '..' entries are omitted, and the returned
14239 * name is in the on-disk encoding.
14241 * On Windows, as is true of all GLib functions which operate on
14242 * filenames, the returned name is in UTF-8.
14244 * Returns: The entry's name or %NULL if there are no
14245 * more entries. The return value is owned by GLib and
14246 * must not be modified or freed.
14252 * @dir: a #GDir* created by g_dir_open()
14254 * Resets the given directory. The next call to g_dir_read_name()
14255 * will return the first entry again.
14261 * @v1: (allow-none): a key
14262 * @v2: (allow-none): a key to compare with @v1
14264 * Compares two #gpointer arguments and returns %TRUE if they are equal.
14265 * It can be passed to g_hash_table_new() as the @key_equal_func
14266 * parameter, when using opaque pointers compared by pointer value as keys
14267 * in a #GHashTable.
14269 * This equality function is also appropriate for keys that are integers stored
14270 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
14272 * Returns: %TRUE if the two keys match.
14278 * @v: (allow-none): a #gpointer key
14280 * Converts a gpointer to a hash value.
14281 * It can be passed to g_hash_table_new() as the @hash_func parameter,
14282 * when using opaque pointers compared by pointer value as keys in a
14285 * This hash function is also appropriate for keys that are integers stored
14286 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
14288 * Returns: a hash value corresponding to the key.
14294 * @file_name: the name of the file
14296 * Gets the directory components of a file name.
14298 * If the file name has no directory components "." is returned.
14299 * The returned string should be freed when no longer needed.
14301 * Returns: the directory components of the file
14302 * Deprecated: use g_path_get_dirname() instead
14308 * @domain: (allow-none): the translation domain to use, or %NULL to use
14309 * the domain set with textdomain()
14310 * @msgid: message to translate
14311 * @msgid_plural: plural form of the message
14312 * @n: the quantity for which translation is needed
14314 * This function is a wrapper of dngettext() which does not translate
14315 * the message if the default domain as set with textdomain() has no
14316 * translations for the current locale.
14318 * See g_dgettext() for details of how this differs from dngettext()
14321 * Returns: The translated string
14328 * @v1: a pointer to a #gdouble key
14329 * @v2: a pointer to a #gdouble key to compare with @v1
14331 * Compares the two #gdouble values being pointed to and returns
14332 * %TRUE if they are equal.
14333 * It can be passed to g_hash_table_new() as the @key_equal_func
14334 * parameter, when using non-%NULL pointers to doubles as keys in a
14337 * Returns: %TRUE if the two keys match.
14344 * @v: a pointer to a #gdouble key
14346 * Converts a pointer to a #gdouble to a hash value.
14347 * It can be passed to g_hash_table_new() as the @hash_func parameter,
14348 * It can be passed to g_hash_table_new() as the @hash_func parameter,
14349 * when using non-%NULL pointers to doubles as keys in a #GHashTable.
14351 * Returns: a hash value corresponding to the key.
14358 * @domain: (allow-none): the translation domain to use, or %NULL to use
14359 * the domain set with textdomain()
14360 * @msgctxtid: a combined message context and message id, separated
14361 * by a \004 character
14362 * @msgidoffset: the offset of the message id in @msgctxid
14364 * This function is a variant of g_dgettext() which supports
14365 * a disambiguating message context. GNU gettext uses the
14366 * '\004' character to separate the message context and
14367 * message id in @msgctxtid.
14368 * If 0 is passed as @msgidoffset, this function will fall back to
14369 * trying to use the deprecated convention of using "|" as a separation
14372 * This uses g_dgettext() internally. See that functions for differences
14373 * with dgettext() proper.
14375 * Applications should normally not use this function directly,
14376 * but use the C_() macro for translations with context.
14378 * Returns: The translated string
14385 * @domain: (allow-none): the translation domain to use, or %NULL to use
14386 * the domain set with textdomain()
14387 * @context: the message context
14388 * @msgid: the message
14390 * This function is a variant of g_dgettext() which supports
14391 * a disambiguating message context. GNU gettext uses the
14392 * '\004' character to separate the message context and
14393 * message id in @msgctxtid.
14395 * This uses g_dgettext() internally. See that functions for differences
14396 * with dgettext() proper.
14398 * This function differs from C_() in that it is not a macro and
14399 * thus you may use non-string-literals as context and msgid arguments.
14401 * Returns: The translated string
14407 * g_environ_getenv:
14408 * @envp: (allow-none) (array zero-terminated=1) (transfer none): an environment
14409 * list (eg, as returned from g_get_environ()), or %NULL
14410 * for an empty environment list
14411 * @variable: the environment variable to get, in the GLib file name
14414 * Returns the value of the environment variable @variable in the
14415 * provided list @envp.
14417 * Returns: the value of the environment variable, or %NULL if
14418 * the environment variable is not set in @envp. The returned
14419 * string is owned by @envp, and will be freed if @variable is
14420 * set or unset again.
14426 * g_environ_setenv:
14427 * @envp: (allow-none) (array zero-terminated=1) (transfer full): an
14428 * environment list that can be freed using g_strfreev() (e.g., as
14429 * returned from g_get_environ()), or %NULL for an empty
14431 * @variable: the environment variable to set, must not contain '='
14432 * @value: the value for to set the variable to
14433 * @overwrite: whether to change the variable if it already exists
14435 * Sets the environment variable @variable in the provided list
14438 * Returns: (array zero-terminated=1) (transfer full): the
14439 * updated environment list. Free it using g_strfreev().
14445 * g_environ_unsetenv:
14446 * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment
14447 * list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()),
14448 * or %NULL for an empty environment list
14449 * @variable: the environment variable to remove, must not contain '='
14451 * Removes the environment variable @variable from the provided
14452 * environment @envp.
14454 * Returns: (array zero-terminated=1) (transfer full): the
14455 * updated environment list. Free it using g_strfreev().
14462 * @...: format string, followed by parameters to insert
14463 * into the format string (as with printf())
14465 * A convenience function/macro to log an error message.
14467 * Error messages are always fatal, resulting in a call to
14468 * abort() to terminate the application. This function will
14469 * result in a core dump; don't use it for errors you expect.
14470 * Using this function indicates a bug in your program, i.e.
14471 * an assertion failure.
14473 * If g_log_default_handler() is used as the log handler function, a new-line
14474 * character will automatically be appended to @..., and need not be entered
14481 * @error: a #GError
14483 * Makes a copy of @error.
14485 * Returns: a new #GError
14491 * @error: a #GError
14493 * Frees a #GError and associated resources.
14499 * @error: (allow-none): a #GError or %NULL
14500 * @domain: an error domain
14501 * @code: an error code
14503 * Returns %TRUE if @error matches @domain and @code, %FALSE
14504 * otherwise. In particular, when @error is %NULL, %FALSE will
14507 * Returns: whether @error has @domain and @code
14513 * @domain: error domain
14514 * @code: error code
14515 * @format: printf()-style format for error message
14516 * @...: parameters for message format
14518 * Creates a new #GError with the given @domain and @code,
14519 * and a message formatted with @format.
14521 * Returns: a new #GError
14526 * g_error_new_literal:
14527 * @domain: error domain
14528 * @code: error code
14529 * @message: error message
14531 * Creates a new #GError; unlike g_error_new(), @message is
14532 * not a printf()-style format string. Use this function if
14533 * @message contains text you don't have control over,
14534 * that could include printf() escape sequences.
14536 * Returns: a new #GError
14541 * g_error_new_valist:
14542 * @domain: error domain
14543 * @code: error code
14544 * @format: printf()-style format for error message
14545 * @args: #va_list of parameters for the message format
14547 * Creates a new #GError with the given @domain and @code,
14548 * and a message formatted with @format.
14550 * Returns: a new #GError
14556 * g_file_error_from_errno:
14557 * @err_no: an "errno" value
14559 * Gets a #GFileError constant based on the passed-in @err_no.
14560 * For example, if you pass in <literal>EEXIST</literal> this function returns
14561 * #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
14562 * assume that all #GFileError values will exist.
14564 * Normally a #GFileError value goes into a #GError returned
14565 * from a function that manipulates files. So you would use
14566 * g_file_error_from_errno() when constructing a #GError.
14568 * Returns: #GFileError corresponding to the given @errno
14573 * g_file_get_contents:
14574 * @filename: (type filename): name of a file to read contents from, in the GLib file name encoding
14575 * @contents: (out) (array length=length) (element-type guint8): location to store an allocated string, use g_free() to free
14576 * the returned string
14577 * @length: (allow-none): location to store length in bytes of the contents, or %NULL
14578 * @error: return location for a #GError, or %NULL
14580 * Reads an entire file into allocated memory, with good error
14583 * If the call was successful, it returns %TRUE and sets @contents to the file
14584 * contents and @length to the length of the file contents in bytes. The string
14585 * stored in @contents will be nul-terminated, so for text files you can pass
14586 * %NULL for the @length argument. If the call was not successful, it returns
14587 * %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
14588 * codes are those in the #GFileError enumeration. In the error case,
14589 * @contents is set to %NULL and @length is set to zero.
14591 * Returns: %TRUE on success, %FALSE if an error occurred
14597 * @tmpl: (type filename) (allow-none): Template for file name, as in
14598 * g_mkstemp(), basename only, or %NULL for a default template
14599 * @name_used: (out) (type filename): location to store actual name used,
14601 * @error: return location for a #GError
14603 * Opens a file for writing in the preferred directory for temporary
14604 * files (as returned by g_get_tmp_dir()).
14606 * @tmpl should be a string in the GLib file name encoding containing
14607 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14608 * However, unlike these functions, the template should only be a
14609 * basename, no directory components are allowed. If template is
14610 * %NULL, a default template is used.
14612 * Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
14613 * modified, and might thus be a read-only literal string.
14615 * Upon success, and if @name_used is non-%NULL, the actual name used
14616 * is returned in @name_used. This string should be freed with g_free()
14617 * when not needed any longer. The returned name is in the GLib file
14620 * Returns: A file handle (as from open()) to the file opened for
14621 * reading and writing. The file is opened in binary mode on platforms
14622 * where there is a difference. The file handle should be closed with
14623 * close(). In case of errors, -1 is returned and @error will be set.
14628 * g_file_read_link:
14629 * @filename: the symbolic link
14630 * @error: return location for a #GError
14632 * Reads the contents of the symbolic link @filename like the POSIX
14633 * readlink() function. The returned string is in the encoding used
14634 * for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
14636 * Returns: A newly-allocated string with the contents of the symbolic link,
14637 * or %NULL if an error occurred.
14643 * g_file_set_contents:
14644 * @filename: (type filename): name of a file to write @contents to, in the GLib file name
14646 * @contents: (array length=length) (element-type guint8): string to write to the file
14647 * @length: length of @contents, or -1 if @contents is a nul-terminated string
14648 * @error: return location for a #GError, or %NULL
14650 * Writes all of @contents to a file named @filename, with good error checking.
14651 * If a file called @filename already exists it will be overwritten.
14653 * This write is atomic in the sense that it is first written to a temporary
14654 * file which is then renamed to the final name. Notes:
14657 * On Unix, if @filename already exists hard links to @filename will break.
14658 * Also since the file is recreated, existing permissions, access control
14659 * lists, metadata etc. may be lost. If @filename is a symbolic link,
14660 * the link itself will be replaced, not the linked file.
14663 * On Windows renaming a file will not remove an existing file with the
14664 * new name, so on Windows there is a race condition between the existing
14665 * file being removed and the temporary file being renamed.
14668 * On Windows there is no way to remove a file that is open to some
14669 * process, or mapped into memory. Thus, this function will fail if
14670 * @filename already exists and is open.
14674 * If the call was successful, it returns %TRUE. If the call was not successful,
14675 * it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
14676 * Possible error codes are those in the #GFileError enumeration.
14678 * Note that the name for the temporary file is constructed by appending up
14679 * to 7 characters to @filename.
14681 * Returns: %TRUE on success, %FALSE if an error occurred
14688 * @filename: a filename to test in the GLib file name encoding
14689 * @test: bitfield of #GFileTest flags
14691 * Returns %TRUE if any of the tests in the bitfield @test are
14692 * %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
14693 * G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
14694 * the check whether it's a directory doesn't matter since the existence
14695 * test is %TRUE. With the current set of available tests, there's no point
14696 * passing in more than one test at a time.
14698 * Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
14699 * so for a symbolic link to a regular file g_file_test() will return
14700 * %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
14702 * Note, that for a dangling symbolic link g_file_test() will return
14703 * %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
14705 * You should never use g_file_test() to test whether it is safe
14706 * to perform an operation, because there is always the possibility
14707 * of the condition changing before you actually perform the operation.
14708 * For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
14709 * to know whether it is safe to write to a file without being
14710 * tricked into writing into a different location. It doesn't work!
14712 * /* DON'T DO THIS */
14713 * if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
14715 * fd = g_open (filename, O_WRONLY);
14716 * /* write to fd */
14720 * Another thing to note is that %G_FILE_TEST_EXISTS and
14721 * %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
14722 * system call. This usually doesn't matter, but if your program
14723 * is setuid or setgid it means that these tests will give you
14724 * the answer for the real user ID and group ID, rather than the
14725 * effective user ID and group ID.
14727 * On Windows, there are no symlinks, so testing for
14728 * %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
14729 * %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
14730 * its name indicates that it is executable, checking for well-known
14731 * extensions and those listed in the <envar>PATHEXT</envar> environment variable.
14733 * Returns: whether a test was %TRUE
14738 * g_filename_display_basename:
14739 * @filename: an absolute pathname in the GLib file name encoding
14741 * Returns the display basename for the particular filename, guaranteed
14742 * to be valid UTF-8. The display name might not be identical to the filename,
14743 * for instance there might be problems converting it to UTF-8, and some files
14744 * can be translated in the display.
14746 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14747 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14748 * You can search the result for the UTF-8 encoding of this character (which is
14749 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14752 * You must pass the whole absolute pathname to this functions so that
14753 * translation of well known locations can be done.
14755 * This function is preferred over g_filename_display_name() if you know the
14756 * whole path, as it allows translation.
14758 * Returns: a newly allocated string containing
14759 * a rendition of the basename of the filename in valid UTF-8
14765 * g_filename_display_name:
14766 * @filename: a pathname hopefully in the GLib file name encoding
14768 * Converts a filename into a valid UTF-8 string. The conversion is
14769 * not necessarily reversible, so you should keep the original around
14770 * and use the return value of this function only for display purposes.
14771 * Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
14772 * even if the filename actually isn't in the GLib file name encoding.
14774 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14775 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14776 * You can search the result for the UTF-8 encoding of this character (which is
14777 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14780 * If you know the whole pathname of the file you should use
14781 * g_filename_display_basename(), since that allows location-based
14782 * translation of filenames.
14784 * Returns: a newly allocated string containing
14785 * a rendition of the filename in valid UTF-8
14791 * g_filename_from_uri:
14792 * @uri: a uri describing a filename (escaped, encoded in ASCII).
14793 * @hostname: (out) (allow-none): Location to store hostname for the URI, or %NULL.
14794 * If there is no hostname in the URI, %NULL will be
14795 * stored in this location.
14796 * @error: location to store the error occurring, or %NULL to ignore
14797 * errors. Any of the errors in #GConvertError may occur.
14799 * Converts an escaped ASCII-encoded URI to a local filename in the
14800 * encoding used for filenames.
14802 * Returns: (type filename): a newly-allocated string holding
14803 * the resulting filename, or %NULL on an error.
14808 * g_filename_from_utf8:
14809 * @utf8string: a UTF-8 encoded string.
14810 * @len: the length of the string, or -1 if the string is
14812 * @bytes_read: (out) (allow-none): location to store the number of bytes in
14813 * the input string that were successfully converted, or %NULL.
14814 * Even if the conversion was successful, this may be
14815 * less than @len if there were partial characters
14816 * at the end of the input. If the error
14817 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
14818 * stored will the byte offset after the last valid
14820 * @bytes_written: (out): the number of bytes stored in the output buffer (not
14821 * including the terminating nul).
14822 * @error: location to store the error occurring, or %NULL to ignore
14823 * errors. Any of the errors in #GConvertError may occur.
14825 * Converts a string from UTF-8 to the encoding GLib uses for
14826 * filenames. Note that on Windows GLib uses UTF-8 for filenames;
14827 * on other platforms, this function indirectly depends on the
14828 * <link linkend="setlocale">current locale</link>.
14830 * Returns: (array length=bytes_written) (element-type guint8) (transfer full):
14831 * The converted string, or %NULL on an error.
14836 * g_filename_to_uri:
14837 * @filename: an absolute filename specified in the GLib file name encoding,
14838 * which is the on-disk file name bytes on Unix, and UTF-8 on
14840 * @hostname: (allow-none): A UTF-8 encoded hostname, or %NULL for none.
14841 * @error: location to store the error occurring, or %NULL to ignore
14842 * errors. Any of the errors in #GConvertError may occur.
14844 * Converts an absolute filename to an escaped ASCII-encoded URI, with the path
14845 * component following Section 3.3. of RFC 2396.
14847 * Returns: a newly-allocated string holding the resulting
14848 * URI, or %NULL on an error.
14853 * g_filename_to_utf8:
14854 * @opsysstring: a string in the encoding for filenames
14855 * @len: the length of the string, or -1 if the string is
14856 * nul-terminated<footnoteref linkend="nul-unsafe"/>.
14857 * @bytes_read: location to store the number of bytes in the
14858 * input string that were successfully converted, or %NULL.
14859 * Even if the conversion was successful, this may be
14860 * less than @len if there were partial characters
14861 * at the end of the input. If the error
14862 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
14863 * stored will the byte offset after the last valid
14865 * @bytes_written: the number of bytes stored in the output buffer (not
14866 * including the terminating nul).
14867 * @error: location to store the error occurring, or %NULL to ignore
14868 * errors. Any of the errors in #GConvertError may occur.
14870 * Converts a string which is in the encoding used by GLib for
14871 * filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
14872 * for filenames; on other platforms, this function indirectly depends on
14873 * the <link linkend="setlocale">current locale</link>.
14875 * Returns: The converted string, or %NULL on an error.
14880 * g_find_program_in_path:
14881 * @program: a program name in the GLib file name encoding
14883 * Locates the first executable named @program in the user's path, in the
14884 * same way that execvp() would locate it. Returns an allocated string
14885 * with the absolute path name, or %NULL if the program is not found in
14886 * the path. If @program is already an absolute path, returns a copy of
14887 * @program if @program exists and is executable, and %NULL otherwise.
14889 * On Windows, if @program does not have a file type suffix, tries
14890 * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
14891 * the <envar>PATHEXT</envar> environment variable.
14893 * On Windows, it looks for the file in the same way as CreateProcess()
14894 * would. This means first in the directory where the executing
14895 * program was loaded from, then in the current directory, then in the
14896 * Windows 32-bit system directory, then in the Windows directory, and
14897 * finally in the directories in the <envar>PATH</envar> environment
14898 * variable. If the program is found, the return value contains the
14899 * full name including the type suffix.
14901 * Returns: a newly-allocated string with the absolute path, or %NULL
14907 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14908 * @mode: a string describing the mode in which the file should be
14911 * A wrapper for the stdio fopen() function. The fopen() function
14912 * opens a file and associates a new stream with it.
14914 * Because file descriptors are specific to the C library on Windows,
14915 * and a file descriptor is partof the <type>FILE</type> struct, the
14916 * <type>FILE</type> pointer returned by this function makes sense
14917 * only to functions in the same C library. Thus if the GLib-using
14918 * code uses a different C library than GLib does, the
14919 * <type>FILE</type> pointer returned by this function cannot be
14920 * passed to C library functions like fprintf() or fread().
14922 * See your C library manual for more details about fopen().
14924 * Returns: A <type>FILE</type> pointer if the file was successfully
14925 * opened, or %NULL if an error occurred
14932 * @size: a size in bytes
14934 * Formats a size (for example the size of a file) into a human readable
14935 * string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
14936 * and are displayed rounded to the nearest tenth. E.g. the file size
14937 * 3292528 bytes will be converted into the string "3.2 MB".
14939 * The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
14941 * This string should be freed with g_free() when not needed any longer.
14943 * See g_format_size_full() for more options about how the size might be
14946 * Returns: a newly-allocated formatted string containing a human readable
14953 * g_format_size_for_display:
14954 * @size: a size in bytes
14956 * Formats a size (for example the size of a file) into a human
14957 * readable string. Sizes are rounded to the nearest size prefix
14958 * (KB, MB, GB) and are displayed rounded to the nearest tenth.
14959 * E.g. the file size 3292528 bytes will be converted into the
14962 * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
14964 * This string should be freed with g_free() when not needed any longer.
14966 * Returns: a newly-allocated formatted string containing a human
14967 * readable file size
14969 * Deprecated: 2.30: This function is broken due to its use of SI
14970 * suffixes to denote IEC units. Use g_format_size() instead.
14975 * g_format_size_full:
14976 * @size: a size in bytes
14977 * @flags: #GFormatSizeFlags to modify the output
14981 * This function is similar to g_format_size() but allows for flags
14982 * that modify the output. See #GFormatSizeFlags.
14984 * Returns: a newly-allocated formatted string containing a human
14985 * readable file size
14992 * @file: the stream to write to.
14993 * @format: a standard printf() format string, but notice
14994 * <link linkend="string-precision">string precision pitfalls</link>.
14995 * @...: the arguments to insert in the output.
14997 * An implementation of the standard fprintf() function which supports
14998 * positional parameters, as specified in the Single Unix Specification.
15000 * Returns: the number of bytes printed.
15007 * @mem: the memory to free
15009 * Frees the memory pointed to by @mem.
15010 * If @mem is %NULL it simply returns.
15016 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
15017 * @mode: a string describing the mode in which the file should be
15019 * @stream: (allow-none): an existing stream which will be reused, or %NULL
15021 * A wrapper for the POSIX freopen() function. The freopen() function
15022 * opens a file and associates it with an existing stream.
15024 * See your C library manual for more details about freopen().
15026 * Returns: A <literal>FILE</literal> pointer if the file was successfully
15027 * opened, or %NULL if an error occurred.
15033 * g_get_application_name:
15035 * Gets a human-readable name for the application, as set by
15036 * g_set_application_name(). This name should be localized if
15037 * possible, and is intended for display to the user. Contrast with
15038 * g_get_prgname(), which gets a non-localized name. If
15039 * g_set_application_name() has not been called, returns the result of
15040 * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
15043 * Returns: human-readable application name. may return %NULL
15050 * @charset: return location for character set name
15052 * Obtains the character set for the <link linkend="setlocale">current
15053 * locale</link>; you might use this character set as an argument to
15054 * g_convert(), to convert from the current locale's encoding to some
15055 * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
15056 * are nice shortcuts, though.)
15058 * On Windows the character set returned by this function is the
15059 * so-called system default ANSI code-page. That is the character set
15060 * used by the "narrow" versions of C library and Win32 functions that
15061 * handle file names. It might be different from the character set
15062 * used by the C library's current locale.
15064 * The return value is %TRUE if the locale's encoding is UTF-8, in that
15065 * case you can perhaps avoid calling g_convert().
15067 * The string returned in @charset is not allocated, and should not be
15070 * Returns: %TRUE if the returned charset is UTF-8
15077 * Gets the character set for the current locale.
15079 * Returns: a newly allocated string containing the name
15080 * of the character set. This string must be freed with g_free().
15085 * g_get_current_dir:
15087 * Gets the current directory.
15089 * The returned string should be freed when no longer needed.
15090 * The encoding of the returned string is system defined.
15091 * On Windows, it is always UTF-8.
15093 * Returns: the current directory
15098 * g_get_current_time:
15099 * @result: #GTimeVal structure in which to store current time.
15101 * Equivalent to the UNIX gettimeofday() function, but portable.
15103 * You may find g_get_real_time() to be more convenient.
15110 * Gets the list of environment variables for the current process.
15112 * The list is %NULL terminated and each item in the list is of the
15113 * form 'NAME=VALUE'.
15115 * This is equivalent to direct access to the 'environ' global variable,
15118 * The return value is freshly allocated and it should be freed with
15119 * g_strfreev() when it is no longer needed.
15121 * Returns: (array zero-terminated=1) (transfer full): the list of
15122 * environment variables
15128 * g_get_filename_charsets:
15129 * @charsets: return location for the %NULL-terminated list of encoding names
15131 * Determines the preferred character sets used for filenames.
15132 * The first character set from the @charsets is the filename encoding, the
15133 * subsequent character sets are used when trying to generate a displayable
15134 * representation of a filename, see g_filename_display_name().
15136 * On Unix, the character sets are determined by consulting the
15137 * environment variables <envar>G_FILENAME_ENCODING</envar> and
15138 * <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
15139 * used in the GLib API is always UTF-8 and said environment variables
15142 * <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
15143 * of character set names. The special token "@locale" is taken to
15144 * mean the character set for the <link linkend="setlocale">current
15145 * locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
15146 * <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
15147 * locale is taken as the filename encoding. If neither environment variable
15148 * is set, UTF-8 is taken as the filename encoding, but the character
15149 * set of the current locale is also put in the list of encodings.
15151 * The returned @charsets belong to GLib and must not be freed.
15153 * Note that on Unix, regardless of the locale character set or
15154 * <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
15155 * on a system might be in any random encoding or just gibberish.
15157 * Returns: %TRUE if the filename encoding is UTF-8.
15165 * Gets the current user's home directory.
15167 * As with most UNIX tools, this function will return the value of the
15168 * <envar>HOME</envar> environment variable if it is set to an existing
15169 * absolute path name, falling back to the <filename>passwd</filename>
15170 * file in the case that it is unset.
15172 * If the path given in <envar>HOME</envar> is non-absolute, does not
15173 * exist, or is not a directory, the result is undefined.
15176 * Before version 2.36 this function would ignore the
15177 * <envar>HOME</envar> environment variable, taking the value from the
15178 * <filename>passwd</filename> database instead. This was changed to
15179 * increase the compatibility of GLib with other programs (and the XDG
15180 * basedir specification) and to increase testability of programs
15181 * based on GLib (by making it easier to run them from test
15184 * If your program has a strong requirement for either the new or the
15185 * old behaviour (and if you don't wish to increase your GLib
15186 * dependency to ensure that the new behaviour is in effect) then you
15187 * should either directly check the <envar>HOME</envar> environment
15188 * variable yourself or unset it before calling any functions in GLib.
15191 * Returns: the current user's home directory
15198 * Return a name for the machine.
15200 * The returned name is not necessarily a fully-qualified domain name,
15201 * or even present in DNS or some other name service at all. It need
15202 * not even be unique on your local network or site, but usually it
15203 * is. Callers should not rely on the return value having any specific
15204 * properties like uniqueness for security purposes. Even if the name
15205 * of the machine is changed while an application is running, the
15206 * return value from this function does not change. The returned
15207 * string is owned by GLib and should not be modified or freed. If no
15208 * name can be determined, a default fixed string "localhost" is
15211 * Returns: the host name of the machine.
15217 * g_get_language_names:
15219 * Computes a list of applicable locale names, which can be used to
15220 * e.g. construct locale-dependent filenames or search paths. The returned
15221 * list is sorted from most desirable to least desirable and always contains
15222 * the default locale "C".
15224 * For example, if LANGUAGE=de:en_US, then the returned list is
15225 * "de", "en_US", "en", "C".
15227 * This function consults the environment variables <envar>LANGUAGE</envar>,
15228 * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
15229 * to find the list of locales specified by the user.
15231 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib
15232 * that must not be modified or freed.
15238 * g_get_locale_variants:
15239 * @locale: a locale identifier
15241 * Returns a list of derived variants of @locale, which can be used to
15242 * e.g. construct locale-dependent filenames or search paths. The returned
15243 * list is sorted from most desirable to least desirable.
15244 * This function handles territory, charset and extra locale modifiers.
15246 * For example, if @locale is "fr_BE", then the returned list
15247 * is "fr_BE", "fr".
15249 * If you need the list of variants for the <emphasis>current locale</emphasis>,
15250 * use g_get_language_names().
15252 * Returns: (transfer full) (array zero-terminated=1) (element-type utf8): a newly
15253 * allocated array of newly allocated strings with the locale variants. Free with
15260 * g_get_monotonic_time:
15262 * Queries the system monotonic time, if available.
15264 * On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
15265 * is a very shallow wrapper for that. Otherwise, we make a best effort
15266 * that probably involves returning the wall clock time (with at least
15267 * microsecond accuracy, subject to the limitations of the OS kernel).
15269 * It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
15270 * not count time spent while the machine is suspended.
15272 * On Windows, "limitations of the OS kernel" is a rather substantial
15273 * statement. Depending on the configuration of the system, the wall
15274 * clock time is updated as infrequently as 64 times a second (which
15275 * is approximately every 16ms). Also, on XP (but not on Vista or later)
15276 * the monotonic clock is locally monotonic, but may differ in exact
15277 * value between processes due to timer wrap handling.
15279 * Returns: the monotonic time, in microseconds
15285 * g_get_num_processors:
15287 * Determine the approximate number of threads that the system will
15288 * schedule simultaneously for this process. This is intended to be
15289 * used as a parameter to g_thread_pool_new() for CPU bound tasks and
15292 * Returns: Number of schedulable threads, always greater than 0
15300 * Gets the name of the program. This name should <emphasis>not</emphasis>
15301 * be localized, contrast with g_get_application_name().
15302 * (If you are using GDK or GTK+ the program name is set in gdk_init(),
15303 * which is called by gtk_init(). The program name is found by taking
15304 * the last component of <literal>argv[0]</literal>.)
15306 * Returns: the name of the program. The returned string belongs
15307 * to GLib and must not be modified or freed.
15314 * Gets the real name of the user. This usually comes from the user's entry
15315 * in the <filename>passwd</filename> file. The encoding of the returned
15316 * string is system-defined. (On Windows, it is, however, always UTF-8.)
15317 * If the real user name cannot be determined, the string "Unknown" is
15320 * Returns: the user's real name.
15327 * Queries the system wall-clock time.
15329 * This call is functionally equivalent to g_get_current_time() except
15330 * that the return value is often more convenient than dealing with a
15333 * You should only use this call if you are actually interested in the real
15334 * wall-clock time. g_get_monotonic_time() is probably more useful for
15335 * measuring intervals.
15337 * Returns: the number of microseconds since January 1, 1970 UTC.
15343 * g_get_system_config_dirs:
15345 * Returns an ordered list of base directories in which to access
15346 * system-wide configuration information.
15348 * On UNIX platforms this is determined using the mechanisms described in
15349 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15350 * XDG Base Directory Specification</ulink>.
15351 * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
15353 * On Windows is the directory that contains application data for all users.
15354 * A typical path is C:\Documents and Settings\All Users\Application Data.
15355 * This folder is used for application data that is not user specific.
15356 * For example, an application can store a spell-check dictionary, a database
15357 * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
15358 * This information will not roam and is available to anyone using the computer.
15360 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must
15361 * not be modified or freed.
15367 * g_get_system_data_dirs:
15369 * Returns an ordered list of base directories in which to access
15370 * system-wide application data.
15372 * On UNIX platforms this is determined using the mechanisms described in
15373 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15374 * XDG Base Directory Specification</ulink>
15375 * In this case the list of directories retrieved will be XDG_DATA_DIRS.
15377 * On Windows the first elements in the list are the Application Data
15378 * and Documents folders for All Users. (These can be determined only
15379 * on Windows 2000 or later and are not present in the list on other
15380 * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
15381 * CSIDL_COMMON_DOCUMENTS.
15383 * Then follows the "share" subfolder in the installation folder for
15384 * the package containing the DLL that calls this function, if it can
15387 * Finally the list contains the "share" subfolder in the installation
15388 * folder for GLib, and in the installation folder for the package the
15389 * application's .exe file belongs to.
15391 * The installation folders above are determined by looking up the
15392 * folder where the module (DLL or EXE) in question is located. If the
15393 * folder's name is "bin", its parent is used, otherwise the folder
15396 * Note that on Windows the returned list can vary depending on where
15397 * this function is called.
15399 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must
15400 * not be modified or freed.
15408 * Gets the directory to use for temporary files.
15410 * On UNIX, this is taken from the <envar>TMPDIR</envar> environment
15411 * variable. If the variable is not set, <literal>P_tmpdir</literal> is
15412 * used, as defined by the system C library. Failing that, a hard-coded
15413 * default of "/tmp" is returned.
15415 * On Windows, the <envar>TEMP</envar> environment variable is used,
15416 * with the root directory of the Windows installation (eg: "C:\") used
15419 * The encoding of the returned string is system-defined. On Windows, it
15420 * is always UTF-8. The return value is never %NULL or the empty string.
15422 * Returns: the directory to use for temporary files.
15427 * g_get_user_cache_dir:
15429 * Returns a base directory in which to store non-essential, cached
15430 * data specific to particular user.
15432 * On UNIX platforms this is determined using the mechanisms described in
15433 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15434 * XDG Base Directory Specification</ulink>.
15435 * In this case the directory retrieved will be XDG_CACHE_HOME.
15437 * On Windows is the directory that serves as a common repository for
15438 * temporary Internet files. A typical path is
15439 * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
15440 * See documentation for CSIDL_INTERNET_CACHE.
15442 * Returns: a string owned by GLib that must not be modified
15449 * g_get_user_config_dir:
15451 * Returns a base directory in which to store user-specific application
15452 * configuration information such as user preferences and settings.
15454 * On UNIX platforms this is determined using the mechanisms described in
15455 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15456 * XDG Base Directory Specification</ulink>.
15457 * In this case the directory retrieved will be XDG_CONFIG_HOME.
15459 * On Windows this is the folder to use for local (as opposed to
15460 * roaming) application data. See documentation for
15461 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
15462 * what g_get_user_data_dir() returns.
15464 * Returns: a string owned by GLib that must not be modified
15471 * g_get_user_data_dir:
15473 * Returns a base directory in which to access application data such
15474 * as icons that is customized for a particular user.
15476 * On UNIX platforms this is determined using the mechanisms described in
15477 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15478 * XDG Base Directory Specification</ulink>.
15479 * In this case the directory retrieved will be XDG_DATA_HOME.
15481 * On Windows this is the folder to use for local (as opposed to
15482 * roaming) application data. See documentation for
15483 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
15484 * what g_get_user_config_dir() returns.
15486 * Returns: a string owned by GLib that must not be modified
15495 * Gets the user name of the current user. The encoding of the returned
15496 * string is system-defined. On UNIX, it might be the preferred file name
15497 * encoding, or something else, and there is no guarantee that it is even
15498 * consistent on a machine. On Windows, it is always UTF-8.
15500 * Returns: the user name of the current user.
15505 * g_get_user_runtime_dir:
15507 * Returns a directory that is unique to the current user on the local
15510 * On UNIX platforms this is determined using the mechanisms described in
15511 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15512 * XDG Base Directory Specification</ulink>. This is the directory
15513 * specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
15514 * In the case that this variable is not set, GLib will issue a warning
15515 * message to stderr and return the value of g_get_user_cache_dir().
15517 * On Windows this is the folder to use for local (as opposed to
15518 * roaming) application data. See documentation for
15519 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
15520 * what g_get_user_config_dir() returns.
15522 * Returns: a string owned by GLib that must not be modified or freed.
15528 * g_get_user_special_dir:
15529 * @directory: the logical id of special directory
15531 * Returns the full path of a special directory using its logical id.
15533 * On Unix this is done using the XDG special user directories.
15534 * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
15535 * falls back to <filename>$HOME/Desktop</filename> when XDG special
15536 * user directories have not been set up.
15538 * Depending on the platform, the user might be able to change the path
15539 * of the special directory without requiring the session to restart; GLib
15540 * will not reflect any change once the special directories are loaded.
15542 * Returns: the path to the specified special directory, or %NULL
15543 * if the logical id was not found. The returned string is owned by
15544 * GLib and should not be modified or freed.
15551 * @variable: the environment variable to get, in the GLib file name
15554 * Returns the value of an environment variable.
15556 * The name and value are in the GLib file name encoding. On UNIX,
15557 * this means the actual bytes which might or might not be in some
15558 * consistent character set and encoding. On Windows, it is in UTF-8.
15559 * On Windows, in case the environment variable's value contains
15560 * references to other environment variables, they are expanded.
15562 * Returns: the value of the environment variable, or %NULL if
15563 * the environment variable is not found. The returned string
15564 * may be overwritten by the next call to g_getenv(), g_setenv()
15570 * g_hash_table_add:
15571 * @hash_table: a #GHashTable
15572 * @key: a key to insert
15574 * This is a convenience function for using a #GHashTable as a set. It
15575 * is equivalent to calling g_hash_table_replace() with @key as both the
15576 * key and the value.
15578 * When a hash table only ever contains keys that have themselves as the
15579 * corresponding value it is able to be stored more efficiently. See
15580 * the discussion in the section description.
15587 * g_hash_table_contains:
15588 * @hash_table: a #GHashTable
15589 * @key: a key to check
15591 * Checks if @key is in @hash_table.
15598 * g_hash_table_destroy:
15599 * @hash_table: a #GHashTable
15601 * Destroys all keys and values in the #GHashTable and decrements its
15602 * reference count by 1. If keys and/or values are dynamically allocated,
15603 * you should either free them first or create the #GHashTable with destroy
15604 * notifiers using g_hash_table_new_full(). In the latter case the destroy
15605 * functions you supplied will be called on all keys and values during the
15606 * destruction phase.
15611 * g_hash_table_find:
15612 * @hash_table: a #GHashTable
15613 * @predicate: function to test the key/value pairs for a certain property
15614 * @user_data: user data to pass to the function
15616 * Calls the given function for key/value pairs in the #GHashTable
15617 * until @predicate returns %TRUE. The function is passed the key
15618 * and value of each pair, and the given @user_data parameter. The
15619 * hash table may not be modified while iterating over it (you can't
15620 * add/remove items).
15622 * Note, that hash tables are really only optimized for forward
15623 * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
15624 * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
15625 * once per every entry in a hash table) should probably be reworked
15626 * to use additional or different data structures for reverse lookups
15627 * (keep in mind that an O(n) find/foreach operation issued for all n
15628 * values in a hash table ends up needing O(n*n) operations).
15630 * Returns: (allow-none): The value of the first key/value pair is returned,
15631 * for which @predicate evaluates to %TRUE. If no pair with the
15632 * requested property is found, %NULL is returned.
15638 * g_hash_table_foreach:
15639 * @hash_table: a #GHashTable
15640 * @func: the function to call for each key/value pair
15641 * @user_data: user data to pass to the function
15643 * Calls the given function for each of the key/value pairs in the
15644 * #GHashTable. The function is passed the key and value of each
15645 * pair, and the given @user_data parameter. The hash table may not
15646 * be modified while iterating over it (you can't add/remove
15647 * items). To remove all items matching a predicate, use
15648 * g_hash_table_foreach_remove().
15650 * See g_hash_table_find() for performance caveats for linear
15651 * order searches in contrast to g_hash_table_lookup().
15656 * g_hash_table_foreach_remove:
15657 * @hash_table: a #GHashTable
15658 * @func: the function to call for each key/value pair
15659 * @user_data: user data to pass to the function
15661 * Calls the given function for each key/value pair in the
15662 * #GHashTable. If the function returns %TRUE, then the key/value
15663 * pair is removed from the #GHashTable. If you supplied key or
15664 * value destroy functions when creating the #GHashTable, they are
15665 * used to free the memory allocated for the removed keys and values.
15667 * See #GHashTableIter for an alternative way to loop over the
15668 * key/value pairs in the hash table.
15670 * Returns: the number of key/value pairs removed
15675 * g_hash_table_foreach_steal:
15676 * @hash_table: a #GHashTable
15677 * @func: the function to call for each key/value pair
15678 * @user_data: user data to pass to the function
15680 * Calls the given function for each key/value pair in the
15681 * #GHashTable. If the function returns %TRUE, then the key/value
15682 * pair is removed from the #GHashTable, but no key or value
15683 * destroy functions are called.
15685 * See #GHashTableIter for an alternative way to loop over the
15686 * key/value pairs in the hash table.
15688 * Returns: the number of key/value pairs removed.
15693 * g_hash_table_freeze:
15694 * @hash_table: a #GHashTable
15696 * This function is deprecated and will be removed in the next major
15697 * release of GLib. It does nothing.
15702 * g_hash_table_get_keys:
15703 * @hash_table: a #GHashTable
15705 * Retrieves every key inside @hash_table. The returned data is valid
15706 * until changes to the hash release those keys.
15708 * Returns: a #GList containing all the keys inside the hash
15709 * table. The content of the list is owned by the hash table and
15710 * should not be modified or freed. Use g_list_free() when done
15717 * g_hash_table_get_keys_as_array:
15718 * @hash_table: a #GHashTable
15719 * @length: (out): the length of the returned array
15721 * Retrieves every key inside @hash_table, as an array.
15723 * The returned array is %NULL-terminated but may contain %NULL as a
15724 * key. Use @length to determine the true length if it's possible that
15725 * %NULL was used as the value for a key.
15727 * Note: in the common case of a string-keyed #GHashTable, the return
15728 * value of this function can be conveniently cast to (gchar **).
15730 * You should always free the return result with g_free(). In the
15731 * above-mentioned case of a string-keyed hash table, it may be
15732 * appropriate to use g_strfreev() if you call g_hash_table_steal_all()
15733 * first to transfer ownership of the keys.
15735 * Returns: (array length=length) (transfer container): a
15736 * %NULL-terminated array containing each key from the table.
15742 * g_hash_table_get_values:
15743 * @hash_table: a #GHashTable
15745 * Retrieves every value inside @hash_table. The returned data
15746 * is valid until @hash_table is modified.
15748 * Returns: a #GList containing all the values inside the hash
15749 * table. The content of the list is owned by the hash table and
15750 * should not be modified or freed. Use g_list_free() when done
15757 * g_hash_table_insert:
15758 * @hash_table: a #GHashTable
15759 * @key: a key to insert
15760 * @value: the value to associate with the key
15762 * Inserts a new key and value into a #GHashTable.
15764 * If the key already exists in the #GHashTable its current
15765 * value is replaced with the new value. If you supplied a
15766 * @value_destroy_func when creating the #GHashTable, the old
15767 * value is freed using that function. If you supplied a
15768 * @key_destroy_func when creating the #GHashTable, the passed
15769 * key is freed using that function.
15774 * g_hash_table_iter_get_hash_table:
15775 * @iter: an initialized #GHashTableIter
15777 * Returns the #GHashTable associated with @iter.
15779 * Returns: the #GHashTable associated with @iter.
15785 * g_hash_table_iter_init:
15786 * @iter: an uninitialized #GHashTableIter
15787 * @hash_table: a #GHashTable
15789 * Initializes a key/value pair iterator and associates it with
15790 * @hash_table. Modifying the hash table after calling this function
15791 * invalidates the returned iterator.
15793 * GHashTableIter iter;
15794 * gpointer key, value;
15796 * g_hash_table_iter_init (&iter, hash_table);
15797 * while (g_hash_table_iter_next (&iter, &key, &value))
15799 * /* do something with key and value */
15808 * g_hash_table_iter_next:
15809 * @iter: an initialized #GHashTableIter
15810 * @key: (allow-none): a location to store the key, or %NULL
15811 * @value: (allow-none): a location to store the value, or %NULL
15813 * Advances @iter and retrieves the key and/or value that are now
15814 * pointed to as a result of this advancement. If %FALSE is returned,
15815 * @key and @value are not set, and the iterator becomes invalid.
15817 * Returns: %FALSE if the end of the #GHashTable has been reached.
15823 * g_hash_table_iter_remove:
15824 * @iter: an initialized #GHashTableIter
15826 * Removes the key/value pair currently pointed to by the iterator
15827 * from its associated #GHashTable. Can only be called after
15828 * g_hash_table_iter_next() returned %TRUE, and cannot be called
15829 * more than once for the same key/value pair.
15831 * If the #GHashTable was created using g_hash_table_new_full(),
15832 * the key and value are freed using the supplied destroy functions,
15833 * otherwise you have to make sure that any dynamically allocated
15834 * values are freed yourself.
15841 * g_hash_table_iter_replace:
15842 * @iter: an initialized #GHashTableIter
15843 * @value: the value to replace with
15845 * Replaces the value currently pointed to by the iterator
15846 * from its associated #GHashTable. Can only be called after
15847 * g_hash_table_iter_next() returned %TRUE.
15849 * If you supplied a @value_destroy_func when creating the
15850 * #GHashTable, the old value is freed using that function.
15857 * g_hash_table_iter_steal:
15858 * @iter: an initialized #GHashTableIter
15860 * Removes the key/value pair currently pointed to by the
15861 * iterator from its associated #GHashTable, without calling
15862 * the key and value destroy functions. Can only be called
15863 * after g_hash_table_iter_next() returned %TRUE, and cannot
15864 * be called more than once for the same key/value pair.
15871 * g_hash_table_lookup:
15872 * @hash_table: a #GHashTable
15873 * @key: the key to look up
15875 * Looks up a key in a #GHashTable. Note that this function cannot
15876 * distinguish between a key that is not present and one which is present
15877 * and has the value %NULL. If you need this distinction, use
15878 * g_hash_table_lookup_extended().
15880 * Returns: (allow-none): the associated value, or %NULL if the key is not found
15885 * g_hash_table_lookup_extended:
15886 * @hash_table: a #GHashTable
15887 * @lookup_key: the key to look up
15888 * @orig_key: (allow-none): return location for the original key, or %NULL
15889 * @value: (allow-none): return location for the value associated with the key, or %NULL
15891 * Looks up a key in the #GHashTable, returning the original key and the
15892 * associated value and a #gboolean which is %TRUE if the key was found. This
15893 * is useful if you need to free the memory allocated for the original key,
15894 * for example before calling g_hash_table_remove().
15896 * You can actually pass %NULL for @lookup_key to test
15897 * whether the %NULL key exists, provided the hash and equal functions
15898 * of @hash_table are %NULL-safe.
15900 * Returns: %TRUE if the key was found in the #GHashTable
15905 * g_hash_table_new:
15906 * @hash_func: a function to create a hash value from a key
15907 * @key_equal_func: a function to check two keys for equality
15909 * Creates a new #GHashTable with a reference count of 1.
15911 * Hash values returned by @hash_func are used to determine where keys
15912 * are stored within the #GHashTable data structure. The g_direct_hash(),
15913 * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
15914 * functions are provided for some common types of keys.
15915 * If @hash_func is %NULL, g_direct_hash() is used.
15917 * @key_equal_func is used when looking up keys in the #GHashTable.
15918 * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
15919 * and g_str_equal() functions are provided for the most common types
15920 * of keys. If @key_equal_func is %NULL, keys are compared directly in
15921 * a similar fashion to g_direct_equal(), but without the overhead of
15924 * Returns: a new #GHashTable
15929 * g_hash_table_new_full:
15930 * @hash_func: a function to create a hash value from a key
15931 * @key_equal_func: a function to check two keys for equality
15932 * @key_destroy_func: (allow-none): a function to free the memory allocated for the key
15933 * used when removing the entry from the #GHashTable, or %NULL
15934 * if you don't want to supply such a function.
15935 * @value_destroy_func: (allow-none): a function to free the memory allocated for the
15936 * value used when removing the entry from the #GHashTable, or %NULL
15937 * if you don't want to supply such a function.
15939 * Creates a new #GHashTable like g_hash_table_new() with a reference
15940 * count of 1 and allows to specify functions to free the memory
15941 * allocated for the key and value that get called when removing the
15942 * entry from the #GHashTable.
15944 * Returns: a new #GHashTable
15949 * g_hash_table_ref:
15950 * @hash_table: a valid #GHashTable
15952 * Atomically increments the reference count of @hash_table by one.
15953 * This function is MT-safe and may be called from any thread.
15955 * Returns: the passed in #GHashTable
15961 * g_hash_table_remove:
15962 * @hash_table: a #GHashTable
15963 * @key: the key to remove
15965 * Removes a key and its associated value from a #GHashTable.
15967 * If the #GHashTable was created using g_hash_table_new_full(), the
15968 * key and value are freed using the supplied destroy functions, otherwise
15969 * you have to make sure that any dynamically allocated values are freed
15972 * Returns: %TRUE if the key was found and removed from the #GHashTable
15977 * g_hash_table_remove_all:
15978 * @hash_table: a #GHashTable
15980 * Removes all keys and their associated values from a #GHashTable.
15982 * If the #GHashTable was created using g_hash_table_new_full(),
15983 * the keys and values are freed using the supplied destroy functions,
15984 * otherwise you have to make sure that any dynamically allocated
15985 * values are freed yourself.
15992 * g_hash_table_replace:
15993 * @hash_table: a #GHashTable
15994 * @key: a key to insert
15995 * @value: the value to associate with the key
15997 * Inserts a new key and value into a #GHashTable similar to
15998 * g_hash_table_insert(). The difference is that if the key
15999 * already exists in the #GHashTable, it gets replaced by the
16000 * new key. If you supplied a @value_destroy_func when creating
16001 * the #GHashTable, the old value is freed using that function.
16002 * If you supplied a @key_destroy_func when creating the
16003 * #GHashTable, the old key is freed using that function.
16008 * g_hash_table_size:
16009 * @hash_table: a #GHashTable
16011 * Returns the number of elements contained in the #GHashTable.
16013 * Returns: the number of key/value pairs in the #GHashTable.
16018 * g_hash_table_steal:
16019 * @hash_table: a #GHashTable
16020 * @key: the key to remove
16022 * Removes a key and its associated value from a #GHashTable without
16023 * calling the key and value destroy functions.
16025 * Returns: %TRUE if the key was found and removed from the #GHashTable
16030 * g_hash_table_steal_all:
16031 * @hash_table: a #GHashTable
16033 * Removes all keys and their associated values from a #GHashTable
16034 * without calling the key and value destroy functions.
16041 * g_hash_table_thaw:
16042 * @hash_table: a #GHashTable
16044 * This function is deprecated and will be removed in the next major
16045 * release of GLib. It does nothing.
16050 * g_hash_table_unref:
16051 * @hash_table: a valid #GHashTable
16053 * Atomically decrements the reference count of @hash_table by one.
16054 * If the reference count drops to 0, all keys and values will be
16055 * destroyed, and all memory allocated by the hash table is released.
16056 * This function is MT-safe and may be called from any thread.
16064 * @hmac: the #GHmac to copy
16066 * Copies a #GHmac. If @hmac has been closed, by calling
16067 * g_hmac_get_string() or g_hmac_get_digest(), the copied
16068 * HMAC will be closed as well.
16070 * Returns: the copy of the passed #GHmac. Use g_hmac_unref()
16071 * when finished using it.
16077 * g_hmac_get_digest:
16079 * @buffer: output buffer
16080 * @digest_len: an inout parameter. The caller initializes it to the
16081 * size of @buffer. After the call it contains the length of the digest
16083 * Gets the digest from @checksum as a raw binary array and places it
16084 * into @buffer. The size of the digest depends on the type of checksum.
16086 * Once this function has been called, the #GHmac is closed and can
16087 * no longer be updated with g_checksum_update().
16094 * g_hmac_get_string:
16097 * Gets the HMAC as an hexadecimal string.
16099 * Once this function has been called the #GHmac can no longer be
16100 * updated with g_hmac_update().
16102 * The hexadecimal characters will be lower case.
16104 * Returns: the hexadecimal representation of the HMAC. The
16105 * returned string is owned by the HMAC and should not be modified
16113 * @digest_type: the desired type of digest
16114 * @key: (array length=key_len): the key for the HMAC
16115 * @key_len: the length of the keys
16117 * Creates a new #GHmac, using the digest algorithm @digest_type.
16118 * If the @digest_type is not known, %NULL is returned.
16119 * A #GHmac can be used to compute the HMAC of a key and an
16120 * arbitrary binary blob, using different hashing algorithms.
16122 * A #GHmac works by feeding a binary blob through g_hmac_update()
16123 * until the data is complete; the digest can then be extracted
16124 * using g_hmac_get_string(), which will return the checksum as a
16125 * hexadecimal string; or g_hmac_get_digest(), which will return a
16126 * array of raw bytes. Once either g_hmac_get_string() or
16127 * g_hmac_get_digest() have been called on a #GHmac, the HMAC
16128 * will be closed and it won't be possible to call g_hmac_update()
16131 * Returns: the newly created #GHmac, or %NULL.
16132 * Use g_hmac_unref() to free the memory allocated by it.
16139 * @hmac: a valid #GHmac
16141 * Atomically increments the reference count of @hmac by one.
16143 * This function is MT-safe and may be called from any thread.
16145 * Returns: the passed in #GHmac.
16154 * Atomically decrements the reference count of @hmac by one.
16156 * If the reference count drops to 0, all keys and values will be
16157 * destroyed, and all memory allocated by the hash table is released.
16158 * This function is MT-safe and may be called from any thread.
16159 * Frees the memory allocated for @hmac.
16168 * @data: (array length=length): buffer used to compute the checksum
16169 * @length: size of the buffer, or -1 if it is a nul-terminated string
16171 * Feeds @data into an existing #GHmac.
16173 * The HMAC must still be open, that is g_hmac_get_string() or
16174 * g_hmac_get_digest() must not have been called on @hmac.
16182 * @hook_list: a #GHookList
16184 * Allocates space for a #GHook and initializes it.
16186 * Returns: a new #GHook
16192 * @hook_list: a #GHookList
16193 * @hook: the #GHook to add to the end of @hook_list
16195 * Appends a #GHook onto the end of a #GHookList.
16200 * g_hook_compare_ids:
16201 * @new_hook: a #GHook
16202 * @sibling: a #GHook to compare with @new_hook
16204 * Compares the ids of two #GHook elements, returning a negative value
16205 * if the second id is greater than the first.
16207 * Returns: a value <= 0 if the id of @sibling is >= the id of @new_hook
16213 * @hook_list: a #GHookList
16214 * @hook_id: a hook ID
16216 * Destroys a #GHook, given its ID.
16218 * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed
16223 * g_hook_destroy_link:
16224 * @hook_list: a #GHookList
16225 * @hook: the #GHook to remove
16227 * Removes one #GHook from a #GHookList, marking it
16228 * inactive and calling g_hook_unref() on it.
16234 * @hook_list: a #GHookList
16235 * @need_valids: %TRUE if #GHook elements which have been destroyed
16236 * should be skipped
16237 * @func: the function to call for each #GHook, which should return
16238 * %TRUE when the #GHook has been found
16239 * @data: the data to pass to @func
16241 * Finds a #GHook in a #GHookList using the given function to
16242 * test for a match.
16244 * Returns: the found #GHook or %NULL if no matching #GHook is found
16249 * g_hook_find_data:
16250 * @hook_list: a #GHookList
16251 * @need_valids: %TRUE if #GHook elements which have been destroyed
16252 * should be skipped
16253 * @data: the data to find
16255 * Finds a #GHook in a #GHookList with the given data.
16257 * Returns: the #GHook with the given @data or %NULL if no matching
16263 * g_hook_find_func:
16264 * @hook_list: a #GHookList
16265 * @need_valids: %TRUE if #GHook elements which have been destroyed
16266 * should be skipped
16267 * @func: the function to find
16269 * Finds a #GHook in a #GHookList with the given function.
16271 * Returns: the #GHook with the given @func or %NULL if no matching
16277 * g_hook_find_func_data:
16278 * @hook_list: a #GHookList
16279 * @need_valids: %TRUE if #GHook elements which have been destroyed
16280 * should be skipped
16281 * @func: the function to find
16282 * @data: the data to find
16284 * Finds a #GHook in a #GHookList with the given function and data.
16286 * Returns: the #GHook with the given @func and @data or %NULL if
16287 * no matching #GHook is found
16292 * g_hook_first_valid:
16293 * @hook_list: a #GHookList
16294 * @may_be_in_call: %TRUE if hooks which are currently running
16295 * (e.g. in another thread) are considered valid. If set to %FALSE,
16296 * these are skipped
16298 * Returns the first #GHook in a #GHookList which has not been destroyed.
16299 * The reference count for the #GHook is incremented, so you must call
16300 * g_hook_unref() to restore it when no longer needed. (Or call
16301 * g_hook_next_valid() if you are stepping through the #GHookList.)
16303 * Returns: the first valid #GHook, or %NULL if none are valid
16309 * @hook_list: a #GHookList
16310 * @hook: the #GHook to free
16312 * Calls the #GHookList @finalize_hook function if it exists,
16313 * and frees the memory allocated for the #GHook.
16319 * @hook_list: a #GHookList
16320 * @hook_id: a hook id
16322 * Returns the #GHook with the given id, or %NULL if it is not found.
16324 * Returns: the #GHook with the given id, or %NULL if it is not found
16329 * g_hook_insert_before:
16330 * @hook_list: a #GHookList
16331 * @sibling: the #GHook to insert the new #GHook before
16332 * @hook: the #GHook to insert
16334 * Inserts a #GHook into a #GHookList, before a given #GHook.
16339 * g_hook_insert_sorted:
16340 * @hook_list: a #GHookList
16341 * @hook: the #GHook to insert
16342 * @func: the comparison function used to sort the #GHook elements
16344 * Inserts a #GHook into a #GHookList, sorted by the given function.
16349 * g_hook_list_clear:
16350 * @hook_list: a #GHookList
16352 * Removes all the #GHook elements from a #GHookList.
16357 * g_hook_list_init:
16358 * @hook_list: a #GHookList
16359 * @hook_size: the size of each element in the #GHookList,
16360 * typically <literal>sizeof (GHook)</literal>
16362 * Initializes a #GHookList.
16363 * This must be called before the #GHookList is used.
16368 * g_hook_list_invoke:
16369 * @hook_list: a #GHookList
16370 * @may_recurse: %TRUE if functions which are already running
16371 * (e.g. in another thread) can be called. If set to %FALSE,
16372 * these are skipped
16374 * Calls all of the #GHook functions in a #GHookList.
16379 * g_hook_list_invoke_check:
16380 * @hook_list: a #GHookList
16381 * @may_recurse: %TRUE if functions which are already running
16382 * (e.g. in another thread) can be called. If set to %FALSE,
16383 * these are skipped
16385 * Calls all of the #GHook functions in a #GHookList.
16386 * Any function which returns %FALSE is removed from the #GHookList.
16391 * g_hook_list_marshal:
16392 * @hook_list: a #GHookList
16393 * @may_recurse: %TRUE if hooks which are currently running
16394 * (e.g. in another thread) are considered valid. If set to %FALSE,
16395 * these are skipped
16396 * @marshaller: the function to call for each #GHook
16397 * @marshal_data: data to pass to @marshaller
16399 * Calls a function on each valid #GHook.
16404 * g_hook_list_marshal_check:
16405 * @hook_list: a #GHookList
16406 * @may_recurse: %TRUE if hooks which are currently running
16407 * (e.g. in another thread) are considered valid. If set to %FALSE,
16408 * these are skipped
16409 * @marshaller: the function to call for each #GHook
16410 * @marshal_data: data to pass to @marshaller
16412 * Calls a function on each valid #GHook and destroys it if the
16413 * function returns %FALSE.
16418 * g_hook_next_valid:
16419 * @hook_list: a #GHookList
16420 * @hook: the current #GHook
16421 * @may_be_in_call: %TRUE if hooks which are currently running
16422 * (e.g. in another thread) are considered valid. If set to %FALSE,
16423 * these are skipped
16425 * Returns the next #GHook in a #GHookList which has not been destroyed.
16426 * The reference count for the #GHook is incremented, so you must call
16427 * g_hook_unref() to restore it when no longer needed. (Or continue to call
16428 * g_hook_next_valid() until %NULL is returned.)
16430 * Returns: the next valid #GHook, or %NULL if none are valid
16436 * @hook_list: a #GHookList
16437 * @hook: the #GHook to add to the start of @hook_list
16439 * Prepends a #GHook on the start of a #GHookList.
16445 * @hook_list: a #GHookList
16446 * @hook: the #GHook to increment the reference count of
16448 * Increments the reference count for a #GHook.
16450 * Returns: the @hook that was passed in (since 2.6)
16456 * @hook_list: a #GHookList
16457 * @hook: the #GHook to unref
16459 * Decrements the reference count of a #GHook.
16460 * If the reference count falls to 0, the #GHook is removed
16461 * from the #GHookList and g_hook_free() is called to free it.
16466 * g_hostname_is_ascii_encoded:
16467 * @hostname: a hostname
16469 * Tests if @hostname contains segments with an ASCII-compatible
16470 * encoding of an Internationalized Domain Name. If this returns
16471 * %TRUE, you should decode the hostname with g_hostname_to_unicode()
16472 * before displaying it to the user.
16474 * Note that a hostname might contain a mix of encoded and unencoded
16475 * segments, and so it is possible for g_hostname_is_non_ascii() and
16476 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
16478 * Returns: %TRUE if @hostname contains any ASCII-encoded
16485 * g_hostname_is_ip_address:
16486 * @hostname: a hostname (or IP address in string form)
16488 * Tests if @hostname is the string form of an IPv4 or IPv6 address.
16489 * (Eg, "192.168.0.1".)
16491 * Returns: %TRUE if @hostname is an IP address
16497 * g_hostname_is_non_ascii:
16498 * @hostname: a hostname
16500 * Tests if @hostname contains Unicode characters. If this returns
16501 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
16502 * before using it in non-IDN-aware contexts.
16504 * Note that a hostname might contain a mix of encoded and unencoded
16505 * segments, and so it is possible for g_hostname_is_non_ascii() and
16506 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
16508 * Returns: %TRUE if @hostname contains any non-ASCII characters
16514 * g_hostname_to_ascii:
16515 * @hostname: a valid UTF-8 or ASCII hostname
16517 * Converts @hostname to its canonical ASCII form; an ASCII-only
16518 * string containing no uppercase letters and not ending with a
16521 * Returns: an ASCII hostname, which must be freed, or %NULL if
16522 * @hostname is in some way invalid.
16528 * g_hostname_to_unicode:
16529 * @hostname: a valid UTF-8 or ASCII hostname
16531 * Converts @hostname to its canonical presentation form; a UTF-8
16532 * string in Unicode normalization form C, containing no uppercase
16533 * letters, no forbidden characters, and no ASCII-encoded segments,
16534 * and not ending with a trailing dot.
16536 * Of course if @hostname is not an internationalized hostname, then
16537 * the canonical presentation form will be entirely ASCII.
16539 * Returns: a UTF-8 hostname, which must be freed, or %NULL if
16540 * @hostname is in some way invalid.
16547 * @val: a 32-bit integer value in host byte order
16549 * Converts a 32-bit integer value from host to network byte order.
16551 * Returns: @val converted to network byte order
16557 * @val: a 16-bit integer value in host byte order
16559 * Converts a 16-bit integer value from host to network byte order.
16561 * Returns: @val converted to network byte order
16567 * @converter: conversion descriptor from g_iconv_open()
16568 * @inbuf: bytes to convert
16569 * @inbytes_left: inout parameter, bytes remaining to convert in @inbuf
16570 * @outbuf: converted output bytes
16571 * @outbytes_left: inout parameter, bytes available to fill in @outbuf
16573 * Same as the standard UNIX routine iconv(), but
16574 * may be implemented via libiconv on UNIX flavors that lack
16575 * a native implementation.
16577 * GLib provides g_convert() and g_locale_to_utf8() which are likely
16578 * more convenient than the raw iconv wrappers.
16580 * Returns: count of non-reversible conversions, or -1 on error
16586 * @converter: a conversion descriptor from g_iconv_open()
16588 * Same as the standard UNIX routine iconv_close(), but
16589 * may be implemented via libiconv on UNIX flavors that lack
16590 * a native implementation. Should be called to clean up
16591 * the conversion descriptor from g_iconv_open() when
16592 * you are done converting things.
16594 * GLib provides g_convert() and g_locale_to_utf8() which are likely
16595 * more convenient than the raw iconv wrappers.
16597 * Returns: -1 on error, 0 on success
16603 * @to_codeset: destination codeset
16604 * @from_codeset: source codeset
16606 * Same as the standard UNIX routine iconv_open(), but
16607 * may be implemented via libiconv on UNIX flavors that lack
16608 * a native implementation.
16610 * GLib provides g_convert() and g_locale_to_utf8() which are likely
16611 * more convenient than the raw iconv wrappers.
16613 * Returns: a "conversion descriptor", or (GIConv)-1 if
16614 * opening the converter failed.
16620 * @function: function to call
16621 * @data: data to pass to @function.
16623 * Adds a function to be called whenever there are no higher priority
16624 * events pending to the default main loop. The function is given the
16625 * default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
16626 * returns %FALSE it is automatically removed from the list of event
16627 * sources and will not be called again.
16629 * This internally creates a main loop source using g_idle_source_new()
16630 * and attaches it to the main loop context using g_source_attach().
16631 * You can do these steps manually if you need greater control.
16633 * Returns: the ID (greater than 0) of the event source.
16638 * g_idle_add_full: (rename-to g_idle_add)
16639 * @priority: the priority of the idle source. Typically this will be in the
16640 * range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
16641 * @function: function to call
16642 * @data: data to pass to @function
16643 * @notify: (allow-none): function to call when the idle is removed, or %NULL
16645 * Adds a function to be called whenever there are no higher priority
16646 * events pending. If the function returns %FALSE it is automatically
16647 * removed from the list of event sources and will not be called again.
16649 * This internally creates a main loop source using g_idle_source_new()
16650 * and attaches it to the main loop context using g_source_attach().
16651 * You can do these steps manually if you need greater control.
16653 * Returns: the ID (greater than 0) of the event source.
16658 * g_idle_remove_by_data:
16659 * @data: the data for the idle source's callback.
16661 * Removes the idle function with the given data.
16663 * Returns: %TRUE if an idle source was found and removed.
16668 * g_idle_source_new:
16670 * Creates a new idle source.
16672 * The source will not initially be associated with any #GMainContext
16673 * and must be added to one with g_source_attach() before it will be
16674 * executed. Note that the default priority for idle sources is
16675 * %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
16676 * have a default priority of %G_PRIORITY_DEFAULT.
16678 * Returns: the newly-created idle source
16684 * @v1: a pointer to a #gint64 key
16685 * @v2: a pointer to a #gint64 key to compare with @v1
16687 * Compares the two #gint64 values being pointed to and returns
16688 * %TRUE if they are equal.
16689 * It can be passed to g_hash_table_new() as the @key_equal_func
16690 * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
16693 * Returns: %TRUE if the two keys match.
16700 * @v: a pointer to a #gint64 key
16702 * Converts a pointer to a #gint64 to a hash value.
16704 * It can be passed to g_hash_table_new() as the @hash_func parameter,
16705 * when using non-%NULL pointers to 64-bit integer values as keys in a
16708 * Returns: a hash value corresponding to the key.
16715 * @v1: a pointer to a #gint key
16716 * @v2: a pointer to a #gint key to compare with @v1
16718 * Compares the two #gint values being pointed to and returns
16719 * %TRUE if they are equal.
16720 * It can be passed to g_hash_table_new() as the @key_equal_func
16721 * parameter, when using non-%NULL pointers to integers as keys in a
16724 * Note that this function acts on pointers to #gint, not on #gint directly:
16725 * if your hash table's keys are of the form
16726 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
16728 * Returns: %TRUE if the two keys match.
16734 * @v: a pointer to a #gint key
16736 * Converts a pointer to a #gint to a hash value.
16737 * It can be passed to g_hash_table_new() as the @hash_func parameter,
16738 * when using non-%NULL pointers to integer values as keys in a #GHashTable.
16740 * Note that this function acts on pointers to #gint, not on #gint directly:
16741 * if your hash table's keys are of the form
16742 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
16744 * Returns: a hash value corresponding to the key.
16749 * g_intern_static_string:
16750 * @string: (allow-none): a static string
16752 * Returns a canonical representation for @string. Interned strings
16753 * can be compared for equality by comparing the pointers, instead of
16754 * using strcmp(). g_intern_static_string() does not copy the string,
16755 * therefore @string must not be freed or modified.
16757 * Returns: a canonical representation for the string
16764 * @string: (allow-none): a string
16766 * Returns a canonical representation for @string. Interned strings
16767 * can be compared for equality by comparing the pointers, instead of
16770 * Returns: a canonical representation for the string
16777 * @channel: a #GIOChannel
16778 * @condition: the condition to watch for
16779 * @func: the function to call when the condition is satisfied
16780 * @user_data: user data to pass to @func
16782 * Adds the #GIOChannel into the default main loop context
16783 * with the default priority.
16785 * Returns: the event source id
16790 * g_io_add_watch_full: (rename-to g_io_add_watch)
16791 * @channel: a #GIOChannel
16792 * @priority: the priority of the #GIOChannel source
16793 * @condition: the condition to watch for
16794 * @func: the function to call when the condition is satisfied
16795 * @user_data: user data to pass to @func
16796 * @notify: the function to call when the source is removed
16798 * Adds the #GIOChannel into the default main loop context
16799 * with the given priority.
16801 * This internally creates a main loop source using g_io_create_watch()
16802 * and attaches it to the main loop context with g_source_attach().
16803 * You can do these steps manually if you need greater control.
16805 * Returns: the event source id
16810 * g_io_channel_close:
16811 * @channel: A #GIOChannel
16813 * Close an IO channel. Any pending data to be written will be
16814 * flushed, ignoring errors. The channel will not be freed until the
16815 * last reference is dropped using g_io_channel_unref().
16817 * Deprecated: 2.2: Use g_io_channel_shutdown() instead.
16822 * g_io_channel_error_from_errno:
16823 * @en: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
16825 * Converts an <literal>errno</literal> error number to a #GIOChannelError.
16827 * Returns: a #GIOChannelError error number, e.g.
16828 * %G_IO_CHANNEL_ERROR_INVAL.
16833 * g_io_channel_error_quark:
16835 * Returns: the quark used as %G_IO_CHANNEL_ERROR
16840 * g_io_channel_flush:
16841 * @channel: a #GIOChannel
16842 * @error: location to store an error of type #GIOChannelError
16844 * Flushes the write buffer for the GIOChannel.
16846 * Returns: the status of the operation: One of
16847 * #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
16848 * #G_IO_STATUS_ERROR.
16853 * g_io_channel_get_buffer_condition:
16854 * @channel: A #GIOChannel
16856 * This function returns a #GIOCondition depending on whether there
16857 * is data to be read/space to write data in the internal buffers in
16858 * the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
16860 * Returns: A #GIOCondition
16865 * g_io_channel_get_buffer_size:
16866 * @channel: a #GIOChannel
16868 * Gets the buffer size.
16870 * Returns: the size of the buffer.
16875 * g_io_channel_get_buffered:
16876 * @channel: a #GIOChannel
16878 * Returns whether @channel is buffered.
16880 * Returns: %TRUE if the @channel is buffered.
16885 * g_io_channel_get_close_on_unref:
16886 * @channel: a #GIOChannel.
16888 * Returns whether the file/socket/whatever associated with @channel
16889 * will be closed when @channel receives its final unref and is
16890 * destroyed. The default value of this is %TRUE for channels created
16891 * by g_io_channel_new_file (), and %FALSE for all other channels.
16893 * Returns: Whether the channel will be closed on the final unref of
16894 * the GIOChannel data structure.
16899 * g_io_channel_get_encoding:
16900 * @channel: a #GIOChannel
16902 * Gets the encoding for the input/output of the channel.
16903 * The internal encoding is always UTF-8. The encoding %NULL
16904 * makes the channel safe for binary data.
16906 * Returns: A string containing the encoding, this string is
16907 * owned by GLib and must not be freed.
16912 * g_io_channel_get_flags:
16913 * @channel: a #GIOChannel
16915 * Gets the current flags for a #GIOChannel, including read-only
16916 * flags such as %G_IO_FLAG_IS_READABLE.
16918 * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
16919 * are cached for internal use by the channel when it is created.
16920 * If they should change at some later point (e.g. partial shutdown
16921 * of a socket with the UNIX shutdown() function), the user
16922 * should immediately call g_io_channel_get_flags() to update
16923 * the internal values of these flags.
16925 * Returns: the flags which are set on the channel
16930 * g_io_channel_get_line_term:
16931 * @channel: a #GIOChannel
16932 * @length: a location to return the length of the line terminator
16934 * This returns the string that #GIOChannel uses to determine
16935 * where in the file a line break occurs. A value of %NULL
16936 * indicates autodetection.
16938 * Returns: The line termination string. This value
16939 * is owned by GLib and must not be freed.
16944 * g_io_channel_init:
16945 * @channel: a #GIOChannel
16947 * Initializes a #GIOChannel struct.
16949 * This is called by each of the above functions when creating a
16950 * #GIOChannel, and so is not often needed by the application
16951 * programmer (unless you are creating a new type of #GIOChannel).
16956 * g_io_channel_new_file:
16957 * @filename: A string containing the name of a file
16958 * @mode: One of "r", "w", "a", "r+", "w+", "a+". These have
16959 * the same meaning as in fopen()
16960 * @error: A location to return an error of type %G_FILE_ERROR
16962 * Open a file @filename as a #GIOChannel using mode @mode. This
16963 * channel will be closed when the last reference to it is dropped,
16964 * so there is no need to call g_io_channel_close() (though doing
16965 * so will not cause problems, as long as no attempt is made to
16966 * access the channel after it is closed).
16968 * Returns: A #GIOChannel on success, %NULL on failure.
16973 * g_io_channel_read:
16974 * @channel: a #GIOChannel
16975 * @buf: a buffer to read the data into (which should be at least
16976 * count bytes long)
16977 * @count: the number of bytes to read from the #GIOChannel
16978 * @bytes_read: returns the number of bytes actually read
16980 * Reads data from a #GIOChannel.
16982 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16983 * Deprecated: 2.2: Use g_io_channel_read_chars() instead.
16988 * g_io_channel_read_chars:
16989 * @channel: a #GIOChannel
16990 * @buf: (out caller-allocates) (array length=count) (element-type guint8):
16991 * a buffer to read data into
16992 * @count: (in): the size of the buffer. Note that the buffer may not be
16993 * complelely filled even if there is data in the buffer if the
16994 * remaining data is not a complete character.
16995 * @bytes_read: (allow-none) (out): The number of bytes read. This may be
16996 * zero even on success if count < 6 and the channel's encoding
16997 * is non-%NULL. This indicates that the next UTF-8 character is
16998 * too wide for the buffer.
16999 * @error: a location to return an error of type #GConvertError
17000 * or #GIOChannelError.
17002 * Replacement for g_io_channel_read() with the new API.
17004 * Returns: the status of the operation.
17009 * g_io_channel_read_line:
17010 * @channel: a #GIOChannel
17011 * @str_return: (out): The line read from the #GIOChannel, including the
17012 * line terminator. This data should be freed with g_free()
17013 * when no longer needed. This is a nul-terminated string.
17014 * If a @length of zero is returned, this will be %NULL instead.
17015 * @length: (allow-none) (out): location to store length of the read data, or %NULL
17016 * @terminator_pos: (allow-none) (out): location to store position of line terminator, or %NULL
17017 * @error: A location to return an error of type #GConvertError
17018 * or #GIOChannelError
17020 * Reads a line, including the terminating character(s),
17021 * from a #GIOChannel into a newly-allocated string.
17022 * @str_return will contain allocated memory if the return
17023 * is %G_IO_STATUS_NORMAL.
17025 * Returns: the status of the operation.
17030 * g_io_channel_read_line_string:
17031 * @channel: a #GIOChannel
17032 * @buffer: a #GString into which the line will be written.
17033 * If @buffer already contains data, the old data will
17035 * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
17036 * @error: a location to store an error of type #GConvertError
17037 * or #GIOChannelError
17039 * Reads a line from a #GIOChannel, using a #GString as a buffer.
17041 * Returns: the status of the operation.
17046 * g_io_channel_read_to_end:
17047 * @channel: a #GIOChannel
17048 * @str_return: (out) (array length=length) (element-type guint8): Location to
17049 * store a pointer to a string holding the remaining data in the
17050 * #GIOChannel. This data should be freed with g_free() when no
17051 * longer needed. This data is terminated by an extra nul
17052 * character, but there may be other nuls in the intervening data.
17053 * @length: (out): location to store length of the data
17054 * @error: location to return an error of type #GConvertError
17055 * or #GIOChannelError
17057 * Reads all the remaining data from the file.
17059 * Returns: %G_IO_STATUS_NORMAL on success.
17060 * This function never returns %G_IO_STATUS_EOF.
17065 * g_io_channel_read_unichar:
17066 * @channel: a #GIOChannel
17067 * @thechar: (out): a location to return a character
17068 * @error: a location to return an error of type #GConvertError
17069 * or #GIOChannelError
17071 * Reads a Unicode character from @channel.
17072 * This function cannot be called on a channel with %NULL encoding.
17074 * Returns: a #GIOStatus
17079 * g_io_channel_ref:
17080 * @channel: a #GIOChannel
17082 * Increments the reference count of a #GIOChannel.
17084 * Returns: the @channel that was passed in (since 2.6)
17089 * g_io_channel_seek:
17090 * @channel: a #GIOChannel
17091 * @offset: an offset, in bytes, which is added to the position specified
17093 * @type: the position in the file, which can be %G_SEEK_CUR (the current
17094 * position), %G_SEEK_SET (the start of the file), or %G_SEEK_END
17095 * (the end of the file)
17097 * Sets the current position in the #GIOChannel, similar to the standard
17098 * library function fseek().
17100 * Returns: %G_IO_ERROR_NONE if the operation was successful.
17101 * Deprecated: 2.2: Use g_io_channel_seek_position() instead.
17106 * g_io_channel_seek_position:
17107 * @channel: a #GIOChannel
17108 * @offset: The offset in bytes from the position specified by @type
17109 * @type: a #GSeekType. The type %G_SEEK_CUR is only allowed in those
17110 * cases where a call to g_io_channel_set_encoding ()
17111 * is allowed. See the documentation for
17112 * g_io_channel_set_encoding () for details.
17113 * @error: A location to return an error of type #GIOChannelError
17115 * Replacement for g_io_channel_seek() with the new API.
17117 * Returns: the status of the operation.
17122 * g_io_channel_set_buffer_size:
17123 * @channel: a #GIOChannel
17124 * @size: the size of the buffer, or 0 to let GLib pick a good size
17126 * Sets the buffer size.
17131 * g_io_channel_set_buffered:
17132 * @channel: a #GIOChannel
17133 * @buffered: whether to set the channel buffered or unbuffered
17135 * The buffering state can only be set if the channel's encoding
17136 * is %NULL. For any other encoding, the channel must be buffered.
17138 * A buffered channel can only be set unbuffered if the channel's
17139 * internal buffers have been flushed. Newly created channels or
17140 * channels which have returned %G_IO_STATUS_EOF
17141 * not require such a flush. For write-only channels, a call to
17142 * g_io_channel_flush () is sufficient. For all other channels,
17143 * the buffers may be flushed by a call to g_io_channel_seek_position ().
17144 * This includes the possibility of seeking with seek type %G_SEEK_CUR
17145 * and an offset of zero. Note that this means that socket-based
17146 * channels cannot be set unbuffered once they have had data
17149 * On unbuffered channels, it is safe to mix read and write
17150 * calls from the new and old APIs, if this is necessary for
17151 * maintaining old code.
17153 * The default state of the channel is buffered.
17158 * g_io_channel_set_close_on_unref:
17159 * @channel: a #GIOChannel
17160 * @do_close: Whether to close the channel on the final unref of
17161 * the GIOChannel data structure. The default value of
17162 * this is %TRUE for channels created by g_io_channel_new_file (),
17163 * and %FALSE for all other channels.
17165 * Setting this flag to %TRUE for a channel you have already closed
17166 * can cause problems.
17171 * g_io_channel_set_encoding:
17172 * @channel: a #GIOChannel
17173 * @encoding: (allow-none): the encoding type
17174 * @error: location to store an error of type #GConvertError
17176 * Sets the encoding for the input/output of the channel.
17177 * The internal encoding is always UTF-8. The default encoding
17178 * for the external file is UTF-8.
17180 * The encoding %NULL is safe to use with binary data.
17182 * The encoding can only be set if one of the following conditions
17186 * The channel was just created, and has not been written to or read
17188 * </para></listitem>
17190 * The channel is write-only.
17191 * </para></listitem>
17193 * The channel is a file, and the file pointer was just
17194 * repositioned by a call to g_io_channel_seek_position().
17195 * (This flushes all the internal buffers.)
17196 * </para></listitem>
17198 * The current encoding is %NULL or UTF-8.
17199 * </para></listitem>
17201 * One of the (new API) read functions has just returned %G_IO_STATUS_EOF
17202 * (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
17203 * </para></listitem>
17205 * One of the functions g_io_channel_read_chars() or
17206 * g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
17207 * %G_IO_STATUS_ERROR. This may be useful in the case of
17208 * %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
17209 * Returning one of these statuses from g_io_channel_read_line(),
17210 * g_io_channel_read_line_string(), or g_io_channel_read_to_end()
17211 * does <emphasis>not</emphasis> guarantee that the encoding can
17213 * </para></listitem>
17215 * Channels which do not meet one of the above conditions cannot call
17216 * g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
17217 * they are "seekable", cannot call g_io_channel_write_chars() after
17218 * calling one of the API "read" functions.
17220 * Returns: %G_IO_STATUS_NORMAL if the encoding was successfully set.
17225 * g_io_channel_set_flags:
17226 * @channel: a #GIOChannel
17227 * @flags: the flags to set on the IO channel
17228 * @error: A location to return an error of type #GIOChannelError
17230 * Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
17232 * Returns: the status of the operation.
17237 * g_io_channel_set_line_term:
17238 * @channel: a #GIOChannel
17239 * @line_term: (allow-none): The line termination string. Use %NULL for
17240 * autodetect. Autodetection breaks on "\n", "\r\n", "\r", "\0",
17241 * and the Unicode paragraph separator. Autodetection should not be
17242 * used for anything other than file-based channels.
17243 * @length: The length of the termination string. If -1 is passed, the
17244 * string is assumed to be nul-terminated. This option allows
17245 * termination strings with embedded nuls.
17247 * This sets the string that #GIOChannel uses to determine
17248 * where in the file a line break occurs.
17253 * g_io_channel_shutdown:
17254 * @channel: a #GIOChannel
17255 * @flush: if %TRUE, flush pending
17256 * @err: location to store a #GIOChannelError
17258 * Close an IO channel. Any pending data to be written will be
17259 * flushed if @flush is %TRUE. The channel will not be freed until the
17260 * last reference is dropped using g_io_channel_unref().
17262 * Returns: the status of the operation.
17267 * g_io_channel_unix_get_fd:
17268 * @channel: a #GIOChannel, created with g_io_channel_unix_new().
17270 * Returns the file descriptor of the #GIOChannel.
17272 * On Windows this function returns the file descriptor or socket of
17275 * Returns: the file descriptor of the #GIOChannel.
17280 * g_io_channel_unix_new:
17281 * @fd: a file descriptor.
17283 * Creates a new #GIOChannel given a file descriptor. On UNIX systems
17284 * this works for plain files, pipes, and sockets.
17286 * The returned #GIOChannel has a reference count of 1.
17288 * The default encoding for #GIOChannel is UTF-8. If your application
17289 * is reading output from a command using via pipe, you may need to set
17290 * the encoding to the encoding of the current locale (see
17291 * g_get_charset()) with the g_io_channel_set_encoding() function.
17293 * If you want to read raw binary data without interpretation, then
17294 * call the g_io_channel_set_encoding() function with %NULL for the
17295 * encoding argument.
17297 * This function is available in GLib on Windows, too, but you should
17298 * avoid using it on Windows. The domain of file descriptors and
17299 * sockets overlap. There is no way for GLib to know which one you mean
17300 * in case the argument you pass to this function happens to be both a
17301 * valid file descriptor and socket. If that happens a warning is
17302 * issued, and GLib assumes that it is the file descriptor you mean.
17304 * Returns: a new #GIOChannel.
17309 * g_io_channel_unref:
17310 * @channel: a #GIOChannel
17312 * Decrements the reference count of a #GIOChannel.
17317 * g_io_channel_win32_new_fd:
17318 * @fd: a C library file descriptor.
17320 * Creates a new #GIOChannel given a file descriptor on Windows. This
17321 * works for file descriptors from the C runtime.
17323 * This function works for file descriptors as returned by the open(),
17324 * creat(), pipe() and fileno() calls in the Microsoft C runtime. In
17325 * order to meaningfully use this function your code should use the
17326 * same C runtime as GLib uses, which is msvcrt.dll. Note that in
17327 * current Microsoft compilers it is near impossible to convince it to
17328 * build code that would use msvcrt.dll. The last Microsoft compiler
17329 * version that supported using msvcrt.dll as the C runtime was version
17330 * 6. The GNU compiler and toolchain for Windows, also known as Mingw,
17331 * fully supports msvcrt.dll.
17333 * If you have created a #GIOChannel for a file descriptor and started
17334 * watching (polling) it, you shouldn't call read() on the file
17335 * descriptor. This is because adding polling for a file descriptor is
17336 * implemented in GLib on Windows by starting a thread that sits
17337 * blocked in a read() from the file descriptor most of the time. All
17338 * reads from the file descriptor should be done by this internal GLib
17339 * thread. Your code should call only g_io_channel_read().
17341 * This function is available only in GLib on Windows.
17343 * Returns: a new #GIOChannel.
17348 * g_io_channel_win32_new_messages:
17349 * @hwnd: a window handle.
17351 * Creates a new #GIOChannel given a window handle on Windows.
17353 * This function creates a #GIOChannel that can be used to poll for
17354 * Windows messages for the window in question.
17356 * Returns: a new #GIOChannel.
17361 * g_io_channel_win32_new_socket:
17362 * @socket: a Winsock socket
17364 * Creates a new #GIOChannel given a socket on Windows.
17366 * This function works for sockets created by Winsock. It's available
17367 * only in GLib on Windows.
17369 * Polling a #GSource created to watch a channel for a socket puts the
17370 * socket in non-blocking mode. This is a side-effect of the
17371 * implementation and unavoidable.
17373 * Returns: a new #GIOChannel
17378 * g_io_channel_write:
17379 * @channel: a #GIOChannel
17380 * @buf: the buffer containing the data to write
17381 * @count: the number of bytes to write
17382 * @bytes_written: the number of bytes actually written
17384 * Writes data to a #GIOChannel.
17386 * Returns: %G_IO_ERROR_NONE if the operation was successful.
17387 * Deprecated: 2.2: Use g_io_channel_write_chars() instead.
17392 * g_io_channel_write_chars:
17393 * @channel: a #GIOChannel
17394 * @buf: (array) (element-type guint8): a buffer to write data from
17395 * @count: the size of the buffer. If -1, the buffer
17396 * is taken to be a nul-terminated string.
17397 * @bytes_written: (out): The number of bytes written. This can be nonzero
17398 * even if the return value is not %G_IO_STATUS_NORMAL.
17399 * If the return value is %G_IO_STATUS_NORMAL and the
17400 * channel is blocking, this will always be equal
17401 * to @count if @count >= 0.
17402 * @error: a location to return an error of type #GConvertError
17403 * or #GIOChannelError
17405 * Replacement for g_io_channel_write() with the new API.
17407 * On seekable channels with encodings other than %NULL or UTF-8, generic
17408 * mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
17409 * may only be made on a channel from which data has been read in the
17410 * cases described in the documentation for g_io_channel_set_encoding ().
17412 * Returns: the status of the operation.
17417 * g_io_channel_write_unichar:
17418 * @channel: a #GIOChannel
17419 * @thechar: a character
17420 * @error: location to return an error of type #GConvertError
17421 * or #GIOChannelError
17423 * Writes a Unicode character to @channel.
17424 * This function cannot be called on a channel with %NULL encoding.
17426 * Returns: a #GIOStatus
17431 * g_io_create_watch:
17432 * @channel: a #GIOChannel to watch
17433 * @condition: conditions to watch for
17435 * Creates a #GSource that's dispatched when @condition is met for the
17436 * given @channel. For example, if condition is #G_IO_IN, the source will
17437 * be dispatched when there's data available for reading.
17439 * g_io_add_watch() is a simpler interface to this same functionality, for
17440 * the case where you want to add the source to the default main loop context
17441 * at the default priority.
17443 * On Windows, polling a #GSource created to watch a channel for a socket
17444 * puts the socket in non-blocking mode. This is a side-effect of the
17445 * implementation and unavoidable.
17447 * Returns: a new #GSource
17452 * g_key_file_free: (skip)
17453 * @key_file: a #GKeyFile
17455 * Clears all keys and groups from @key_file, and decreases the
17456 * reference count by 1. If the reference count reaches zero,
17457 * frees the key file and all its allocated memory.
17464 * g_key_file_get_boolean:
17465 * @key_file: a #GKeyFile
17466 * @group_name: a group name
17468 * @error: return location for a #GError
17470 * Returns the value associated with @key under @group_name as a
17473 * If @key cannot be found then %FALSE is returned and @error is set
17474 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
17475 * associated with @key cannot be interpreted as a boolean then %FALSE
17476 * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17478 * Returns: the value associated with the key as a boolean,
17479 * or %FALSE if the key was not found or could not be parsed.
17485 * g_key_file_get_boolean_list:
17486 * @key_file: a #GKeyFile
17487 * @group_name: a group name
17489 * @length: (out): the number of booleans returned
17490 * @error: return location for a #GError
17492 * Returns the values associated with @key under @group_name as
17495 * If @key cannot be found then %NULL is returned and @error is set to
17496 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17497 * with @key cannot be interpreted as booleans then %NULL is returned
17498 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17500 * Returns: (array length=length) (element-type gboolean) (transfer container):
17501 * the values associated with the key as a list of booleans, or %NULL if the
17502 * key was not found or could not be parsed. The returned list of booleans
17503 * should be freed with g_free() when no longer needed.
17509 * g_key_file_get_comment:
17510 * @key_file: a #GKeyFile
17511 * @group_name: (allow-none): a group name, or %NULL
17513 * @error: return location for a #GError
17515 * Retrieves a comment above @key from @group_name.
17516 * If @key is %NULL then @comment will be read from above
17517 * @group_name. If both @key and @group_name are %NULL, then
17518 * @comment will be read from above the first group in the file.
17520 * Returns: a comment that should be freed with g_free()
17526 * g_key_file_get_double:
17527 * @key_file: a #GKeyFile
17528 * @group_name: a group name
17530 * @error: return location for a #GError
17532 * Returns the value associated with @key under @group_name as a
17533 * double. If @group_name is %NULL, the start_group is used.
17535 * If @key cannot be found then 0.0 is returned and @error is set to
17536 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
17537 * with @key cannot be interpreted as a double then 0.0 is returned
17538 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17540 * Returns: the value associated with the key as a double, or
17541 * 0.0 if the key was not found or could not be parsed.
17547 * g_key_file_get_double_list:
17548 * @key_file: a #GKeyFile
17549 * @group_name: a group name
17551 * @length: (out): the number of doubles returned
17552 * @error: return location for a #GError
17554 * Returns the values associated with @key under @group_name as
17557 * If @key cannot be found then %NULL is returned and @error is set to
17558 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17559 * with @key cannot be interpreted as doubles then %NULL is returned
17560 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17562 * Returns: (array length=length) (element-type gdouble) (transfer container):
17563 * the values associated with the key as a list of doubles, or %NULL if the
17564 * key was not found or could not be parsed. The returned list of doubles
17565 * should be freed with g_free() when no longer needed.
17571 * g_key_file_get_groups:
17572 * @key_file: a #GKeyFile
17573 * @length: (out) (allow-none): return location for the number of returned groups, or %NULL
17575 * Returns all groups in the key file loaded with @key_file.
17576 * The array of returned groups will be %NULL-terminated, so
17577 * @length may optionally be %NULL.
17579 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings.
17580 * Use g_strfreev() to free it.
17586 * g_key_file_get_int64:
17587 * @key_file: a non-%NULL #GKeyFile
17588 * @group_name: a non-%NULL group name
17589 * @key: a non-%NULL key
17590 * @error: return location for a #GError
17592 * Returns the value associated with @key under @group_name as a signed
17593 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17594 * 64-bit results without truncation.
17596 * Returns: the value associated with the key as a signed 64-bit integer, or
17597 * 0 if the key was not found or could not be parsed.
17603 * g_key_file_get_integer:
17604 * @key_file: a #GKeyFile
17605 * @group_name: a group name
17607 * @error: return location for a #GError
17609 * Returns the value associated with @key under @group_name as an
17612 * If @key cannot be found then 0 is returned and @error is set to
17613 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
17614 * with @key cannot be interpreted as an integer then 0 is returned
17615 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17617 * Returns: the value associated with the key as an integer, or
17618 * 0 if the key was not found or could not be parsed.
17624 * g_key_file_get_integer_list:
17625 * @key_file: a #GKeyFile
17626 * @group_name: a group name
17628 * @length: (out): the number of integers returned
17629 * @error: return location for a #GError
17631 * Returns the values associated with @key under @group_name as
17634 * If @key cannot be found then %NULL is returned and @error is set to
17635 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17636 * with @key cannot be interpreted as integers then %NULL is returned
17637 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17639 * Returns: (array length=length) (element-type gint) (transfer container):
17640 * the values associated with the key as a list of integers, or %NULL if
17641 * the key was not found or could not be parsed. The returned list of
17642 * integers should be freed with g_free() when no longer needed.
17648 * g_key_file_get_keys:
17649 * @key_file: a #GKeyFile
17650 * @group_name: a group name
17651 * @length: (out) (allow-none): return location for the number of keys returned, or %NULL
17652 * @error: return location for a #GError, or %NULL
17654 * Returns all keys for the group name @group_name. The array of
17655 * returned keys will be %NULL-terminated, so @length may
17656 * optionally be %NULL. In the event that the @group_name cannot
17657 * be found, %NULL is returned and @error is set to
17658 * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17660 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings.
17661 * Use g_strfreev() to free it.
17667 * g_key_file_get_locale_string:
17668 * @key_file: a #GKeyFile
17669 * @group_name: a group name
17671 * @locale: (allow-none): a locale identifier or %NULL
17672 * @error: return location for a #GError, or %NULL
17674 * Returns the value associated with @key under @group_name
17675 * translated in the given @locale if available. If @locale is
17676 * %NULL then the current locale is assumed.
17678 * If @key cannot be found then %NULL is returned and @error is set
17679 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
17680 * with @key cannot be interpreted or no suitable translation can
17681 * be found then the untranslated value is returned.
17683 * Returns: a newly allocated string or %NULL if the specified
17684 * key cannot be found.
17690 * g_key_file_get_locale_string_list:
17691 * @key_file: a #GKeyFile
17692 * @group_name: a group name
17694 * @locale: (allow-none): a locale identifier or %NULL
17695 * @length: (out) (allow-none): return location for the number of returned strings or %NULL
17696 * @error: return location for a #GError or %NULL
17698 * Returns the values associated with @key under @group_name
17699 * translated in the given @locale if available. If @locale is
17700 * %NULL then the current locale is assumed.
17702 * If @key cannot be found then %NULL is returned and @error is set
17703 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
17704 * with @key cannot be interpreted or no suitable translations
17705 * can be found then the untranslated values are returned. The
17706 * returned array is %NULL-terminated, so @length may optionally
17709 * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full): a newly allocated %NULL-terminated string array
17710 * or %NULL if the key isn't found. The string array should be freed
17711 * with g_strfreev().
17717 * g_key_file_get_start_group:
17718 * @key_file: a #GKeyFile
17720 * Returns the name of the start group of the file.
17722 * Returns: The start group of the key file.
17728 * g_key_file_get_string:
17729 * @key_file: a #GKeyFile
17730 * @group_name: a group name
17732 * @error: return location for a #GError, or %NULL
17734 * Returns the string value associated with @key under @group_name.
17735 * Unlike g_key_file_get_value(), this function handles escape sequences
17738 * In the event the key cannot be found, %NULL is returned and
17739 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17740 * event that the @group_name cannot be found, %NULL is returned
17741 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17743 * Returns: a newly allocated string or %NULL if the specified
17744 * key cannot be found.
17750 * g_key_file_get_string_list:
17751 * @key_file: a #GKeyFile
17752 * @group_name: a group name
17754 * @length: (out) (allow-none): return location for the number of returned strings, or %NULL
17755 * @error: return location for a #GError, or %NULL
17757 * Returns the values associated with @key under @group_name.
17759 * In the event the key cannot be found, %NULL is returned and
17760 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17761 * event that the @group_name cannot be found, %NULL is returned
17762 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17764 * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full):
17765 * a %NULL-terminated string array or %NULL if the specified
17766 * key cannot be found. The array should be freed with g_strfreev().
17772 * g_key_file_get_uint64:
17773 * @key_file: a non-%NULL #GKeyFile
17774 * @group_name: a non-%NULL group name
17775 * @key: a non-%NULL key
17776 * @error: return location for a #GError
17778 * Returns the value associated with @key under @group_name as an unsigned
17779 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17780 * large positive results without truncation.
17782 * Returns: the value associated with the key as an unsigned 64-bit integer,
17783 * or 0 if the key was not found or could not be parsed.
17789 * g_key_file_get_value:
17790 * @key_file: a #GKeyFile
17791 * @group_name: a group name
17793 * @error: return location for a #GError, or %NULL
17795 * Returns the raw value associated with @key under @group_name.
17796 * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
17798 * In the event the key cannot be found, %NULL is returned and
17799 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17800 * event that the @group_name cannot be found, %NULL is returned
17801 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17803 * Returns: a newly allocated string or %NULL if the specified
17804 * key cannot be found.
17810 * g_key_file_has_group:
17811 * @key_file: a #GKeyFile
17812 * @group_name: a group name
17814 * Looks whether the key file has the group @group_name.
17816 * Returns: %TRUE if @group_name is a part of @key_file, %FALSE
17823 * g_key_file_has_key: (skip)
17824 * @key_file: a #GKeyFile
17825 * @group_name: a group name
17827 * @error: return location for a #GError
17829 * Looks whether the key file has the key @key in the group
17832 * <note>This function does not follow the rules for #GError strictly;
17833 * the return value both carries meaning and signals an error. To use
17834 * this function, you must pass a #GError pointer in @error, and check
17835 * whether it is not %NULL to see if an error occurred.</note>
17837 * Language bindings should use g_key_file_get_value() to test whether
17838 * or not a key exists.
17840 * Returns: %TRUE if @key is a part of @group_name, %FALSE
17847 * g_key_file_load_from_data:
17848 * @key_file: an empty #GKeyFile struct
17849 * @data: key file loaded in memory
17850 * @length: the length of @data in bytes (or -1 if data is nul-terminated)
17851 * @flags: flags from #GKeyFileFlags
17852 * @error: return location for a #GError, or %NULL
17854 * Loads a key file from memory into an empty #GKeyFile structure.
17855 * If the object cannot be created then %error is set to a #GKeyFileError.
17857 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17863 * g_key_file_load_from_data_dirs:
17864 * @key_file: an empty #GKeyFile struct
17865 * @file: (type filename): a relative path to a filename to open and parse
17866 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path
17867 * of the file, or %NULL
17868 * @flags: flags from #GKeyFileFlags
17869 * @error: return location for a #GError, or %NULL
17871 * This function looks for a key file named @file in the paths
17872 * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
17873 * loads the file into @key_file and returns the file's full path in
17874 * @full_path. If the file could not be loaded then an %error is
17875 * set to either a #GFileError or #GKeyFileError.
17877 * Returns: %TRUE if a key file could be loaded, %FALSE othewise
17883 * g_key_file_load_from_dirs:
17884 * @key_file: an empty #GKeyFile struct
17885 * @file: (type filename): a relative path to a filename to open and parse
17886 * @search_dirs: (array zero-terminated=1) (element-type filename): %NULL-terminated array of directories to search
17887 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path
17888 * of the file, or %NULL
17889 * @flags: flags from #GKeyFileFlags
17890 * @error: return location for a #GError, or %NULL
17892 * This function looks for a key file named @file in the paths
17893 * specified in @search_dirs, loads the file into @key_file and
17894 * returns the file's full path in @full_path. If the file could not
17895 * be loaded then an %error is set to either a #GFileError or
17898 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17904 * g_key_file_load_from_file:
17905 * @key_file: an empty #GKeyFile struct
17906 * @file: (type filename): the path of a filename to load, in the GLib filename encoding
17907 * @flags: flags from #GKeyFileFlags
17908 * @error: return location for a #GError, or %NULL
17910 * Loads a key file into an empty #GKeyFile structure.
17911 * If the file could not be loaded then @error is set to
17912 * either a #GFileError or #GKeyFileError.
17914 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17922 * Creates a new empty #GKeyFile object. Use
17923 * g_key_file_load_from_file(), g_key_file_load_from_data(),
17924 * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
17925 * read an existing key file.
17927 * Returns: (transfer full): an empty #GKeyFile.
17933 * g_key_file_ref: (skip)
17934 * @key_file: a #GKeyFile
17936 * Increases the reference count of @key_file.
17938 * Returns: the same @key_file.
17944 * g_key_file_remove_comment:
17945 * @key_file: a #GKeyFile
17946 * @group_name: (allow-none): a group name, or %NULL
17947 * @key: (allow-none): a key
17948 * @error: return location for a #GError
17950 * Removes a comment above @key from @group_name.
17951 * If @key is %NULL then @comment will be removed above @group_name.
17952 * If both @key and @group_name are %NULL, then @comment will
17953 * be removed above the first group in the file.
17955 * Returns: %TRUE if the comment was removed, %FALSE otherwise
17961 * g_key_file_remove_group:
17962 * @key_file: a #GKeyFile
17963 * @group_name: a group name
17964 * @error: return location for a #GError or %NULL
17966 * Removes the specified group, @group_name,
17967 * from the key file.
17969 * Returns: %TRUE if the group was removed, %FALSE otherwise
17975 * g_key_file_remove_key:
17976 * @key_file: a #GKeyFile
17977 * @group_name: a group name
17978 * @key: a key name to remove
17979 * @error: return location for a #GError or %NULL
17981 * Removes @key in @group_name from the key file.
17983 * Returns: %TRUE if the key was removed, %FALSE otherwise
17989 * g_key_file_save_to_file:
17990 * @key_file: a #GKeyFile
17991 * @filename: the name of the file to write to
17992 * @error: a pointer to a %NULL #GError, or %NULL
17994 * Writes the contents of @key_file to @filename using
17995 * g_file_set_contents().
17997 * This function can fail for any of the reasons that
17998 * g_file_set_contents() may fail.
18000 * Returns: %TRUE if successful, else %FALSE with @error set
18006 * g_key_file_set_boolean:
18007 * @key_file: a #GKeyFile
18008 * @group_name: a group name
18010 * @value: %TRUE or %FALSE
18012 * Associates a new boolean value with @key under @group_name.
18013 * If @key cannot be found then it is created.
18020 * g_key_file_set_boolean_list:
18021 * @key_file: a #GKeyFile
18022 * @group_name: a group name
18024 * @list: (array length=length): an array of boolean values
18025 * @length: length of @list
18027 * Associates a list of boolean values with @key under @group_name.
18028 * If @key cannot be found then it is created.
18029 * If @group_name is %NULL, the start_group is used.
18036 * g_key_file_set_comment:
18037 * @key_file: a #GKeyFile
18038 * @group_name: (allow-none): a group name, or %NULL
18039 * @key: (allow-none): a key
18040 * @comment: a comment
18041 * @error: return location for a #GError
18043 * Places a comment above @key from @group_name.
18044 * If @key is %NULL then @comment will be written above @group_name.
18045 * If both @key and @group_name are %NULL, then @comment will be
18046 * written above the first group in the file.
18048 * Returns: %TRUE if the comment was written, %FALSE otherwise
18054 * g_key_file_set_double:
18055 * @key_file: a #GKeyFile
18056 * @group_name: a group name
18058 * @value: an double value
18060 * Associates a new double value with @key under @group_name.
18061 * If @key cannot be found then it is created.
18068 * g_key_file_set_double_list:
18069 * @key_file: a #GKeyFile
18070 * @group_name: a group name
18072 * @list: (array length=length): an array of double values
18073 * @length: number of double values in @list
18075 * Associates a list of double values with @key under
18076 * @group_name. If @key cannot be found then it is created.
18083 * g_key_file_set_int64:
18084 * @key_file: a #GKeyFile
18085 * @group_name: a group name
18087 * @value: an integer value
18089 * Associates a new integer value with @key under @group_name.
18090 * If @key cannot be found then it is created.
18097 * g_key_file_set_integer:
18098 * @key_file: a #GKeyFile
18099 * @group_name: a group name
18101 * @value: an integer value
18103 * Associates a new integer value with @key under @group_name.
18104 * If @key cannot be found then it is created.
18111 * g_key_file_set_integer_list:
18112 * @key_file: a #GKeyFile
18113 * @group_name: a group name
18115 * @list: (array length=length): an array of integer values
18116 * @length: number of integer values in @list
18118 * Associates a list of integer values with @key under @group_name.
18119 * If @key cannot be found then it is created.
18126 * g_key_file_set_list_separator:
18127 * @key_file: a #GKeyFile
18128 * @separator: the separator
18130 * Sets the character which is used to separate
18131 * values in lists. Typically ';' or ',' are used
18132 * as separators. The default list separator is ';'.
18139 * g_key_file_set_locale_string:
18140 * @key_file: a #GKeyFile
18141 * @group_name: a group name
18143 * @locale: a locale identifier
18144 * @string: a string
18146 * Associates a string value for @key and @locale under @group_name.
18147 * If the translation for @key cannot be found then it is created.
18154 * g_key_file_set_locale_string_list:
18155 * @key_file: a #GKeyFile
18156 * @group_name: a group name
18158 * @locale: a locale identifier
18159 * @list: (array zero-terminated=1 length=length): a %NULL-terminated array of locale string values
18160 * @length: the length of @list
18162 * Associates a list of string values for @key and @locale under
18163 * @group_name. If the translation for @key cannot be found then
18171 * g_key_file_set_string:
18172 * @key_file: a #GKeyFile
18173 * @group_name: a group name
18175 * @string: a string
18177 * Associates a new string value with @key under @group_name.
18178 * If @key cannot be found then it is created.
18179 * If @group_name cannot be found then it is created.
18180 * Unlike g_key_file_set_value(), this function handles characters
18181 * that need escaping, such as newlines.
18188 * g_key_file_set_string_list:
18189 * @key_file: a #GKeyFile
18190 * @group_name: a group name
18192 * @list: (array zero-terminated=1 length=length) (element-type utf8): an array of string values
18193 * @length: number of string values in @list
18195 * Associates a list of string values for @key under @group_name.
18196 * If @key cannot be found then it is created.
18197 * If @group_name cannot be found then it is created.
18204 * g_key_file_set_uint64:
18205 * @key_file: a #GKeyFile
18206 * @group_name: a group name
18208 * @value: an integer value
18210 * Associates a new integer value with @key under @group_name.
18211 * If @key cannot be found then it is created.
18218 * g_key_file_set_value:
18219 * @key_file: a #GKeyFile
18220 * @group_name: a group name
18224 * Associates a new value with @key under @group_name.
18226 * If @key cannot be found then it is created. If @group_name cannot
18227 * be found then it is created. To set an UTF-8 string which may contain
18228 * characters that need escaping (such as newlines or spaces), use
18229 * g_key_file_set_string().
18236 * g_key_file_to_data:
18237 * @key_file: a #GKeyFile
18238 * @length: (out) (allow-none): return location for the length of the
18239 * returned string, or %NULL
18240 * @error: return location for a #GError, or %NULL
18242 * This function outputs @key_file as a string.
18244 * Note that this function never reports an error,
18245 * so it is safe to pass %NULL as @error.
18247 * Returns: a newly allocated string holding
18248 * the contents of the #GKeyFile
18254 * g_key_file_unref:
18255 * @key_file: a #GKeyFile
18257 * Decreases the reference count of @key_file by 1. If the reference count
18258 * reaches zero, frees the key file and all its allocated memory.
18267 * Allocates space for one #GList element. It is called by
18268 * g_list_append(), g_list_prepend(), g_list_insert() and
18269 * g_list_insert_sorted() and so is rarely used on its own.
18271 * Returns: a pointer to the newly-allocated #GList element.
18277 * @list: a pointer to a #GList
18278 * @data: the data for the new element
18280 * Adds a new element on to the end of the list.
18283 * The return value is the new start of the list, which
18284 * may have changed, so make sure you store the new value.
18288 * Note that g_list_append() has to traverse the entire list
18289 * to find the end, which is inefficient when adding multiple
18290 * elements. A common idiom to avoid the inefficiency is to prepend
18291 * the elements and reverse the list when all elements have been added.
18295 * /* Notice that these are initialized to the empty list. */
18296 * GList *list = NULL, *number_list = NULL;
18298 * /* This is a list of strings. */
18299 * list = g_list_append (list, "first");
18300 * list = g_list_append (list, "second");
18302 * /* This is a list of integers. */
18303 * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
18304 * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
18307 * Returns: the new start of the #GList
18314 * @list2: the #GList to add to the end of the first #GList
18316 * Adds the second #GList onto the end of the first #GList.
18317 * Note that the elements of the second #GList are not copied.
18318 * They are used directly.
18320 * Returns: the start of the new #GList
18331 * Note that this is a "shallow" copy. If the list elements
18332 * consist of pointers to data, the pointers are copied but
18333 * the actual data is not. See g_list_copy_deep() if you need
18334 * to copy the data as well.
18337 * Returns: a copy of @list
18342 * g_list_copy_deep:
18344 * @func: a copy function used to copy every element in the list
18345 * @user_data: user data passed to the copy function @func, or #NULL
18347 * Makes a full (deep) copy of a #GList.
18349 * In contrast with g_list_copy(), this function uses @func to make a copy of
18350 * each list element, in addition to copying the list container itself.
18352 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
18353 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
18356 * For instance, if @list holds a list of GObjects, you can do:
18358 * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
18361 * And, to entirely free the new list, you could do:
18363 * g_list_free_full (another_list, g_object_unref);
18366 * Returns: a full copy of @list, use #g_list_free_full to free it
18372 * g_list_delete_link:
18374 * @link_: node to delete from @list
18376 * Removes the node link_ from the list and frees it.
18377 * Compare this to g_list_remove_link() which removes the node
18378 * without freeing it.
18380 * Returns: the new head of @list
18387 * @data: the element data to find
18389 * Finds the element in a #GList which
18390 * contains the given data.
18392 * Returns: the found #GList element,
18393 * or %NULL if it is not found
18398 * g_list_find_custom:
18400 * @data: user data passed to the function
18401 * @func: the function to call for each element.
18402 * It should return 0 when the desired element is found
18404 * Finds an element in a #GList, using a supplied function to
18405 * find the desired element. It iterates over the list, calling
18406 * the given function which should return 0 when the desired
18407 * element is found. The function takes two #gconstpointer arguments,
18408 * the #GList element's data as the first argument and the
18411 * Returns: the found #GList element, or %NULL if it is not found
18419 * Gets the first element in a #GList.
18421 * Returns: the first element in the #GList,
18422 * or %NULL if the #GList has no elements
18429 * @func: the function to call with each element's data
18430 * @user_data: user data to pass to the function
18432 * Calls a function for each element of a #GList.
18440 * Frees all of the memory used by a #GList.
18441 * The freed elements are returned to the slice allocator.
18444 * If list elements contain dynamically-allocated memory,
18445 * you should either use g_list_free_full() or free them manually
18454 * Another name for g_list_free_1().
18460 * @list: a #GList element
18462 * Frees one #GList element.
18463 * It is usually used after g_list_remove_link().
18468 * g_list_free_full:
18469 * @list: a pointer to a #GList
18470 * @free_func: the function to be called to free each element's data
18472 * Convenience method, which frees all the memory used by a #GList, and
18473 * calls the specified destroy function on every element's data.
18482 * @data: the data to find
18484 * Gets the position of the element containing
18485 * the given data (starting from 0).
18487 * Returns: the index of the element containing the data,
18488 * or -1 if the data is not found
18494 * @list: a pointer to a #GList
18495 * @data: the data for the new element
18496 * @position: the position to insert the element. If this is
18497 * negative, or is larger than the number of elements in the
18498 * list, the new element is added on to the end of the list.
18500 * Inserts a new element into the list at the given position.
18502 * Returns: the new start of the #GList
18507 * g_list_insert_before:
18508 * @list: a pointer to a #GList
18509 * @sibling: the list element before which the new element
18510 * is inserted or %NULL to insert at the end of the list
18511 * @data: the data for the new element
18513 * Inserts a new element into the list before the given position.
18515 * Returns: the new start of the #GList
18520 * g_list_insert_sorted:
18521 * @list: a pointer to a #GList
18522 * @data: the data for the new element
18523 * @func: the function to compare elements in the list. It should
18524 * return a number > 0 if the first parameter comes after the
18525 * second parameter in the sort order.
18527 * Inserts a new element into the list, using the given comparison
18528 * function to determine its position.
18530 * Returns: the new start of the #GList
18535 * g_list_insert_sorted_with_data:
18536 * @list: a pointer to a #GList
18537 * @data: the data for the new element
18538 * @func: the function to compare elements in the list.
18539 * It should return a number > 0 if the first parameter
18540 * comes after the second parameter in the sort order.
18541 * @user_data: user data to pass to comparison function.
18543 * Inserts a new element into the list, using the given comparison
18544 * function to determine its position.
18546 * Returns: the new start of the #GList
18555 * Gets the last element in a #GList.
18557 * Returns: the last element in the #GList,
18558 * or %NULL if the #GList has no elements
18566 * Gets the number of elements in a #GList.
18569 * This function iterates over the whole list to
18570 * count its elements.
18573 * Returns: the number of elements in the #GList
18579 * @list: an element in a #GList.
18581 * A convenience macro to get the next element in a #GList.
18583 * Returns: the next element, or %NULL if there are no more elements.
18590 * @n: the position of the element, counting from 0
18592 * Gets the element at the given position in a #GList.
18594 * Returns: the element, or %NULL if the position is off
18595 * the end of the #GList
18602 * @n: the position of the element
18604 * Gets the data of the element at the given position.
18606 * Returns: the element's data, or %NULL if the position
18607 * is off the end of the #GList
18614 * @n: the position of the element, counting from 0
18616 * Gets the element @n places before @list.
18618 * Returns: the element, or %NULL if the position is
18619 * off the end of the #GList
18626 * @llink: an element in the #GList
18628 * Gets the position of the given element
18629 * in the #GList (starting from 0).
18631 * Returns: the position of the element in the #GList,
18632 * or -1 if the element is not found
18638 * @list: a pointer to a #GList
18639 * @data: the data for the new element
18641 * Adds a new element on to the start of the list.
18644 * The return value is the new start of the list, which
18645 * may have changed, so make sure you store the new value.
18649 * /* Notice that it is initialized to the empty list. */
18650 * GList *list = NULL;
18651 * list = g_list_prepend (list, "last");
18652 * list = g_list_prepend (list, "first");
18655 * Returns: the new start of the #GList
18661 * @list: an element in a #GList.
18663 * A convenience macro to get the previous element in a #GList.
18665 * Returns: the previous element, or %NULL if there are no previous
18673 * @data: the data of the element to remove
18675 * Removes an element from a #GList.
18676 * If two elements contain the same data, only the first is removed.
18677 * If none of the elements contain the data, the #GList is unchanged.
18679 * Returns: the new start of the #GList
18684 * g_list_remove_all:
18686 * @data: data to remove
18688 * Removes all list nodes with data equal to @data.
18689 * Returns the new head of the list. Contrast with
18690 * g_list_remove() which removes only the first node
18691 * matching the given data.
18693 * Returns: new head of @list
18698 * g_list_remove_link:
18700 * @llink: an element in the #GList
18702 * Removes an element from a #GList, without freeing the element.
18703 * The removed element's prev and next links are set to %NULL, so
18704 * that it becomes a self-contained list with one element.
18706 * Returns: the new start of the #GList, without the element
18714 * Reverses a #GList.
18715 * It simply switches the next and prev pointers of each element.
18717 * Returns: the start of the reversed #GList
18724 * @compare_func: the comparison function used to sort the #GList.
18725 * This function is passed the data from 2 elements of the #GList
18726 * and should return 0 if they are equal, a negative value if the
18727 * first element comes before the second, or a positive value if
18728 * the first element comes after the second.
18730 * Sorts a #GList using the given comparison function. The algorithm
18731 * used is a stable sort.
18733 * Returns: the start of the sorted #GList
18738 * g_list_sort_with_data:
18740 * @compare_func: comparison function
18741 * @user_data: user data to pass to comparison function
18743 * Like g_list_sort(), but the comparison function accepts
18744 * a user data argument.
18746 * Returns: the new head of @list
18753 * Gets the names of all variables set in the environment.
18755 * Programs that want to be portable to Windows should typically use
18756 * this function and g_getenv() instead of using the environ array
18757 * from the C library directly. On Windows, the strings in the environ
18758 * array are in system codepage encoding, while in most of the typical
18759 * use cases for environment variables in GLib-using programs you want
18760 * the UTF-8 encoding that this function and g_getenv() provide.
18762 * Returns: (array zero-terminated=1) (transfer full): a %NULL-terminated
18763 * list of strings which must be freed with g_strfreev().
18769 * g_locale_from_utf8:
18770 * @utf8string: a UTF-8 encoded string
18771 * @len: the length of the string, or -1 if the string is
18772 * nul-terminated<footnoteref linkend="nul-unsafe"/>.
18773 * @bytes_read: location to store the number of bytes in the
18774 * input string that were successfully converted, or %NULL.
18775 * Even if the conversion was successful, this may be
18776 * less than @len if there were partial characters
18777 * at the end of the input. If the error
18778 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
18779 * stored will the byte offset after the last valid
18781 * @bytes_written: the number of bytes stored in the output buffer (not
18782 * including the terminating nul).
18783 * @error: location to store the error occurring, or %NULL to ignore
18784 * errors. Any of the errors in #GConvertError may occur.
18786 * Converts a string from UTF-8 to the encoding used for strings by
18787 * the C runtime (usually the same as that used by the operating
18788 * system) in the <link linkend="setlocale">current locale</link>. On
18789 * Windows this means the system codepage.
18791 * Returns: A newly-allocated buffer containing the converted string,
18792 * or %NULL on an error, and error will be set.
18797 * g_locale_to_utf8:
18798 * @opsysstring: a string in the encoding of the current locale. On Windows
18799 * this means the system codepage.
18800 * @len: the length of the string, or -1 if the string is
18801 * nul-terminated<footnoteref linkend="nul-unsafe"/>.
18802 * @bytes_read: location to store the number of bytes in the
18803 * input string that were successfully converted, or %NULL.
18804 * Even if the conversion was successful, this may be
18805 * less than @len if there were partial characters
18806 * at the end of the input. If the error
18807 * #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
18808 * stored will the byte offset after the last valid
18810 * @bytes_written: the number of bytes stored in the output buffer (not
18811 * including the terminating nul).
18812 * @error: location to store the error occurring, or %NULL to ignore
18813 * errors. Any of the errors in #GConvertError may occur.
18815 * Converts a string which is in the encoding used for strings by
18816 * the C runtime (usually the same as that used by the operating
18817 * system) in the <link linkend="setlocale">current locale</link> into a
18820 * Returns: A newly-allocated buffer containing the converted string,
18821 * or %NULL on an error, and error will be set.
18827 * @log_domain: the log domain, usually #G_LOG_DOMAIN
18828 * @log_level: the log level, either from #GLogLevelFlags
18829 * or a user-defined level
18830 * @format: the message format. See the printf() documentation
18831 * @...: the parameters to insert into the format string
18833 * Logs an error or debugging message.
18835 * If the log level has been set as fatal, the abort()
18836 * function is called to terminate the program.
18838 * If g_log_default_handler() is used as the log handler function, a new-line
18839 * character will automatically be appended to @..., and need not be entered
18845 * g_log_default_handler:
18846 * @log_domain: the log domain of the message
18847 * @log_level: the level of the message
18848 * @message: the message
18849 * @unused_data: data passed from g_log() which is unused
18851 * The default log handler set up by GLib; g_log_set_default_handler()
18852 * allows to install an alternate default log handler.
18853 * This is used if no log handler has been set for the particular log
18854 * domain and log level combination. It outputs the message to stderr
18855 * or stdout and if the log level is fatal it calls abort(). It automatically
18856 * prints a new-line character after the message, so one does not need to be
18857 * manually included in @message.
18859 * The behavior of this log handler can be influenced by a number of
18860 * environment variables:
18863 * <term><envar>G_MESSAGES_PREFIXED</envar></term>
18865 * A :-separated list of log levels for which messages should
18866 * be prefixed by the program name and PID of the aplication.
18870 * <term><envar>G_MESSAGES_DEBUG</envar></term>
18872 * A space-separated list of log domains for which debug and
18873 * informational messages are printed. By default these
18874 * messages are not printed.
18879 * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
18880 * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
18886 * g_log_remove_handler:
18887 * @log_domain: the log domain
18888 * @handler_id: the id of the handler, which was returned
18889 * in g_log_set_handler()
18891 * Removes the log handler.
18896 * g_log_set_always_fatal:
18897 * @fatal_mask: the mask containing bits set for each level
18898 * of error which is to be fatal
18900 * Sets the message levels which are always fatal, in any log domain.
18901 * When a message with any of these levels is logged the program terminates.
18902 * You can only set the levels defined by GLib to be fatal.
18903 * %G_LOG_LEVEL_ERROR is always fatal.
18905 * You can also make some message levels fatal at runtime by setting
18906 * the <envar>G_DEBUG</envar> environment variable (see
18907 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
18909 * Returns: the old fatal mask
18914 * g_log_set_default_handler:
18915 * @log_func: the log handler function
18916 * @user_data: data passed to the log handler
18918 * Installs a default log handler which is used if no
18919 * log handler has been set for the particular log domain
18920 * and log level combination. By default, GLib uses
18921 * g_log_default_handler() as default log handler.
18923 * Returns: the previous default log handler
18929 * g_log_set_fatal_mask:
18930 * @log_domain: the log domain
18931 * @fatal_mask: the new fatal mask
18933 * Sets the log levels which are fatal in the given domain.
18934 * %G_LOG_LEVEL_ERROR is always fatal.
18936 * Returns: the old fatal mask for the log domain
18941 * g_log_set_handler:
18942 * @log_domain: (allow-none): the log domain, or %NULL for the default ""
18943 * application domain
18944 * @log_levels: the log levels to apply the log handler for.
18945 * To handle fatal and recursive messages as well, combine
18946 * the log levels with the #G_LOG_FLAG_FATAL and
18947 * #G_LOG_FLAG_RECURSION bit flags.
18948 * @log_func: the log handler function
18949 * @user_data: data passed to the log handler
18951 * Sets the log handler for a domain and a set of log levels.
18952 * To handle fatal and recursive messages the @log_levels parameter
18953 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
18956 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
18957 * you want to set a handler for this log level you must combine it with
18958 * #G_LOG_FLAG_FATAL.
18961 * <title>Adding a log handler for all warning messages in the default
18962 * (application) domain</title>
18964 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
18965 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18966 * </programlisting>
18970 * <title>Adding a log handler for all critical messages from GTK+</title>
18972 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
18973 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18974 * </programlisting>
18978 * <title>Adding a log handler for <emphasis>all</emphasis> messages from
18981 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
18982 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18983 * </programlisting>
18986 * Returns: the id of the new handler
18992 * @log_domain: the log domain
18993 * @log_level: the log level
18994 * @format: the message format. See the printf() documentation
18995 * @args: the parameters to insert into the format string
18997 * Logs an error or debugging message.
18999 * If the log level has been set as fatal, the abort()
19000 * function is called to terminate the program.
19002 * If g_log_default_handler() is used as the log handler function, a new-line
19003 * character will automatically be appended to @..., and need not be entered
19010 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
19011 * @buf: a pointer to a <structname>stat</structname> struct, which
19012 * will be filled with the file information
19014 * A wrapper for the POSIX lstat() function. The lstat() function is
19015 * like stat() except that in the case of symbolic links, it returns
19016 * information about the symbolic link itself and not the file that it
19017 * refers to. If the system does not support symbolic links g_lstat()
19018 * is identical to g_stat().
19020 * See your C library manual for more details about lstat().
19022 * Returns: 0 if the information was successfully retrieved, -1 if an error
19029 * g_main_context_acquire:
19030 * @context: a #GMainContext
19032 * Tries to become the owner of the specified context.
19033 * If some other thread is the owner of the context,
19034 * returns %FALSE immediately. Ownership is properly
19035 * recursive: the owner can require ownership again
19036 * and will release ownership when g_main_context_release()
19037 * is called as many times as g_main_context_acquire().
19039 * You must be the owner of a context before you
19040 * can call g_main_context_prepare(), g_main_context_query(),
19041 * g_main_context_check(), g_main_context_dispatch().
19043 * Returns: %TRUE if the operation succeeded, and
19044 * this thread is now the owner of @context.
19049 * g_main_context_add_poll:
19050 * @context: (allow-none): a #GMainContext (or %NULL for the default context)
19051 * @fd: a #GPollFD structure holding information about a file
19052 * descriptor to watch.
19053 * @priority: the priority for this file descriptor which should be
19054 * the same as the priority used for g_source_attach() to ensure that the
19055 * file descriptor is polled whenever the results may be needed.
19057 * Adds a file descriptor to the set of file descriptors polled for
19058 * this context. This will very seldom be used directly. Instead
19059 * a typical event source will use g_source_add_unix_fd() instead.
19064 * g_main_context_check:
19065 * @context: a #GMainContext
19066 * @max_priority: the maximum numerical priority of sources to check
19067 * @fds: (array length=n_fds): array of #GPollFD's that was passed to
19068 * the last call to g_main_context_query()
19069 * @n_fds: return value of g_main_context_query()
19071 * Passes the results of polling back to the main loop.
19073 * Returns: %TRUE if some sources are ready to be dispatched.
19078 * g_main_context_default:
19080 * Returns the global default main context. This is the main context
19081 * used for main loop functions when a main loop is not explicitly
19082 * specified, and corresponds to the "main" main loop. See also
19083 * g_main_context_get_thread_default().
19085 * Returns: (transfer none): the global default main context.
19090 * g_main_context_dispatch:
19091 * @context: a #GMainContext
19093 * Dispatches all pending sources.
19098 * g_main_context_find_source_by_funcs_user_data:
19099 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
19100 * @funcs: the @source_funcs passed to g_source_new().
19101 * @user_data: the user data from the callback.
19103 * Finds a source with the given source functions and user data. If
19104 * multiple sources exist with the same source function and user data,
19105 * the first one found will be returned.
19107 * Returns: (transfer none): the source, if one was found, otherwise %NULL
19112 * g_main_context_find_source_by_id:
19113 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19114 * @source_id: the source ID, as returned by g_source_get_id().
19116 * Finds a #GSource given a pair of context and ID.
19118 * Returns: (transfer none): the #GSource if found, otherwise, %NULL
19123 * g_main_context_find_source_by_user_data:
19124 * @context: a #GMainContext
19125 * @user_data: the user_data for the callback.
19127 * Finds a source with the given user data for the callback. If
19128 * multiple sources exist with the same user data, the first
19129 * one found will be returned.
19131 * Returns: (transfer none): the source, if one was found, otherwise %NULL
19136 * g_main_context_get_poll_func:
19137 * @context: a #GMainContext
19139 * Gets the poll function set by g_main_context_set_poll_func().
19141 * Returns: the poll function
19146 * g_main_context_get_thread_default:
19148 * Gets the thread-default #GMainContext for this thread. Asynchronous
19149 * operations that want to be able to be run in contexts other than
19150 * the default one should call this method or
19151 * g_main_context_ref_thread_default() to get a #GMainContext to add
19152 * their #GSource<!-- -->s to. (Note that even in single-threaded
19153 * programs applications may sometimes want to temporarily push a
19154 * non-default context, so it is not safe to assume that this will
19155 * always return %NULL if you are running in the default thread.)
19157 * If you need to hold a reference on the context, use
19158 * g_main_context_ref_thread_default() instead.
19160 * Returns: (transfer none): the thread-default #GMainContext, or
19161 * %NULL if the thread-default context is the global default context.
19167 * g_main_context_invoke:
19168 * @context: (allow-none): a #GMainContext, or %NULL
19169 * @function: function to call
19170 * @data: data to pass to @function
19172 * Invokes a function in such a way that @context is owned during the
19173 * invocation of @function.
19175 * If @context is %NULL then the global default main context — as
19176 * returned by g_main_context_default() — is used.
19178 * If @context is owned by the current thread, @function is called
19179 * directly. Otherwise, if @context is the thread-default main context
19180 * of the current thread and g_main_context_acquire() succeeds, then
19181 * @function is called and g_main_context_release() is called
19184 * In any other case, an idle source is created to call @function and
19185 * that source is attached to @context (presumably to be run in another
19186 * thread). The idle source is attached with #G_PRIORITY_DEFAULT
19187 * priority. If you want a different priority, use
19188 * g_main_context_invoke_full().
19190 * Note that, as with normal idle functions, @function should probably
19191 * return %FALSE. If it returns %TRUE, it will be continuously run in a
19192 * loop (and may prevent this call from returning).
19199 * g_main_context_invoke_full:
19200 * @context: (allow-none): a #GMainContext, or %NULL
19201 * @priority: the priority at which to run @function
19202 * @function: function to call
19203 * @data: data to pass to @function
19204 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
19206 * Invokes a function in such a way that @context is owned during the
19207 * invocation of @function.
19209 * This function is the same as g_main_context_invoke() except that it
19210 * lets you specify the priority incase @function ends up being
19211 * scheduled as an idle and also lets you give a #GDestroyNotify for @data.
19213 * @notify should not assume that it is called from any particular
19214 * thread or with any particular context acquired.
19221 * g_main_context_is_owner:
19222 * @context: a #GMainContext
19224 * Determines whether this thread holds the (recursive)
19225 * ownership of this #GMainContext. This is useful to
19226 * know before waiting on another thread that may be
19227 * blocking to get ownership of @context.
19229 * Returns: %TRUE if current thread is owner of @context.
19235 * g_main_context_iteration:
19236 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19237 * @may_block: whether the call may block.
19239 * Runs a single iteration for the given main loop. This involves
19240 * checking to see if any event sources are ready to be processed,
19241 * then if no events sources are ready and @may_block is %TRUE, waiting
19242 * for a source to become ready, then dispatching the highest priority
19243 * events sources that are ready. Otherwise, if @may_block is %FALSE
19244 * sources are not waited to become ready, only those highest priority
19245 * events sources will be dispatched (if any), that are ready at this
19246 * given moment without further waiting.
19248 * Note that even when @may_block is %TRUE, it is still possible for
19249 * g_main_context_iteration() to return %FALSE, since the wait may
19250 * be interrupted for other reasons than an event source becoming ready.
19252 * Returns: %TRUE if events were dispatched.
19257 * g_main_context_new:
19259 * Creates a new #GMainContext structure.
19261 * Returns: the new #GMainContext
19266 * g_main_context_pending:
19267 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19269 * Checks if any sources have pending events for the given context.
19271 * Returns: %TRUE if events are pending.
19276 * g_main_context_pop_thread_default:
19277 * @context: (allow-none): a #GMainContext object, or %NULL
19279 * Pops @context off the thread-default context stack (verifying that
19280 * it was on the top of the stack).
19287 * g_main_context_prepare:
19288 * @context: a #GMainContext
19289 * @priority: location to store priority of highest priority
19290 * source already ready.
19292 * Prepares to poll sources within a main loop. The resulting information
19293 * for polling is determined by calling g_main_context_query ().
19295 * Returns: %TRUE if some source is ready to be dispatched
19296 * prior to polling.
19301 * g_main_context_push_thread_default:
19302 * @context: (allow-none): a #GMainContext, or %NULL for the global default context
19304 * Acquires @context and sets it as the thread-default context for the
19305 * current thread. This will cause certain asynchronous operations
19306 * (such as most <link linkend="gio">gio</link>-based I/O) which are
19307 * started in this thread to run under @context and deliver their
19308 * results to its main loop, rather than running under the global
19309 * default context in the main thread. Note that calling this function
19310 * changes the context returned by
19311 * g_main_context_get_thread_default(), <emphasis>not</emphasis> the
19312 * one returned by g_main_context_default(), so it does not affect the
19313 * context used by functions like g_idle_add().
19315 * Normally you would call this function shortly after creating a new
19316 * thread, passing it a #GMainContext which will be run by a
19317 * #GMainLoop in that thread, to set a new default context for all
19318 * async operations in that thread. (In this case, you don't need to
19319 * ever call g_main_context_pop_thread_default().) In some cases
19320 * however, you may want to schedule a single operation in a
19321 * non-default context, or temporarily use a non-default context in
19322 * the main thread. In that case, you can wrap the call to the
19323 * asynchronous operation inside a
19324 * g_main_context_push_thread_default() /
19325 * g_main_context_pop_thread_default() pair, but it is up to you to
19326 * ensure that no other asynchronous operations accidentally get
19327 * started while the non-default context is active.
19329 * Beware that libraries that predate this function may not correctly
19330 * handle being used from a thread with a thread-default context. Eg,
19331 * see g_file_supports_thread_contexts().
19338 * g_main_context_query:
19339 * @context: a #GMainContext
19340 * @max_priority: maximum priority source to check
19341 * @timeout_: (out): location to store timeout to be used in polling
19342 * @fds: (out caller-allocates) (array length=n_fds): location to
19343 * store #GPollFD records that need to be polled.
19344 * @n_fds: length of @fds.
19346 * Determines information necessary to poll this main loop.
19348 * Returns: the number of records actually stored in @fds,
19349 * or, if more than @n_fds records need to be stored, the number
19350 * of records that need to be stored.
19355 * g_main_context_ref:
19356 * @context: a #GMainContext
19358 * Increases the reference count on a #GMainContext object by one.
19360 * Returns: the @context that was passed in (since 2.6)
19365 * g_main_context_ref_thread_default:
19367 * Gets the thread-default #GMainContext for this thread, as with
19368 * g_main_context_get_thread_default(), but also adds a reference to
19369 * it with g_main_context_ref(). In addition, unlike
19370 * g_main_context_get_thread_default(), if the thread-default context
19371 * is the global default context, this will return that #GMainContext
19372 * (with a ref added to it) rather than returning %NULL.
19374 * Returns: (transfer full): the thread-default #GMainContext. Unref
19375 * with g_main_context_unref() when you are done with it.
19381 * g_main_context_release:
19382 * @context: a #GMainContext
19384 * Releases ownership of a context previously acquired by this thread
19385 * with g_main_context_acquire(). If the context was acquired multiple
19386 * times, the ownership will be released only when g_main_context_release()
19387 * is called as many times as it was acquired.
19392 * g_main_context_remove_poll:
19393 * @context: a #GMainContext
19394 * @fd: a #GPollFD descriptor previously added with g_main_context_add_poll()
19396 * Removes file descriptor from the set of file descriptors to be
19397 * polled for a particular context.
19402 * g_main_context_set_poll_func:
19403 * @context: a #GMainContext
19404 * @func: the function to call to poll all file descriptors
19406 * Sets the function to use to handle polling of file descriptors. It
19407 * will be used instead of the poll() system call
19408 * (or GLib's replacement function, which is used where
19409 * poll() isn't available).
19411 * This function could possibly be used to integrate the GLib event
19412 * loop with an external event loop.
19417 * g_main_context_unref:
19418 * @context: a #GMainContext
19420 * Decreases the reference count on a #GMainContext object by one. If
19421 * the result is zero, free the context and free all associated memory.
19426 * g_main_context_wait:
19427 * @context: a #GMainContext
19428 * @cond: a condition variable
19429 * @mutex: a mutex, currently held
19431 * Tries to become the owner of the specified context,
19432 * as with g_main_context_acquire(). But if another thread
19433 * is the owner, atomically drop @mutex and wait on @cond until
19434 * that owner releases ownership or until @cond is signaled, then
19435 * try again (once) to become the owner.
19437 * Returns: %TRUE if the operation succeeded, and
19438 * this thread is now the owner of @context.
19443 * g_main_context_wakeup:
19444 * @context: a #GMainContext
19446 * If @context is currently blocking in g_main_context_iteration()
19447 * waiting for a source to become ready, cause it to stop blocking
19448 * and return. Otherwise, cause the next invocation of
19449 * g_main_context_iteration() to return without blocking.
19451 * This API is useful for low-level control over #GMainContext; for
19452 * example, integrating it with main loop implementations such as
19455 * Another related use for this function is when implementing a main
19456 * loop with a termination condition, computed from multiple threads:
19459 * #define NUM_TASKS 10
19460 * static volatile gint tasks_remaining = NUM_TASKS;
19463 * while (g_atomic_int_get (&tasks_remaining) != 0)
19464 * g_main_context_iteration (NULL, TRUE);
19467 * Then in a thread:
19471 * if (g_atomic_int_dec_and_test (&tasks_remaining))
19472 * g_main_context_wakeup (NULL);
19478 * g_main_current_source:
19480 * Returns the currently firing source for this thread.
19482 * Returns: (transfer none): The currently firing source or %NULL.
19490 * Returns the depth of the stack of calls to
19491 * g_main_context_dispatch() on any #GMainContext in the current thread.
19492 * That is, when called from the toplevel, it gives 0. When
19493 * called from within a callback from g_main_context_iteration()
19494 * (or g_main_loop_run(), etc.) it returns 1. When called from within
19495 * a callback to a recursive call to g_main_context_iteration(),
19496 * it returns 2. And so forth.
19498 * This function is useful in a situation like the following:
19499 * Imagine an extremely simple "garbage collected" system.
19502 * static GList *free_list;
19505 * allocate_memory (gsize size)
19507 * gpointer result = g_malloc (size);
19508 * free_list = g_list_prepend (free_list, result);
19513 * free_allocated_memory (void)
19516 * for (l = free_list; l; l = l->next);
19517 * g_free (l->data);
19518 * g_list_free (free_list);
19519 * free_list = NULL;
19526 * g_main_context_iteration (NULL, TRUE);
19527 * free_allocated_memory();
19531 * This works from an application, however, if you want to do the same
19532 * thing from a library, it gets more difficult, since you no longer
19533 * control the main loop. You might think you can simply use an idle
19534 * function to make the call to free_allocated_memory(), but that
19535 * doesn't work, since the idle function could be called from a
19536 * recursive callback. This can be fixed by using g_main_depth()
19540 * allocate_memory (gsize size)
19542 * FreeListBlock *block = g_new (FreeListBlock, 1);
19543 * block->mem = g_malloc (size);
19544 * block->depth = g_main_depth ();
19545 * free_list = g_list_prepend (free_list, block);
19546 * return block->mem;
19550 * free_allocated_memory (void)
19554 * int depth = g_main_depth ();
19555 * for (l = free_list; l; );
19557 * GList *next = l->next;
19558 * FreeListBlock *block = l->data;
19559 * if (block->depth > depth)
19561 * g_free (block->mem);
19563 * free_list = g_list_delete_link (free_list, l);
19571 * There is a temptation to use g_main_depth() to solve
19572 * problems with reentrancy. For instance, while waiting for data
19573 * to be received from the network in response to a menu item,
19574 * the menu item might be selected again. It might seem that
19575 * one could make the menu item's callback return immediately
19576 * and do nothing if g_main_depth() returns a value greater than 1.
19577 * However, this should be avoided since the user then sees selecting
19578 * the menu item do nothing. Furthermore, you'll find yourself adding
19579 * these checks all over your code, since there are doubtless many,
19580 * many things that the user could do. Instead, you can use the
19581 * following techniques:
19586 * Use gtk_widget_set_sensitive() or modal dialogs to prevent
19587 * the user from interacting with elements while the main
19588 * loop is recursing.
19593 * Avoid main loop recursion in situations where you can't handle
19594 * arbitrary callbacks. Instead, structure your code so that you
19595 * simply return to the main loop and then get called again when
19596 * there is more work to do.
19601 * Returns: The main loop recursion level in the current thread
19606 * g_main_loop_get_context:
19607 * @loop: a #GMainLoop.
19609 * Returns the #GMainContext of @loop.
19611 * Returns: (transfer none): the #GMainContext of @loop
19616 * g_main_loop_is_running:
19617 * @loop: a #GMainLoop.
19619 * Checks to see if the main loop is currently being run via g_main_loop_run().
19621 * Returns: %TRUE if the mainloop is currently being run.
19627 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
19628 * @is_running: set to %TRUE to indicate that the loop is running. This
19629 * is not very important since calling g_main_loop_run() will set this to
19632 * Creates a new #GMainLoop structure.
19634 * Returns: a new #GMainLoop.
19639 * g_main_loop_quit:
19640 * @loop: a #GMainLoop
19642 * Stops a #GMainLoop from running. Any calls to g_main_loop_run()
19643 * for the loop will return.
19645 * Note that sources that have already been dispatched when
19646 * g_main_loop_quit() is called will still be executed.
19652 * @loop: a #GMainLoop
19654 * Increases the reference count on a #GMainLoop object by one.
19662 * @loop: a #GMainLoop
19664 * Runs a main loop until g_main_loop_quit() is called on the loop.
19665 * If this is called for the thread of the loop's #GMainContext,
19666 * it will process events from the loop, otherwise it will
19672 * g_main_loop_unref:
19673 * @loop: a #GMainLoop
19675 * Decreases the reference count on a #GMainLoop object by one. If
19676 * the result is zero, free the loop and free all associated memory.
19682 * @n_bytes: the number of bytes to allocate
19684 * Allocates @n_bytes bytes of memory.
19685 * If @n_bytes is 0 it returns %NULL.
19687 * Returns: a pointer to the allocated memory
19693 * @n_bytes: the number of bytes to allocate
19695 * Allocates @n_bytes bytes of memory, initialized to 0's.
19696 * If @n_bytes is 0 it returns %NULL.
19698 * Returns: a pointer to the allocated memory
19704 * @n_blocks: the number of blocks to allocate
19705 * @n_block_bytes: the size of each block in bytes
19707 * This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
19708 * but care is taken to detect possible overflow during multiplication.
19711 * Returns: a pointer to the allocated memory
19717 * @n_blocks: the number of blocks to allocate
19718 * @n_block_bytes: the size of each block in bytes
19720 * This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
19721 * but care is taken to detect possible overflow during multiplication.
19724 * Returns: a pointer to the allocated memory
19729 * g_mapped_file_free:
19730 * @file: a #GMappedFile
19732 * This call existed before #GMappedFile had refcounting and is currently
19733 * exactly the same as g_mapped_file_unref().
19736 * Deprecated: 2.22: Use g_mapped_file_unref() instead.
19741 * g_mapped_file_get_bytes:
19742 * @file: a #GMappedFile
19744 * Creates a new #GBytes which references the data mapped from @file.
19745 * The mapped contents of the file must not be modified after creating this
19746 * bytes object, because a #GBytes should be immutable.
19748 * Returns: (transfer full): A newly allocated #GBytes referencing data
19755 * g_mapped_file_get_contents:
19756 * @file: a #GMappedFile
19758 * Returns the contents of a #GMappedFile.
19760 * Note that the contents may not be zero-terminated,
19761 * even if the #GMappedFile is backed by a text file.
19763 * If the file is empty then %NULL is returned.
19765 * Returns: the contents of @file, or %NULL.
19771 * g_mapped_file_get_length:
19772 * @file: a #GMappedFile
19774 * Returns the length of the contents of a #GMappedFile.
19776 * Returns: the length of the contents of @file.
19782 * g_mapped_file_new:
19783 * @filename: The path of the file to load, in the GLib filename encoding
19784 * @writable: whether the mapping should be writable
19785 * @error: return location for a #GError, or %NULL
19787 * Maps a file into memory. On UNIX, this is using the mmap() function.
19789 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19790 * it is an error to modify the mapped buffer. Modifications to the buffer
19791 * are not visible to other processes mapping the same file, and are not
19792 * written back to the file.
19794 * Note that modifications of the underlying file might affect the contents
19795 * of the #GMappedFile. Therefore, mapping should only be used if the file
19796 * will not be modified, or if all modifications of the file are done
19797 * atomically (e.g. using g_file_set_contents()).
19799 * If @filename is the name of an empty, regular file, the function
19800 * will successfully return an empty #GMappedFile. In other cases of
19801 * size 0 (e.g. device files such as /dev/null), @error will be set
19802 * to the #GFileError value #G_FILE_ERROR_INVAL.
19804 * Returns: a newly allocated #GMappedFile which must be unref'd
19805 * with g_mapped_file_unref(), or %NULL if the mapping failed.
19811 * g_mapped_file_new_from_fd:
19812 * @fd: The file descriptor of the file to load
19813 * @writable: whether the mapping should be writable
19814 * @error: return location for a #GError, or %NULL
19816 * Maps a file into memory. On UNIX, this is using the mmap() function.
19818 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19819 * it is an error to modify the mapped buffer. Modifications to the buffer
19820 * are not visible to other processes mapping the same file, and are not
19821 * written back to the file.
19823 * Note that modifications of the underlying file might affect the contents
19824 * of the #GMappedFile. Therefore, mapping should only be used if the file
19825 * will not be modified, or if all modifications of the file are done
19826 * atomically (e.g. using g_file_set_contents()).
19828 * Returns: a newly allocated #GMappedFile which must be unref'd
19829 * with g_mapped_file_unref(), or %NULL if the mapping failed.
19835 * g_mapped_file_ref:
19836 * @file: a #GMappedFile
19838 * Increments the reference count of @file by one. It is safe to call
19839 * this function from any thread.
19841 * Returns: the passed in #GMappedFile.
19847 * g_mapped_file_unref:
19848 * @file: a #GMappedFile
19850 * Decrements the reference count of @file by one. If the reference count
19851 * drops to 0, unmaps the buffer of @file and frees it.
19853 * It is safe to call this function from any thread.
19860 * g_markup_collect_attributes:
19861 * @element_name: the current tag name
19862 * @attribute_names: the attribute names
19863 * @attribute_values: the attribute values
19864 * @error: a pointer to a #GError or %NULL
19865 * @first_type: the #GMarkupCollectType of the first attribute
19866 * @first_attr: the name of the first attribute
19867 * @...: a pointer to the storage location of the first attribute
19868 * (or %NULL), followed by more types names and pointers, ending
19869 * with %G_MARKUP_COLLECT_INVALID
19871 * Collects the attributes of the element from the data passed to the
19872 * #GMarkupParser start_element function, dealing with common error
19873 * conditions and supporting boolean values.
19875 * This utility function is not required to write a parser but can save
19878 * The @element_name, @attribute_names, @attribute_values and @error
19879 * parameters passed to the start_element callback should be passed
19880 * unmodified to this function.
19882 * Following these arguments is a list of "supported" attributes to collect.
19883 * It is an error to specify multiple attributes with the same name. If any
19884 * attribute not in the list appears in the @attribute_names array then an
19885 * unknown attribute error will result.
19887 * The #GMarkupCollectType field allows specifying the type of collection
19888 * to perform and if a given attribute must appear or is optional.
19890 * The attribute name is simply the name of the attribute to collect.
19892 * The pointer should be of the appropriate type (see the descriptions
19893 * under #GMarkupCollectType) and may be %NULL in case a particular
19894 * attribute is to be allowed but ignored.
19896 * This function deals with issuing errors for missing attributes
19897 * (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19898 * (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19899 * attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19900 * as parse errors for boolean-valued attributes (again of type
19901 * %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19902 * will be returned and @error will be set as appropriate.
19904 * Returns: %TRUE if successful
19910 * g_markup_escape_text:
19911 * @text: some valid UTF-8 text
19912 * @length: length of @text in bytes, or -1 if the text is nul-terminated
19914 * Escapes text so that the markup parser will parse it verbatim.
19915 * Less than, greater than, ampersand, etc. are replaced with the
19916 * corresponding entities. This function would typically be used
19917 * when writing out a file to be parsed with the markup parser.
19919 * Note that this function doesn't protect whitespace and line endings
19920 * from being processed according to the XML rules for normalization
19921 * of line endings and attribute values.
19923 * Note also that this function will produce character references in
19924 * the range of &#x1; ... &#x1f; for all control sequences
19925 * except for tabstop, newline and carriage return. The character
19926 * references in this range are not valid XML 1.0, but they are
19927 * valid XML 1.1 and will be accepted by the GMarkup parser.
19929 * Returns: a newly allocated string with the escaped text
19934 * g_markup_parse_context_end_parse:
19935 * @context: a #GMarkupParseContext
19936 * @error: return location for a #GError
19938 * Signals to the #GMarkupParseContext that all data has been
19939 * fed into the parse context with g_markup_parse_context_parse().
19941 * This function reports an error if the document isn't complete,
19942 * for example if elements are still open.
19944 * Returns: %TRUE on success, %FALSE if an error was set
19949 * g_markup_parse_context_free:
19950 * @context: a #GMarkupParseContext
19952 * Frees a #GMarkupParseContext.
19954 * This function can't be called from inside one of the
19955 * #GMarkupParser functions or while a subparser is pushed.
19960 * g_markup_parse_context_get_element:
19961 * @context: a #GMarkupParseContext
19963 * Retrieves the name of the currently open element.
19965 * If called from the start_element or end_element handlers this will
19966 * give the element_name as passed to those functions. For the parent
19967 * elements, see g_markup_parse_context_get_element_stack().
19969 * Returns: the name of the currently open element, or %NULL
19975 * g_markup_parse_context_get_element_stack:
19976 * @context: a #GMarkupParseContext
19978 * Retrieves the element stack from the internal state of the parser.
19980 * The returned #GSList is a list of strings where the first item is
19981 * the currently open tag (as would be returned by
19982 * g_markup_parse_context_get_element()) and the next item is its
19983 * immediate parent.
19985 * This function is intended to be used in the start_element and
19986 * end_element handlers where g_markup_parse_context_get_element()
19987 * would merely return the name of the element that is being
19990 * Returns: the element stack, which must not be modified
19996 * g_markup_parse_context_get_position:
19997 * @context: a #GMarkupParseContext
19998 * @line_number: (allow-none): return location for a line number, or %NULL
19999 * @char_number: (allow-none): return location for a char-on-line number, or %NULL
20001 * Retrieves the current line number and the number of the character on
20002 * that line. Intended for use in error messages; there are no strict
20003 * semantics for what constitutes the "current" line number other than
20004 * "the best number we could come up with for error messages."
20009 * g_markup_parse_context_get_user_data:
20010 * @context: a #GMarkupParseContext
20012 * Returns the user_data associated with @context.
20014 * This will either be the user_data that was provided to
20015 * g_markup_parse_context_new() or to the most recent call
20016 * of g_markup_parse_context_push().
20018 * Returns: the provided user_data. The returned data belongs to
20019 * the markup context and will be freed when
20020 * g_markup_parse_context_free() is called.
20026 * g_markup_parse_context_new:
20027 * @parser: a #GMarkupParser
20028 * @flags: one or more #GMarkupParseFlags
20029 * @user_data: user data to pass to #GMarkupParser functions
20030 * @user_data_dnotify: user data destroy notifier called when
20031 * the parse context is freed
20033 * Creates a new parse context. A parse context is used to parse
20034 * marked-up documents. You can feed any number of documents into
20035 * a context, as long as no errors occur; once an error occurs,
20036 * the parse context can't continue to parse text (you have to
20037 * free it and create a new parse context).
20039 * Returns: a new #GMarkupParseContext
20044 * g_markup_parse_context_parse:
20045 * @context: a #GMarkupParseContext
20046 * @text: chunk of text to parse
20047 * @text_len: length of @text in bytes
20048 * @error: return location for a #GError
20050 * Feed some data to the #GMarkupParseContext.
20052 * The data need not be valid UTF-8; an error will be signaled if
20053 * it's invalid. The data need not be an entire document; you can
20054 * feed a document into the parser incrementally, via multiple calls
20055 * to this function. Typically, as you receive data from a network
20056 * connection or file, you feed each received chunk of data into this
20057 * function, aborting the process if an error occurs. Once an error
20058 * is reported, no further data may be fed to the #GMarkupParseContext;
20059 * all errors are fatal.
20061 * Returns: %FALSE if an error occurred, %TRUE on success
20066 * g_markup_parse_context_pop:
20067 * @context: a #GMarkupParseContext
20069 * Completes the process of a temporary sub-parser redirection.
20071 * This function exists to collect the user_data allocated by a
20072 * matching call to g_markup_parse_context_push(). It must be called
20073 * in the end_element handler corresponding to the start_element
20074 * handler during which g_markup_parse_context_push() was called.
20075 * You must not call this function from the error callback -- the
20076 * @user_data is provided directly to the callback in that case.
20078 * This function is not intended to be directly called by users
20079 * interested in invoking subparsers. Instead, it is intended to
20080 * be used by the subparsers themselves to implement a higher-level
20083 * Returns: the user data passed to g_markup_parse_context_push()
20089 * g_markup_parse_context_push:
20090 * @context: a #GMarkupParseContext
20091 * @parser: a #GMarkupParser
20092 * @user_data: user data to pass to #GMarkupParser functions
20094 * Temporarily redirects markup data to a sub-parser.
20096 * This function may only be called from the start_element handler of
20097 * a #GMarkupParser. It must be matched with a corresponding call to
20098 * g_markup_parse_context_pop() in the matching end_element handler
20099 * (except in the case that the parser aborts due to an error).
20101 * All tags, text and other data between the matching tags is
20102 * redirected to the subparser given by @parser. @user_data is used
20103 * as the user_data for that parser. @user_data is also passed to the
20104 * error callback in the event that an error occurs. This includes
20105 * errors that occur in subparsers of the subparser.
20107 * The end tag matching the start tag for which this call was made is
20108 * handled by the previous parser (which is given its own user_data)
20109 * which is why g_markup_parse_context_pop() is provided to allow "one
20110 * last access" to the @user_data provided to this function. In the
20111 * case of error, the @user_data provided here is passed directly to
20112 * the error callback of the subparser and g_markup_parse_context_pop()
20113 * should not be called. In either case, if @user_data was allocated
20114 * then it ought to be freed from both of these locations.
20116 * This function is not intended to be directly called by users
20117 * interested in invoking subparsers. Instead, it is intended to be
20118 * used by the subparsers themselves to implement a higher-level
20121 * As an example, see the following implementation of a simple
20122 * parser that counts the number of tags encountered.
20131 * counter_start_element (GMarkupParseContext *context,
20132 * const gchar *element_name,
20133 * const gchar **attribute_names,
20134 * const gchar **attribute_values,
20135 * gpointer user_data,
20138 * CounterData *data = user_data;
20140 * data->tag_count++;
20144 * counter_error (GMarkupParseContext *context,
20146 * gpointer user_data)
20148 * CounterData *data = user_data;
20150 * g_slice_free (CounterData, data);
20153 * static GMarkupParser counter_subparser =
20155 * counter_start_element,
20163 * In order to allow this parser to be easily used as a subparser, the
20164 * following interface is provided:
20168 * start_counting (GMarkupParseContext *context)
20170 * CounterData *data = g_slice_new (CounterData);
20172 * data->tag_count = 0;
20173 * g_markup_parse_context_push (context, &counter_subparser, data);
20177 * end_counting (GMarkupParseContext *context)
20179 * CounterData *data = g_markup_parse_context_pop (context);
20182 * result = data->tag_count;
20183 * g_slice_free (CounterData, data);
20189 * The subparser would then be used as follows:
20192 * static void start_element (context, element_name, ...)
20194 * if (strcmp (element_name, "count-these") == 0)
20195 * start_counting (context);
20197 * /* else, handle other tags... */
20200 * static void end_element (context, element_name, ...)
20202 * if (strcmp (element_name, "count-these") == 0)
20203 * g_print ("Counted %d tags\n", end_counting (context));
20205 * /* else, handle other tags... */
20214 * g_markup_parse_context_ref:
20215 * @context: a #GMarkupParseContext
20217 * Increases the reference count of @context.
20219 * Returns: the same @context
20225 * g_markup_parse_context_unref:
20226 * @context: a #GMarkupParseContext
20228 * Decreases the reference count of @context. When its reference count
20229 * drops to 0, it is freed.
20236 * g_markup_printf_escaped:
20237 * @format: printf() style format string
20238 * @...: the arguments to insert in the format string
20240 * Formats arguments according to @format, escaping
20241 * all string and character arguments in the fashion
20242 * of g_markup_escape_text(). This is useful when you
20243 * want to insert literal strings into XML-style markup
20244 * output, without having to worry that the strings
20245 * might themselves contain markup.
20248 * const char *store = "Fortnum & Mason";
20249 * const char *item = "Tea";
20252 * output = g_markup_printf_escaped ("<purchase>"
20253 * "<store>%s</store>"
20254 * "<item>%s</item>"
20255 * "</purchase>",
20259 * Returns: newly allocated result from formatting
20260 * operation. Free with g_free().
20266 * g_markup_vprintf_escaped:
20267 * @format: printf() style format string
20268 * @args: variable argument list, similar to vprintf()
20270 * Formats the data in @args according to @format, escaping
20271 * all string and character arguments in the fashion
20272 * of g_markup_escape_text(). See g_markup_printf_escaped().
20274 * Returns: newly allocated result from formatting
20275 * operation. Free with g_free().
20281 * g_match_info_expand_references:
20282 * @match_info: (allow-none): a #GMatchInfo or %NULL
20283 * @string_to_expand: the string to expand
20284 * @error: location to store the error occurring, or %NULL to ignore errors
20286 * Returns a new string containing the text in @string_to_expand with
20287 * references and escape sequences expanded. References refer to the last
20288 * match done with @string against @regex and have the same syntax used by
20289 * g_regex_replace().
20291 * The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
20292 * passed to g_regex_new().
20294 * The backreferences are extracted from the string passed to the match
20295 * function, so you cannot call this function after freeing the string.
20297 * @match_info may be %NULL in which case @string_to_expand must not
20298 * contain references. For instance "foo\n" does not refer to an actual
20299 * pattern and '\n' merely will be replaced with \n character,
20300 * while to expand "\0" (whole match) one needs the result of a match.
20301 * Use g_regex_check_replacement() to find out whether @string_to_expand
20302 * contains references.
20304 * Returns: (allow-none): the expanded string, or %NULL if an error occurred
20310 * g_match_info_fetch:
20311 * @match_info: #GMatchInfo structure
20312 * @match_num: number of the sub expression
20314 * Retrieves the text matching the @match_num<!-- -->'th capturing
20315 * parentheses. 0 is the full text of the match, 1 is the first paren
20316 * set, 2 the second, and so on.
20318 * If @match_num is a valid sub pattern but it didn't match anything
20319 * (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
20320 * string is returned.
20322 * If the match was obtained using the DFA algorithm, that is using
20323 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20324 * string is not that of a set of parentheses but that of a matched
20325 * substring. Substrings are matched in reverse order of length, so
20326 * 0 is the longest match.
20328 * The string is fetched from the string passed to the match function,
20329 * so you cannot call this function after freeing the string.
20331 * Returns: (allow-none): The matched substring, or %NULL if an error
20332 * occurred. You have to free the string yourself
20338 * g_match_info_fetch_all:
20339 * @match_info: a #GMatchInfo structure
20341 * Bundles up pointers to each of the matching substrings from a match
20342 * and stores them in an array of gchar pointers. The first element in
20343 * the returned array is the match number 0, i.e. the entire matched
20346 * If a sub pattern didn't match anything (e.g. sub pattern 1, matching
20347 * "b" against "(a)?b") then an empty string is inserted.
20349 * If the last match was obtained using the DFA algorithm, that is using
20350 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20351 * strings are not that matched by sets of parentheses but that of the
20352 * matched substring. Substrings are matched in reverse order of length,
20353 * so the first one is the longest match.
20355 * The strings are fetched from the string passed to the match function,
20356 * so you cannot call this function after freeing the string.
20358 * Returns: (transfer full): a %NULL-terminated array of gchar *
20359 * pointers. It must be freed using g_strfreev(). If the previous
20360 * match failed %NULL is returned
20366 * g_match_info_fetch_named:
20367 * @match_info: #GMatchInfo structure
20368 * @name: name of the subexpression
20370 * Retrieves the text matching the capturing parentheses named @name.
20372 * If @name is a valid sub pattern name but it didn't match anything
20373 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
20374 * then an empty string is returned.
20376 * The string is fetched from the string passed to the match function,
20377 * so you cannot call this function after freeing the string.
20379 * Returns: (allow-none): The matched substring, or %NULL if an error
20380 * occurred. You have to free the string yourself
20386 * g_match_info_fetch_named_pos:
20387 * @match_info: #GMatchInfo structure
20388 * @name: name of the subexpression
20389 * @start_pos: (out) (allow-none): pointer to location where to store
20390 * the start position, or %NULL
20391 * @end_pos: (out) (allow-none): pointer to location where to store
20392 * the end position, or %NULL
20394 * Retrieves the position in bytes of the capturing parentheses named @name.
20396 * If @name is a valid sub pattern name but it didn't match anything
20397 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
20398 * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
20400 * Returns: %TRUE if the position was fetched, %FALSE otherwise.
20401 * If the position cannot be fetched, @start_pos and @end_pos
20402 * are left unchanged.
20408 * g_match_info_fetch_pos:
20409 * @match_info: #GMatchInfo structure
20410 * @match_num: number of the sub expression
20411 * @start_pos: (out) (allow-none): pointer to location where to store
20412 * the start position, or %NULL
20413 * @end_pos: (out) (allow-none): pointer to location where to store
20414 * the end position, or %NULL
20416 * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
20417 * parentheses. 0 is the full text of the match, 1 is the first
20418 * paren set, 2 the second, and so on.
20420 * If @match_num is a valid sub pattern but it didn't match anything
20421 * (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
20422 * and @end_pos are set to -1 and %TRUE is returned.
20424 * If the match was obtained using the DFA algorithm, that is using
20425 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20426 * position is not that of a set of parentheses but that of a matched
20427 * substring. Substrings are matched in reverse order of length, so
20428 * 0 is the longest match.
20430 * Returns: %TRUE if the position was fetched, %FALSE otherwise. If
20431 * the position cannot be fetched, @start_pos and @end_pos are left
20438 * g_match_info_free:
20439 * @match_info: (allow-none): a #GMatchInfo, or %NULL
20441 * If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
20449 * g_match_info_get_match_count:
20450 * @match_info: a #GMatchInfo structure
20452 * Retrieves the number of matched substrings (including substring 0,
20453 * that is the whole matched text), so 1 is returned if the pattern
20454 * has no substrings in it and 0 is returned if the match failed.
20456 * If the last match was obtained using the DFA algorithm, that is
20457 * using g_regex_match_all() or g_regex_match_all_full(), the retrieved
20458 * count is not that of the number of capturing parentheses but that of
20459 * the number of matched substrings.
20461 * Returns: Number of matched substrings, or -1 if an error occurred
20467 * g_match_info_get_regex:
20468 * @match_info: a #GMatchInfo
20470 * Returns #GRegex object used in @match_info. It belongs to Glib
20471 * and must not be freed. Use g_regex_ref() if you need to keep it
20472 * after you free @match_info object.
20474 * Returns: #GRegex object used in @match_info
20480 * g_match_info_get_string:
20481 * @match_info: a #GMatchInfo
20483 * Returns the string searched with @match_info. This is the
20484 * string passed to g_regex_match() or g_regex_replace() so
20485 * you may not free it before calling this function.
20487 * Returns: the string searched with @match_info
20493 * g_match_info_is_partial_match:
20494 * @match_info: a #GMatchInfo structure
20496 * Usually if the string passed to g_regex_match*() matches as far as
20497 * it goes, but is too short to match the entire pattern, %FALSE is
20498 * returned. There are circumstances where it might be helpful to
20499 * distinguish this case from other cases in which there is no match.
20501 * Consider, for example, an application where a human is required to
20502 * type in data for a field with specific formatting requirements. An
20503 * example might be a date in the form ddmmmyy, defined by the pattern
20504 * "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
20505 * If the application sees the user’s keystrokes one by one, and can
20506 * check that what has been typed so far is potentially valid, it is
20507 * able to raise an error as soon as a mistake is made.
20509 * GRegex supports the concept of partial matching by means of the
20510 * #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD flags.
20511 * When they are used, the return code for
20512 * g_regex_match() or g_regex_match_full() is, as usual, %TRUE
20513 * for a complete match, %FALSE otherwise. But, when these functions
20514 * return %FALSE, you can check if the match was partial calling
20515 * g_match_info_is_partial_match().
20517 * The difference between #G_REGEX_MATCH_PARTIAL_SOFT and
20518 * #G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
20519 * with #G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
20520 * possible complete match, while with #G_REGEX_MATCH_PARTIAL_HARD matching
20521 * stops at the partial match.
20522 * When both #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD
20523 * are set, the latter takes precedence.
20525 * There were formerly some restrictions on the pattern for partial matching.
20526 * The restrictions no longer apply.
20528 * See <ulink>man:pcrepartial</ulink> for more information on partial matching.
20530 * Returns: %TRUE if the match was partial, %FALSE otherwise
20536 * g_match_info_matches:
20537 * @match_info: a #GMatchInfo structure
20539 * Returns whether the previous match operation succeeded.
20541 * Returns: %TRUE if the previous match operation succeeded,
20548 * g_match_info_next:
20549 * @match_info: a #GMatchInfo structure
20550 * @error: location to store the error occurring, or %NULL to ignore errors
20552 * Scans for the next match using the same parameters of the previous
20553 * call to g_regex_match_full() or g_regex_match() that returned
20556 * The match is done on the string passed to the match function, so you
20557 * cannot free it before calling this function.
20559 * Returns: %TRUE is the string matched, %FALSE otherwise
20565 * g_match_info_ref:
20566 * @match_info: a #GMatchInfo
20568 * Increases reference count of @match_info by 1.
20570 * Returns: @match_info
20576 * g_match_info_unref:
20577 * @match_info: a #GMatchInfo
20579 * Decreases reference count of @match_info by 1. When reference count drops
20580 * to zero, it frees all the memory associated with the match_info structure.
20587 * g_mem_gc_friendly:
20589 * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
20590 * includes the key <literal>gc-friendly</literal>.
20595 * g_mem_is_system_malloc:
20597 * Checks whether the allocator used by g_malloc() is the system's
20598 * malloc implementation. If it returns %TRUE memory allocated with
20599 * malloc() can be used interchangeable with memory allocated using g_malloc().
20600 * This function is useful for avoiding an extra copy of allocated memory returned
20601 * by a non-GLib-based API.
20603 * A different allocator can be set using g_mem_set_vtable().
20605 * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
20612 * Outputs a summary of memory usage.
20614 * It outputs the frequency of allocations of different sizes,
20615 * the total number of bytes which have been allocated,
20616 * the total number of bytes which have been freed,
20617 * and the difference between the previous two values, i.e. the number of bytes
20620 * Note that this function will not output anything unless you have
20621 * previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
20626 * g_mem_set_vtable:
20627 * @vtable: table of memory allocation routines.
20629 * Sets the #GMemVTable to use for memory allocation. You can use this to provide
20630 * custom memory allocation routines. <emphasis>This function must be called
20631 * before using any other GLib functions.</emphasis> The @vtable only needs to
20632 * provide malloc(), realloc(), and free() functions; GLib can provide default
20633 * implementations of the others. The malloc() and realloc() implementations
20634 * should return %NULL on failure, GLib will handle error-checking for you.
20635 * @vtable is copied, so need not persist after this function has been called.
20641 * @mem: the memory to copy.
20642 * @byte_size: the number of bytes to copy.
20644 * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
20645 * from @mem. If @mem is %NULL it returns %NULL.
20647 * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
20654 * @dest: the destination address to copy the bytes to.
20655 * @src: the source address to copy the bytes from.
20656 * @len: the number of bytes to copy.
20658 * Copies a block of memory @len bytes long, from @src to @dest.
20659 * The source and destination areas may overlap.
20661 * In order to use this function, you must include
20662 * <filename>string.h</filename> yourself, because this macro will
20663 * typically simply resolve to memmove() and GLib does not include
20664 * <filename>string.h</filename> for you.
20670 * @...: format string, followed by parameters to insert
20671 * into the format string (as with printf())
20673 * A convenience function/macro to log a normal message.
20675 * If g_log_default_handler() is used as the log handler function, a new-line
20676 * character will automatically be appended to @..., and need not be entered
20683 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
20684 * @mode: permissions to use for the newly created directory
20686 * A wrapper for the POSIX mkdir() function. The mkdir() function
20687 * attempts to create a directory with the given name and permissions.
20688 * The mode argument is ignored on Windows.
20690 * See your C library manual for more details about mkdir().
20692 * Returns: 0 if the directory was successfully created, -1 if an error
20699 * g_mkdir_with_parents:
20700 * @pathname: a pathname in the GLib file name encoding
20701 * @mode: permissions to use for newly created directories
20703 * Create a directory if it doesn't already exist. Create intermediate
20704 * parent directories as needed, too.
20706 * Returns: 0 if the directory already exists, or was successfully
20707 * created. Returns -1 if an error occurred, with errno set.
20714 * @tmpl: (type filename): template directory name
20716 * Creates a temporary directory. See the mkdtemp() documentation
20717 * on most UNIX-like systems.
20719 * The parameter is a string that should follow the rules for
20720 * mkdtemp() templates, i.e. contain the string "XXXXXX".
20721 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
20722 * sequence does not have to occur at the very end of the template
20723 * and you can pass a @mode and additional @flags. The X string will
20724 * be modified to form the name of a directory that didn't exist.
20725 * The string should be in the GLib file name encoding. Most importantly,
20726 * on Windows it should be in UTF-8.
20728 * Returns: A pointer to @tmpl, which has been modified
20729 * to hold the directory name. In case of errors, %NULL is
20730 * returned and %errno will be set.
20737 * @tmpl: (type filename): template directory name
20738 * @mode: permissions to create the temporary directory with
20740 * Creates a temporary directory. See the mkdtemp() documentation
20741 * on most UNIX-like systems.
20743 * The parameter is a string that should follow the rules for
20744 * mkdtemp() templates, i.e. contain the string "XXXXXX".
20745 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
20746 * sequence does not have to occur at the very end of the template
20747 * and you can pass a @mode. The X string will be modified to form
20748 * the name of a directory that didn't exist. The string should be
20749 * in the GLib file name encoding. Most importantly, on Windows it
20750 * should be in UTF-8.
20752 * Returns: A pointer to @tmpl, which has been modified
20753 * to hold the directory name. In case of errors, %NULL is
20754 * returned, and %errno will be set.
20761 * @tmpl: (type filename): template filename
20763 * Opens a temporary file. See the mkstemp() documentation
20764 * on most UNIX-like systems.
20766 * The parameter is a string that should follow the rules for
20767 * mkstemp() templates, i.e. contain the string "XXXXXX".
20768 * g_mkstemp() is slightly more flexible than mkstemp() in that the
20769 * sequence does not have to occur at the very end of the template.
20770 * The X string will be modified to form the name of a file that
20771 * didn't exist. The string should be in the GLib file name encoding.
20772 * Most importantly, on Windows it should be in UTF-8.
20774 * Returns: A file handle (as from open()) to the file
20775 * opened for reading and writing. The file is opened in binary
20776 * mode on platforms where there is a difference. The file handle
20777 * should be closed with close(). In case of errors, -1 is
20778 * returned and %errno will be set.
20784 * @tmpl: (type filename): template filename
20785 * @flags: flags to pass to an open() call in addition to O_EXCL
20786 * and O_CREAT, which are passed automatically
20787 * @mode: permissions to create the temporary file with
20789 * Opens a temporary file. See the mkstemp() documentation
20790 * on most UNIX-like systems.
20792 * The parameter is a string that should follow the rules for
20793 * mkstemp() templates, i.e. contain the string "XXXXXX".
20794 * g_mkstemp_full() is slightly more flexible than mkstemp()
20795 * in that the sequence does not have to occur at the very end of the
20796 * template and you can pass a @mode and additional @flags. The X
20797 * string will be modified to form the name of a file that didn't exist.
20798 * The string should be in the GLib file name encoding. Most importantly,
20799 * on Windows it should be in UTF-8.
20801 * Returns: A file handle (as from open()) to the file
20802 * opened for reading and writing. The file handle should be
20803 * closed with close(). In case of errors, -1 is returned
20804 * and %errno will be set.
20811 * @mutex: an initialized #GMutex
20813 * Frees the resources allocated to a mutex with g_mutex_init().
20815 * This function should not be used with a #GMutex that has been
20816 * statically allocated.
20818 * Calling g_mutex_clear() on a locked mutex leads to undefined
20827 * @mutex: an uninitialized #GMutex
20829 * Initializes a #GMutex so that it can be used.
20831 * This function is useful to initialize a mutex that has been
20832 * allocated on the stack, or as part of a larger structure.
20833 * It is not necessary to initialize a mutex that has been
20834 * statically allocated.
20844 * b = g_new (Blob, 1);
20845 * g_mutex_init (&b->m);
20848 * To undo the effect of g_mutex_init() when a mutex is no longer
20849 * needed, use g_mutex_clear().
20851 * Calling g_mutex_init() on an already initialized #GMutex leads
20852 * to undefined behaviour.
20860 * @mutex: a #GMutex
20862 * Locks @mutex. If @mutex is already locked by another thread, the
20863 * current thread will block until @mutex is unlocked by the other
20866 * <note>#GMutex is neither guaranteed to be recursive nor to be
20867 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
20868 * already been locked by the same thread results in undefined behaviour
20869 * (including but not limited to deadlocks).</note>
20875 * @mutex: a #GMutex
20877 * Tries to lock @mutex. If @mutex is already locked by another thread,
20878 * it immediately returns %FALSE. Otherwise it locks @mutex and returns
20881 * <note>#GMutex is neither guaranteed to be recursive nor to be
20882 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
20883 * already been locked by the same thread results in undefined behaviour
20884 * (including but not limited to deadlocks or arbitrary return values).
20887 * Returns: %TRUE if @mutex could be locked
20893 * @mutex: a #GMutex
20895 * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
20896 * call for @mutex, it will become unblocked and can lock @mutex itself.
20898 * Calling g_mutex_unlock() on a mutex that is not locked by the
20899 * current thread leads to undefined behaviour.
20904 * g_node_child_index:
20906 * @data: the data to find
20908 * Gets the position of the first child of a #GNode
20909 * which contains the given data.
20911 * Returns: the index of the child of @node which contains
20912 * @data, or -1 if the data is not found
20917 * g_node_child_position:
20919 * @child: a child of @node
20921 * Gets the position of a #GNode with respect to its siblings.
20922 * @child must be a child of @node. The first child is numbered 0,
20923 * the second 1, and so on.
20925 * Returns: the position of @child with respect to its siblings
20930 * g_node_children_foreach:
20932 * @flags: which types of children are to be visited, one of
20933 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20934 * @func: the function to call for each visited node
20935 * @data: user data to pass to the function
20937 * Calls a function for each of the children of a #GNode.
20938 * Note that it doesn't descend beneath the child nodes.
20946 * Recursively copies a #GNode (but does not deep-copy the data inside the
20947 * nodes, see g_node_copy_deep() if you need that).
20949 * Returns: a new #GNode containing the same data pointers
20954 * g_node_copy_deep:
20956 * @copy_func: the function which is called to copy the data inside each node,
20957 * or %NULL to use the original data.
20958 * @data: data to pass to @copy_func
20960 * Recursively copies a #GNode and its data.
20962 * Returns: a new #GNode containing copies of the data in @node.
20971 * Gets the depth of a #GNode.
20973 * If @node is %NULL the depth is 0. The root node has a depth of 1.
20974 * For the children of the root node the depth is 2. And so on.
20976 * Returns: the depth of the #GNode
20982 * @root: the root of the tree/subtree to destroy
20984 * Removes @root and its children from the tree, freeing any memory
20991 * @root: the root #GNode of the tree to search
20992 * @order: the order in which nodes are visited - %G_IN_ORDER,
20993 * %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
20994 * @flags: which types of children are to be searched, one of
20995 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20996 * @data: the data to find
20998 * Finds a #GNode in a tree.
21000 * Returns: the found #GNode, or %NULL if the data is not found
21005 * g_node_find_child:
21007 * @flags: which types of children are to be searched, one of
21008 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21009 * @data: the data to find
21011 * Finds the first child of a #GNode with the given data.
21013 * Returns: the found child #GNode, or %NULL if the data is not found
21018 * g_node_first_sibling:
21021 * Gets the first sibling of a #GNode.
21022 * This could possibly be the node itself.
21024 * Returns: the first sibling of @node
21032 * Gets the root of a tree.
21034 * Returns: the root of the tree
21040 * @parent: the #GNode to place @node under
21041 * @position: the position to place @node at, with respect to its siblings
21042 * If position is -1, @node is inserted as the last child of @parent
21043 * @node: the #GNode to insert
21045 * Inserts a #GNode beneath the parent at the given position.
21047 * Returns: the inserted #GNode
21052 * g_node_insert_after:
21053 * @parent: the #GNode to place @node under
21054 * @sibling: the sibling #GNode to place @node after.
21055 * If sibling is %NULL, the node is inserted as the first child of @parent.
21056 * @node: the #GNode to insert
21058 * Inserts a #GNode beneath the parent after the given sibling.
21060 * Returns: the inserted #GNode
21065 * g_node_insert_before:
21066 * @parent: the #GNode to place @node under
21067 * @sibling: the sibling #GNode to place @node before.
21068 * If sibling is %NULL, the node is inserted as the last child of @parent.
21069 * @node: the #GNode to insert
21071 * Inserts a #GNode beneath the parent before the given sibling.
21073 * Returns: the inserted #GNode
21078 * g_node_is_ancestor:
21080 * @descendant: a #GNode
21082 * Returns %TRUE if @node is an ancestor of @descendant.
21083 * This is true if node is the parent of @descendant,
21084 * or if node is the grandparent of @descendant etc.
21086 * Returns: %TRUE if @node is an ancestor of @descendant
21091 * g_node_last_child:
21092 * @node: a #GNode (must not be %NULL)
21094 * Gets the last child of a #GNode.
21096 * Returns: the last child of @node, or %NULL if @node has no children
21101 * g_node_last_sibling:
21104 * Gets the last sibling of a #GNode.
21105 * This could possibly be the node itself.
21107 * Returns: the last sibling of @node
21112 * g_node_max_height:
21115 * Gets the maximum height of all branches beneath a #GNode.
21116 * This is the maximum distance from the #GNode to all leaf nodes.
21118 * If @root is %NULL, 0 is returned. If @root has no children,
21119 * 1 is returned. If @root has children, 2 is returned. And so on.
21121 * Returns: the maximum height of the tree beneath @root
21126 * g_node_n_children:
21129 * Gets the number of children of a #GNode.
21131 * Returns: the number of children of @node
21138 * @flags: which types of children are to be counted, one of
21139 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21141 * Gets the number of nodes in a tree.
21143 * Returns: the number of nodes in the tree
21149 * @data: the data of the new node
21151 * Creates a new #GNode containing the given data.
21152 * Used to create the first node in a tree.
21154 * Returns: a new #GNode
21159 * g_node_nth_child:
21161 * @n: the index of the desired child
21163 * Gets a child of a #GNode, using the given index.
21164 * The first child is at index 0. If the index is
21165 * too big, %NULL is returned.
21167 * Returns: the child of @node at index @n
21173 * @parent: the #GNode to place the new #GNode under
21174 * @node: the #GNode to insert
21176 * Inserts a #GNode as the first child of the given parent.
21178 * Returns: the inserted #GNode
21183 * g_node_reverse_children:
21186 * Reverses the order of the children of a #GNode.
21187 * (It doesn't change the order of the grandchildren.)
21193 * @root: the root #GNode of the tree to traverse
21194 * @order: the order in which nodes are visited - %G_IN_ORDER,
21195 * %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
21196 * @flags: which types of children are to be visited, one of
21197 * %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21198 * @max_depth: the maximum depth of the traversal. Nodes below this
21199 * depth will not be visited. If max_depth is -1 all nodes in
21200 * the tree are visited. If depth is 1, only the root is visited.
21201 * If depth is 2, the root and its children are visited. And so on.
21202 * @func: the function to call for each visited #GNode
21203 * @data: user data to pass to the function
21205 * Traverses a tree starting at the given root #GNode.
21206 * It calls the given function for each node visited.
21207 * The traversal can be halted at any point by returning %TRUE from @func.
21213 * @node: the #GNode to unlink, which becomes the root of a new tree
21215 * Unlinks a #GNode from a tree, resulting in two separate trees.
21221 * @val: a 32-bit integer value in network byte order
21223 * Converts a 32-bit integer value from network to host byte order.
21225 * Returns: @val converted to host byte order.
21231 * @val: a 16-bit integer value in network byte order
21233 * Converts a 16-bit integer value from network to host byte order.
21235 * Returns: @val converted to host byte order
21240 * g_nullify_pointer:
21241 * @nullify_location: the memory address of the pointer.
21243 * Set the pointer at the specified location to %NULL.
21248 * g_on_error_query:
21249 * @prg_name: the program name, needed by <command>gdb</command>
21250 * for the [S]tack trace option. If @prg_name is %NULL, g_get_prgname()
21251 * is called to get the program name (which will work correctly if
21252 * gdk_init() or gtk_init() has been called)
21254 * Prompts the user with
21255 * <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
21256 * This function is intended to be used for debugging use only.
21257 * The following example shows how it can be used together with
21258 * the g_log() functions.
21261 * #include <glib.h>
21264 * log_handler (const gchar *log_domain,
21265 * GLogLevelFlags log_level,
21266 * const gchar *message,
21267 * gpointer user_data)
21269 * g_log_default_handler (log_domain, log_level, message, user_data);
21271 * g_on_error_query (MY_PROGRAM_NAME);
21275 * main (int argc, char *argv[])
21277 * g_log_set_handler (MY_LOG_DOMAIN,
21278 * G_LOG_LEVEL_WARNING |
21279 * G_LOG_LEVEL_ERROR |
21280 * G_LOG_LEVEL_CRITICAL,
21283 * /* ... */
21286 * If [E]xit is selected, the application terminates with a call
21287 * to <literal>_exit(0)</literal>.
21289 * If [S]tack trace is selected, g_on_error_stack_trace() is called.
21290 * This invokes <command>gdb</command>, which attaches to the current
21291 * process and shows a stack trace. The prompt is then shown again.
21293 * If [P]roceed is selected, the function returns.
21295 * This function may cause different actions on non-UNIX platforms.
21300 * g_on_error_stack_trace:
21301 * @prg_name: the program name, needed by <command>gdb</command>
21302 * for the [S]tack trace option.
21304 * Invokes <command>gdb</command>, which attaches to the current
21305 * process and shows a stack trace. Called by g_on_error_query()
21306 * when the [S]tack trace option is selected. You can get the current
21307 * process's "program name" with g_get_prgname(), assuming that you
21308 * have called gtk_init() or gdk_init().
21310 * This function may cause different actions on non-UNIX platforms.
21316 * @once: a #GOnce structure
21317 * @func: the #GThreadFunc function associated to @once. This function
21318 * is called only once, regardless of the number of times it and
21319 * its associated #GOnce struct are passed to g_once().
21320 * @arg: data to be passed to @func
21322 * The first call to this routine by a process with a given #GOnce
21323 * struct calls @func with the given argument. Thereafter, subsequent
21324 * calls to g_once() with the same #GOnce struct do not call @func
21325 * again, but return the stored result of the first call. On return
21326 * from g_once(), the status of @once will be %G_ONCE_STATUS_READY.
21328 * For example, a mutex or a thread-specific data key must be created
21329 * exactly once. In a threaded environment, calling g_once() ensures
21330 * that the initialization is serialized across multiple threads.
21332 * Calling g_once() recursively on the same #GOnce struct in
21333 * @func will lead to a deadlock.
21337 * get_debug_flags (void)
21339 * static GOnce my_once = G_ONCE_INIT;
21341 * g_once (&my_once, parse_debug_flags, NULL);
21343 * return my_once.retval;
21352 * g_once_init_enter:
21353 * @location: location of a static initializable variable containing 0
21355 * Function to be called when starting a critical initialization
21356 * section. The argument @location must point to a static
21357 * 0-initialized variable that will be set to a value other than 0 at
21358 * the end of the initialization section. In combination with
21359 * g_once_init_leave() and the unique address @value_location, it can
21360 * be ensured that an initialization section will be executed only once
21361 * during a program's life time, and that concurrent threads are
21362 * blocked until initialization completed. To be used in constructs
21366 * static gsize initialization_value = 0;
21368 * if (g_once_init_enter (&initialization_value))
21370 * gsize setup_value = 42; /** initialization code here **/
21372 * g_once_init_leave (&initialization_value, setup_value);
21375 * /** use initialization_value here **/
21378 * Returns: %TRUE if the initialization section should be entered,
21379 * %FALSE and blocks otherwise
21385 * g_once_init_leave:
21386 * @location: location of a static initializable variable containing 0
21387 * @result: new non-0 value for *@value_location
21389 * Counterpart to g_once_init_enter(). Expects a location of a static
21390 * 0-initialized initialization variable, and an initialization value
21391 * other than 0. Sets the variable to the initialization value, and
21392 * releases concurrent threads blocking in g_once_init_enter() on this
21393 * initialization variable.
21401 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
21402 * @flags: as in open()
21403 * @mode: as in open()
21405 * A wrapper for the POSIX open() function. The open() function is
21406 * used to convert a pathname into a file descriptor.
21408 * On POSIX systems file descriptors are implemented by the operating
21409 * system. On Windows, it's the C library that implements open() and
21410 * file descriptors. The actual Win32 API for opening files is quite
21411 * different, see MSDN documentation for CreateFile(). The Win32 API
21412 * uses file handles, which are more randomish integers, not small
21413 * integers like file descriptors.
21415 * Because file descriptors are specific to the C library on Windows,
21416 * the file descriptor returned by this function makes sense only to
21417 * functions in the same C library. Thus if the GLib-using code uses a
21418 * different C library than GLib does, the file descriptor returned by
21419 * this function cannot be passed to C library functions like write()
21422 * See your C library manual for more details about open().
21424 * Returns: a new file descriptor, or -1 if an error occurred. The
21425 * return value can be used exactly like the return value from open().
21431 * g_option_context_add_group:
21432 * @context: a #GOptionContext
21433 * @group: the group to add
21435 * Adds a #GOptionGroup to the @context, so that parsing with @context
21436 * will recognize the options in the group. Note that the group will
21437 * be freed together with the context when g_option_context_free() is
21438 * called, so you must not free the group yourself after adding it
21446 * g_option_context_add_main_entries:
21447 * @context: a #GOptionContext
21448 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
21449 * @translation_domain: (allow-none): a translation domain to use for translating
21450 * the <option>--help</option> output for the options in @entries
21451 * with gettext(), or %NULL
21453 * A convenience function which creates a main group if it doesn't
21454 * exist, adds the @entries to it and sets the translation domain.
21461 * g_option_context_free:
21462 * @context: a #GOptionContext
21464 * Frees context and all the groups which have been
21467 * Please note that parsed arguments need to be freed separately (see
21475 * g_option_context_get_description:
21476 * @context: a #GOptionContext
21478 * Returns the description. See g_option_context_set_description().
21480 * Returns: the description
21486 * g_option_context_get_help:
21487 * @context: a #GOptionContext
21488 * @main_help: if %TRUE, only include the main group
21489 * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
21491 * Returns a formatted, translated help text for the given context.
21492 * To obtain the text produced by <option>--help</option>, call
21493 * <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
21494 * To obtain the text produced by <option>--help-all</option>, call
21495 * <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
21496 * To obtain the help text for an option group, call
21497 * <literal>g_option_context_get_help (context, FALSE, group)</literal>.
21499 * Returns: A newly allocated string containing the help text
21505 * g_option_context_get_help_enabled:
21506 * @context: a #GOptionContext
21508 * Returns whether automatic <option>--help</option> generation
21509 * is turned on for @context. See g_option_context_set_help_enabled().
21511 * Returns: %TRUE if automatic help generation is turned on.
21517 * g_option_context_get_ignore_unknown_options:
21518 * @context: a #GOptionContext
21520 * Returns whether unknown options are ignored or not. See
21521 * g_option_context_set_ignore_unknown_options().
21523 * Returns: %TRUE if unknown options are ignored.
21529 * g_option_context_get_main_group:
21530 * @context: a #GOptionContext
21532 * Returns a pointer to the main group of @context.
21534 * Returns: the main group of @context, or %NULL if @context doesn't
21535 * have a main group. Note that group belongs to @context and should
21536 * not be modified or freed.
21542 * g_option_context_get_summary:
21543 * @context: a #GOptionContext
21545 * Returns the summary. See g_option_context_set_summary().
21547 * Returns: the summary
21553 * g_option_context_new:
21554 * @parameter_string: (allow-none): a string which is displayed in
21555 * the first line of <option>--help</option> output, after the
21557 * <literal><replaceable>programname</replaceable> [OPTION...]</literal>
21559 * Creates a new option context.
21561 * The @parameter_string can serve multiple purposes. It can be used
21562 * to add descriptions for "rest" arguments, which are not parsed by
21563 * the #GOptionContext, typically something like "FILES" or
21564 * "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
21565 * collecting "rest" arguments, GLib handles this automatically by
21566 * using the @arg_description of the corresponding #GOptionEntry in
21567 * the usage summary.
21569 * Another usage is to give a short summary of the program
21570 * functionality, like " - frob the strings", which will be displayed
21571 * in the same line as the usage. For a longer description of the
21572 * program functionality that should be displayed as a paragraph
21573 * below the usage line, use g_option_context_set_summary().
21575 * Note that the @parameter_string is translated using the
21576 * function set with g_option_context_set_translate_func(), so
21577 * it should normally be passed untranslated.
21579 * Returns: a newly created #GOptionContext, which must be
21580 * freed with g_option_context_free() after use.
21586 * g_option_context_parse:
21587 * @context: a #GOptionContext
21588 * @argc: (inout) (allow-none): a pointer to the number of command line arguments
21589 * @argv: (inout) (array length=argc) (allow-none): a pointer to the array of command line arguments
21590 * @error: a return location for errors
21592 * Parses the command line arguments, recognizing options
21593 * which have been added to @context. A side-effect of
21594 * calling this function is that g_set_prgname() will be
21597 * If the parsing is successful, any parsed arguments are
21598 * removed from the array and @argc and @argv are updated
21599 * accordingly. A '--' option is stripped from @argv
21600 * unless there are unparsed options before and after it,
21601 * or some of the options after it start with '-'. In case
21602 * of an error, @argc and @argv are left unmodified.
21604 * If automatic <option>--help</option> support is enabled
21605 * (see g_option_context_set_help_enabled()), and the
21606 * @argv array contains one of the recognized help options,
21607 * this function will produce help output to stdout and
21608 * call <literal>exit (0)</literal>.
21610 * Note that function depends on the
21611 * <link linkend="setlocale">current locale</link> for
21612 * automatic character set conversion of string and filename
21615 * Returns: %TRUE if the parsing was successful,
21616 * %FALSE if an error occurred
21622 * g_option_context_set_description:
21623 * @context: a #GOptionContext
21624 * @description: (allow-none): a string to be shown in <option>--help</option> output
21625 * after the list of options, or %NULL
21627 * Adds a string to be displayed in <option>--help</option> output
21628 * after the list of options. This text often includes a bug reporting
21631 * Note that the summary is translated (see
21632 * g_option_context_set_translate_func()).
21639 * g_option_context_set_help_enabled:
21640 * @context: a #GOptionContext
21641 * @help_enabled: %TRUE to enable <option>--help</option>, %FALSE to disable it
21643 * Enables or disables automatic generation of <option>--help</option>
21644 * output. By default, g_option_context_parse() recognizes
21645 * <option>--help</option>, <option>-h</option>,
21646 * <option>-?</option>, <option>--help-all</option>
21647 * and <option>--help-</option><replaceable>groupname</replaceable> and creates
21648 * suitable output to stdout.
21655 * g_option_context_set_ignore_unknown_options:
21656 * @context: a #GOptionContext
21657 * @ignore_unknown: %TRUE to ignore unknown options, %FALSE to produce
21658 * an error when unknown options are met
21660 * Sets whether to ignore unknown options or not. If an argument is
21661 * ignored, it is left in the @argv array after parsing. By default,
21662 * g_option_context_parse() treats unknown options as error.
21664 * This setting does not affect non-option arguments (i.e. arguments
21665 * which don't start with a dash). But note that GOption cannot reliably
21666 * determine whether a non-option belongs to a preceding unknown option.
21673 * g_option_context_set_main_group:
21674 * @context: a #GOptionContext
21675 * @group: the group to set as main group
21677 * Sets a #GOptionGroup as main group of the @context.
21678 * This has the same effect as calling g_option_context_add_group(),
21679 * the only difference is that the options in the main group are
21680 * treated differently when generating <option>--help</option> output.
21687 * g_option_context_set_summary:
21688 * @context: a #GOptionContext
21689 * @summary: (allow-none): a string to be shown in <option>--help</option> output
21690 * before the list of options, or %NULL
21692 * Adds a string to be displayed in <option>--help</option> output
21693 * before the list of options. This is typically a summary of the
21694 * program functionality.
21696 * Note that the summary is translated (see
21697 * g_option_context_set_translate_func() and
21698 * g_option_context_set_translation_domain()).
21705 * g_option_context_set_translate_func:
21706 * @context: a #GOptionContext
21707 * @func: (allow-none): the #GTranslateFunc, or %NULL
21708 * @data: (allow-none): user data to pass to @func, or %NULL
21709 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
21711 * Sets the function which is used to translate the contexts
21712 * user-visible strings, for <option>--help</option> output.
21713 * If @func is %NULL, strings are not translated.
21715 * Note that option groups have their own translation functions,
21716 * this function only affects the @parameter_string (see g_option_context_new()),
21717 * the summary (see g_option_context_set_summary()) and the description
21718 * (see g_option_context_set_description()).
21720 * If you are using gettext(), you only need to set the translation
21721 * domain, see g_option_context_set_translation_domain().
21728 * g_option_context_set_translation_domain:
21729 * @context: a #GOptionContext
21730 * @domain: the domain to use
21732 * A convenience function to use gettext() for translating
21733 * user-visible strings.
21740 * g_option_group_add_entries:
21741 * @group: a #GOptionGroup
21742 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
21744 * Adds the options specified in @entries to @group.
21751 * g_option_group_free:
21752 * @group: a #GOptionGroup
21754 * Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
21755 * free groups which have been added to a #GOptionContext.
21762 * g_option_group_new:
21763 * @name: the name for the option group, this is used to provide
21764 * help for the options in this group with <option>--help-</option>@name
21765 * @description: a description for this group to be shown in
21766 * <option>--help</option>. This string is translated using the translation
21767 * domain or translation function of the group
21768 * @help_description: a description for the <option>--help-</option>@name option.
21769 * This string is translated using the translation domain or translation function
21771 * @user_data: (allow-none): user data that will be passed to the pre- and post-parse hooks,
21772 * the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
21773 * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
21775 * Creates a new #GOptionGroup.
21777 * Returns: a newly created option group. It should be added
21778 * to a #GOptionContext or freed with g_option_group_free().
21784 * g_option_group_set_error_hook:
21785 * @group: a #GOptionGroup
21786 * @error_func: a function to call when an error occurs
21788 * Associates a function with @group which will be called
21789 * from g_option_context_parse() when an error occurs.
21791 * Note that the user data to be passed to @error_func can be
21792 * specified when constructing the group with g_option_group_new().
21799 * g_option_group_set_parse_hooks:
21800 * @group: a #GOptionGroup
21801 * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
21802 * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
21804 * Associates two functions with @group which will be called
21805 * from g_option_context_parse() before the first option is parsed
21806 * and after the last option has been parsed, respectively.
21808 * Note that the user data to be passed to @pre_parse_func and
21809 * @post_parse_func can be specified when constructing the group
21810 * with g_option_group_new().
21817 * g_option_group_set_translate_func:
21818 * @group: a #GOptionGroup
21819 * @func: (allow-none): the #GTranslateFunc, or %NULL
21820 * @data: (allow-none): user data to pass to @func, or %NULL
21821 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
21823 * Sets the function which is used to translate user-visible
21824 * strings, for <option>--help</option> output. Different
21825 * groups can use different #GTranslateFunc<!-- -->s. If @func
21826 * is %NULL, strings are not translated.
21828 * If you are using gettext(), you only need to set the translation
21829 * domain, see g_option_group_set_translation_domain().
21836 * g_option_group_set_translation_domain:
21837 * @group: a #GOptionGroup
21838 * @domain: the domain to use
21840 * A convenience function to use gettext() for translating
21841 * user-visible strings.
21848 * g_parse_debug_string:
21849 * @string: (allow-none): a list of debug options separated by colons, spaces, or
21850 * commas, or %NULL.
21851 * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate
21852 * strings with bit flags.
21853 * @nkeys: the number of #GDebugKey<!-- -->s in the array.
21855 * Parses a string containing debugging options
21856 * into a %guint containing bit flags. This is used
21857 * within GDK and GTK+ to parse the debug options passed on the
21858 * command line or through environment variables.
21860 * If @string is equal to <code>"all"</code>, all flags are set. Any flags
21861 * specified along with <code>"all"</code> in @string are inverted; thus,
21862 * <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
21863 * except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
21865 * If @string is equal to <code>"help"</code>, all the available keys in @keys
21866 * are printed out to standard error.
21868 * Returns: the combined set of bit flags.
21873 * g_path_get_basename:
21874 * @file_name: the name of the file
21876 * Gets the last component of the filename.
21878 * If @file_name ends with a directory separator it gets the component
21879 * before the last slash. If @file_name consists only of directory
21880 * separators (and on Windows, possibly a drive letter), a single
21881 * separator is returned. If @file_name is empty, it gets ".".
21883 * Returns: a newly allocated string containing the last
21884 * component of the filename
21889 * g_path_get_dirname:
21890 * @file_name: the name of the file
21892 * Gets the directory components of a file name.
21894 * If the file name has no directory components "." is returned.
21895 * The returned string should be freed when no longer needed.
21897 * Returns: the directory components of the file
21902 * g_path_is_absolute:
21903 * @file_name: a file name
21905 * Returns %TRUE if the given @file_name is an absolute file name.
21906 * Note that this is a somewhat vague concept on Windows.
21908 * On POSIX systems, an absolute file name is well-defined. It always
21909 * starts from the single root directory. For example "/usr/local".
21911 * On Windows, the concepts of current drive and drive-specific
21912 * current directory introduce vagueness. This function interprets as
21913 * an absolute file name one that either begins with a directory
21914 * separator such as "\Users\tml" or begins with the root on a drive,
21915 * for example "C:\Windows". The first case also includes UNC paths
21916 * such as "\\myserver\docs\foo". In all cases, either slashes or
21917 * backslashes are accepted.
21919 * Note that a file name relative to the current drive root does not
21920 * truly specify a file uniquely over time and across processes, as
21921 * the current drive is a per-process value and can be changed.
21923 * File names relative the current directory on some specific drive,
21924 * such as "D:foo/bar", are not interpreted as absolute by this
21925 * function, but they obviously are not relative to the normal current
21926 * directory as returned by getcwd() or g_get_current_dir()
21927 * either. Such paths should be avoided, or need to be handled using
21928 * Windows-specific code.
21930 * Returns: %TRUE if @file_name is absolute
21935 * g_path_skip_root:
21936 * @file_name: a file name
21938 * Returns a pointer into @file_name after the root component,
21939 * i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
21940 * is not an absolute path it returns %NULL.
21942 * Returns: a pointer into @file_name after the root component
21948 * @pspec: a #GPatternSpec
21949 * @string_length: the length of @string (in bytes, i.e. strlen(),
21950 * <emphasis>not</emphasis> g_utf8_strlen())
21951 * @string: the UTF-8 encoded string to match
21952 * @string_reversed: (allow-none): the reverse of @string or %NULL
21954 * Matches a string against a compiled pattern. Passing the correct
21955 * length of the string given is mandatory. The reversed string can be
21956 * omitted by passing %NULL, this is more efficient if the reversed
21957 * version of the string to be matched is not at hand, as
21958 * g_pattern_match() will only construct it if the compiled pattern
21959 * requires reverse matches.
21961 * Note that, if the user code will (possibly) match a string against a
21962 * multitude of patterns containing wildcards, chances are high that
21963 * some patterns will require a reversed string. In this case, it's
21964 * more efficient to provide the reversed string to avoid multiple
21965 * constructions thereof in the various calls to g_pattern_match().
21967 * Note also that the reverse of a UTF-8 encoded string can in general
21968 * <emphasis>not</emphasis> be obtained by g_strreverse(). This works
21969 * only if the string doesn't contain any multibyte characters. GLib
21970 * offers the g_utf8_strreverse() function to reverse UTF-8 encoded
21973 * Returns: %TRUE if @string matches @pspec
21978 * g_pattern_match_simple:
21979 * @pattern: the UTF-8 encoded pattern
21980 * @string: the UTF-8 encoded string to match
21982 * Matches a string against a pattern given as a string. If this
21983 * function is to be called in a loop, it's more efficient to compile
21984 * the pattern once with g_pattern_spec_new() and call
21985 * g_pattern_match_string() repeatedly.
21987 * Returns: %TRUE if @string matches @pspec
21992 * g_pattern_match_string:
21993 * @pspec: a #GPatternSpec
21994 * @string: the UTF-8 encoded string to match
21996 * Matches a string against a compiled pattern. If the string is to be
21997 * matched against more than one pattern, consider using
21998 * g_pattern_match() instead while supplying the reversed string.
22000 * Returns: %TRUE if @string matches @pspec
22005 * g_pattern_spec_equal:
22006 * @pspec1: a #GPatternSpec
22007 * @pspec2: another #GPatternSpec
22009 * Compares two compiled pattern specs and returns whether they will
22010 * match the same set of strings.
22012 * Returns: Whether the compiled patterns are equal
22017 * g_pattern_spec_free:
22018 * @pspec: a #GPatternSpec
22020 * Frees the memory allocated for the #GPatternSpec.
22025 * g_pattern_spec_new:
22026 * @pattern: a zero-terminated UTF-8 encoded string
22028 * Compiles a pattern to a #GPatternSpec.
22030 * Returns: a newly-allocated #GPatternSpec
22035 * g_pointer_bit_lock:
22036 * @address: a pointer to a #gpointer-sized value
22037 * @lock_bit: a bit value between 0 and 31
22039 * This is equivalent to g_bit_lock, but working on pointers (or other
22040 * pointer-sized values).
22042 * For portability reasons, you may only lock on the bottom 32 bits of
22050 * g_pointer_bit_trylock:
22051 * @address: a pointer to a #gpointer-sized value
22052 * @lock_bit: a bit value between 0 and 31
22054 * This is equivalent to g_bit_trylock, but working on pointers (or
22055 * other pointer-sized values).
22057 * For portability reasons, you may only lock on the bottom 32 bits of
22060 * Returns: %TRUE if the lock was acquired
22066 * g_pointer_bit_unlock:
22067 * @address: a pointer to a #gpointer-sized value
22068 * @lock_bit: a bit value between 0 and 31
22070 * This is equivalent to g_bit_unlock, but working on pointers (or other
22071 * pointer-sized values).
22073 * For portability reasons, you may only lock on the bottom 32 bits of
22082 * @fds: file descriptors to poll
22083 * @nfds: the number of file descriptors in @fds
22084 * @timeout: amount of time to wait, in milliseconds, or -1 to wait forever
22086 * Polls @fds, as with the poll() system call, but portably. (On
22087 * systems that don't have poll(), it is emulated using select().)
22088 * This is used internally by #GMainContext, but it can be called
22089 * directly if you need to block until a file descriptor is ready, but
22090 * don't want to run the full main loop.
22092 * Each element of @fds is a #GPollFD describing a single file
22093 * descriptor to poll. The %fd field indicates the file descriptor,
22094 * and the %events field indicates the events to poll for. On return,
22095 * the %revents fields will be filled with the events that actually
22098 * On POSIX systems, the file descriptors in @fds can be any sort of
22099 * file descriptor, but the situation is much more complicated on
22100 * Windows. If you need to use g_poll() in code that has to run on
22101 * Windows, the easiest solution is to construct all of your
22102 * #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
22104 * Returns: the number of entries in @fds whose %revents fields
22105 * were filled in, or 0 if the operation timed out, or -1 on error or
22106 * if the call was interrupted.
22113 * @err: (allow-none): a return location for a #GError, or %NULL
22114 * @format: printf()-style format string
22115 * @...: arguments to @format
22117 * Formats a string according to @format and
22118 * prefix it to an existing error message. If
22119 * @err is %NULL (ie: no error variable) then do
22122 * If *@err is %NULL (ie: an error variable is
22123 * present but there is no error condition) then
22124 * also do nothing. Whether or not it makes
22125 * sense to take advantage of this feature is up
22134 * @format: the message format. See the printf() documentation
22135 * @...: the parameters to insert into the format string
22137 * Outputs a formatted message via the print handler.
22138 * The default print handler simply outputs the message to stdout, without
22139 * appending a trailing new-line character. Typically, @format should end with
22140 * its own new-line character.
22142 * g_print() should not be used from within libraries for debugging
22143 * messages, since it may be redirected by applications to special
22144 * purpose message windows or even files. Instead, libraries should
22145 * use g_log(), or the convenience functions g_message(), g_warning()
22152 * @format: the message format. See the printf() documentation
22153 * @...: the parameters to insert into the format string
22155 * Outputs a formatted message via the error message handler.
22156 * The default handler simply outputs the message to stderr, without appending
22157 * a trailing new-line character. Typically, @format should end with its own
22158 * new-line character.
22160 * g_printerr() should not be used from within libraries.
22161 * Instead g_log() should be used, or the convenience functions
22162 * g_message(), g_warning() and g_error().
22168 * @format: a standard printf() format string, but notice
22169 * <link linkend="string-precision">string precision pitfalls</link>.
22170 * @...: the arguments to insert in the output.
22172 * An implementation of the standard printf() function which supports
22173 * positional parameters, as specified in the Single Unix Specification.
22175 * As with the standard printf(), this does not automatically append a trailing
22176 * new-line character to the message, so typically @format should end with its
22177 * own new-line character.
22179 * Returns: the number of bytes printed.
22185 * g_printf_string_upper_bound:
22186 * @format: the format string. See the printf() documentation
22187 * @args: the parameters to be inserted into the format string
22189 * Calculates the maximum space needed to store the output
22190 * of the sprintf() function.
22192 * Returns: the maximum space needed to store the formatted string
22198 * @key: a #GPrivate
22200 * Returns the current value of the thread local variable @key.
22202 * If the value has not yet been set in this thread, %NULL is returned.
22203 * Values are never copied between threads (when a new thread is
22204 * created, for example).
22206 * Returns: the thread-local value
22211 * g_private_replace:
22212 * @key: a #GPrivate
22213 * @value: the new value
22215 * Sets the thread local variable @key to have the value @value in the
22218 * This function differs from g_private_set() in the following way: if
22219 * the previous value was non-%NULL then the #GDestroyNotify handler for
22220 * @key is run on it.
22228 * @key: a #GPrivate
22229 * @value: the new value
22231 * Sets the thread local variable @key to have the value @value in the
22234 * This function differs from g_private_replace() in the following way:
22235 * the #GDestroyNotify for @key is not called on the old value.
22240 * g_propagate_error:
22241 * @dest: error return location
22242 * @src: error to move into the return location
22244 * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
22245 * The error variable @dest points to must be %NULL.
22250 * g_propagate_prefixed_error:
22251 * @dest: error return location
22252 * @src: error to move into the return location
22253 * @format: printf()-style format string
22254 * @...: arguments to @format
22256 * If @dest is %NULL, free @src; otherwise,
22257 * moves @src into *@dest. *@dest must be %NULL.
22258 * After the move, add a prefix as with
22259 * g_prefix_error().
22267 * @array: a #GPtrArray.
22268 * @data: the pointer to add.
22270 * Adds a pointer to the end of the pointer array. The array will grow
22271 * in size automatically if necessary.
22276 * g_ptr_array_foreach:
22277 * @array: a #GPtrArray
22278 * @func: the function to call for each array element
22279 * @user_data: user data to pass to the function
22281 * Calls a function for each element of a #GPtrArray.
22288 * g_ptr_array_free:
22289 * @array: a #GPtrArray.
22290 * @free_seg: if %TRUE the actual pointer array is freed as well.
22292 * Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
22293 * it frees the memory block holding the elements as well. Pass %FALSE
22294 * if you want to free the #GPtrArray wrapper but preserve the
22295 * underlying array for use elsewhere. If the reference count of @array
22296 * is greater than one, the #GPtrArray wrapper is preserved but the
22297 * size of @array will be set to zero.
22299 * <note><para>If array contents point to dynamically-allocated
22300 * memory, they should be freed separately if @free_seg is %TRUE and no
22301 * #GDestroyNotify function has been set for @array.</para></note>
22303 * Returns: the pointer array if @free_seg is %FALSE, otherwise %NULL.
22304 * The pointer array should be freed using g_free().
22309 * g_ptr_array_index:
22310 * @array: a #GPtrArray.
22311 * @index_: the index of the pointer to return.
22313 * Returns the pointer at the given index of the pointer array.
22316 * This does not perform bounds checking on the given @index_, so you are
22317 * responsible for checking it against the array length.</para></note>
22319 * Returns: the pointer at the given index.
22326 * Creates a new #GPtrArray with a reference count of 1.
22328 * Returns: the new #GPtrArray.
22333 * g_ptr_array_new_full:
22334 * @reserved_size: number of pointers preallocated.
22335 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22337 * Creates a new #GPtrArray with @reserved_size pointers preallocated
22338 * and a reference count of 1. This avoids frequent reallocation, if
22339 * you are going to add many pointers to the array. Note however that
22340 * the size of the array is still 0. It also set @element_free_func
22341 * for freeing each element when the array is destroyed either via
22342 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
22343 * set to %TRUE or when removing elements.
22345 * Returns: A new #GPtrArray.
22351 * g_ptr_array_new_with_free_func:
22352 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22354 * Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
22355 * for freeing each element when the array is destroyed either via
22356 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
22357 * set to %TRUE or when removing elements.
22359 * Returns: A new #GPtrArray.
22366 * @array: a #GPtrArray
22368 * Atomically increments the reference count of @array by one.
22369 * This function is thread-safe and may be called from any thread.
22371 * Returns: The passed in #GPtrArray
22377 * g_ptr_array_remove:
22378 * @array: a #GPtrArray.
22379 * @data: the pointer to remove.
22381 * Removes the first occurrence of the given pointer from the pointer
22382 * array. The following elements are moved down one place. If @array
22383 * has a non-%NULL #GDestroyNotify function it is called for the
22386 * It returns %TRUE if the pointer was removed, or %FALSE if the
22387 * pointer was not found.
22389 * Returns: %TRUE if the pointer is removed. %FALSE if the pointer is
22390 * not found in the array.
22395 * g_ptr_array_remove_fast:
22396 * @array: a #GPtrArray.
22397 * @data: the pointer to remove.
22399 * Removes the first occurrence of the given pointer from the pointer
22400 * array. The last element in the array is used to fill in the space,
22401 * so this function does not preserve the order of the array. But it is
22402 * faster than g_ptr_array_remove(). If @array has a non-%NULL
22403 * #GDestroyNotify function it is called for the removed element.
22405 * It returns %TRUE if the pointer was removed, or %FALSE if the
22406 * pointer was not found.
22408 * Returns: %TRUE if the pointer was found in the array.
22413 * g_ptr_array_remove_index:
22414 * @array: a #GPtrArray.
22415 * @index_: the index of the pointer to remove.
22417 * Removes the pointer at the given index from the pointer array. The
22418 * following elements are moved down one place. If @array has a
22419 * non-%NULL #GDestroyNotify function it is called for the removed
22422 * Returns: the pointer which was removed.
22427 * g_ptr_array_remove_index_fast:
22428 * @array: a #GPtrArray.
22429 * @index_: the index of the pointer to remove.
22431 * Removes the pointer at the given index from the pointer array. The
22432 * last element in the array is used to fill in the space, so this
22433 * function does not preserve the order of the array. But it is faster
22434 * than g_ptr_array_remove_index(). If @array has a non-%NULL
22435 * #GDestroyNotify function it is called for the removed element.
22437 * Returns: the pointer which was removed.
22442 * g_ptr_array_remove_range:
22443 * @array: a @GPtrArray.
22444 * @index_: the index of the first pointer to remove.
22445 * @length: the number of pointers to remove.
22447 * Removes the given number of pointers starting at the given index
22448 * from a #GPtrArray. The following elements are moved to close the
22449 * gap. If @array has a non-%NULL #GDestroyNotify function it is called
22450 * for the removed elements.
22457 * g_ptr_array_set_free_func:
22458 * @array: A #GPtrArray.
22459 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22461 * Sets a function for freeing each element when @array is destroyed
22462 * either via g_ptr_array_unref(), when g_ptr_array_free() is called
22463 * with @free_segment set to %TRUE or when removing elements.
22470 * g_ptr_array_set_size:
22471 * @array: a #GPtrArray.
22472 * @length: the new length of the pointer array.
22474 * Sets the size of the array. When making the array larger,
22475 * newly-added elements will be set to %NULL. When making it smaller,
22476 * if @array has a non-%NULL #GDestroyNotify function then it will be
22477 * called for the removed elements.
22482 * g_ptr_array_sized_new:
22483 * @reserved_size: number of pointers preallocated.
22485 * Creates a new #GPtrArray with @reserved_size pointers preallocated
22486 * and a reference count of 1. This avoids frequent reallocation, if
22487 * you are going to add many pointers to the array. Note however that
22488 * the size of the array is still 0.
22490 * Returns: the new #GPtrArray.
22495 * g_ptr_array_sort:
22496 * @array: a #GPtrArray.
22497 * @compare_func: comparison function.
22499 * Sorts the array, using @compare_func which should be a qsort()-style
22500 * comparison function (returns less than zero for first arg is less
22501 * than second arg, zero for equal, greater than zero if irst arg is
22502 * greater than second arg).
22504 * <note><para>The comparison function for g_ptr_array_sort() doesn't
22505 * take the pointers from the array as arguments, it takes pointers to
22506 * the pointers in the array.</para></note>
22508 * This is guaranteed to be a stable sort since version 2.32.
22513 * g_ptr_array_sort_with_data:
22514 * @array: a #GPtrArray.
22515 * @compare_func: comparison function.
22516 * @user_data: data to pass to @compare_func.
22518 * Like g_ptr_array_sort(), but the comparison function has an extra
22519 * user data argument.
22521 * <note><para>The comparison function for g_ptr_array_sort_with_data()
22522 * doesn't take the pointers from the array as arguments, it takes
22523 * pointers to the pointers in the array.</para></note>
22525 * This is guaranteed to be a stable sort since version 2.32.
22530 * g_ptr_array_unref:
22531 * @array: A #GPtrArray.
22533 * Atomically decrements the reference count of @array by one. If the
22534 * reference count drops to 0, the effect is the same as calling
22535 * g_ptr_array_free() with @free_segment set to %TRUE. This function
22536 * is MT-safe and may be called from any thread.
22543 * g_qsort_with_data:
22544 * @pbase: start of array to sort
22545 * @total_elems: elements in the array
22546 * @size: size of each element
22547 * @compare_func: function to compare elements
22548 * @user_data: data to pass to @compare_func
22550 * This is just like the standard C qsort() function, but
22551 * the comparison routine accepts a user data argument.
22553 * This is guaranteed to be a stable sort since version 2.32.
22558 * g_quark_from_static_string:
22559 * @string: (allow-none): a string.
22561 * Gets the #GQuark identifying the given (static) string. If the
22562 * string does not currently have an associated #GQuark, a new #GQuark
22563 * is created, linked to the given string.
22565 * Note that this function is identical to g_quark_from_string() except
22566 * that if a new #GQuark is created the string itself is used rather
22567 * than a copy. This saves memory, but can only be used if the string
22568 * will <emphasis>always</emphasis> exist. It can be used with
22569 * statically allocated strings in the main program, but not with
22570 * statically allocated memory in dynamically loaded modules, if you
22571 * expect to ever unload the module again (e.g. do not use this
22572 * function in GTK+ theme engines).
22574 * Returns: the #GQuark identifying the string, or 0 if @string is
22580 * g_quark_from_string:
22581 * @string: (allow-none): a string.
22583 * Gets the #GQuark identifying the given string. If the string does
22584 * not currently have an associated #GQuark, a new #GQuark is created,
22585 * using a copy of the string.
22587 * Returns: the #GQuark identifying the string, or 0 if @string is
22593 * g_quark_to_string:
22594 * @quark: a #GQuark.
22596 * Gets the string associated with the given #GQuark.
22598 * Returns: the string associated with the #GQuark
22603 * g_quark_try_string:
22604 * @string: (allow-none): a string.
22606 * Gets the #GQuark associated with the given string, or 0 if string is
22607 * %NULL or it has no associated #GQuark.
22609 * If you want the GQuark to be created if it doesn't already exist,
22610 * use g_quark_from_string() or g_quark_from_static_string().
22612 * Returns: the #GQuark associated with the string, or 0 if @string is
22613 * %NULL or there is no #GQuark associated with it.
22619 * @queue: a #GQueue
22621 * Removes all the elements in @queue. If queue elements contain
22622 * dynamically-allocated memory, they should be freed first.
22630 * @queue: a #GQueue
22632 * Copies a @queue. Note that is a shallow copy. If the elements in the
22633 * queue consist of pointers to data, the pointers are copied, but the
22634 * actual data is not.
22636 * Returns: A copy of @queue
22642 * g_queue_delete_link:
22643 * @queue: a #GQueue
22644 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
22646 * Removes @link_ from @queue and frees it.
22648 * @link_ must be part of @queue.
22656 * @queue: a #GQueue
22657 * @data: data to find
22659 * Finds the first link in @queue which contains @data.
22661 * Returns: The first link in @queue which contains @data.
22667 * g_queue_find_custom:
22668 * @queue: a #GQueue
22669 * @data: user data passed to @func
22670 * @func: a #GCompareFunc to call for each element. It should return 0
22671 * when the desired element is found
22673 * Finds an element in a #GQueue, using a supplied function to find the
22674 * desired element. It iterates over the queue, calling the given function
22675 * which should return 0 when the desired element is found. The function
22676 * takes two gconstpointer arguments, the #GQueue element's data as the
22677 * first argument and the given user data as the second argument.
22679 * Returns: The found link, or %NULL if it wasn't found
22686 * @queue: a #GQueue
22687 * @func: the function to call for each element's data
22688 * @user_data: user data to pass to @func
22690 * Calls @func for each element in the queue passing @user_data to the
22699 * @queue: a #GQueue.
22701 * Frees the memory allocated for the #GQueue. Only call this function if
22702 * @queue was created with g_queue_new(). If queue elements contain
22703 * dynamically-allocated memory, they should be freed first.
22706 * If queue elements contain dynamically-allocated memory,
22707 * you should either use g_queue_free_full() or free them manually
22714 * g_queue_free_full:
22715 * @queue: a pointer to a #GQueue
22716 * @free_func: the function to be called to free each element's data
22718 * Convenience method, which frees all the memory used by a #GQueue, and
22719 * calls the specified destroy function on every element's data.
22726 * g_queue_get_length:
22727 * @queue: a #GQueue
22729 * Returns the number of items in @queue.
22731 * Returns: The number of items in @queue.
22738 * @queue: a #GQueue
22739 * @data: the data to find.
22741 * Returns the position of the first element in @queue which contains @data.
22743 * Returns: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
22750 * @queue: an uninitialized #GQueue
22752 * A statically-allocated #GQueue must be initialized with this function
22753 * before it can be used. Alternatively you can initialize it with
22754 * #G_QUEUE_INIT. It is not necessary to initialize queues created with
22762 * g_queue_insert_after:
22763 * @queue: a #GQueue
22764 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
22765 * @data: the data to insert
22767 * Inserts @data into @queue after @sibling
22769 * @sibling must be part of @queue
22776 * g_queue_insert_before:
22777 * @queue: a #GQueue
22778 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
22779 * @data: the data to insert
22781 * Inserts @data into @queue before @sibling.
22783 * @sibling must be part of @queue.
22790 * g_queue_insert_sorted:
22791 * @queue: a #GQueue
22792 * @data: the data to insert
22793 * @func: the #GCompareDataFunc used to compare elements in the queue. It is
22794 * called with two elements of the @queue and @user_data. It should
22795 * return 0 if the elements are equal, a negative value if the first
22796 * element comes before the second, and a positive value if the second
22797 * element comes before the first.
22798 * @user_data: user data passed to @func.
22800 * Inserts @data into @queue using @func to determine the new position.
22807 * g_queue_is_empty:
22808 * @queue: a #GQueue.
22810 * Returns %TRUE if the queue is empty.
22812 * Returns: %TRUE if the queue is empty.
22817 * g_queue_link_index:
22818 * @queue: a #GQueue
22819 * @link_: A #GList link
22821 * Returns the position of @link_ in @queue.
22823 * Returns: The position of @link_, or -1 if the link is
22824 * not part of @queue
22832 * Creates a new #GQueue.
22834 * Returns: a new #GQueue.
22839 * g_queue_peek_head:
22840 * @queue: a #GQueue.
22842 * Returns the first element of the queue.
22844 * Returns: the data of the first element in the queue, or %NULL if the queue
22850 * g_queue_peek_head_link:
22851 * @queue: a #GQueue
22853 * Returns the first link in @queue
22855 * Returns: the first link in @queue, or %NULL if @queue is empty
22861 * g_queue_peek_nth:
22862 * @queue: a #GQueue
22863 * @n: the position of the element.
22865 * Returns the @n'th element of @queue.
22867 * Returns: The data for the @n'th element of @queue, or %NULL if @n is
22868 * off the end of @queue.
22874 * g_queue_peek_nth_link:
22875 * @queue: a #GQueue
22876 * @n: the position of the link
22878 * Returns the link at the given position
22880 * Returns: The link at the @n'th position, or %NULL if @n is off the
22887 * g_queue_peek_tail:
22888 * @queue: a #GQueue.
22890 * Returns the last element of the queue.
22892 * Returns: the data of the last element in the queue, or %NULL if the queue
22898 * g_queue_peek_tail_link:
22899 * @queue: a #GQueue
22901 * Returns the last link @queue.
22903 * Returns: the last link in @queue, or %NULL if @queue is empty
22909 * g_queue_pop_head:
22910 * @queue: a #GQueue.
22912 * Removes the first element of the queue.
22914 * Returns: the data of the first element in the queue, or %NULL if the queue
22920 * g_queue_pop_head_link:
22921 * @queue: a #GQueue.
22923 * Removes the first element of the queue.
22925 * Returns: the #GList element at the head of the queue, or %NULL if the queue
22932 * @queue: a #GQueue
22933 * @n: the position of the element.
22935 * Removes the @n'th element of @queue.
22937 * Returns: the element's data, or %NULL if @n is off the end of @queue.
22943 * g_queue_pop_nth_link:
22944 * @queue: a #GQueue
22945 * @n: the link's position
22947 * Removes and returns the link at the given position.
22949 * Returns: The @n'th link, or %NULL if @n is off the end of @queue.
22955 * g_queue_pop_tail:
22956 * @queue: a #GQueue.
22958 * Removes the last element of the queue.
22960 * Returns: the data of the last element in the queue, or %NULL if the queue
22966 * g_queue_pop_tail_link:
22967 * @queue: a #GQueue.
22969 * Removes the last element of the queue.
22971 * Returns: the #GList element at the tail of the queue, or %NULL if the queue
22977 * g_queue_push_head:
22978 * @queue: a #GQueue.
22979 * @data: the data for the new element.
22981 * Adds a new element at the head of the queue.
22986 * g_queue_push_head_link:
22987 * @queue: a #GQueue.
22988 * @link_: a single #GList element, <emphasis>not</emphasis> a list with
22989 * more than one element.
22991 * Adds a new element at the head of the queue.
22996 * g_queue_push_nth:
22997 * @queue: a #GQueue
22998 * @data: the data for the new element
22999 * @n: the position to insert the new element. If @n is negative or
23000 * larger than the number of elements in the @queue, the element is
23001 * added to the end of the queue.
23003 * Inserts a new element into @queue at the given position
23010 * g_queue_push_nth_link:
23011 * @queue: a #GQueue
23012 * @n: the position to insert the link. If this is negative or larger than
23013 * the number of elements in @queue, the link is added to the end of
23015 * @link_: the link to add to @queue
23017 * Inserts @link into @queue at the given position.
23024 * g_queue_push_tail:
23025 * @queue: a #GQueue.
23026 * @data: the data for the new element.
23028 * Adds a new element at the tail of the queue.
23033 * g_queue_push_tail_link:
23034 * @queue: a #GQueue.
23035 * @link_: a single #GList element, <emphasis>not</emphasis> a list with
23036 * more than one element.
23038 * Adds a new element at the tail of the queue.
23044 * @queue: a #GQueue
23045 * @data: data to remove.
23047 * Removes the first element in @queue that contains @data.
23049 * Returns: %TRUE if @data was found and removed from @queue
23055 * g_queue_remove_all:
23056 * @queue: a #GQueue
23057 * @data: data to remove
23059 * Remove all elements whose data equals @data from @queue.
23061 * Returns: the number of elements removed from @queue
23068 * @queue: a #GQueue
23070 * Reverses the order of the items in @queue.
23078 * @queue: a #GQueue
23079 * @compare_func: the #GCompareDataFunc used to sort @queue. This function
23080 * is passed two elements of the queue and should return 0 if they are
23081 * equal, a negative value if the first comes before the second, and
23082 * a positive value if the second comes before the first.
23083 * @user_data: user data passed to @compare_func
23085 * Sorts @queue using @compare_func.
23093 * @queue: a #GQueue
23094 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
23096 * Unlinks @link_ so that it will no longer be part of @queue. The link is
23099 * @link_ must be part of @queue,
23107 * @rand_: a #GRand.
23109 * Returns a random #gboolean from @rand_. This corresponds to a
23110 * unbiased coin toss.
23112 * Returns: a random #gboolean.
23118 * @rand_: a #GRand.
23120 * Copies a #GRand into a new one with the same exact state as before.
23121 * This way you can take a snapshot of the random number generator for
23124 * Returns: the new #GRand.
23131 * @rand_: a #GRand.
23133 * Returns the next random #gdouble from @rand_ equally distributed over
23134 * the range [0..1).
23136 * Returns: A random number.
23141 * g_rand_double_range:
23142 * @rand_: a #GRand.
23143 * @begin: lower closed bound of the interval.
23144 * @end: upper open bound of the interval.
23146 * Returns the next random #gdouble from @rand_ equally distributed over
23147 * the range [@begin..@end).
23149 * Returns: A random number.
23155 * @rand_: a #GRand.
23157 * Frees the memory allocated for the #GRand.
23163 * @rand_: a #GRand.
23165 * Returns the next random #guint32 from @rand_ equally distributed over
23166 * the range [0..2^32-1].
23168 * Returns: A random number.
23173 * g_rand_int_range:
23174 * @rand_: a #GRand.
23175 * @begin: lower closed bound of the interval.
23176 * @end: upper open bound of the interval.
23178 * Returns the next random #gint32 from @rand_ equally distributed over
23179 * the range [@begin..@end-1].
23181 * Returns: A random number.
23188 * Creates a new random number generator initialized with a seed taken
23189 * either from <filename>/dev/urandom</filename> (if existing) or from
23190 * the current time (as a fallback). On Windows, the seed is taken from
23193 * Returns: the new #GRand.
23198 * g_rand_new_with_seed:
23199 * @seed: a value to initialize the random number generator.
23201 * Creates a new random number generator initialized with @seed.
23203 * Returns: the new #GRand.
23208 * g_rand_new_with_seed_array:
23209 * @seed: an array of seeds to initialize the random number generator.
23210 * @seed_length: an array of seeds to initialize the random number generator.
23212 * Creates a new random number generator initialized with @seed.
23214 * Returns: the new #GRand.
23221 * @rand_: a #GRand.
23222 * @seed: a value to reinitialize the random number generator.
23224 * Sets the seed for the random number generator #GRand to @seed.
23229 * g_rand_set_seed_array:
23230 * @rand_: a #GRand.
23231 * @seed: array to initialize with
23232 * @seed_length: length of array
23234 * Initializes the random number generator by an array of
23235 * longs. Array can be of arbitrary size, though only the
23236 * first 624 values are taken. This function is useful
23237 * if you have many low entropy seeds, or if you require more then
23238 * 32bits of actual entropy for your application.
23245 * g_random_boolean:
23247 * Returns a random #gboolean. This corresponds to a unbiased coin toss.
23249 * Returns: a random #gboolean.
23256 * Returns a random #gdouble equally distributed over the range [0..1).
23258 * Returns: A random number.
23263 * g_random_double_range:
23264 * @begin: lower closed bound of the interval.
23265 * @end: upper open bound of the interval.
23267 * Returns a random #gdouble equally distributed over the range [@begin..@end).
23269 * Returns: A random number.
23276 * Return a random #guint32 equally distributed over the range
23279 * Returns: A random number.
23284 * g_random_int_range:
23285 * @begin: lower closed bound of the interval.
23286 * @end: upper open bound of the interval.
23288 * Returns a random #gint32 equally distributed over the range
23289 * [@begin..@end-1].
23291 * Returns: A random number.
23296 * g_random_set_seed:
23297 * @seed: a value to reinitialize the global random number generator.
23299 * Sets the seed for the global random number generator, which is used
23300 * by the <function>g_random_*</function> functions, to @seed.
23306 * @mem: the memory to reallocate
23307 * @n_bytes: new size of the memory in bytes
23309 * Reallocates the memory pointed to by @mem, so that it now has space for
23310 * @n_bytes bytes of memory. It returns the new address of the memory, which may
23311 * have been moved. @mem may be %NULL, in which case it's considered to
23312 * have zero-length. @n_bytes may be 0, in which case %NULL will be returned
23313 * and @mem will be freed unless it is %NULL.
23315 * Returns: the new address of the allocated memory
23321 * @mem: the memory to reallocate
23322 * @n_blocks: the number of blocks to allocate
23323 * @n_block_bytes: the size of each block in bytes
23325 * This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
23326 * but care is taken to detect possible overflow during multiplication.
23329 * Returns: the new address of the allocated memory
23334 * g_rec_mutex_clear:
23335 * @rec_mutex: an initialized #GRecMutex
23337 * Frees the resources allocated to a recursive mutex with
23338 * g_rec_mutex_init().
23340 * This function should not be used with a #GRecMutex that has been
23341 * statically allocated.
23343 * Calling g_rec_mutex_clear() on a locked recursive mutex leads
23344 * to undefined behaviour.
23351 * g_rec_mutex_init:
23352 * @rec_mutex: an uninitialized #GRecMutex
23354 * Initializes a #GRecMutex so that it can be used.
23356 * This function is useful to initialize a recursive mutex
23357 * that has been allocated on the stack, or as part of a larger
23360 * It is not necessary to initialise a recursive mutex that has been
23361 * statically allocated.
23371 * b = g_new (Blob, 1);
23372 * g_rec_mutex_init (&b->m);
23375 * Calling g_rec_mutex_init() on an already initialized #GRecMutex
23376 * leads to undefined behaviour.
23378 * To undo the effect of g_rec_mutex_init() when a recursive mutex
23379 * is no longer needed, use g_rec_mutex_clear().
23386 * g_rec_mutex_lock:
23387 * @rec_mutex: a #GRecMutex
23389 * Locks @rec_mutex. If @rec_mutex is already locked by another
23390 * thread, the current thread will block until @rec_mutex is
23391 * unlocked by the other thread. If @rec_mutex is already locked
23392 * by the current thread, the 'lock count' of @rec_mutex is increased.
23393 * The mutex will only become available again when it is unlocked
23394 * as many times as it has been locked.
23401 * g_rec_mutex_trylock:
23402 * @rec_mutex: a #GRecMutex
23404 * Tries to lock @rec_mutex. If @rec_mutex is already locked
23405 * by another thread, it immediately returns %FALSE. Otherwise
23406 * it locks @rec_mutex and returns %TRUE.
23408 * Returns: %TRUE if @rec_mutex could be locked
23414 * g_rec_mutex_unlock:
23415 * @rec_mutex: a #GRecMutex
23417 * Unlocks @rec_mutex. If another thread is blocked in a
23418 * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
23419 * and can lock @rec_mutex itself.
23421 * Calling g_rec_mutex_unlock() on a recursive mutex that is not
23422 * locked by the current thread leads to undefined behaviour.
23429 * g_regex_check_replacement:
23430 * @replacement: the replacement string
23431 * @has_references: (out) (allow-none): location to store information about
23432 * references in @replacement or %NULL
23433 * @error: location to store error
23435 * Checks whether @replacement is a valid replacement string
23436 * (see g_regex_replace()), i.e. that all escape sequences in
23439 * If @has_references is not %NULL then @replacement is checked
23440 * for pattern references. For instance, replacement text 'foo\n'
23441 * does not contain references and may be evaluated without information
23442 * about actual match, but '\0\1' (whole match followed by first
23443 * subpattern) requires valid #GMatchInfo object.
23445 * Returns: whether @replacement is a valid replacement string
23451 * g_regex_escape_nul:
23452 * @string: the string to escape
23453 * @length: the length of @string
23455 * Escapes the nul characters in @string to "\x00". It can be used
23456 * to compile a regex with embedded nul characters.
23458 * For completeness, @length can be -1 for a nul-terminated string.
23459 * In this case the output string will be of course equal to @string.
23461 * Returns: a newly-allocated escaped string
23467 * g_regex_escape_string:
23468 * @string: (array length=length): the string to escape
23469 * @length: the length of @string, or -1 if @string is nul-terminated
23471 * Escapes the special characters used for regular expressions
23472 * in @string, for instance "a.b*c" becomes "a\.b\*c". This
23473 * function is useful to dynamically generate regular expressions.
23475 * @string can contain nul characters that are replaced with "\0",
23476 * in this case remember to specify the correct length of @string
23479 * Returns: a newly-allocated escaped string
23485 * g_regex_get_capture_count:
23486 * @regex: a #GRegex
23488 * Returns the number of capturing subpatterns in the pattern.
23490 * Returns: the number of capturing subpatterns
23496 * g_regex_get_compile_flags:
23497 * @regex: a #GRegex
23499 * Returns the compile options that @regex was created with.
23501 * Returns: flags from #GRegexCompileFlags
23507 * g_regex_get_has_cr_or_lf:
23508 * @regex: a #GRegex structure
23510 * Checks whether the pattern contains explicit CR or LF references.
23512 * Returns: %TRUE if the pattern contains explicit CR or LF references
23518 * g_regex_get_match_flags:
23519 * @regex: a #GRegex
23521 * Returns the match options that @regex was created with.
23523 * Returns: flags from #GRegexMatchFlags
23529 * g_regex_get_max_backref:
23530 * @regex: a #GRegex
23532 * Returns the number of the highest back reference
23533 * in the pattern, or 0 if the pattern does not contain
23536 * Returns: the number of the highest back reference
23542 * g_regex_get_max_lookbehind:
23543 * @regex: a #GRegex structure
23545 * Gets the number of characters in the longest lookbehind assertion in the
23546 * pattern. This information is useful when doing multi-segment matching using
23547 * the partial matching facilities.
23549 * Returns: the number of characters in the longest lookbehind assertion.
23555 * g_regex_get_pattern:
23556 * @regex: a #GRegex structure
23558 * Gets the pattern string associated with @regex, i.e. a copy of
23559 * the string passed to g_regex_new().
23561 * Returns: the pattern of @regex
23567 * g_regex_get_string_number:
23568 * @regex: #GRegex structure
23569 * @name: name of the subexpression
23571 * Retrieves the number of the subexpression named @name.
23573 * Returns: The number of the subexpression or -1 if @name
23581 * @regex: a #GRegex structure from g_regex_new()
23582 * @string: the string to scan for matches
23583 * @match_options: match options
23584 * @match_info: (out) (allow-none): pointer to location where to store
23585 * the #GMatchInfo, or %NULL if you do not need it
23587 * Scans for a match in string for the pattern in @regex.
23588 * The @match_options are combined with the match options specified
23589 * when the @regex structure was created, letting you have more
23590 * flexibility in reusing #GRegex structures.
23592 * A #GMatchInfo structure, used to get information on the match,
23593 * is stored in @match_info if not %NULL. Note that if @match_info
23594 * is not %NULL then it is created even if the function returns %FALSE,
23595 * i.e. you must free it regardless if regular expression actually matched.
23597 * To retrieve all the non-overlapping matches of the pattern in
23598 * string you can use g_match_info_next().
23602 * print_uppercase_words (const gchar *string)
23604 * /* Print all uppercase-only words. */
23606 * GMatchInfo *match_info;
23608 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
23609 * g_regex_match (regex, string, 0, &match_info);
23610 * while (g_match_info_matches (match_info))
23612 * gchar *word = g_match_info_fetch (match_info, 0);
23613 * g_print ("Found: %s\n", word);
23615 * g_match_info_next (match_info, NULL);
23617 * g_match_info_free (match_info);
23618 * g_regex_unref (regex);
23622 * @string is not copied and is used in #GMatchInfo internally. If
23623 * you use any #GMatchInfo method (except g_match_info_free()) after
23624 * freeing or modifying @string then the behaviour is undefined.
23626 * Returns: %TRUE is the string matched, %FALSE otherwise
23632 * g_regex_match_all:
23633 * @regex: a #GRegex structure from g_regex_new()
23634 * @string: the string to scan for matches
23635 * @match_options: match options
23636 * @match_info: (out) (allow-none): pointer to location where to store
23637 * the #GMatchInfo, or %NULL if you do not need it
23639 * Using the standard algorithm for regular expression matching only
23640 * the longest match in the string is retrieved. This function uses
23641 * a different algorithm so it can retrieve all the possible matches.
23642 * For more documentation see g_regex_match_all_full().
23644 * A #GMatchInfo structure, used to get information on the match, is
23645 * stored in @match_info if not %NULL. Note that if @match_info is
23646 * not %NULL then it is created even if the function returns %FALSE,
23647 * i.e. you must free it regardless if regular expression actually
23650 * @string is not copied and is used in #GMatchInfo internally. If
23651 * you use any #GMatchInfo method (except g_match_info_free()) after
23652 * freeing or modifying @string then the behaviour is undefined.
23654 * Returns: %TRUE is the string matched, %FALSE otherwise
23660 * g_regex_match_all_full:
23661 * @regex: a #GRegex structure from g_regex_new()
23662 * @string: (array length=string_len): the string to scan for matches
23663 * @string_len: the length of @string, or -1 if @string is nul-terminated
23664 * @start_position: starting index of the string to match
23665 * @match_options: match options
23666 * @match_info: (out) (allow-none): pointer to location where to store
23667 * the #GMatchInfo, or %NULL if you do not need it
23668 * @error: location to store the error occurring, or %NULL to ignore errors
23670 * Using the standard algorithm for regular expression matching only
23671 * the longest match in the string is retrieved, it is not possible
23672 * to obtain all the available matches. For instance matching
23673 * "<a> <b> <c>" against the pattern "<.*>"
23674 * you get "<a> <b> <c>".
23676 * This function uses a different algorithm (called DFA, i.e. deterministic
23677 * finite automaton), so it can retrieve all the possible matches, all
23678 * starting at the same point in the string. For instance matching
23679 * "<a> <b> <c>" against the pattern "<.*>"
23680 * you would obtain three matches: "<a> <b> <c>",
23681 * "<a> <b>" and "<a>".
23683 * The number of matched strings is retrieved using
23684 * g_match_info_get_match_count(). To obtain the matched strings and
23685 * their position you can use, respectively, g_match_info_fetch() and
23686 * g_match_info_fetch_pos(). Note that the strings are returned in
23687 * reverse order of length; that is, the longest matching string is
23690 * Note that the DFA algorithm is slower than the standard one and it
23691 * is not able to capture substrings, so backreferences do not work.
23693 * Setting @start_position differs from just passing over a shortened
23694 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23695 * that begins with any kind of lookbehind assertion, such as "\b".
23697 * A #GMatchInfo structure, used to get information on the match, is
23698 * stored in @match_info if not %NULL. Note that if @match_info is
23699 * not %NULL then it is created even if the function returns %FALSE,
23700 * i.e. you must free it regardless if regular expression actually
23703 * @string is not copied and is used in #GMatchInfo internally. If
23704 * you use any #GMatchInfo method (except g_match_info_free()) after
23705 * freeing or modifying @string then the behaviour is undefined.
23707 * Returns: %TRUE is the string matched, %FALSE otherwise
23713 * g_regex_match_full:
23714 * @regex: a #GRegex structure from g_regex_new()
23715 * @string: (array length=string_len): the string to scan for matches
23716 * @string_len: the length of @string, or -1 if @string is nul-terminated
23717 * @start_position: starting index of the string to match
23718 * @match_options: match options
23719 * @match_info: (out) (allow-none): pointer to location where to store
23720 * the #GMatchInfo, or %NULL if you do not need it
23721 * @error: location to store the error occurring, or %NULL to ignore errors
23723 * Scans for a match in string for the pattern in @regex.
23724 * The @match_options are combined with the match options specified
23725 * when the @regex structure was created, letting you have more
23726 * flexibility in reusing #GRegex structures.
23728 * Setting @start_position differs from just passing over a shortened
23729 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23730 * that begins with any kind of lookbehind assertion, such as "\b".
23732 * A #GMatchInfo structure, used to get information on the match, is
23733 * stored in @match_info if not %NULL. Note that if @match_info is
23734 * not %NULL then it is created even if the function returns %FALSE,
23735 * i.e. you must free it regardless if regular expression actually
23738 * @string is not copied and is used in #GMatchInfo internally. If
23739 * you use any #GMatchInfo method (except g_match_info_free()) after
23740 * freeing or modifying @string then the behaviour is undefined.
23742 * To retrieve all the non-overlapping matches of the pattern in
23743 * string you can use g_match_info_next().
23747 * print_uppercase_words (const gchar *string)
23749 * /* Print all uppercase-only words. */
23751 * GMatchInfo *match_info;
23752 * GError *error = NULL;
23754 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
23755 * g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
23756 * while (g_match_info_matches (match_info))
23758 * gchar *word = g_match_info_fetch (match_info, 0);
23759 * g_print ("Found: %s\n", word);
23761 * g_match_info_next (match_info, &error);
23763 * g_match_info_free (match_info);
23764 * g_regex_unref (regex);
23765 * if (error != NULL)
23767 * g_printerr ("Error while matching: %s\n", error->message);
23768 * g_error_free (error);
23773 * Returns: %TRUE is the string matched, %FALSE otherwise
23779 * g_regex_match_simple:
23780 * @pattern: the regular expression
23781 * @string: the string to scan for matches
23782 * @compile_options: compile options for the regular expression, or 0
23783 * @match_options: match options, or 0
23785 * Scans for a match in @string for @pattern.
23787 * This function is equivalent to g_regex_match() but it does not
23788 * require to compile the pattern with g_regex_new(), avoiding some
23789 * lines of code when you need just to do a match without extracting
23790 * substrings, capture counts, and so on.
23792 * If this function is to be called on the same @pattern more than
23793 * once, it's more efficient to compile the pattern once with
23794 * g_regex_new() and then use g_regex_match().
23796 * Returns: %TRUE if the string matched, %FALSE otherwise
23803 * @pattern: the regular expression
23804 * @compile_options: compile options for the regular expression, or 0
23805 * @match_options: match options for the regular expression, or 0
23806 * @error: return location for a #GError
23808 * Compiles the regular expression to an internal form, and does
23809 * the initial setup of the #GRegex structure.
23811 * Returns: a #GRegex structure. Call g_regex_unref() when you
23819 * @regex: a #GRegex
23821 * Increases reference count of @regex by 1.
23830 * @regex: a #GRegex structure
23831 * @string: (array length=string_len): the string to perform matches against
23832 * @string_len: the length of @string, or -1 if @string is nul-terminated
23833 * @start_position: starting index of the string to match
23834 * @replacement: text to replace each match with
23835 * @match_options: options for the match
23836 * @error: location to store the error occurring, or %NULL to ignore errors
23838 * Replaces all occurrences of the pattern in @regex with the
23839 * replacement text. Backreferences of the form '\number' or
23840 * '\g<number>' in the replacement text are interpolated by the
23841 * number-th captured subexpression of the match, '\g<name>' refers
23842 * to the captured subexpression with the given name. '\0' refers to the
23843 * complete match, but '\0' followed by a number is the octal representation
23844 * of a character. To include a literal '\' in the replacement, write '\\'.
23845 * There are also escapes that changes the case of the following text:
23848 * <varlistentry><term>\l</term>
23850 * <para>Convert to lower case the next character</para>
23853 * <varlistentry><term>\u</term>
23855 * <para>Convert to upper case the next character</para>
23858 * <varlistentry><term>\L</term>
23860 * <para>Convert to lower case till \E</para>
23863 * <varlistentry><term>\U</term>
23865 * <para>Convert to upper case till \E</para>
23868 * <varlistentry><term>\E</term>
23870 * <para>End case modification</para>
23875 * If you do not need to use backreferences use g_regex_replace_literal().
23877 * The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
23878 * passed to g_regex_new(). If you want to use not UTF-8 encoded stings
23879 * you can use g_regex_replace_literal().
23881 * Setting @start_position differs from just passing over a shortened
23882 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
23883 * begins with any kind of lookbehind assertion, such as "\b".
23885 * Returns: a newly allocated string containing the replacements
23891 * g_regex_replace_eval:
23892 * @regex: a #GRegex structure from g_regex_new()
23893 * @string: (array length=string_len): string to perform matches against
23894 * @string_len: the length of @string, or -1 if @string is nul-terminated
23895 * @start_position: starting index of the string to match
23896 * @match_options: options for the match
23897 * @eval: a function to call for each match
23898 * @user_data: user data to pass to the function
23899 * @error: location to store the error occurring, or %NULL to ignore errors
23901 * Replaces occurrences of the pattern in regex with the output of
23902 * @eval for that occurrence.
23904 * Setting @start_position differs from just passing over a shortened
23905 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23906 * that begins with any kind of lookbehind assertion, such as "\b".
23908 * The following example uses g_regex_replace_eval() to replace multiple
23912 * eval_cb (const GMatchInfo *info,
23919 * match = g_match_info_fetch (info, 0);
23920 * r = g_hash_table_lookup ((GHashTable *)data, match);
23921 * g_string_append (res, r);
23927 * /* ... */
23933 * h = g_hash_table_new (g_str_hash, g_str_equal);
23935 * g_hash_table_insert (h, "1", "ONE");
23936 * g_hash_table_insert (h, "2", "TWO");
23937 * g_hash_table_insert (h, "3", "THREE");
23938 * g_hash_table_insert (h, "4", "FOUR");
23940 * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
23941 * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
23942 * g_hash_table_destroy (h);
23944 * /* ... */
23947 * Returns: a newly allocated string containing the replacements
23953 * g_regex_replace_literal:
23954 * @regex: a #GRegex structure
23955 * @string: (array length=string_len): the string to perform matches against
23956 * @string_len: the length of @string, or -1 if @string is nul-terminated
23957 * @start_position: starting index of the string to match
23958 * @replacement: text to replace each match with
23959 * @match_options: options for the match
23960 * @error: location to store the error occurring, or %NULL to ignore errors
23962 * Replaces all occurrences of the pattern in @regex with the
23963 * replacement text. @replacement is replaced literally, to
23964 * include backreferences use g_regex_replace().
23966 * Setting @start_position differs from just passing over a
23967 * shortened string and setting #G_REGEX_MATCH_NOTBOL in the
23968 * case of a pattern that begins with any kind of lookbehind
23969 * assertion, such as "\b".
23971 * Returns: a newly allocated string containing the replacements
23978 * @regex: a #GRegex structure
23979 * @string: the string to split with the pattern
23980 * @match_options: match time option flags
23982 * Breaks the string on the pattern, and returns an array of the tokens.
23983 * If the pattern contains capturing parentheses, then the text for each
23984 * of the substrings will also be returned. If the pattern does not match
23985 * anywhere in the string, then the whole string is returned as the first
23988 * As a special case, the result of splitting the empty string "" is an
23989 * empty vector, not a vector containing a single string. The reason for
23990 * this special case is that being able to represent a empty vector is
23991 * typically more useful than consistent handling of empty elements. If
23992 * you do need to represent empty elements, you'll need to check for the
23993 * empty string before calling this function.
23995 * A pattern that can match empty strings splits @string into separate
23996 * characters wherever it matches the empty string between characters.
23997 * For example splitting "ab c" using as a separator "\s*", you will get
23998 * "a", "b" and "c".
24000 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free
24001 * it using g_strfreev()
24007 * g_regex_split_full:
24008 * @regex: a #GRegex structure
24009 * @string: (array length=string_len): the string to split with the pattern
24010 * @string_len: the length of @string, or -1 if @string is nul-terminated
24011 * @start_position: starting index of the string to match
24012 * @match_options: match time option flags
24013 * @max_tokens: the maximum number of tokens to split @string into.
24014 * If this is less than 1, the string is split completely
24015 * @error: return location for a #GError
24017 * Breaks the string on the pattern, and returns an array of the tokens.
24018 * If the pattern contains capturing parentheses, then the text for each
24019 * of the substrings will also be returned. If the pattern does not match
24020 * anywhere in the string, then the whole string is returned as the first
24023 * As a special case, the result of splitting the empty string "" is an
24024 * empty vector, not a vector containing a single string. The reason for
24025 * this special case is that being able to represent a empty vector is
24026 * typically more useful than consistent handling of empty elements. If
24027 * you do need to represent empty elements, you'll need to check for the
24028 * empty string before calling this function.
24030 * A pattern that can match empty strings splits @string into separate
24031 * characters wherever it matches the empty string between characters.
24032 * For example splitting "ab c" using as a separator "\s*", you will get
24033 * "a", "b" and "c".
24035 * Setting @start_position differs from just passing over a shortened
24036 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
24037 * that begins with any kind of lookbehind assertion, such as "\b".
24039 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free
24040 * it using g_strfreev()
24046 * g_regex_split_simple:
24047 * @pattern: the regular expression
24048 * @string: the string to scan for matches
24049 * @compile_options: compile options for the regular expression, or 0
24050 * @match_options: match options, or 0
24052 * Breaks the string on the pattern, and returns an array of
24053 * the tokens. If the pattern contains capturing parentheses,
24054 * then the text for each of the substrings will also be returned.
24055 * If the pattern does not match anywhere in the string, then the
24056 * whole string is returned as the first token.
24058 * This function is equivalent to g_regex_split() but it does
24059 * not require to compile the pattern with g_regex_new(), avoiding
24060 * some lines of code when you need just to do a split without
24061 * extracting substrings, capture counts, and so on.
24063 * If this function is to be called on the same @pattern more than
24064 * once, it's more efficient to compile the pattern once with
24065 * g_regex_new() and then use g_regex_split().
24067 * As a special case, the result of splitting the empty string ""
24068 * is an empty vector, not a vector containing a single string.
24069 * The reason for this special case is that being able to represent
24070 * a empty vector is typically more useful than consistent handling
24071 * of empty elements. If you do need to represent empty elements,
24072 * you'll need to check for the empty string before calling this
24075 * A pattern that can match empty strings splits @string into
24076 * separate characters wherever it matches the empty string between
24077 * characters. For example splitting "ab c" using as a separator
24078 * "\s*", you will get "a", "b" and "c".
24080 * Returns: (transfer full): a %NULL-terminated array of strings. Free
24081 * it using g_strfreev()
24088 * @regex: a #GRegex
24090 * Decreases reference count of @regex by 1. When reference count drops
24091 * to zero, it frees all the memory associated with the regex structure.
24098 * g_reload_user_special_dirs_cache:
24100 * Resets the cache used for g_get_user_special_dir(), so
24101 * that the latest on-disk version is used. Call this only
24102 * if you just changed the data on disk yourself.
24104 * Due to threadsafety issues this may cause leaking of strings
24105 * that were previously returned from g_get_user_special_dir()
24106 * that can't be freed. We ensure to only leak the data for
24107 * the directories that actually changed value though.
24115 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24117 * A wrapper for the POSIX remove() function. The remove() function
24118 * deletes a name from the filesystem.
24120 * See your C library manual for more details about how remove() works
24121 * on your system. On Unix, remove() removes also directories, as it
24122 * calls unlink() for files and rmdir() for directories. On Windows,
24123 * although remove() in the C library only works for files, this
24124 * function tries first remove() and then if that fails rmdir(), and
24125 * thus works for both files and directories. Note however, that on
24126 * Windows, it is in general not possible to remove a file that is
24127 * open to some process, or mapped into memory.
24129 * If this function fails on Windows you can't infer too much from the
24130 * errno value. rmdir() is tried regardless of what caused remove() to
24131 * fail. Any errno value set by remove() will be overwritten by that
24134 * Returns: 0 if the file was successfully removed, -1 if an error
24142 * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24143 * @newfilename: a pathname in the GLib file name encoding
24145 * A wrapper for the POSIX rename() function. The rename() function
24146 * renames a file, moving it between directories if required.
24148 * See your C library manual for more details about how rename() works
24149 * on your system. It is not possible in general on Windows to rename
24150 * a file that is open to some process.
24152 * Returns: 0 if the renaming succeeded, -1 if an error occurred
24159 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24161 * A wrapper for the POSIX rmdir() function. The rmdir() function
24162 * deletes a directory from the filesystem.
24164 * See your C library manual for more details about how rmdir() works
24167 * Returns: 0 if the directory was successfully removed, -1 if an error
24175 * @rw_lock: an initialized #GRWLock
24177 * Frees the resources allocated to a lock with g_rw_lock_init().
24179 * This function should not be used with a #GRWLock that has been
24180 * statically allocated.
24182 * Calling g_rw_lock_clear() when any thread holds the lock
24183 * leads to undefined behaviour.
24191 * @rw_lock: an uninitialized #GRWLock
24193 * Initializes a #GRWLock so that it can be used.
24195 * This function is useful to initialize a lock that has been
24196 * allocated on the stack, or as part of a larger structure. It is not
24197 * necessary to initialise a reader-writer lock that has been statically
24208 * b = g_new (Blob, 1);
24209 * g_rw_lock_init (&b->l);
24212 * To undo the effect of g_rw_lock_init() when a lock is no longer
24213 * needed, use g_rw_lock_clear().
24215 * Calling g_rw_lock_init() on an already initialized #GRWLock leads
24216 * to undefined behaviour.
24223 * g_rw_lock_reader_lock:
24224 * @rw_lock: a #GRWLock
24226 * Obtain a read lock on @rw_lock. If another thread currently holds
24227 * the write lock on @rw_lock or blocks waiting for it, the current
24228 * thread will block. Read locks can be taken recursively.
24230 * It is implementation-defined how many threads are allowed to
24231 * hold read locks on the same lock simultaneously.
24238 * g_rw_lock_reader_trylock:
24239 * @rw_lock: a #GRWLock
24241 * Tries to obtain a read lock on @rw_lock and returns %TRUE if
24242 * the read lock was successfully obtained. Otherwise it
24245 * Returns: %TRUE if @rw_lock could be locked
24251 * g_rw_lock_reader_unlock:
24252 * @rw_lock: a #GRWLock
24254 * Release a read lock on @rw_lock.
24256 * Calling g_rw_lock_reader_unlock() on a lock that is not held
24257 * by the current thread leads to undefined behaviour.
24264 * g_rw_lock_writer_lock:
24265 * @rw_lock: a #GRWLock
24267 * Obtain a write lock on @rw_lock. If any thread already holds
24268 * a read or write lock on @rw_lock, the current thread will block
24269 * until all other threads have dropped their locks on @rw_lock.
24276 * g_rw_lock_writer_trylock:
24277 * @rw_lock: a #GRWLock
24279 * Tries to obtain a write lock on @rw_lock. If any other thread holds
24280 * a read or write lock on @rw_lock, it immediately returns %FALSE.
24281 * Otherwise it locks @rw_lock and returns %TRUE.
24283 * Returns: %TRUE if @rw_lock could be locked
24289 * g_rw_lock_writer_unlock:
24290 * @rw_lock: a #GRWLock
24292 * Release a write lock on @rw_lock.
24294 * Calling g_rw_lock_writer_unlock() on a lock that is not held
24295 * by the current thread leads to undefined behaviour.
24302 * g_scanner_add_symbol:
24303 * @scanner: a #GScanner
24304 * @symbol: the symbol to add
24305 * @value: the value of the symbol
24307 * Adds a symbol to the default scope.
24309 * Deprecated: 2.2: Use g_scanner_scope_add_symbol() instead.
24314 * g_scanner_cur_line:
24315 * @scanner: a #GScanner
24317 * Returns the current line in the input stream (counting
24318 * from 1). This is the line of the last token parsed via
24319 * g_scanner_get_next_token().
24321 * Returns: the current line
24326 * g_scanner_cur_position:
24327 * @scanner: a #GScanner
24329 * Returns the current position in the current line (counting
24330 * from 0). This is the position of the last token parsed via
24331 * g_scanner_get_next_token().
24333 * Returns: the current position on the line
24338 * g_scanner_cur_token:
24339 * @scanner: a #GScanner
24341 * Gets the current token type. This is simply the @token
24342 * field in the #GScanner structure.
24344 * Returns: the current token type
24349 * g_scanner_cur_value:
24350 * @scanner: a #GScanner
24352 * Gets the current token value. This is simply the @value
24353 * field in the #GScanner structure.
24355 * Returns: the current token value
24360 * g_scanner_destroy:
24361 * @scanner: a #GScanner
24363 * Frees all memory used by the #GScanner.
24369 * @scanner: a #GScanner
24371 * Returns %TRUE if the scanner has reached the end of
24372 * the file or text buffer.
24374 * Returns: %TRUE if the scanner has reached the end of
24375 * the file or text buffer
24381 * @scanner: a #GScanner
24382 * @format: the message format. See the printf() documentation
24383 * @...: the parameters to insert into the format string
24385 * Outputs an error message, via the #GScanner message handler.
24390 * g_scanner_foreach_symbol:
24391 * @scanner: a #GScanner
24392 * @func: the function to call with each symbol
24393 * @data: data to pass to the function
24395 * Calls a function for each symbol in the default scope.
24397 * Deprecated: 2.2: Use g_scanner_scope_foreach_symbol() instead.
24402 * g_scanner_freeze_symbol_table:
24403 * @scanner: a #GScanner
24405 * There is no reason to use this macro, since it does nothing.
24407 * Deprecated: 2.2: This macro does nothing.
24412 * g_scanner_get_next_token:
24413 * @scanner: a #GScanner
24415 * Parses the next token just like g_scanner_peek_next_token()
24416 * and also removes it from the input stream. The token data is
24417 * placed in the @token, @value, @line, and @position fields of
24418 * the #GScanner structure.
24420 * Returns: the type of the token
24425 * g_scanner_input_file:
24426 * @scanner: a #GScanner
24427 * @input_fd: a file descriptor
24429 * Prepares to scan a file.
24434 * g_scanner_input_text:
24435 * @scanner: a #GScanner
24436 * @text: the text buffer to scan
24437 * @text_len: the length of the text buffer
24439 * Prepares to scan a text buffer.
24444 * g_scanner_lookup_symbol:
24445 * @scanner: a #GScanner
24446 * @symbol: the symbol to look up
24448 * Looks up a symbol in the current scope and return its value.
24449 * If the symbol is not bound in the current scope, %NULL is
24452 * Returns: the value of @symbol in the current scope, or %NULL
24453 * if @symbol is not bound in the current scope
24459 * @config_templ: the initial scanner settings
24461 * Creates a new #GScanner.
24463 * The @config_templ structure specifies the initial settings
24464 * of the scanner, which are copied into the #GScanner
24465 * @config field. If you pass %NULL then the default settings
24468 * Returns: the new #GScanner
24473 * g_scanner_peek_next_token:
24474 * @scanner: a #GScanner
24476 * Parses the next token, without removing it from the input stream.
24477 * The token data is placed in the @next_token, @next_value, @next_line,
24478 * and @next_position fields of the #GScanner structure.
24480 * Note that, while the token is not removed from the input stream
24481 * (i.e. the next call to g_scanner_get_next_token() will return the
24482 * same token), it will not be reevaluated. This can lead to surprising
24483 * results when changing scope or the scanner configuration after peeking
24484 * the next token. Getting the next token after switching the scope or
24485 * configuration will return whatever was peeked before, regardless of
24486 * any symbols that may have been added or removed in the new scope.
24488 * Returns: the type of the token
24493 * g_scanner_remove_symbol:
24494 * @scanner: a #GScanner
24495 * @symbol: the symbol to remove
24497 * Removes a symbol from the default scope.
24499 * Deprecated: 2.2: Use g_scanner_scope_remove_symbol() instead.
24504 * g_scanner_scope_add_symbol:
24505 * @scanner: a #GScanner
24506 * @scope_id: the scope id
24507 * @symbol: the symbol to add
24508 * @value: the value of the symbol
24510 * Adds a symbol to the given scope.
24515 * g_scanner_scope_foreach_symbol:
24516 * @scanner: a #GScanner
24517 * @scope_id: the scope id
24518 * @func: the function to call for each symbol/value pair
24519 * @user_data: user data to pass to the function
24521 * Calls the given function for each of the symbol/value pairs
24522 * in the given scope of the #GScanner. The function is passed
24523 * the symbol and value of each pair, and the given @user_data
24529 * g_scanner_scope_lookup_symbol:
24530 * @scanner: a #GScanner
24531 * @scope_id: the scope id
24532 * @symbol: the symbol to look up
24534 * Looks up a symbol in a scope and return its value. If the
24535 * symbol is not bound in the scope, %NULL is returned.
24537 * Returns: the value of @symbol in the given scope, or %NULL
24538 * if @symbol is not bound in the given scope.
24543 * g_scanner_scope_remove_symbol:
24544 * @scanner: a #GScanner
24545 * @scope_id: the scope id
24546 * @symbol: the symbol to remove
24548 * Removes a symbol from a scope.
24553 * g_scanner_set_scope:
24554 * @scanner: a #GScanner
24555 * @scope_id: the new scope id
24557 * Sets the current scope.
24559 * Returns: the old scope id
24564 * g_scanner_sync_file_offset:
24565 * @scanner: a #GScanner
24567 * Rewinds the filedescriptor to the current buffer position
24568 * and blows the file read ahead buffer. This is useful for
24569 * third party uses of the scanners filedescriptor, which hooks
24570 * onto the current scanning position.
24575 * g_scanner_thaw_symbol_table:
24576 * @scanner: a #GScanner
24578 * There is no reason to use this macro, since it does nothing.
24580 * Deprecated: 2.2: This macro does nothing.
24585 * g_scanner_unexp_token:
24586 * @scanner: a #GScanner
24587 * @expected_token: the expected token
24588 * @identifier_spec: a string describing how the scanner's user
24589 * refers to identifiers (%NULL defaults to "identifier").
24590 * This is used if @expected_token is %G_TOKEN_IDENTIFIER or
24591 * %G_TOKEN_IDENTIFIER_NULL.
24592 * @symbol_spec: a string describing how the scanner's user refers
24593 * to symbols (%NULL defaults to "symbol"). This is used if
24594 * @expected_token is %G_TOKEN_SYMBOL or any token value greater
24595 * than %G_TOKEN_LAST.
24596 * @symbol_name: the name of the symbol, if the scanner's current
24597 * token is a symbol.
24598 * @message: a message string to output at the end of the
24599 * warning/error, or %NULL.
24600 * @is_error: if %TRUE it is output as an error. If %FALSE it is
24601 * output as a warning.
24603 * Outputs a message through the scanner's msg_handler,
24604 * resulting from an unexpected token in the input stream.
24605 * Note that you should not call g_scanner_peek_next_token()
24606 * followed by g_scanner_unexp_token() without an intermediate
24607 * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
24608 * evaluates the scanner's current token (not the peeked token)
24609 * to construct part of the message.
24615 * @scanner: a #GScanner
24616 * @format: the message format. See the printf() documentation
24617 * @...: the parameters to insert into the format string
24619 * Outputs a warning message, via the #GScanner message handler.
24624 * g_sequence_append:
24625 * @seq: a #GSequence
24626 * @data: the data for the new item
24628 * Adds a new item to the end of @seq.
24630 * Returns: an iterator pointing to the new item
24636 * g_sequence_foreach:
24637 * @seq: a #GSequence
24638 * @func: the function to call for each item in @seq
24639 * @user_data: user data passed to @func
24641 * Calls @func for each item in the sequence passing @user_data
24649 * g_sequence_foreach_range:
24650 * @begin: a #GSequenceIter
24651 * @end: a #GSequenceIter
24653 * @user_data: user data passed to @func
24655 * Calls @func for each item in the range (@begin, @end) passing
24656 * @user_data to the function.
24664 * @seq: a #GSequence
24666 * Frees the memory allocated for @seq. If @seq has a data destroy
24667 * function associated with it, that function is called on all items in
24676 * @iter: a #GSequenceIter
24678 * Returns the data that @iter points to.
24680 * Returns: the data that @iter points to
24686 * g_sequence_get_begin_iter:
24687 * @seq: a #GSequence
24689 * Returns the begin iterator for @seq.
24691 * Returns: the begin iterator for @seq.
24697 * g_sequence_get_end_iter:
24698 * @seq: a #GSequence
24700 * Returns the end iterator for @seg
24702 * Returns: the end iterator for @seq
24708 * g_sequence_get_iter_at_pos:
24709 * @seq: a #GSequence
24710 * @pos: a position in @seq, or -1 for the end.
24712 * Returns the iterator at position @pos. If @pos is negative or larger
24713 * than the number of items in @seq, the end iterator is returned.
24715 * Returns: The #GSequenceIter at position @pos
24721 * g_sequence_get_length:
24722 * @seq: a #GSequence
24724 * Returns the length of @seq
24726 * Returns: the length of @seq
24732 * g_sequence_insert_before:
24733 * @iter: a #GSequenceIter
24734 * @data: the data for the new item
24736 * Inserts a new item just before the item pointed to by @iter.
24738 * Returns: an iterator pointing to the new item
24744 * g_sequence_insert_sorted:
24745 * @seq: a #GSequence
24746 * @data: the data to insert
24747 * @cmp_func: the function used to compare items in the sequence
24748 * @cmp_data: user data passed to @cmp_func.
24750 * Inserts @data into @sequence using @func to determine the new
24751 * position. The sequence must already be sorted according to @cmp_func;
24752 * otherwise the new position of @data is undefined.
24754 * @cmp_func is called with two items of the @seq and @user_data.
24755 * It should return 0 if the items are equal, a negative value
24756 * if the first item comes before the second, and a positive value
24757 * if the second item comes before the first.
24759 * Returns: a #GSequenceIter pointing to the new item.
24765 * g_sequence_insert_sorted_iter:
24766 * @seq: a #GSequence
24767 * @data: data for the new item
24768 * @iter_cmp: the function used to compare iterators in the sequence
24769 * @cmp_data: user data passed to @cmp_func
24771 * Like g_sequence_insert_sorted(), but uses
24772 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
24773 * the compare function.
24775 * @iter_cmp is called with two iterators pointing into @seq.
24776 * It should return 0 if the iterators are equal, a negative
24777 * value if the first iterator comes before the second, and a
24778 * positive value if the second iterator comes before the first.
24780 * It is called with two iterators pointing into @seq. It should
24781 * return 0 if the iterators are equal, a negative value if the
24782 * first iterator comes before the second, and a positive value
24783 * if the second iterator comes before the first.
24785 * Returns: a #GSequenceIter pointing to the new item
24791 * g_sequence_iter_compare:
24792 * @a: a #GSequenceIter
24793 * @b: a #GSequenceIter
24795 * Returns a negative number if @a comes before @b, 0 if they are equal,
24796 * and a positive number if @a comes after @b.
24798 * The @a and @b iterators must point into the same sequence.
24800 * Returns: A negative number if @a comes before @b, 0 if they are
24801 * equal, and a positive number if @a comes after @b.
24807 * g_sequence_iter_get_position:
24808 * @iter: a #GSequenceIter
24810 * Returns the position of @iter
24812 * Returns: the position of @iter
24818 * g_sequence_iter_get_sequence:
24819 * @iter: a #GSequenceIter
24821 * Returns the #GSequence that @iter points into.
24823 * Returns: the #GSequence that @iter points into.
24829 * g_sequence_iter_is_begin:
24830 * @iter: a #GSequenceIter
24832 * Returns whether @iter is the begin iterator
24834 * Returns: whether @iter is the begin iterator
24840 * g_sequence_iter_is_end:
24841 * @iter: a #GSequenceIter
24843 * Returns whether @iter is the end iterator
24845 * Returns: Whether @iter is the end iterator.
24851 * g_sequence_iter_move:
24852 * @iter: a #GSequenceIter
24853 * @delta: A positive or negative number indicating how many positions away
24854 * from @iter the returned #GSequenceIter will be.
24856 * Returns the #GSequenceIter which is @delta positions away from @iter.
24857 * If @iter is closer than -@delta positions to the beginning of the sequence,
24858 * the begin iterator is returned. If @iter is closer than @delta positions
24859 * to the end of the sequence, the end iterator is returned.
24861 * Returns: a #GSequenceIter which is @delta positions away from @iter.
24867 * g_sequence_iter_next:
24868 * @iter: a #GSequenceIter
24870 * Returns an iterator pointing to the next position after @iter. If
24871 * @iter is the end iterator, the end iterator is returned.
24873 * Returns: a #GSequenceIter pointing to the next position after @iter.
24879 * g_sequence_iter_prev:
24880 * @iter: a #GSequenceIter
24882 * Returns an iterator pointing to the previous position before @iter. If
24883 * @iter is the begin iterator, the begin iterator is returned.
24885 * Returns: a #GSequenceIter pointing to the previous position before
24892 * g_sequence_lookup:
24893 * @seq: a #GSequence
24894 * @data: data to lookup
24895 * @cmp_func: the function used to compare items in the sequence
24896 * @cmp_data: user data passed to @cmp_func.
24898 * Returns an iterator pointing to the position of the first item found
24899 * equal to @data according to @cmp_func and @cmp_data. If more than one
24900 * item is equal, it is not guaranteed that it is the first which is
24901 * returned. In that case, you can use g_sequence_iter_next() and
24902 * g_sequence_iter_prev() to get others.
24904 * @cmp_func is called with two items of the @seq and @user_data.
24905 * It should return 0 if the items are equal, a negative value if
24906 * the first item comes before the second, and a positive value if
24907 * the second item comes before the first.
24910 * This function will fail if the data contained in the sequence is
24911 * unsorted. Use g_sequence_insert_sorted() or
24912 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24913 * you want to add a large amount of data, call g_sequence_sort() after
24914 * doing unsorted insertions.
24917 * Returns: an #GSequenceIter pointing to the position of the
24918 * first item found equal to @data according to @cmp_func and
24919 * @cmp_data, or %NULL if no such item exists.
24925 * g_sequence_lookup_iter:
24926 * @seq: a #GSequence
24927 * @data: data to lookup
24928 * @iter_cmp: the function used to compare iterators in the sequence
24929 * @cmp_data: user data passed to @iter_cmp
24931 * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
24932 * instead of a #GCompareDataFunc as the compare function.
24934 * @iter_cmp is called with two iterators pointing into @seq.
24935 * It should return 0 if the iterators are equal, a negative value
24936 * if the first iterator comes before the second, and a positive
24937 * value if the second iterator comes before the first.
24940 * This function will fail if the data contained in the sequence is
24941 * unsorted. Use g_sequence_insert_sorted() or
24942 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24943 * you want to add a large amount of data, call g_sequence_sort() after
24944 * doing unsorted insertions.
24947 * Returns: an #GSequenceIter pointing to the position of
24948 * the first item found equal to @data according to @cmp_func
24949 * and @cmp_data, or %NULL if no such item exists.
24956 * @src: a #GSequenceIter pointing to the item to move
24957 * @dest: a #GSequenceIter pointing to the position to which
24958 * the item is moved.
24960 * Moves the item pointed to by @src to the position indicated by @dest.
24961 * After calling this function @dest will point to the position immediately
24962 * after @src. It is allowed for @src and @dest to point into different
24970 * g_sequence_move_range:
24971 * @dest: a #GSequenceIter
24972 * @begin: a #GSequenceIter
24973 * @end: a #GSequenceIter
24975 * Inserts the (@begin, @end) range at the destination pointed to by ptr.
24976 * The @begin and @end iters must point into the same sequence. It is
24977 * allowed for @dest to point to a different sequence than the one pointed
24978 * into by @begin and @end.
24980 * If @dest is NULL, the range indicated by @begin and @end is
24981 * removed from the sequence. If @dest iter points to a place within
24982 * the (@begin, @end) range, the range does not move.
24990 * @data_destroy: (allow-none): a #GDestroyNotify function, or %NULL
24992 * Creates a new GSequence. The @data_destroy function, if non-%NULL will
24993 * be called on all items when the sequence is destroyed and on items that
24994 * are removed from the sequence.
24996 * Returns: a new #GSequence
25002 * g_sequence_prepend:
25003 * @seq: a #GSequence
25004 * @data: the data for the new item
25006 * Adds a new item to the front of @seq
25008 * Returns: an iterator pointing to the new item
25014 * g_sequence_range_get_midpoint:
25015 * @begin: a #GSequenceIter
25016 * @end: a #GSequenceIter
25018 * Finds an iterator somewhere in the range (@begin, @end). This
25019 * iterator will be close to the middle of the range, but is not
25020 * guaranteed to be <emphasis>exactly</emphasis> in the middle.
25022 * The @begin and @end iterators must both point to the same sequence and
25023 * @begin must come before or be equal to @end in the sequence.
25025 * Returns: A #GSequenceIter pointing somewhere in the
25026 * (@begin, @end) range.
25032 * g_sequence_remove:
25033 * @iter: a #GSequenceIter
25035 * Removes the item pointed to by @iter. It is an error to pass the
25036 * end iterator to this function.
25038 * If the sequence has a data destroy function associated with it, this
25039 * function is called on the data for the removed item.
25046 * g_sequence_remove_range:
25047 * @begin: a #GSequenceIter
25048 * @end: a #GSequenceIter
25050 * Removes all items in the (@begin, @end) range.
25052 * If the sequence has a data destroy function associated with it, this
25053 * function is called on the data for the removed items.
25060 * g_sequence_search:
25061 * @seq: a #GSequence
25062 * @data: data for the new item
25063 * @cmp_func: the function used to compare items in the sequence
25064 * @cmp_data: user data passed to @cmp_func.
25066 * Returns an iterator pointing to the position where @data would
25067 * be inserted according to @cmp_func and @cmp_data.
25069 * @cmp_func is called with two items of the @seq and @user_data.
25070 * It should return 0 if the items are equal, a negative value if
25071 * the first item comes before the second, and a positive value if
25072 * the second item comes before the first.
25074 * If you are simply searching for an existing element of the sequence,
25075 * consider using g_sequence_lookup().
25078 * This function will fail if the data contained in the sequence is
25079 * unsorted. Use g_sequence_insert_sorted() or
25080 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
25081 * you want to add a large amount of data, call g_sequence_sort() after
25082 * doing unsorted insertions.
25085 * Returns: an #GSequenceIter pointing to the position where @data
25086 * would have been inserted according to @cmp_func and @cmp_data.
25092 * g_sequence_search_iter:
25093 * @seq: a #GSequence
25094 * @data: data for the new item
25095 * @iter_cmp: the function used to compare iterators in the sequence
25096 * @cmp_data: user data passed to @iter_cmp
25098 * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
25099 * instead of a #GCompareDataFunc as the compare function.
25101 * @iter_cmp is called with two iterators pointing into @seq.
25102 * It should return 0 if the iterators are equal, a negative value
25103 * if the first iterator comes before the second, and a positive
25104 * value if the second iterator comes before the first.
25106 * If you are simply searching for an existing element of the sequence,
25107 * consider using g_sequence_lookup_iter().
25110 * This function will fail if the data contained in the sequence is
25111 * unsorted. Use g_sequence_insert_sorted() or
25112 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
25113 * you want to add a large amount of data, call g_sequence_sort() after
25114 * doing unsorted insertions.
25117 * Returns: a #GSequenceIter pointing to the position in @seq
25118 * where @data would have been inserted according to @iter_cmp
25126 * @iter: a #GSequenceIter
25127 * @data: new data for the item
25129 * Changes the data for the item pointed to by @iter to be @data. If
25130 * the sequence has a data destroy function associated with it, that
25131 * function is called on the existing data that @iter pointed to.
25139 * @seq: a #GSequence
25140 * @cmp_func: the function used to sort the sequence
25141 * @cmp_data: user data passed to @cmp_func
25143 * Sorts @seq using @cmp_func.
25145 * @cmp_func is passed two items of @seq and should
25146 * return 0 if they are equal, a negative value if the
25147 * first comes before the second, and a positive value
25148 * if the second comes before the first.
25155 * g_sequence_sort_changed:
25156 * @iter: A #GSequenceIter
25157 * @cmp_func: the function used to compare items in the sequence
25158 * @cmp_data: user data passed to @cmp_func.
25160 * Moves the data pointed to a new position as indicated by @cmp_func. This
25161 * function should be called for items in a sequence already sorted according
25162 * to @cmp_func whenever some aspect of an item changes so that @cmp_func
25163 * may return different values for that item.
25165 * @cmp_func is called with two items of the @seq and @user_data.
25166 * It should return 0 if the items are equal, a negative value if
25167 * the first item comes before the second, and a positive value if
25168 * the second item comes before the first.
25175 * g_sequence_sort_changed_iter:
25176 * @iter: a #GSequenceIter
25177 * @iter_cmp: the function used to compare iterators in the sequence
25178 * @cmp_data: user data passed to @cmp_func
25180 * Like g_sequence_sort_changed(), but uses
25181 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
25182 * the compare function.
25184 * @iter_cmp is called with two iterators pointing into @seq. It should
25185 * return 0 if the iterators are equal, a negative value if the first
25186 * iterator comes before the second, and a positive value if the second
25187 * iterator comes before the first.
25194 * g_sequence_sort_iter:
25195 * @seq: a #GSequence
25196 * @cmp_func: the function used to compare iterators in the sequence
25197 * @cmp_data: user data passed to @cmp_func
25199 * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
25200 * of a GCompareDataFunc as the compare function
25202 * @cmp_func is called with two iterators pointing into @seq. It should
25203 * return 0 if the iterators are equal, a negative value if the first
25204 * iterator comes before the second, and a positive value if the second
25205 * iterator comes before the first.
25213 * @a: a #GSequenceIter
25214 * @b: a #GSequenceIter
25216 * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
25217 * to point into difference sequences.
25224 * g_set_application_name:
25225 * @application_name: localized name of the application
25227 * Sets a human-readable name for the application. This name should be
25228 * localized if possible, and is intended for display to the user.
25229 * Contrast with g_set_prgname(), which sets a non-localized name.
25230 * g_set_prgname() will be called automatically by gtk_init(),
25231 * but g_set_application_name() will not.
25233 * Note that for thread safety reasons, this function can only
25236 * The application name will be used in contexts such as error messages,
25237 * or when displaying an application's name in the task list.
25245 * @err: (allow-none): a return location for a #GError, or %NULL
25246 * @domain: error domain
25247 * @code: error code
25248 * @format: printf()-style format
25249 * @...: args for @format
25251 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
25252 * must be %NULL. A new #GError is created and assigned to *@err.
25257 * g_set_error_literal:
25258 * @err: (allow-none): a return location for a #GError, or %NULL
25259 * @domain: error domain
25260 * @code: error code
25261 * @message: error message
25263 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
25264 * must be %NULL. A new #GError is created and assigned to *@err.
25265 * Unlike g_set_error(), @message is not a printf()-style format string.
25266 * Use this function if @message contains text you don't have control over,
25267 * that could include printf() escape sequences.
25275 * @prgname: the name of the program.
25277 * Sets the name of the program. This name should <emphasis>not</emphasis>
25278 * be localized, contrast with g_set_application_name(). Note that for
25279 * thread-safety reasons this function can only be called once.
25284 * g_set_print_handler:
25285 * @func: the new print handler
25287 * Sets the print handler.
25289 * Any messages passed to g_print() will be output via
25290 * the new handler. The default handler simply outputs
25291 * the message to stdout. By providing your own handler
25292 * you can redirect the output, to a GTK+ widget or a
25293 * log file for example.
25295 * Returns: the old print handler
25300 * g_set_printerr_handler:
25301 * @func: the new error message handler
25303 * Sets the handler for printing error messages.
25305 * Any messages passed to g_printerr() will be output via
25306 * the new handler. The default handler simply outputs the
25307 * message to stderr. By providing your own handler you can
25308 * redirect the output, to a GTK+ widget or a log file for
25311 * Returns: the old error message handler
25317 * @variable: the environment variable to set, must not contain '='.
25318 * @value: the value for to set the variable to.
25319 * @overwrite: whether to change the variable if it already exists.
25321 * Sets an environment variable. Both the variable's name and value
25322 * should be in the GLib file name encoding. On UNIX, this means that
25323 * they can be arbitrary byte strings. On Windows, they should be in
25326 * Note that on some systems, when variables are overwritten, the memory
25327 * used for the previous variables and its value isn't reclaimed.
25330 * Environment variable handling in UNIX is not thread-safe, and your
25331 * program may crash if one thread calls g_setenv() while another
25332 * thread is calling getenv(). (And note that many functions, such as
25333 * gettext(), call getenv() internally.) This function is only safe to
25334 * use at the very start of your program, before creating any other
25335 * threads (or creating objects that create worker threads of their
25338 * If you need to set up the environment for a child process, you can
25339 * use g_get_environ() to get an environment array, modify that with
25340 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
25341 * array directly to execvpe(), g_spawn_async(), or the like.
25342 * </para></warning>
25344 * Returns: %FALSE if the environment variable couldn't be set.
25350 * g_shell_parse_argv:
25351 * @command_line: command line to parse
25352 * @argcp: (out): return location for number of args
25353 * @argvp: (out) (array length=argcp zero-terminated=1): return location for array of args
25354 * @error: return location for error
25356 * Parses a command line into an argument vector, in much the same way
25357 * the shell would, but without many of the expansions the shell would
25358 * perform (variable expansion, globs, operators, filename expansion,
25359 * etc. are not supported). The results are defined to be the same as
25360 * those you would get from a UNIX98 /bin/sh, as long as the input
25361 * contains none of the unsupported shell expansions. If the input
25362 * does contain such expansions, they are passed through
25363 * literally. Possible errors are those from the #G_SHELL_ERROR
25364 * domain. Free the returned vector with g_strfreev().
25366 * Returns: %TRUE on success, %FALSE if error set
25372 * @unquoted_string: a literal string
25374 * Quotes a string so that the shell (/bin/sh) will interpret the
25375 * quoted string to mean @unquoted_string. If you pass a filename to
25376 * the shell, for example, you should first quote it with this
25377 * function. The return value must be freed with g_free(). The
25378 * quoting style used is undefined (single or double quotes may be
25381 * Returns: quoted string
25387 * @quoted_string: shell-quoted string
25388 * @error: error return location or NULL
25390 * Unquotes a string as the shell (/bin/sh) would. Only handles
25391 * quotes; if a string contains file globs, arithmetic operators,
25392 * variables, backticks, redirections, or other special-to-the-shell
25393 * features, the result will be different from the result a real shell
25394 * would produce (the variables, backticks, etc. will be passed
25395 * through literally instead of being expanded). This function is
25396 * guaranteed to succeed if applied to the result of
25397 * g_shell_quote(). If it fails, it returns %NULL and sets the
25398 * error. The @quoted_string need not actually contain quoted or
25399 * escaped text; g_shell_unquote() simply goes through the string and
25400 * unquotes/unescapes anything that the shell would. Both single and
25401 * double quotes are handled, as are escapes including escaped
25402 * newlines. The return value must be freed with g_free(). Possible
25403 * errors are in the #G_SHELL_ERROR domain.
25405 * Shell quoting rules are a bit strange. Single quotes preserve the
25406 * literal string exactly. escape sequences are not allowed; not even
25407 * \' - if you want a ' in the quoted text, you have to do something
25408 * like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
25409 * be escaped with backslash. Otherwise double quotes preserve things
25412 * Returns: an unquoted string
25418 * @block_size: the number of bytes to allocate
25420 * Allocates a block of memory from the slice allocator.
25421 * The block adress handed out can be expected to be aligned
25422 * to at least <literal>1 * sizeof (void*)</literal>,
25423 * though in general slices are 2 * sizeof (void*) bytes aligned,
25424 * if a malloc() fallback implementation is used instead,
25425 * the alignment may be reduced in a libc dependent fashion.
25426 * Note that the underlying slice allocation mechanism can
25427 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25428 * environment variable.
25430 * Returns: a pointer to the allocated memory block
25437 * @block_size: the number of bytes to allocate
25439 * Allocates a block of memory via g_slice_alloc() and initializes
25440 * the returned memory to 0. Note that the underlying slice allocation
25441 * mechanism can be changed with the
25442 * <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25443 * environment variable.
25445 * Returns: a pointer to the allocated block
25452 * @block_size: the number of bytes to allocate
25453 * @mem_block: the memory to copy
25455 * Allocates a block of memory from the slice allocator
25456 * and copies @block_size bytes into it from @mem_block.
25458 * Returns: a pointer to the allocated memory block
25465 * @type: the type to duplicate, typically a structure name
25466 * @mem: the memory to copy into the allocated block
25468 * A convenience macro to duplicate a block of memory using
25469 * the slice allocator.
25471 * It calls g_slice_copy() with <literal>sizeof (@type)</literal>
25472 * and casts the returned pointer to a pointer of the given type,
25473 * avoiding a type cast in the source code.
25474 * Note that the underlying slice allocation mechanism can
25475 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25476 * environment variable.
25478 * Returns: a pointer to the allocated block, cast to a pointer to @type
25485 * @type: the type of the block to free, typically a structure name
25486 * @mem: a pointer to the block to free
25488 * A convenience macro to free a block of memory that has
25489 * been allocated from the slice allocator.
25491 * It calls g_slice_free1() using <literal>sizeof (type)</literal>
25492 * as the block size.
25493 * Note that the exact release behaviour can be changed with the
25494 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25495 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25496 * related debugging options.
25504 * @block_size: the size of the block
25505 * @mem_block: a pointer to the block to free
25507 * Frees a block of memory.
25509 * The memory must have been allocated via g_slice_alloc() or
25510 * g_slice_alloc0() and the @block_size has to match the size
25511 * specified upon allocation. Note that the exact release behaviour
25512 * can be changed with the
25513 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25514 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25515 * related debugging options.
25522 * g_slice_free_chain:
25523 * @type: the type of the @mem_chain blocks
25524 * @mem_chain: a pointer to the first block of the chain
25525 * @next: the field name of the next pointer in @type
25527 * Frees a linked list of memory blocks of structure type @type.
25528 * The memory blocks must be equal-sized, allocated via
25529 * g_slice_alloc() or g_slice_alloc0() and linked together by
25530 * a @next pointer (similar to #GSList). The name of the
25531 * @next field in @type is passed as third argument.
25532 * Note that the exact release behaviour can be changed with the
25533 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25534 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25535 * related debugging options.
25542 * g_slice_free_chain_with_offset:
25543 * @block_size: the size of the blocks
25544 * @mem_chain: a pointer to the first block of the chain
25545 * @next_offset: the offset of the @next field in the blocks
25547 * Frees a linked list of memory blocks of structure type @type.
25549 * The memory blocks must be equal-sized, allocated via
25550 * g_slice_alloc() or g_slice_alloc0() and linked together by a
25551 * @next pointer (similar to #GSList). The offset of the @next
25552 * field in each block is passed as third argument.
25553 * Note that the exact release behaviour can be changed with the
25554 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25555 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25556 * related debugging options.
25564 * @type: the type to allocate, typically a structure name
25566 * A convenience macro to allocate a block of memory from the
25569 * It calls g_slice_alloc() with <literal>sizeof (@type)</literal>
25570 * and casts the returned pointer to a pointer of the given type,
25571 * avoiding a type cast in the source code.
25572 * Note that the underlying slice allocation mechanism can
25573 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25574 * environment variable.
25576 * Returns: a pointer to the allocated block, cast to a pointer to @type
25583 * @type: the type to allocate, typically a structure name
25585 * A convenience macro to allocate a block of memory from the
25586 * slice allocator and set the memory to 0.
25588 * It calls g_slice_alloc0() with <literal>sizeof (@type)</literal>
25589 * and casts the returned pointer to a pointer of the given type,
25590 * avoiding a type cast in the source code.
25591 * Note that the underlying slice allocation mechanism can
25592 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25593 * environment variable.
25602 * Allocates space for one #GSList element. It is called by the
25603 * g_slist_append(), g_slist_prepend(), g_slist_insert() and
25604 * g_slist_insert_sorted() functions and so is rarely used on its own.
25606 * Returns: a pointer to the newly-allocated #GSList element.
25613 * @data: the data for the new element
25615 * Adds a new element on to the end of the list.
25618 * The return value is the new start of the list, which may
25619 * have changed, so make sure you store the new value.
25623 * Note that g_slist_append() has to traverse the entire list
25624 * to find the end, which is inefficient when adding multiple
25625 * elements. A common idiom to avoid the inefficiency is to prepend
25626 * the elements and reverse the list when all elements have been added.
25630 * /* Notice that these are initialized to the empty list. */
25631 * GSList *list = NULL, *number_list = NULL;
25633 * /* This is a list of strings. */
25634 * list = g_slist_append (list, "first");
25635 * list = g_slist_append (list, "second");
25637 * /* This is a list of integers. */
25638 * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
25639 * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
25642 * Returns: the new start of the #GSList
25648 * @list1: a #GSList
25649 * @list2: the #GSList to add to the end of the first #GSList
25651 * Adds the second #GSList onto the end of the first #GSList.
25652 * Note that the elements of the second #GSList are not copied.
25653 * They are used directly.
25655 * Returns: the start of the new #GSList
25663 * Copies a #GSList.
25666 * Note that this is a "shallow" copy. If the list elements
25667 * consist of pointers to data, the pointers are copied but
25668 * the actual data isn't. See g_slist_copy_deep() if you need
25669 * to copy the data as well.
25672 * Returns: a copy of @list
25677 * g_slist_copy_deep:
25679 * @func: a copy function used to copy every element in the list
25680 * @user_data: user data passed to the copy function @func, or #NULL
25682 * Makes a full (deep) copy of a #GSList.
25684 * In contrast with g_slist_copy(), this function uses @func to make a copy of
25685 * each list element, in addition to copying the list container itself.
25687 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
25688 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
25691 * For instance, if @list holds a list of GObjects, you can do:
25693 * another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
25696 * And, to entirely free the new list, you could do:
25698 * g_slist_free_full (another_list, g_object_unref);
25701 * Returns: a full copy of @list, use #g_slist_free_full to free it
25707 * g_slist_delete_link:
25709 * @link_: node to delete
25711 * Removes the node link_ from the list and frees it.
25712 * Compare this to g_slist_remove_link() which removes the node
25713 * without freeing it.
25715 * <note>Removing arbitrary nodes from a singly-linked list
25716 * requires time that is proportional to the length of the list
25717 * (ie. O(n)). If you find yourself using g_slist_delete_link()
25718 * frequently, you should consider a different data structure, such
25719 * as the doubly-linked #GList.</note>
25721 * Returns: the new head of @list
25728 * @data: the element data to find
25730 * Finds the element in a #GSList which
25731 * contains the given data.
25733 * Returns: the found #GSList element,
25734 * or %NULL if it is not found
25739 * g_slist_find_custom:
25741 * @data: user data passed to the function
25742 * @func: the function to call for each element.
25743 * It should return 0 when the desired element is found
25745 * Finds an element in a #GSList, using a supplied function to
25746 * find the desired element. It iterates over the list, calling
25747 * the given function which should return 0 when the desired
25748 * element is found. The function takes two #gconstpointer arguments,
25749 * the #GSList element's data as the first argument and the
25752 * Returns: the found #GSList element, or %NULL if it is not found
25759 * @func: the function to call with each element's data
25760 * @user_data: user data to pass to the function
25762 * Calls a function for each element of a #GSList.
25770 * Frees all of the memory used by a #GSList.
25771 * The freed elements are returned to the slice allocator.
25774 * If list elements contain dynamically-allocated memory,
25775 * you should either use g_slist_free_full() or free them manually
25784 * A macro which does the same as g_slist_free_1().
25792 * @list: a #GSList element
25794 * Frees one #GSList element.
25795 * It is usually used after g_slist_remove_link().
25800 * g_slist_free_full:
25801 * @list: a pointer to a #GSList
25802 * @free_func: the function to be called to free each element's data
25804 * Convenience method, which frees all the memory used by a #GSList, and
25805 * calls the specified destroy function on every element's data.
25814 * @data: the data to find
25816 * Gets the position of the element containing
25817 * the given data (starting from 0).
25819 * Returns: the index of the element containing the data,
25820 * or -1 if the data is not found
25827 * @data: the data for the new element
25828 * @position: the position to insert the element.
25829 * If this is negative, or is larger than the number
25830 * of elements in the list, the new element is added on
25831 * to the end of the list.
25833 * Inserts a new element into the list at the given position.
25835 * Returns: the new start of the #GSList
25840 * g_slist_insert_before:
25841 * @slist: a #GSList
25842 * @sibling: node to insert @data before
25843 * @data: data to put in the newly-inserted node
25845 * Inserts a node before @sibling containing @data.
25847 * Returns: the new head of the list.
25852 * g_slist_insert_sorted:
25854 * @data: the data for the new element
25855 * @func: the function to compare elements in the list.
25856 * It should return a number > 0 if the first parameter
25857 * comes after the second parameter in the sort order.
25859 * Inserts a new element into the list, using the given
25860 * comparison function to determine its position.
25862 * Returns: the new start of the #GSList
25867 * g_slist_insert_sorted_with_data:
25869 * @data: the data for the new element
25870 * @func: the function to compare elements in the list.
25871 * It should return a number > 0 if the first parameter
25872 * comes after the second parameter in the sort order.
25873 * @user_data: data to pass to comparison function
25875 * Inserts a new element into the list, using the given
25876 * comparison function to determine its position.
25878 * Returns: the new start of the #GSList
25887 * Gets the last element in a #GSList.
25890 * This function iterates over the whole list.
25893 * Returns: the last element in the #GSList,
25894 * or %NULL if the #GSList has no elements
25902 * Gets the number of elements in a #GSList.
25905 * This function iterates over the whole list to
25906 * count its elements.
25909 * Returns: the number of elements in the #GSList
25915 * @slist: an element in a #GSList.
25917 * A convenience macro to get the next element in a #GSList.
25919 * Returns: the next element, or %NULL if there are no more elements.
25926 * @n: the position of the element, counting from 0
25928 * Gets the element at the given position in a #GSList.
25930 * Returns: the element, or %NULL if the position is off
25931 * the end of the #GSList
25936 * g_slist_nth_data:
25938 * @n: the position of the element
25940 * Gets the data of the element at the given position.
25942 * Returns: the element's data, or %NULL if the position
25943 * is off the end of the #GSList
25948 * g_slist_position:
25950 * @llink: an element in the #GSList
25952 * Gets the position of the given element
25953 * in the #GSList (starting from 0).
25955 * Returns: the position of the element in the #GSList,
25956 * or -1 if the element is not found
25963 * @data: the data for the new element
25965 * Adds a new element on to the start of the list.
25968 * The return value is the new start of the list, which
25969 * may have changed, so make sure you store the new value.
25973 * /* Notice that it is initialized to the empty list. */
25974 * GSList *list = NULL;
25975 * list = g_slist_prepend (list, "last");
25976 * list = g_slist_prepend (list, "first");
25979 * Returns: the new start of the #GSList
25986 * @data: the data of the element to remove
25988 * Removes an element from a #GSList.
25989 * If two elements contain the same data, only the first is removed.
25990 * If none of the elements contain the data, the #GSList is unchanged.
25992 * Returns: the new start of the #GSList
25997 * g_slist_remove_all:
25999 * @data: data to remove
26001 * Removes all list nodes with data equal to @data.
26002 * Returns the new head of the list. Contrast with
26003 * g_slist_remove() which removes only the first node
26004 * matching the given data.
26006 * Returns: new head of @list
26011 * g_slist_remove_link:
26013 * @link_: an element in the #GSList
26015 * Removes an element from a #GSList, without
26016 * freeing the element. The removed element's next
26017 * link is set to %NULL, so that it becomes a
26018 * self-contained list with one element.
26020 * <note>Removing arbitrary nodes from a singly-linked list
26021 * requires time that is proportional to the length of the list
26022 * (ie. O(n)). If you find yourself using g_slist_remove_link()
26023 * frequently, you should consider a different data structure, such
26024 * as the doubly-linked #GList.</note>
26026 * Returns: the new start of the #GSList, without the element
26034 * Reverses a #GSList.
26036 * Returns: the start of the reversed #GSList
26043 * @compare_func: the comparison function used to sort the #GSList.
26044 * This function is passed the data from 2 elements of the #GSList
26045 * and should return 0 if they are equal, a negative value if the
26046 * first element comes before the second, or a positive value if
26047 * the first element comes after the second.
26049 * Sorts a #GSList using the given comparison function.
26051 * Returns: the start of the sorted #GSList
26056 * g_slist_sort_with_data:
26058 * @compare_func: comparison function
26059 * @user_data: data to pass to comparison function
26061 * Like g_slist_sort(), but the sort function accepts a user data argument.
26063 * Returns: new head of the list
26069 * @string: the buffer to hold the output.
26070 * @n: the maximum number of bytes to produce (including the
26071 * terminating nul character).
26072 * @format: a standard printf() format string, but notice
26073 * <link linkend="string-precision">string precision pitfalls</link>.
26074 * @...: the arguments to insert in the output.
26076 * A safer form of the standard sprintf() function. The output is guaranteed
26077 * to not exceed @n characters (including the terminating nul character), so
26078 * it is easy to ensure that a buffer overflow cannot occur.
26080 * See also g_strdup_printf().
26082 * In versions of GLib prior to 1.2.3, this function may return -1 if the
26083 * output was truncated, and the truncated string may not be nul-terminated.
26084 * In versions prior to 1.3.12, this function returns the length of the output
26087 * The return value of g_snprintf() conforms to the snprintf()
26088 * function as standardized in ISO C99. Note that this is different from
26089 * traditional snprintf(), which returns the length of the output string.
26091 * The format string may contain positional parameters, as specified in
26092 * the Single Unix Specification.
26094 * Returns: the number of bytes which would be produced if the buffer
26095 * was large enough.
26100 * g_source_add_child_source:
26101 * @source: a #GSource
26102 * @child_source: a second #GSource that @source should "poll"
26104 * Adds @child_source to @source as a "polled" source; when @source is
26105 * added to a #GMainContext, @child_source will be automatically added
26106 * with the same priority, when @child_source is triggered, it will
26107 * cause @source to dispatch (in addition to calling its own
26108 * callback), and when @source is destroyed, it will destroy
26109 * @child_source as well. (@source will also still be dispatched if
26110 * its own prepare/check functions indicate that it is ready.)
26112 * If you don't need @child_source to do anything on its own when it
26113 * triggers, you can call g_source_set_dummy_callback() on it to set a
26114 * callback that does nothing (except return %TRUE if appropriate).
26116 * @source will hold a reference on @child_source while @child_source
26117 * is attached to it.
26124 * g_source_add_poll:
26125 * @source: a #GSource
26126 * @fd: a #GPollFD structure holding information about a file
26127 * descriptor to watch.
26129 * Adds a file descriptor to the set of file descriptors polled for
26130 * this source. This is usually combined with g_source_new() to add an
26131 * event source. The event source's check function will typically test
26132 * the @revents field in the #GPollFD struct and return %TRUE if events need
26135 * Using this API forces the linear scanning of event sources on each
26136 * main loop iteration. Newly-written event sources should try to use
26137 * g_source_add_unix_fd() instead of this API.
26142 * g_source_add_unix_fd:
26143 * @source: a #GSource
26144 * @fd: the fd to monitor
26145 * @events: an event mask
26147 * Monitors @fd for the IO events in @events.
26149 * The tag returned by this function can be used to remove or modify the
26150 * monitoring of the fd using g_source_remove_unix_fd() or
26151 * g_source_modify_unix_fd().
26153 * It is not necessary to remove the fd before destroying the source; it
26154 * will be cleaned up automatically.
26156 * As the name suggests, this function is not available on Windows.
26158 * Returns: an opaque tag
26165 * @source: a #GSource
26166 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
26168 * Adds a #GSource to a @context so that it will be executed within
26169 * that context. Remove it by calling g_source_destroy().
26171 * Returns: the ID (greater than 0) for the source within the
26177 * g_source_destroy:
26178 * @source: a #GSource
26180 * Removes a source from its #GMainContext, if any, and mark it as
26181 * destroyed. The source cannot be subsequently added to another
26187 * g_source_get_can_recurse:
26188 * @source: a #GSource
26190 * Checks whether a source is allowed to be called recursively.
26191 * see g_source_set_can_recurse().
26193 * Returns: whether recursion is allowed.
26198 * g_source_get_context:
26199 * @source: a #GSource
26201 * Gets the #GMainContext with which the source is associated.
26203 * You can call this on a source that has been destroyed, provided
26204 * that the #GMainContext it was attached to still exists (in which
26205 * case it will return that #GMainContext). In particular, you can
26206 * always call this function on the source returned from
26207 * g_main_current_source(). But calling this function on a source
26208 * whose #GMainContext has been destroyed is an error.
26210 * Returns: (transfer none) (allow-none): the #GMainContext with which the
26211 * source is associated, or %NULL if the context has not
26212 * yet been added to a source.
26217 * g_source_get_current_time:
26218 * @source: a #GSource
26219 * @timeval: #GTimeVal structure in which to store current time.
26221 * This function ignores @source and is otherwise the same as
26222 * g_get_current_time().
26224 * Deprecated: 2.28: use g_source_get_time() instead
26230 * @source: a #GSource
26232 * Returns the numeric ID for a particular source. The ID of a source
26233 * is a positive integer which is unique within a particular main loop
26234 * context. The reverse
26235 * mapping from ID to source is done by g_main_context_find_source_by_id().
26237 * Returns: the ID (greater than 0) for the source
26242 * g_source_get_name:
26243 * @source: a #GSource
26245 * Gets a name for the source, used in debugging and profiling.
26246 * The name may be #NULL if it has never been set with
26247 * g_source_set_name().
26249 * Returns: the name of the source
26255 * g_source_get_priority:
26256 * @source: a #GSource
26258 * Gets the priority of a source.
26260 * Returns: the priority of the source
26265 * g_source_get_ready_time:
26266 * @source: a #GSource
26268 * Gets the "ready time" of @source, as set by
26269 * g_source_set_ready_time().
26271 * Any time before the current monotonic time (including 0) is an
26272 * indication that the source will fire immediately.
26274 * Returns: the monotonic ready time, -1 for "never"
26279 * g_source_get_time:
26280 * @source: a #GSource
26282 * Gets the time to be used when checking this source. The advantage of
26283 * calling this function over calling g_get_monotonic_time() directly is
26284 * that when checking multiple sources, GLib can cache a single value
26285 * instead of having to repeatedly get the system monotonic time.
26287 * The time here is the system monotonic time, if available, or some
26288 * other reasonable alternative otherwise. See g_get_monotonic_time().
26290 * Returns: the monotonic time in microseconds
26296 * g_source_is_destroyed:
26297 * @source: a #GSource
26299 * Returns whether @source has been destroyed.
26301 * This is important when you operate upon your objects
26302 * from within idle handlers, but may have freed the object
26303 * before the dispatch of your idle handler.
26307 * idle_callback (gpointer data)
26309 * SomeWidget *self = data;
26311 * GDK_THREADS_ENTER (<!-- -->);
26312 * /<!-- -->* do stuff with self *<!-- -->/
26313 * self->idle_id = 0;
26314 * GDK_THREADS_LEAVE (<!-- -->);
26316 * return G_SOURCE_REMOVE;
26320 * some_widget_do_stuff_later (SomeWidget *self)
26322 * self->idle_id = g_idle_add (idle_callback, self);
26326 * some_widget_finalize (GObject *object)
26328 * SomeWidget *self = SOME_WIDGET (object);
26330 * if (self->idle_id)
26331 * g_source_remove (self->idle_id);
26333 * G_OBJECT_CLASS (parent_class)->finalize (object);
26337 * This will fail in a multi-threaded application if the
26338 * widget is destroyed before the idle handler fires due
26339 * to the use after free in the callback. A solution, to
26340 * this particular problem, is to check to if the source
26341 * has already been destroy within the callback.
26345 * idle_callback (gpointer data)
26347 * SomeWidget *self = data;
26349 * GDK_THREADS_ENTER ();
26350 * if (!g_source_is_destroyed (g_main_current_source ()))
26352 * /<!-- -->* do stuff with self *<!-- -->/
26354 * GDK_THREADS_LEAVE ();
26360 * Returns: %TRUE if the source has been destroyed
26366 * g_source_modify_unix_fd:
26367 * @source: a #GSource
26368 * @tag: the tag from g_source_add_unix_fd()
26369 * @new_events: the new event mask to watch
26371 * Updates the event mask to watch for the fd identified by @tag.
26373 * @tag is the tag returned from g_source_add_unix_fd().
26375 * If you want to remove a fd, don't set its event mask to zero.
26376 * Instead, call g_source_remove_unix_fd().
26378 * As the name suggests, this function is not available on Windows.
26386 * @source_funcs: structure containing functions that implement
26387 * the sources behavior.
26388 * @struct_size: size of the #GSource structure to create.
26390 * Creates a new #GSource structure. The size is specified to
26391 * allow creating structures derived from #GSource that contain
26392 * additional data. The size passed in must be at least
26393 * <literal>sizeof (GSource)</literal>.
26395 * The source will not initially be associated with any #GMainContext
26396 * and must be added to one with g_source_attach() before it will be
26399 * Returns: the newly-created #GSource.
26404 * g_source_query_unix_fd:
26405 * @source: a #GSource
26406 * @tag: the tag from g_source_add_unix_fd()
26408 * Queries the events reported for the fd corresponding to @tag on
26409 * @source during the last poll.
26411 * The return value of this function is only defined when the function
26412 * is called from the check or dispatch functions for @source.
26414 * As the name suggests, this function is not available on Windows.
26416 * Returns: the conditions reported on the fd
26423 * @source: a #GSource
26425 * Increases the reference count on a source by one.
26433 * @tag: the ID of the source to remove.
26435 * Removes the source with the given id from the default main context.
26437 * The id of a #GSource is given by g_source_get_id(), or will be
26438 * returned by the functions g_source_attach(), g_idle_add(),
26439 * g_idle_add_full(), g_timeout_add(), g_timeout_add_full(),
26440 * g_child_watch_add(), g_child_watch_add_full(), g_io_add_watch(), and
26441 * g_io_add_watch_full().
26443 * See also g_source_destroy(). You must use g_source_destroy() for sources
26444 * added to a non-default main context.
26446 * It is a programmer error to attempt to remove a non-existent source.
26448 * Returns: For historical reasons, this function always returns %TRUE
26453 * g_source_remove_by_funcs_user_data:
26454 * @funcs: The @source_funcs passed to g_source_new()
26455 * @user_data: the user data for the callback
26457 * Removes a source from the default main loop context given the
26458 * source functions and user data. If multiple sources exist with the
26459 * same source functions and user data, only one will be destroyed.
26461 * Returns: %TRUE if a source was found and removed.
26466 * g_source_remove_by_user_data:
26467 * @user_data: the user_data for the callback.
26469 * Removes a source from the default main loop context given the user
26470 * data for the callback. If multiple sources exist with the same user
26471 * data, only one will be destroyed.
26473 * Returns: %TRUE if a source was found and removed.
26478 * g_source_remove_child_source:
26479 * @source: a #GSource
26480 * @child_source: a #GSource previously passed to
26481 * g_source_add_child_source().
26483 * Detaches @child_source from @source and destroys it.
26490 * g_source_remove_poll:
26491 * @source: a #GSource
26492 * @fd: a #GPollFD structure previously passed to g_source_add_poll().
26494 * Removes a file descriptor from the set of file descriptors polled for
26500 * g_source_remove_unix_fd:
26501 * @source: a #GSource
26502 * @tag: the tag from g_source_add_unix_fd()
26504 * Reverses the effect of a previous call to g_source_add_unix_fd().
26506 * You only need to call this if you want to remove an fd from being
26507 * watched while keeping the same source around. In the normal case you
26508 * will just want to destroy the source.
26510 * As the name suggests, this function is not available on Windows.
26517 * g_source_set_callback:
26518 * @source: the source
26519 * @func: a callback function
26520 * @data: the data to pass to callback function
26521 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
26523 * Sets the callback function for a source. The callback for a source is
26524 * called from the source's dispatch function.
26526 * The exact type of @func depends on the type of source; ie. you
26527 * should not count on @func being called with @data as its first
26530 * Typically, you won't use this function. Instead use functions specific
26531 * to the type of source you are using.
26536 * g_source_set_callback_indirect:
26537 * @source: the source
26538 * @callback_data: pointer to callback data "object"
26539 * @callback_funcs: functions for reference counting @callback_data
26540 * and getting the callback and data
26542 * Sets the callback function storing the data as a refcounted callback
26543 * "object". This is used internally. Note that calling
26544 * g_source_set_callback_indirect() assumes
26545 * an initial reference count on @callback_data, and thus
26546 * @callback_funcs->unref will eventually be called once more
26547 * than @callback_funcs->ref.
26552 * g_source_set_can_recurse:
26553 * @source: a #GSource
26554 * @can_recurse: whether recursion is allowed for this source
26556 * Sets whether a source can be called recursively. If @can_recurse is
26557 * %TRUE, then while the source is being dispatched then this source
26558 * will be processed normally. Otherwise, all processing of this
26559 * source is blocked until the dispatch function returns.
26564 * g_source_set_funcs:
26565 * @source: a #GSource
26566 * @funcs: the new #GSourceFuncs
26568 * Sets the source functions (can be used to override
26569 * default implementations) of an unattached source.
26576 * g_source_set_name:
26577 * @source: a #GSource
26578 * @name: debug name for the source
26580 * Sets a name for the source, used in debugging and profiling.
26581 * The name defaults to #NULL.
26583 * The source name should describe in a human-readable way
26584 * what the source does. For example, "X11 event queue"
26585 * or "GTK+ repaint idle handler" or whatever it is.
26587 * It is permitted to call this function multiple times, but is not
26588 * recommended due to the potential performance impact. For example,
26589 * one could change the name in the "check" function of a #GSourceFuncs
26590 * to include details like the event type in the source name.
26597 * g_source_set_name_by_id:
26598 * @tag: a #GSource ID
26599 * @name: debug name for the source
26601 * Sets the name of a source using its ID.
26603 * This is a convenience utility to set source names from the return
26604 * value of g_idle_add(), g_timeout_add(), etc.
26611 * g_source_set_priority:
26612 * @source: a #GSource
26613 * @priority: the new priority.
26615 * Sets the priority of a source. While the main loop is being run, a
26616 * source will be dispatched if it is ready to be dispatched and no
26617 * sources at a higher (numerically smaller) priority are ready to be
26623 * g_source_set_ready_time:
26624 * @source: a #GSource
26625 * @ready_time: the monotonic time at which the source will be ready,
26626 * 0 for "immediately", -1 for "never"
26628 * Sets a #GSource to be dispatched when the given monotonic time is
26629 * reached (or passed). If the monotonic time is in the past (as it
26630 * always will be if @ready_time is 0) then the source will be
26631 * dispatched immediately.
26633 * If @ready_time is -1 then the source is never woken up on the basis
26634 * of the passage of time.
26636 * Dispatching the source does not reset the ready time. You should do
26637 * so yourself, from the source dispatch function.
26639 * Note that if you have a pair of sources where the ready time of one
26640 * suggests that it will be delivered first but the priority for the
26641 * other suggests that it would be delivered first, and the ready time
26642 * for both sources is reached during the same main context iteration
26643 * then the order of dispatch is undefined.
26651 * @source: a #GSource
26653 * Decreases the reference count of a source by one. If the
26654 * resulting reference count is zero the source and associated
26655 * memory will be destroyed.
26660 * g_spaced_primes_closest:
26663 * Gets the smallest prime number from a built-in array of primes which
26664 * is larger than @num. This is used within GLib to calculate the optimum
26665 * size of a #GHashTable.
26667 * The built-in array of primes ranges from 11 to 13845163 such that
26668 * each prime is approximately 1.5-2 times the previous prime.
26670 * Returns: the smallest prime number from a built-in array of primes
26671 * which is larger than @num
26677 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
26678 * @argv: (array zero-terminated=1): child's argument vector
26679 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
26680 * @flags: flags from #GSpawnFlags
26681 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26682 * @user_data: (closure): user data for @child_setup
26683 * @child_pid: (out) (allow-none): return location for child process reference, or %NULL
26684 * @error: return location for error
26686 * See g_spawn_async_with_pipes() for a full description; this function
26687 * simply calls the g_spawn_async_with_pipes() without any pipes.
26689 * You should call g_spawn_close_pid() on the returned child process
26690 * reference when you don't need it any more.
26693 * If you are writing a GTK+ application, and the program you
26694 * are spawning is a graphical application, too, then you may
26695 * want to use gdk_spawn_on_screen() instead to ensure that
26696 * the spawned program opens its windows on the right screen.
26699 * <note><para> Note that the returned @child_pid on Windows is a
26700 * handle to the child process and not its identifier. Process handles
26701 * and process identifiers are different concepts on Windows.
26704 * Returns: %TRUE on success, %FALSE if error is set
26709 * g_spawn_async_with_pipes:
26710 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
26711 * @argv: (array zero-terminated=1): child's argument vector, in the GLib file name encoding
26712 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's, in the GLib file name encoding
26713 * @flags: flags from #GSpawnFlags
26714 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26715 * @user_data: (closure): user data for @child_setup
26716 * @child_pid: (out) (allow-none): return location for child process ID, or %NULL
26717 * @standard_input: (out) (allow-none): return location for file descriptor to write to child's stdin, or %NULL
26718 * @standard_output: (out) (allow-none): return location for file descriptor to read child's stdout, or %NULL
26719 * @standard_error: (out) (allow-none): return location for file descriptor to read child's stderr, or %NULL
26720 * @error: return location for error
26722 * Executes a child program asynchronously (your program will not
26723 * block waiting for the child to exit). The child program is
26724 * specified by the only argument that must be provided, @argv. @argv
26725 * should be a %NULL-terminated array of strings, to be passed as the
26726 * argument vector for the child. The first string in @argv is of
26727 * course the name of the program to execute. By default, the name of
26728 * the program must be a full path. If @flags contains the
26729 * %G_SPAWN_SEARCH_PATH flag, the <envar>PATH</envar> environment variable
26730 * is used to search for the executable. If @flags contains the
26731 * %G_SPAWN_SEARCH_PATH_FROM_ENVP flag, the <envar>PATH</envar> variable from
26732 * @envp is used to search for the executable.
26733 * If both the %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP
26734 * flags are set, the <envar>PATH</envar> variable from @envp takes precedence
26735 * over the environment variable.
26737 * If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
26738 * used, then the program will be run from the current directory (or
26739 * @working_directory, if specified); this might be unexpected or even
26740 * dangerous in some cases when the current directory is world-writable.
26742 * On Windows, note that all the string or string vector arguments to
26743 * this function and the other g_spawn*() functions are in UTF-8, the
26744 * GLib file name encoding. Unicode characters that are not part of
26745 * the system codepage passed in these arguments will be correctly
26746 * available in the spawned program only if it uses wide character API
26747 * to retrieve its command line. For C programs built with Microsoft's
26748 * tools it is enough to make the program have a wmain() instead of
26749 * main(). wmain() has a wide character argument vector as parameter.
26751 * At least currently, mingw doesn't support wmain(), so if you use
26752 * mingw to develop the spawned program, it will have to call the
26753 * undocumented function __wgetmainargs() to get the wide character
26754 * argument vector and environment. See gspawn-win32-helper.c in the
26755 * GLib sources or init.c in the mingw runtime sources for a prototype
26756 * for that function. Alternatively, you can retrieve the Win32 system
26757 * level wide character command line passed to the spawned program
26758 * using the GetCommandLineW() function.
26760 * On Windows the low-level child process creation API
26761 * <function>CreateProcess()</function> doesn't use argument vectors,
26762 * but a command line. The C runtime library's
26763 * <function>spawn*()</function> family of functions (which
26764 * g_spawn_async_with_pipes() eventually calls) paste the argument
26765 * vector elements together into a command line, and the C runtime startup code
26766 * does a corresponding reconstruction of an argument vector from the
26767 * command line, to be passed to main(). Complications arise when you have
26768 * argument vector elements that contain spaces of double quotes. The
26769 * <function>spawn*()</function> functions don't do any quoting or
26770 * escaping, but on the other hand the startup code does do unquoting
26771 * and unescaping in order to enable receiving arguments with embedded
26772 * spaces or double quotes. To work around this asymmetry,
26773 * g_spawn_async_with_pipes() will do quoting and escaping on argument
26774 * vector elements that need it before calling the C runtime
26775 * spawn() function.
26777 * The returned @child_pid on Windows is a handle to the child
26778 * process, not its identifier. Process handles and process
26779 * identifiers are different concepts on Windows.
26781 * @envp is a %NULL-terminated array of strings, where each string
26782 * has the form <literal>KEY=VALUE</literal>. This will become
26783 * the child's environment. If @envp is %NULL, the child inherits its
26784 * parent's environment.
26786 * @flags should be the bitwise OR of any flags you want to affect the
26787 * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
26788 * child will not automatically be reaped; you must use a child watch to
26789 * be notified about the death of the child process. Eventually you must
26790 * call g_spawn_close_pid() on the @child_pid, in order to free
26791 * resources which may be associated with the child process. (On Unix,
26792 * using a child watch is equivalent to calling waitpid() or handling
26793 * the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
26794 * is equivalent to calling CloseHandle() on the process handle returned
26795 * in @child_pid). See g_child_watch_add().
26797 * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
26798 * descriptors will be inherited by the child; otherwise all
26799 * descriptors except stdin/stdout/stderr will be closed before
26800 * calling exec() in the child. %G_SPAWN_SEARCH_PATH
26801 * means that <literal>argv[0]</literal> need not be an absolute path, it
26802 * will be looked for in the <envar>PATH</envar> environment variable.
26803 * %G_SPAWN_SEARCH_PATH_FROM_ENVP means need not be an absolute path, it
26804 * will be looked for in the <envar>PATH</envar> variable from @envp. If
26805 * both %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP are used,
26806 * the value from @envp takes precedence over the environment.
26807 * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
26808 * be discarded, instead of going to the same location as the parent's
26809 * standard output. If you use this flag, @standard_output must be %NULL.
26810 * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
26811 * will be discarded, instead of going to the same location as the parent's
26812 * standard error. If you use this flag, @standard_error must be %NULL.
26813 * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
26814 * standard input (by default, the child's standard input is attached to
26815 * /dev/null). If you use this flag, @standard_input must be %NULL.
26816 * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
26817 * the file to execute, while the remaining elements are the
26818 * actual argument vector to pass to the file. Normally
26819 * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
26820 * passes all of @argv to the child.
26822 * @child_setup and @user_data are a function and user data. On POSIX
26823 * platforms, the function is called in the child after GLib has
26824 * performed all the setup it plans to perform (including creating
26825 * pipes, closing file descriptors, etc.) but before calling
26826 * exec(). That is, @child_setup is called just
26827 * before calling exec() in the child. Obviously
26828 * actions taken in this function will only affect the child, not the
26831 * On Windows, there is no separate fork() and exec()
26832 * functionality. Child processes are created and run with a single
26833 * API call, CreateProcess(). There is no sensible thing @child_setup
26834 * could be used for on Windows so it is ignored and not called.
26836 * If non-%NULL, @child_pid will on Unix be filled with the child's
26837 * process ID. You can use the process ID to send signals to the
26838 * child, or to use g_child_watch_add() (or waitpid()) if you specified the
26839 * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
26840 * filled with a handle to the child process only if you specified the
26841 * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
26842 * process using the Win32 API, for example wait for its termination
26843 * with the <function>WaitFor*()</function> functions, or examine its
26844 * exit code with GetExitCodeProcess(). You should close the handle
26845 * with CloseHandle() or g_spawn_close_pid() when you no longer need it.
26847 * If non-%NULL, the @standard_input, @standard_output, @standard_error
26848 * locations will be filled with file descriptors for writing to the child's
26849 * standard input or reading from its standard output or standard error.
26850 * The caller of g_spawn_async_with_pipes() must close these file descriptors
26851 * when they are no longer in use. If these parameters are %NULL, the corresponding
26852 * pipe won't be created.
26854 * If @standard_input is NULL, the child's standard input is attached to
26855 * /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
26857 * If @standard_error is NULL, the child's standard error goes to the same
26858 * location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
26861 * If @standard_output is NULL, the child's standard output goes to the same
26862 * location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
26865 * @error can be %NULL to ignore errors, or non-%NULL to report errors.
26866 * If an error is set, the function returns %FALSE. Errors
26867 * are reported even if they occur in the child (for example if the
26868 * executable in <literal>argv[0]</literal> is not found). Typically
26869 * the <literal>message</literal> field of returned errors should be displayed
26870 * to users. Possible errors are those from the #G_SPAWN_ERROR domain.
26872 * If an error occurs, @child_pid, @standard_input, @standard_output,
26873 * and @standard_error will not be filled with valid values.
26875 * If @child_pid is not %NULL and an error does not occur then the returned
26876 * process reference must be closed using g_spawn_close_pid().
26879 * If you are writing a GTK+ application, and the program you
26880 * are spawning is a graphical application, too, then you may
26881 * want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
26882 * the spawned program opens its windows on the right screen.
26885 * Returns: %TRUE on success, %FALSE if an error was set
26890 * g_spawn_check_exit_status:
26891 * @exit_status: An exit code as returned from g_spawn_sync()
26892 * @error: a #GError
26894 * Set @error if @exit_status indicates the child exited abnormally
26895 * (e.g. with a nonzero exit code, or via a fatal signal).
26897 * The g_spawn_sync() and g_child_watch_add() family of APIs return an
26898 * exit status for subprocesses encoded in a platform-specific way.
26899 * On Unix, this is guaranteed to be in the same format
26900 * <literal>waitpid(2)</literal> returns, and on Windows it is
26901 * guaranteed to be the result of
26902 * <literal>GetExitCodeProcess()</literal>. Prior to the introduction
26903 * of this function in GLib 2.34, interpreting @exit_status required
26904 * use of platform-specific APIs, which is problematic for software
26905 * using GLib as a cross-platform layer.
26907 * Additionally, many programs simply want to determine whether or not
26908 * the child exited successfully, and either propagate a #GError or
26909 * print a message to standard error. In that common case, this
26910 * function can be used. Note that the error message in @error will
26911 * contain human-readable information about the exit status.
26913 * The <literal>domain</literal> and <literal>code</literal> of @error
26914 * have special semantics in the case where the process has an "exit
26915 * code", as opposed to being killed by a signal. On Unix, this
26916 * happens if <literal>WIFEXITED</literal> would be true of
26917 * @exit_status. On Windows, it is always the case.
26919 * The special semantics are that the actual exit code will be the
26920 * code set in @error, and the domain will be %G_SPAWN_EXIT_ERROR.
26921 * This allows you to differentiate between different exit codes.
26923 * If the process was terminated by some means other than an exit
26924 * status, the domain will be %G_SPAWN_ERROR, and the code will be
26925 * %G_SPAWN_ERROR_FAILED.
26927 * This function just offers convenience; you can of course also check
26928 * the available platform via a macro such as %G_OS_UNIX, and use
26929 * <literal>WIFEXITED()</literal> and <literal>WEXITSTATUS()</literal>
26930 * on @exit_status directly. Do not attempt to scan or parse the
26931 * error message string; it may be translated and/or change in future
26932 * versions of GLib.
26934 * Returns: %TRUE if child exited successfully, %FALSE otherwise (and @error will be set)
26940 * g_spawn_close_pid:
26941 * @pid: The process reference to close
26943 * On some platforms, notably Windows, the #GPid type represents a resource
26944 * which must be closed to prevent resource leaking. g_spawn_close_pid()
26945 * is provided for this purpose. It should be used on all platforms, even
26946 * though it doesn't do anything under UNIX.
26951 * g_spawn_command_line_async:
26952 * @command_line: a command line
26953 * @error: return location for errors
26955 * A simple version of g_spawn_async() that parses a command line with
26956 * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
26957 * command line in the background. Unlike g_spawn_async(), the
26958 * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
26959 * that %G_SPAWN_SEARCH_PATH can have security implications, so
26960 * consider using g_spawn_async() directly if appropriate. Possible
26961 * errors are those from g_shell_parse_argv() and g_spawn_async().
26963 * The same concerns on Windows apply as for g_spawn_command_line_sync().
26965 * Returns: %TRUE on success, %FALSE if error is set.
26970 * g_spawn_command_line_sync:
26971 * @command_line: a command line
26972 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output
26973 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child errors
26974 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid()
26975 * @error: return location for errors
26977 * A simple version of g_spawn_sync() with little-used parameters
26978 * removed, taking a command line instead of an argument vector. See
26979 * g_spawn_sync() for full details. @command_line will be parsed by
26980 * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
26981 * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
26982 * implications, so consider using g_spawn_sync() directly if
26983 * appropriate. Possible errors are those from g_spawn_sync() and those
26984 * from g_shell_parse_argv().
26986 * If @exit_status is non-%NULL, the platform-specific exit status of
26987 * the child is stored there; see the documentation of
26988 * g_spawn_check_exit_status() for how to use and interpret this.
26990 * On Windows, please note the implications of g_shell_parse_argv()
26991 * parsing @command_line. Parsing is done according to Unix shell rules, not
26992 * Windows command interpreter rules.
26993 * Space is a separator, and backslashes are
26994 * special. Thus you cannot simply pass a @command_line containing
26995 * canonical Windows paths, like "c:\\program files\\app\\app.exe", as
26996 * the backslashes will be eaten, and the space will act as a
26997 * separator. You need to enclose such paths with single quotes, like
26998 * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
27000 * Returns: %TRUE on success, %FALSE if an error was set
27006 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
27007 * @argv: (array zero-terminated=1): child's argument vector
27008 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
27009 * @flags: flags from #GSpawnFlags
27010 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
27011 * @user_data: (closure): user data for @child_setup
27012 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output, or %NULL
27013 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child error messages, or %NULL
27014 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid(), or %NULL
27015 * @error: return location for error, or %NULL
27017 * Executes a child synchronously (waits for the child to exit before returning).
27018 * All output from the child is stored in @standard_output and @standard_error,
27019 * if those parameters are non-%NULL. Note that you must set the
27020 * %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
27021 * passing %NULL for @standard_output and @standard_error.
27023 * If @exit_status is non-%NULL, the platform-specific exit status of
27024 * the child is stored there; see the documentation of
27025 * g_spawn_check_exit_status() for how to use and interpret this.
27026 * Note that it is invalid to pass %G_SPAWN_DO_NOT_REAP_CHILD in
27029 * If an error occurs, no data is returned in @standard_output,
27030 * @standard_error, or @exit_status.
27032 * This function calls g_spawn_async_with_pipes() internally; see that
27033 * function for full details on the other parameters and details on
27034 * how these functions work on Windows.
27036 * Returns: %TRUE on success, %FALSE if an error was set.
27042 * @string: A pointer to a memory buffer to contain the resulting string. It
27043 * is up to the caller to ensure that the allocated buffer is large
27044 * enough to hold the formatted result
27045 * @format: a standard printf() format string, but notice
27046 * <link linkend="string-precision">string precision pitfalls</link>.
27047 * @...: the arguments to insert in the output.
27049 * An implementation of the standard sprintf() function which supports
27050 * positional parameters, as specified in the Single Unix Specification.
27052 * Note that it is usually better to use g_snprintf(), to avoid the
27053 * risk of buffer overflow.
27055 * See also g_strdup_printf().
27057 * Returns: the number of bytes printed.
27064 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
27065 * @buf: a pointer to a <structname>stat</structname> struct, which
27066 * will be filled with the file information
27068 * A wrapper for the POSIX stat() function. The stat() function
27069 * returns information about a file. On Windows the stat() function in
27070 * the C library checks only the FAT-style READONLY attribute and does
27071 * not look at the ACL at all. Thus on Windows the protection bits in
27072 * the st_mode field are a fabrication of little use.
27074 * On Windows the Microsoft C libraries have several variants of the
27075 * <structname>stat</structname> struct and stat() function with names
27076 * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
27077 * used here is for 32-bit code the one with 32-bit size and time
27078 * fields, specifically called "_stat32".
27080 * In Microsoft's compiler, by default "struct stat" means one with
27081 * 64-bit time fields while in MinGW "struct stat" is the legacy one
27082 * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
27083 * header defines a type GStatBuf which is the appropriate struct type
27084 * depending on the platform and/or compiler being used. On POSIX it
27085 * is just "struct stat", but note that even on POSIX platforms,
27086 * "stat" might be a macro.
27088 * See your C library manual for more details about stat().
27090 * Returns: 0 if the information was successfully retrieved, -1 if an error
27098 * @dest: destination buffer.
27099 * @src: source string.
27101 * Copies a nul-terminated string into the dest buffer, include the
27102 * trailing nul, and return a pointer to the trailing nul byte.
27103 * This is useful for concatenating multiple strings together
27104 * without having to repeatedly scan for the end.
27106 * Returns: a pointer to trailing nul byte.
27113 * @v2: a key to compare with @v1
27115 * Compares two strings for byte-by-byte equality and returns %TRUE
27116 * if they are equal. It can be passed to g_hash_table_new() as the
27117 * @key_equal_func parameter, when using non-%NULL strings as keys in a
27120 * Note that this function is primarily meant as a hash table comparison
27121 * function. For a general-purpose, %NULL-safe string comparison function,
27124 * Returns: %TRUE if the two keys match
27129 * g_str_has_prefix:
27130 * @str: a nul-terminated string
27131 * @prefix: the nul-terminated prefix to look for
27133 * Looks whether the string @str begins with @prefix.
27135 * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
27141 * g_str_has_suffix:
27142 * @str: a nul-terminated string
27143 * @suffix: the nul-terminated suffix to look for
27145 * Looks whether the string @str ends with @suffix.
27147 * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
27156 * Converts a string to a hash value.
27158 * This function implements the widely used "djb" hash apparently posted
27159 * by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
27160 * unsigned hash value starts at 5381 and for each byte 'c' in the
27161 * string, is updated: <literal>hash = hash * 33 + c</literal>. This
27162 * function uses the signed value of each byte.
27164 * It can be passed to g_hash_table_new() as the @hash_func parameter,
27165 * when using non-%NULL strings as keys in a #GHashTable.
27167 * Returns: a hash value corresponding to the key
27173 * @string: a string.
27175 * Determines if a string is pure ASCII. A string is pure ASCII if it
27176 * contains no bytes with the high bit set.
27178 * Returns: %TRUE if @string is ascii
27184 * g_str_match_string:
27185 * @search_term: the search term from the user
27186 * @potential_hit: the text that may be a hit
27187 * @accept_alternates: %TRUE to accept ASCII alternates
27189 * Checks if a search conducted for @search_term should match
27192 * This function calls g_str_tokenize_and_fold() on both
27193 * @search_term and @potential_hit. ASCII alternates are never taken
27194 * for @search_term but will be taken for @potential_hit according to
27195 * the value of @accept_alternates.
27197 * A hit occurs when each folded token in @search_term is a prefix of a
27198 * folded token from @potential_hit.
27200 * Depending on how you're performing the search, it will typically be
27201 * faster to call g_str_tokenize_and_fold() on each string in
27202 * your corpus and build an index on the returned folded tokens, then
27203 * call g_str_tokenize_and_fold() on the search term and
27204 * perform lookups into that index.
27206 * As some examples, searching for "fred" would match the potential hit
27207 * "Smith, Fred" and also "Frédéric". Searching for "Fréd" would match
27208 * "Frédéric" but not "Frederic" (due to the one-directional nature of
27209 * accent matching). Searching "fo" would match "Foo" and "Bar Foo
27210 * Baz", but not "SFO" (because no word as "fo" as a prefix).
27212 * Returns: %TRUE if @potential_hit is a hit
27218 * g_str_tokenize_and_fold:
27219 * @string: a string
27220 * @translit_locale: (allow-none): the language code (like 'de' or
27221 * 'en_GB') from which @string originates
27222 * @ascii_alternates: (out) (transfer full) (array zero-terminated=1): a
27223 * return location for ASCII alternates
27225 * Tokenises @string and performs folding on each token.
27227 * A token is a non-empty sequence of alphanumeric characters in the
27228 * source string, separated by non-alphanumeric characters. An
27229 * "alphanumeric" character for this purpose is one that matches
27230 * g_unichar_isalnum() or g_unichar_ismark().
27232 * Each token is then (Unicode) normalised and case-folded. If
27233 * @ascii_alternates is non-%NULL and some of the returned tokens
27234 * contain non-ASCII characters, ASCII alternatives will be generated.
27236 * The number of ASCII alternatives that are generated and the method
27237 * for doing so is unspecified, but @translit_locale (if specified) may
27238 * improve the transliteration if the language of the source string is
27241 * Returns: the folded tokens
27248 * @string: a nul-terminated array of bytes
27249 * @valid_chars: bytes permitted in @string
27250 * @substitutor: replacement character for disallowed bytes
27252 * For each character in @string, if the character is not in
27253 * @valid_chars, replaces the character with @substitutor.
27254 * Modifies @string in place, and return @string itself, not
27255 * a copy. The return value is to allow nesting such as
27257 * g_ascii_strup (g_strcanon (str, "abc", '?'))
27267 * @s2: a string to compare with @s1.
27269 * A case-insensitive string comparison, corresponding to the standard
27270 * strcasecmp() function on platforms which support it.
27272 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
27273 * or a positive value if @s1 > @s2.
27274 * Deprecated: 2.2: See g_strncasecmp() for a discussion of why this function
27275 * is deprecated and how to replace it.
27281 * @string: a string to remove the trailing whitespace from
27283 * Removes trailing whitespace from a string.
27285 * This function doesn't allocate or reallocate any memory;
27286 * it modifies @string in place. The pointer to @string is
27287 * returned to allow the nesting of functions.
27289 * Also see g_strchug() and g_strstrip().
27291 * Returns: @string.
27297 * @string: a string to remove the leading whitespace from
27299 * Removes leading whitespace from a string, by moving the rest
27300 * of the characters forward.
27302 * This function doesn't allocate or reallocate any memory;
27303 * it modifies @string in place. The pointer to @string is
27304 * returned to allow the nesting of functions.
27306 * Also see g_strchomp() and g_strstrip().
27314 * @str1: (allow-none): a C string or %NULL
27315 * @str2: (allow-none): another C string or %NULL
27317 * Compares @str1 and @str2 like strcmp(). Handles %NULL
27318 * gracefully by sorting it before non-%NULL strings.
27319 * Comparing two %NULL pointers returns 0.
27321 * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
27328 * @source: a string to compress
27330 * Replaces all escaped characters with their one byte equivalent.
27332 * This function does the reverse conversion of g_strescape().
27334 * Returns: a newly-allocated copy of @source with all escaped
27335 * character compressed
27341 * @string1: the first string to add, which must not be %NULL
27342 * @...: a %NULL-terminated list of strings to append to the string
27344 * Concatenates all of the given strings into one long string.
27345 * The returned string should be freed with g_free() when no longer needed.
27347 * Note that this function is usually not the right function to use to
27348 * assemble a translated message from pieces, since proper translation
27349 * often requires the pieces to be reordered.
27351 * <warning><para>The variable argument list <emphasis>must</emphasis> end
27352 * with %NULL. If you forget the %NULL, g_strconcat() will start appending
27353 * random memory junk to your string.</para></warning>
27355 * Returns: a newly-allocated string containing all the string arguments
27361 * @string: the string to convert
27362 * @delimiters: (allow-none): a string containing the current delimiters, or %NULL
27363 * to use the standard delimiters defined in #G_STR_DELIMITERS
27364 * @new_delimiter: the new delimiter character
27366 * Converts any delimiter characters in @string to @new_delimiter.
27367 * Any characters in @string which are found in @delimiters are
27368 * changed to the @new_delimiter character. Modifies @string in place,
27369 * and returns @string itself, not a copy. The return value is to
27370 * allow nesting such as
27372 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
27381 * @string: the string to convert.
27383 * Converts a string to lower case.
27385 * Returns: the string
27386 * Deprecated: 2.2: This function is totally broken for the reasons discussed
27387 * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
27394 * @str: the string to duplicate
27396 * Duplicates a string. If @str is %NULL it returns %NULL.
27397 * The returned string should be freed with g_free()
27398 * when no longer needed.
27400 * Returns: a newly-allocated copy of @str
27406 * @format: a standard printf() format string, but notice
27407 * <link linkend="string-precision">string precision pitfalls</link>
27408 * @...: the parameters to insert into the format string
27410 * Similar to the standard C sprintf() function but safer, since it
27411 * calculates the maximum space required and allocates memory to hold
27412 * the result. The returned string should be freed with g_free() when no
27415 * Returns: a newly-allocated string holding the result
27420 * g_strdup_vprintf:
27421 * @format: a standard printf() format string, but notice
27422 * <link linkend="string-precision">string precision pitfalls</link>
27423 * @args: the list of parameters to insert into the format string
27425 * Similar to the standard C vsprintf() function but safer, since it
27426 * calculates the maximum space required and allocates memory to hold
27427 * the result. The returned string should be freed with g_free() when
27428 * no longer needed.
27430 * See also g_vasprintf(), which offers the same functionality, but
27431 * additionally returns the length of the allocated string.
27433 * Returns: a newly-allocated string holding the result
27439 * @str_array: a %NULL-terminated array of strings
27441 * Copies %NULL-terminated array of strings. The copy is a deep copy;
27442 * the new array should be freed by first freeing each string, then
27443 * the array itself. g_strfreev() does this for you. If called
27444 * on a %NULL value, g_strdupv() simply returns %NULL.
27446 * Returns: a new %NULL-terminated array of strings.
27452 * @errnum: the system error number. See the standard C %errno
27455 * Returns a string corresponding to the given error code, e.g.
27456 * "no such process". You should use this function in preference to
27457 * strerror(), because it returns a string in UTF-8 encoding, and since
27458 * not all platforms support the strerror() function.
27460 * Returns: a UTF-8 string describing the error code. If the error code
27461 * is unknown, it returns "unknown error (<code>)".
27467 * @source: a string to escape
27468 * @exceptions: a string of characters not to escape in @source
27470 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
27471 * and '"' in the string @source by inserting a '\' before
27472 * them. Additionally all characters in the range 0x01-0x1F (everything
27473 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
27474 * replaced with a '\' followed by their octal representation.
27475 * Characters supplied in @exceptions are not escaped.
27477 * g_strcompress() does the reverse conversion.
27479 * Returns: a newly-allocated copy of @source with certain
27480 * characters escaped. See above.
27486 * @str_array: a %NULL-terminated array of strings to free
27488 * Frees a %NULL-terminated array of strings, and the array itself.
27489 * If called on a %NULL value, g_strfreev() simply returns.
27495 * @string: a #GString
27496 * @val: the string to append onto the end of @string
27498 * Adds a string onto the end of a #GString, expanding
27506 * g_string_append_c:
27507 * @string: a #GString
27508 * @c: the byte to append onto the end of @string
27510 * Adds a byte onto the end of a #GString, expanding
27518 * g_string_append_len:
27519 * @string: a #GString
27520 * @val: bytes to append
27521 * @len: number of bytes of @val to use
27523 * Appends @len bytes of @val to @string. Because @len is
27524 * provided, @val may contain embedded nuls and need not
27525 * be nul-terminated.
27527 * Since this function does not stop at nul bytes, it is
27528 * the caller's responsibility to ensure that @val has at
27529 * least @len addressable bytes.
27536 * g_string_append_printf:
27537 * @string: a #GString
27538 * @format: the string format. See the printf() documentation
27539 * @...: the parameters to insert into the format string
27541 * Appends a formatted string onto the end of a #GString.
27542 * This function is similar to g_string_printf() except
27543 * that the text is appended to the #GString.
27548 * g_string_append_unichar:
27549 * @string: a #GString
27550 * @wc: a Unicode character
27552 * Converts a Unicode character into UTF-8, and appends it
27560 * g_string_append_uri_escaped:
27561 * @string: a #GString
27562 * @unescaped: a string
27563 * @reserved_chars_allowed: a string of reserved characters allowed
27564 * to be used, or %NULL
27565 * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
27567 * Appends @unescaped to @string, escaped any characters that
27568 * are reserved in URIs using URI-style escape sequences.
27576 * g_string_append_vprintf:
27577 * @string: a #GString
27578 * @format: the string format. See the printf() documentation
27579 * @args: the list of arguments to insert in the output
27581 * Appends a formatted string onto the end of a #GString.
27582 * This function is similar to g_string_append_printf()
27583 * except that the arguments to the format string are passed
27591 * g_string_ascii_down:
27592 * @string: a GString
27594 * Converts all uppercase ASCII letters to lowercase ASCII letters.
27596 * Returns: passed-in @string pointer, with all the
27597 * uppercase characters converted to lowercase in place,
27598 * with semantics that exactly match g_ascii_tolower().
27603 * g_string_ascii_up:
27604 * @string: a GString
27606 * Converts all lowercase ASCII letters to uppercase ASCII letters.
27608 * Returns: passed-in @string pointer, with all the
27609 * lowercase characters converted to uppercase in place,
27610 * with semantics that exactly match g_ascii_toupper().
27616 * @string: the destination #GString. Its current contents
27618 * @rval: the string to copy into @string
27620 * Copies the bytes from a string into a #GString,
27621 * destroying any previous contents. It is rather like
27622 * the standard strcpy() function, except that you do not
27623 * have to worry about having enough space to copy the string.
27630 * g_string_chunk_clear:
27631 * @chunk: a #GStringChunk
27633 * Frees all strings contained within the #GStringChunk.
27634 * After calling g_string_chunk_clear() it is not safe to
27635 * access any of the strings which were contained within it.
27642 * g_string_chunk_free:
27643 * @chunk: a #GStringChunk
27645 * Frees all memory allocated by the #GStringChunk.
27646 * After calling g_string_chunk_free() it is not safe to
27647 * access any of the strings which were contained within it.
27652 * g_string_chunk_insert:
27653 * @chunk: a #GStringChunk
27654 * @string: the string to add
27656 * Adds a copy of @string to the #GStringChunk.
27657 * It returns a pointer to the new copy of the string
27658 * in the #GStringChunk. The characters in the string
27659 * can be changed, if necessary, though you should not
27660 * change anything after the end of the string.
27662 * Unlike g_string_chunk_insert_const(), this function
27663 * does not check for duplicates. Also strings added
27664 * with g_string_chunk_insert() will not be searched
27665 * by g_string_chunk_insert_const() when looking for
27668 * Returns: a pointer to the copy of @string within
27669 * the #GStringChunk
27674 * g_string_chunk_insert_const:
27675 * @chunk: a #GStringChunk
27676 * @string: the string to add
27678 * Adds a copy of @string to the #GStringChunk, unless the same
27679 * string has already been added to the #GStringChunk with
27680 * g_string_chunk_insert_const().
27682 * This function is useful if you need to copy a large number
27683 * of strings but do not want to waste space storing duplicates.
27684 * But you must remember that there may be several pointers to
27685 * the same string, and so any changes made to the strings
27686 * should be done very carefully.
27688 * Note that g_string_chunk_insert_const() will not return a
27689 * pointer to a string added with g_string_chunk_insert(), even
27690 * if they do match.
27692 * Returns: a pointer to the new or existing copy of @string
27693 * within the #GStringChunk
27698 * g_string_chunk_insert_len:
27699 * @chunk: a #GStringChunk
27700 * @string: bytes to insert
27701 * @len: number of bytes of @string to insert, or -1 to insert a
27702 * nul-terminated string
27704 * Adds a copy of the first @len bytes of @string to the #GStringChunk.
27705 * The copy is nul-terminated.
27707 * Since this function does not stop at nul bytes, it is the caller's
27708 * responsibility to ensure that @string has at least @len addressable
27711 * The characters in the returned string can be changed, if necessary,
27712 * though you should not change anything after the end of the string.
27714 * Returns: a pointer to the copy of @string within the #GStringChunk
27720 * g_string_chunk_new:
27721 * @size: the default size of the blocks of memory which are
27722 * allocated to store the strings. If a particular string
27723 * is larger than this default size, a larger block of
27724 * memory will be allocated for it.
27726 * Creates a new #GStringChunk.
27728 * Returns: a new #GStringChunk
27734 * @string: a #GString
27736 * Converts a #GString to lowercase.
27738 * Returns: the #GString
27739 * Deprecated: 2.2: This function uses the locale-specific
27740 * tolower() function, which is almost never the right thing.
27741 * Use g_string_ascii_down() or g_utf8_strdown() instead.
27748 * @v2: another #GString
27750 * Compares two strings for equality, returning %TRUE if they are equal.
27751 * For use with #GHashTable.
27753 * Returns: %TRUE if the strings are the same length and contain the
27760 * @string: a #GString
27761 * @pos: the position of the content to remove
27762 * @len: the number of bytes to remove, or -1 to remove all
27765 * Removes @len bytes from a #GString, starting at position @pos.
27766 * The rest of the #GString is shifted down to fill the gap.
27774 * @string: a #GString
27775 * @free_segment: if %TRUE, the actual character data is freed as well
27777 * Frees the memory allocated for the #GString.
27778 * If @free_segment is %TRUE it also frees the character data. If
27779 * it's %FALSE, the caller gains ownership of the buffer and must
27780 * free it after use with g_free().
27782 * Returns: the character data of @string
27783 * (i.e. %NULL if @free_segment is %TRUE)
27788 * g_string_free_to_bytes:
27789 * @string: (transfer full): a #GString
27791 * Transfers ownership of the contents of @string to a newly allocated
27792 * #GBytes. The #GString structure itself is deallocated, and it is
27793 * therefore invalid to use @string after invoking this function.
27795 * Note that while #GString ensures that its buffer always has a
27796 * trailing nul character (not reflected in its "len"), the returned
27797 * #GBytes does not include this extra nul; i.e. it has length exactly
27798 * equal to the "len" member.
27800 * Returns: A newly allocated #GBytes containing contents of @string; @string itself is freed
27807 * @str: a string to hash
27809 * Creates a hash code for @str; for use with #GHashTable.
27811 * Returns: hash code for @str
27817 * @string: a #GString
27818 * @pos: the position to insert the copy of the string
27819 * @val: the string to insert
27821 * Inserts a copy of a string into a #GString,
27822 * expanding it if necessary.
27829 * g_string_insert_c:
27830 * @string: a #GString
27831 * @pos: the position to insert the byte
27832 * @c: the byte to insert
27834 * Inserts a byte into a #GString, expanding it if necessary.
27841 * g_string_insert_len:
27842 * @string: a #GString
27843 * @pos: position in @string where insertion should
27844 * happen, or -1 for at the end
27845 * @val: bytes to insert
27846 * @len: number of bytes of @val to insert
27848 * Inserts @len bytes of @val into @string at @pos.
27849 * Because @len is provided, @val may contain embedded
27850 * nuls and need not be nul-terminated. If @pos is -1,
27851 * bytes are inserted at the end of the string.
27853 * Since this function does not stop at nul bytes, it is
27854 * the caller's responsibility to ensure that @val has at
27855 * least @len addressable bytes.
27862 * g_string_insert_unichar:
27863 * @string: a #GString
27864 * @pos: the position at which to insert character, or -1
27865 * to append at the end of the string
27866 * @wc: a Unicode character
27868 * Converts a Unicode character into UTF-8, and insert it
27869 * into the string at the given position.
27877 * @init: the initial text to copy into the string
27879 * Creates a new #GString, initialized with the given string.
27881 * Returns: the new #GString
27886 * g_string_new_len:
27887 * @init: initial contents of the string
27888 * @len: length of @init to use
27890 * Creates a new #GString with @len bytes of the @init buffer.
27891 * Because a length is provided, @init need not be nul-terminated,
27892 * and can contain embedded nul bytes.
27894 * Since this function does not stop at nul bytes, it is the caller's
27895 * responsibility to ensure that @init has at least @len addressable
27898 * Returns: a new #GString
27903 * g_string_overwrite:
27904 * @string: a #GString
27905 * @pos: the position at which to start overwriting
27906 * @val: the string that will overwrite the @string starting at @pos
27908 * Overwrites part of a string, lengthening it if necessary.
27916 * g_string_overwrite_len:
27917 * @string: a #GString
27918 * @pos: the position at which to start overwriting
27919 * @val: the string that will overwrite the @string starting at @pos
27920 * @len: the number of bytes to write from @val
27922 * Overwrites part of a string, lengthening it if necessary.
27923 * This function will work with embedded nuls.
27931 * g_string_prepend:
27932 * @string: a #GString
27933 * @val: the string to prepend on the start of @string
27935 * Adds a string on to the start of a #GString,
27936 * expanding it if necessary.
27943 * g_string_prepend_c:
27944 * @string: a #GString
27945 * @c: the byte to prepend on the start of the #GString
27947 * Adds a byte onto the start of a #GString,
27948 * expanding it if necessary.
27955 * g_string_prepend_len:
27956 * @string: a #GString
27957 * @val: bytes to prepend
27958 * @len: number of bytes in @val to prepend
27960 * Prepends @len bytes of @val to @string.
27961 * Because @len is provided, @val may contain
27962 * embedded nuls and need not be nul-terminated.
27964 * Since this function does not stop at nul bytes,
27965 * it is the caller's responsibility to ensure that
27966 * @val has at least @len addressable bytes.
27973 * g_string_prepend_unichar:
27974 * @string: a #GString
27975 * @wc: a Unicode character
27977 * Converts a Unicode character into UTF-8, and prepends it
27986 * @string: a #GString
27987 * @format: the string format. See the printf() documentation
27988 * @...: the parameters to insert into the format string
27990 * Writes a formatted string into a #GString.
27991 * This is similar to the standard sprintf() function,
27992 * except that the #GString buffer automatically expands
27993 * to contain the results. The previous contents of the
27994 * #GString are destroyed.
27999 * g_string_set_size:
28000 * @string: a #GString
28001 * @len: the new length
28003 * Sets the length of a #GString. If the length is less than
28004 * the current length, the string will be truncated. If the
28005 * length is greater than the current length, the contents
28006 * of the newly added area are undefined. (However, as
28007 * always, string->str[string->len] will be a nul byte.)
28014 * g_string_sized_new:
28015 * @dfl_size: the default size of the space allocated to
28018 * Creates a new #GString, with enough space for @dfl_size
28019 * bytes. This is useful if you are going to add a lot of
28020 * text to the string and don't want it to be reallocated
28023 * Returns: the new #GString
28028 * g_string_sprintf:
28029 * @string: a #GString
28030 * @format: the string format. See the sprintf() documentation
28031 * @...: the parameters to insert into the format string
28033 * Writes a formatted string into a #GString.
28034 * This is similar to the standard sprintf() function,
28035 * except that the #GString buffer automatically expands
28036 * to contain the results. The previous contents of the
28037 * #GString are destroyed.
28039 * Deprecated: This function has been renamed to g_string_printf().
28044 * g_string_sprintfa:
28045 * @string: a #GString
28046 * @format: the string format. See the sprintf() documentation
28047 * @...: the parameters to insert into the format string
28049 * Appends a formatted string onto the end of a #GString.
28050 * This function is similar to g_string_sprintf() except that
28051 * the text is appended to the #GString.
28053 * Deprecated: This function has been renamed to g_string_append_printf()
28058 * g_string_truncate:
28059 * @string: a #GString
28060 * @len: the new size of @string
28062 * Cuts off the end of the GString, leaving the first @len bytes.
28070 * @string: a #GString
28072 * Converts a #GString to uppercase.
28075 * Deprecated: 2.2: This function uses the locale-specific
28076 * toupper() function, which is almost never the right thing.
28077 * Use g_string_ascii_up() or g_utf8_strup() instead.
28082 * g_string_vprintf:
28083 * @string: a #GString
28084 * @format: the string format. See the printf() documentation
28085 * @args: the parameters to insert into the format string
28087 * Writes a formatted string into a #GString.
28088 * This function is similar to g_string_printf() except that
28089 * the arguments to the format string are passed as a va_list.
28098 * @msgval: another string
28100 * An auxiliary function for gettext() support (see Q_()).
28102 * Returns: @msgval, unless @msgval is identical to @msgid
28103 * and contains a '|' character, in which case a pointer to
28104 * the substring of msgid after the first '|' character is returned.
28111 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
28112 * @...: a %NULL-terminated list of strings to join
28114 * Joins a number of strings together to form one long string, with the
28115 * optional @separator inserted between each of them. The returned string
28116 * should be freed with g_free().
28118 * Returns: a newly-allocated string containing all of the strings joined
28119 * together, with @separator between them
28125 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
28126 * @str_array: a %NULL-terminated array of strings to join
28128 * Joins a number of strings together to form one long string, with the
28129 * optional @separator inserted between each of them. The returned string
28130 * should be freed with g_free().
28132 * Returns: a newly-allocated string containing all of the strings joined
28133 * together, with @separator between them
28139 * @dest: destination buffer, already containing one nul-terminated string
28140 * @src: source buffer
28141 * @dest_size: length of @dest buffer in bytes (not length of existing string
28144 * Portability wrapper that calls strlcat() on systems which have it,
28145 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
28146 * guaranteeing nul-termination for @dest. The total size of @dest won't
28147 * exceed @dest_size.
28149 * At most dest_size - 1 characters will be copied.
28150 * Unlike strncat, dest_size is the full size of dest, not the space left over.
28151 * This function does NOT allocate memory.
28152 * This always NUL terminates (unless siz == 0 or there were no NUL characters
28153 * in the dest_size characters of dest to start with).
28155 * <note><para>Caveat: this is supposedly a more secure alternative to
28156 * strcat() or strncat(), but for real security g_strconcat() is harder
28157 * to mess up.</para></note>
28159 * Returns: size of attempted result, which is MIN (dest_size, strlen
28160 * (original dest)) + strlen (src), so if retval >= dest_size,
28161 * truncation occurred.
28167 * @dest: destination buffer
28168 * @src: source buffer
28169 * @dest_size: length of @dest in bytes
28171 * Portability wrapper that calls strlcpy() on systems which have it,
28172 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
28173 * guaranteed to be nul-terminated; @src must be nul-terminated;
28174 * @dest_size is the buffer size, not the number of chars to copy.
28176 * At most dest_size - 1 characters will be copied. Always nul-terminates
28177 * (unless dest_size == 0). This function does <emphasis>not</emphasis>
28178 * allocate memory. Unlike strncpy(), this function doesn't pad dest (so
28179 * it's often faster). It returns the size of the attempted result,
28180 * strlen (src), so if @retval >= @dest_size, truncation occurred.
28182 * <note><para>Caveat: strlcpy() is supposedly more secure than
28183 * strcpy() or strncpy(), but if you really want to avoid screwups,
28184 * g_strdup() is an even better idea.</para></note>
28186 * Returns: length of @src
28193 * @s2: a string to compare with @s1.
28194 * @n: the maximum number of characters to compare.
28196 * A case-insensitive string comparison, corresponding to the standard
28197 * strncasecmp() function on platforms which support it.
28198 * It is similar to g_strcasecmp() except it only compares the first @n
28199 * characters of the strings.
28201 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
28202 * or a positive value if @s1 > @s2.
28203 * Deprecated: 2.2: The problem with g_strncasecmp() is that it does the
28204 * comparison by calling toupper()/tolower(). These functions are
28205 * locale-specific and operate on single bytes. However, it is impossible
28206 * to handle things correctly from an I18N standpoint by operating on
28207 * bytes, since characters may be multibyte. Thus g_strncasecmp() is
28208 * broken if your string is guaranteed to be ASCII, since it's
28209 * locale-sensitive, and it's broken if your string is localized, since
28210 * it doesn't work on many encodings at all, including UTF-8, EUC-JP,
28213 * There are therefore two replacement techniques: g_ascii_strncasecmp(),
28214 * which only works on ASCII and is not locale-sensitive, and
28215 * g_utf8_casefold() followed by strcmp() on the resulting strings, which is
28216 * good for case-insensitive sorting of UTF-8.
28222 * @str: the string to duplicate
28223 * @n: the maximum number of bytes to copy from @str
28225 * Duplicates the first @n bytes of a string, returning a newly-allocated
28226 * buffer @n + 1 bytes long which will always be nul-terminated.
28227 * If @str is less than @n bytes long the buffer is padded with nuls.
28228 * If @str is %NULL it returns %NULL.
28229 * The returned value should be freed when no longer needed.
28232 * To copy a number of characters from a UTF-8 encoded string, use
28233 * g_utf8_strncpy() instead.
28236 * Returns: a newly-allocated buffer containing the first @n bytes
28237 * of @str, nul-terminated
28243 * @length: the length of the new string
28244 * @fill_char: the byte to fill the string with
28246 * Creates a new string @length bytes long filled with @fill_char.
28247 * The returned string should be freed when no longer needed.
28249 * Returns: a newly-allocated string filled the @fill_char
28255 * @string: the string to reverse
28257 * Reverses all of the bytes in a string. For example,
28258 * <literal>g_strreverse ("abcdef")</literal> will result
28261 * Note that g_strreverse() doesn't work on UTF-8 strings
28262 * containing multibyte characters. For that purpose, use
28263 * g_utf8_strreverse().
28265 * Returns: the same pointer passed in as @string
28271 * @haystack: a nul-terminated string
28272 * @needle: the nul-terminated string to search for
28274 * Searches the string @haystack for the last occurrence
28275 * of the string @needle.
28277 * Returns: a pointer to the found occurrence, or
28278 * %NULL if not found.
28284 * @haystack: a nul-terminated string
28285 * @haystack_len: the maximum length of @haystack
28286 * @needle: the nul-terminated string to search for
28288 * Searches the string @haystack for the last occurrence
28289 * of the string @needle, limiting the length of the search
28290 * to @haystack_len.
28292 * Returns: a pointer to the found occurrence, or
28293 * %NULL if not found.
28299 * @signum: the signal number. See the <literal>signal</literal>
28302 * Returns a string describing the given signal, e.g. "Segmentation fault".
28303 * You should use this function in preference to strsignal(), because it
28304 * returns a string in UTF-8 encoding, and since not all platforms support
28305 * the strsignal() function.
28307 * Returns: a UTF-8 string describing the signal. If the signal is unknown,
28308 * it returns "unknown signal (<signum>)".
28314 * @string: a string to split
28315 * @delimiter: a string which specifies the places at which to split
28316 * the string. The delimiter is not included in any of the resulting
28317 * strings, unless @max_tokens is reached.
28318 * @max_tokens: the maximum number of pieces to split @string into.
28319 * If this is less than 1, the string is split completely.
28321 * Splits a string into a maximum of @max_tokens pieces, using the given
28322 * @delimiter. If @max_tokens is reached, the remainder of @string is
28323 * appended to the last token.
28325 * As a special case, the result of splitting the empty string "" is an empty
28326 * vector, not a vector containing a single string. The reason for this
28327 * special case is that being able to represent a empty vector is typically
28328 * more useful than consistent handling of empty elements. If you do need
28329 * to represent empty elements, you'll need to check for the empty string
28330 * before calling g_strsplit().
28332 * Returns: a newly-allocated %NULL-terminated array of strings. Use
28333 * g_strfreev() to free it.
28339 * @string: The string to be tokenized
28340 * @delimiters: A nul-terminated string containing bytes that are used
28341 * to split the string.
28342 * @max_tokens: The maximum number of tokens to split @string into.
28343 * If this is less than 1, the string is split completely
28345 * Splits @string into a number of tokens not containing any of the characters
28346 * in @delimiter. A token is the (possibly empty) longest string that does not
28347 * contain any of the characters in @delimiters. If @max_tokens is reached, the
28348 * remainder is appended to the last token.
28350 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
28351 * %NULL-terminated vector containing the three strings "abc", "def",
28354 * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
28355 * vector containing the four strings "", "def", "ghi", and "".
28357 * As a special case, the result of splitting the empty string "" is an empty
28358 * vector, not a vector containing a single string. The reason for this
28359 * special case is that being able to represent a empty vector is typically
28360 * more useful than consistent handling of empty elements. If you do need
28361 * to represent empty elements, you'll need to check for the empty string
28362 * before calling g_strsplit_set().
28364 * Note that this function works on bytes not characters, so it can't be used
28365 * to delimit UTF-8 strings for anything but ASCII characters.
28367 * Returns: a newly-allocated %NULL-terminated array of strings. Use
28368 * g_strfreev() to free it.
28375 * @haystack: a string
28376 * @haystack_len: the maximum length of @haystack. Note that -1 is
28377 * a valid length, if @haystack is nul-terminated, meaning it will
28378 * search through the whole string.
28379 * @needle: the string to search for
28381 * Searches the string @haystack for the first occurrence
28382 * of the string @needle, limiting the length of the search
28383 * to @haystack_len.
28385 * Returns: a pointer to the found occurrence, or
28386 * %NULL if not found.
28392 * @string: a string to remove the leading and trailing whitespace from
28394 * Removes leading and trailing whitespace from a string.
28395 * See g_strchomp() and g_strchug().
28403 * @nptr: the string to convert to a numeric value.
28404 * @endptr: if non-%NULL, it returns the character after
28405 * the last character used in the conversion.
28407 * Converts a string to a #gdouble value.
28408 * It calls the standard strtod() function to handle the conversion, but
28409 * if the string is not completely converted it attempts the conversion
28410 * again with g_ascii_strtod(), and returns the best match.
28412 * This function should seldom be used. The normal situation when reading
28413 * numbers not for human consumption is to use g_ascii_strtod(). Only when
28414 * you know that you must expect both locale formatted and C formatted numbers
28415 * should you use this. Make sure that you don't pass strings such as comma
28416 * separated lists of values, since the commas may be interpreted as a decimal
28417 * point in some locales, causing unexpected results.
28419 * Returns: the #gdouble value.
28425 * @string: the string to convert.
28427 * Converts a string to upper case.
28429 * Returns: the string
28430 * Deprecated: 2.2: This function is totally broken for the reasons discussed
28431 * in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
28437 * @str_array: a %NULL-terminated array of strings
28439 * Returns the length of the given %NULL-terminated
28440 * string array @str_array.
28442 * Returns: length of @str_array.
28449 * @testpath: The test path for a new test case.
28450 * @Fixture: The type of a fixture data structure.
28451 * @tdata: Data argument for the test functions.
28452 * @fsetup: The function to set up the fixture data.
28453 * @ftest: The actual test function.
28454 * @fteardown: The function to tear down the fixture data.
28456 * Hook up a new test case at @testpath, similar to g_test_add_func().
28457 * A fixture data structure with setup and teardown function may be provided
28458 * though, similar to g_test_create_case().
28459 * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and
28460 * fteardown() callbacks can expect a @Fixture pointer as first argument in
28461 * a type safe manner.
28468 * g_test_add_data_func:
28469 * @testpath: /-separated test case path name for the test.
28470 * @test_data: Test data argument for the test function.
28471 * @test_func: The test function to invoke for this test.
28473 * Create a new test case, similar to g_test_create_case(). However
28474 * the test is assumed to use no fixture, and test suites are automatically
28475 * created on the fly and added to the root fixture, based on the
28476 * slash-separated portions of @testpath. The @test_data argument
28477 * will be passed as first argument to @test_func.
28479 * If @testpath includes the component "subprocess" anywhere in it,
28480 * the test will be skipped by default, and only run if explicitly
28481 * required via the <option>-p</option> command-line option or
28482 * g_test_trap_subprocess().
28489 * g_test_add_data_func_full:
28490 * @testpath: /-separated test case path name for the test.
28491 * @test_data: Test data argument for the test function.
28492 * @test_func: The test function to invoke for this test.
28493 * @data_free_func: #GDestroyNotify for @test_data.
28495 * Create a new test case, as with g_test_add_data_func(), but freeing
28496 * @test_data after the test run is complete.
28504 * @testpath: /-separated test case path name for the test.
28505 * @test_func: The test function to invoke for this test.
28507 * Create a new test case, similar to g_test_create_case(). However
28508 * the test is assumed to use no fixture, and test suites are automatically
28509 * created on the fly and added to the root fixture, based on the
28510 * slash-separated portions of @testpath.
28512 * If @testpath includes the component "subprocess" anywhere in it,
28513 * the test will be skipped by default, and only run if explicitly
28514 * required via the <option>-p</option> command-line option or
28515 * g_test_trap_subprocess().
28522 * g_test_assert_expected_messages:
28524 * Asserts that all messages previously indicated via
28525 * g_test_expect_message() have been seen and suppressed.
28527 * If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
28528 * expected via g_test_expect_message() then they will be ignored.
28536 * @bug_uri_snippet: Bug specific bug tracker URI portion.
28538 * This function adds a message to test reports that
28539 * associates a bug URI with a test case.
28540 * Bug URIs are constructed from a base URI set with g_test_bug_base()
28541 * and @bug_uri_snippet.
28549 * @uri_pattern: the base pattern for bug URIs
28551 * Specify the base URI for bug reports.
28553 * The base URI is used to construct bug report messages for
28554 * g_test_message() when g_test_bug() is called.
28555 * Calling this function outside of a test case sets the
28556 * default base URI for all test cases. Calling it from within
28557 * a test case changes the base URI for the scope of the test
28559 * Bug URIs are constructed by appending a bug specific URI
28560 * portion to @uri_pattern, or by replacing the special string
28561 * '\%s' within @uri_pattern if that is present.
28568 * g_test_build_filename:
28569 * @file_type: the type of file (built vs. distributed)
28570 * @first_path: the first segment of the pathname
28571 * @...: %NULL-terminated additional path segments
28573 * Creates the pathname to a data file that is required for a test.
28575 * This function is conceptually similar to g_build_filename() except
28576 * that the first argument has been replaced with a #GTestFileType
28579 * The data file should either have been distributed with the module
28580 * containing the test (%G_TEST_DIST) or built as part of the build
28581 * system of that module (%G_TEST_BUILT).
28583 * In order for this function to work in srcdir != builddir situations,
28584 * the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
28585 * have been defined. As of 2.38, this is done by the Makefile.decl
28586 * included in GLib. Please ensure that your copy is up to date before
28587 * using this function.
28589 * In case neither variable is set, this function will fall back to
28590 * using the dirname portion of argv[0], possibly removing ".libs".
28591 * This allows for casual running of tests directly from the commandline
28592 * in the srcdir == builddir case and should also support running of
28593 * installed tests, assuming the data files have been installed in the
28594 * same relative path as the test binary.
28596 * Returns: the path of the file, to be freed using g_free()
28602 * g_test_create_case:
28603 * @test_name: the name for the test case
28604 * @data_size: the size of the fixture data structure
28605 * @test_data: test data argument for the test functions
28606 * @data_setup: the function to set up the fixture data
28607 * @data_test: the actual test function
28608 * @data_teardown: the function to teardown the fixture data
28610 * Create a new #GTestCase, named @test_name, this API is fairly
28611 * low level, calling g_test_add() or g_test_add_func() is preferable.
28612 * When this test is executed, a fixture structure of size @data_size
28613 * will be allocated and filled with 0s. Then @data_setup is called
28614 * to initialize the fixture. After fixture setup, the actual test
28615 * function @data_test is called. Once the test run completed, the
28616 * fixture structure is torn down by calling @data_teardown and
28617 * after that the memory is released.
28619 * Splitting up a test run into fixture setup, test function and
28620 * fixture teardown is most usful if the same fixture is used for
28621 * multiple tests. In this cases, g_test_create_case() will be
28622 * called with the same fixture, but varying @test_name and
28623 * @data_test arguments.
28625 * Returns: a newly allocated #GTestCase.
28631 * g_test_create_suite:
28632 * @suite_name: a name for the suite
28634 * Create a new test suite with the name @suite_name.
28636 * Returns: A newly allocated #GTestSuite instance.
28642 * g_test_expect_message:
28643 * @log_domain: (allow-none): the log domain of the message
28644 * @log_level: the log level of the message
28645 * @pattern: a glob-style
28646 * <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28648 * Indicates that a message with the given @log_domain and @log_level,
28649 * with text matching @pattern, is expected to be logged. When this
28650 * message is logged, it will not be printed, and the test case will
28653 * Use g_test_assert_expected_messages() to assert that all
28654 * previously-expected messages have been seen and suppressed.
28656 * You can call this multiple times in a row, if multiple messages are
28657 * expected as a result of a single call. (The messages must appear in
28658 * the same order as the calls to g_test_expect_message().)
28663 * /* g_main_context_push_thread_default() should fail if the
28664 * * context is already owned by another thread.
28666 * g_test_expect_message (G_LOG_DOMAIN,
28667 * G_LOG_LEVEL_CRITICAL,
28668 * "assertion*acquired_context*failed");
28669 * g_main_context_push_thread_default (bad_context);
28670 * g_test_assert_expected_messages ();
28673 * Note that you cannot use this to test g_error() messages, since
28674 * g_error() intentionally never returns even if the program doesn't
28675 * abort; use g_test_trap_subprocess() in this case.
28677 * If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
28678 * expected via g_test_expect_message() then they will be ignored.
28687 * Indicates that a test failed. This function can be called
28688 * multiple times from the same test. You can use this function
28689 * if your test failed in a recoverable way.
28691 * Do not use this function if the failure of a test could cause
28692 * other tests to malfunction.
28694 * Calling this function will not stop the test from running, you
28695 * need to return from the test function yourself. So you can
28696 * produce additional diagnostic messages or even continue running
28699 * If not called from inside a test, this function does nothing.
28708 * Returns whether a test has already failed. This will
28709 * be the case when g_test_fail(), g_test_incomplete()
28710 * or g_test_skip() have been called, but also if an
28711 * assertion has failed.
28713 * This can be useful to return early from a test if
28714 * continuing after a failed assertion might be harmful.
28716 * The return value of this function is only meaningful
28717 * if it is called from inside a test function.
28719 * Returns: %TRUE if the test has failed
28726 * @file_type: the type of file (built vs. distributed)
28728 * Gets the pathname of the directory containing test files of the type
28729 * specified by @file_type.
28731 * This is approximately the same as calling g_test_build_filename("."),
28732 * but you don't need to free the return value.
28734 * Returns: the path of the directory, owned by GLib
28740 * g_test_get_filename:
28741 * @file_type: the type of file (built vs. distributed)
28742 * @first_path: the first segment of the pathname
28743 * @...: %NULL-terminated additional path segments
28745 * Gets the pathname to a data file that is required for a test.
28747 * This is the same as g_test_build_filename() with two differences.
28748 * The first difference is that must only use this function from within
28749 * a testcase function. The second difference is that you need not free
28750 * the return value -- it will be automatically freed when the testcase
28751 * finishes running.
28753 * It is safe to use this function from a thread inside of a testcase
28754 * but you must ensure that all such uses occur before the main testcase
28755 * function returns (ie: it is best to ensure that all threads have been
28758 * Returns: the path, automatically freed at the end of the testcase
28766 * Get the toplevel test suite for the test path API.
28768 * Returns: the toplevel #GTestSuite
28774 * g_test_incomplete:
28775 * @msg: (allow-none): explanation
28777 * Indicates that a test failed because of some incomplete
28778 * functionality. This function can be called multiple times
28779 * from the same test.
28781 * Calling this function will not stop the test from running, you
28782 * need to return from the test function yourself. So you can
28783 * produce additional diagnostic messages or even continue running
28786 * If not called from inside a test, this function does nothing.
28794 * @argc: Address of the @argc parameter of the main() function.
28795 * Changed if any arguments were handled.
28796 * @argv: Address of the @argv parameter of main().
28797 * Any parameters understood by g_test_init() stripped before return.
28798 * @...: Reserved for future extension. Currently, you must pass %NULL.
28800 * Initialize the GLib testing framework, e.g. by seeding the
28801 * test random number generator, the name for g_get_prgname()
28802 * and parsing test related command line args.
28803 * So far, the following arguments are understood:
28806 * <term><option>-l</option></term>
28808 * List test cases available in a test executable.
28809 * </para></listitem>
28812 * <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
28814 * Provide a random seed to reproduce test runs using random numbers.
28815 * </para></listitem>
28818 * <term><option>--verbose</option></term>
28819 * <listitem><para>Run tests verbosely.</para></listitem>
28822 * <term><option>-q</option>, <option>--quiet</option></term>
28823 * <listitem><para>Run tests quietly.</para></listitem>
28826 * <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
28828 * Execute all tests matching <replaceable>TESTPATH</replaceable>.
28829 * This can also be used to force a test to run that would otherwise
28830 * be skipped (ie, a test whose name contains "/subprocess").
28831 * </para></listitem>
28834 * <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
28836 * Execute tests according to these test modes:
28839 * <term>perf</term>
28841 * Performance tests, may take long and report results.
28842 * </para></listitem>
28845 * <term>slow, thorough</term>
28847 * Slow and thorough tests, may take quite long and
28848 * maximize coverage.
28849 * </para></listitem>
28852 * <term>quick</term>
28854 * Quick tests, should run really quickly and give good coverage.
28855 * </para></listitem>
28858 * <term>undefined</term>
28860 * Tests for undefined behaviour, may provoke programming errors
28861 * under g_test_trap_subprocess() or g_test_expect_messages() to check
28862 * that appropriate assertions or warnings are given
28863 * </para></listitem>
28866 * <term>no-undefined</term>
28868 * Avoid tests for undefined behaviour
28869 * </para></listitem>
28872 * </para></listitem>
28875 * <term><option>--debug-log</option></term>
28876 * <listitem><para>Debug test logging output.</para></listitem>
28885 * g_test_initialized:
28887 * Returns %TRUE if g_test_init() has been called.
28889 * Returns: %TRUE if g_test_init() has been called.
28895 * g_test_log_buffer_free:
28897 * Internal function for gtester to free test log messages, no ABI guarantees provided.
28902 * g_test_log_buffer_new:
28904 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
28909 * g_test_log_buffer_pop:
28911 * Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
28916 * g_test_log_buffer_push:
28918 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
28923 * g_test_log_msg_free:
28925 * Internal function for gtester to free test log messages, no ABI guarantees provided.
28930 * g_test_log_set_fatal_handler:
28931 * @log_func: the log handler function.
28932 * @user_data: data passed to the log handler.
28934 * Installs a non-error fatal log handler which can be
28935 * used to decide whether log messages which are counted
28936 * as fatal abort the program.
28938 * The use case here is that you are running a test case
28939 * that depends on particular libraries or circumstances
28940 * and cannot prevent certain known critical or warning
28941 * messages. So you install a handler that compares the
28942 * domain and message to precisely not abort in such a case.
28944 * Note that the handler is reset at the beginning of
28945 * any test case, so you have to set it inside each test
28946 * function which needs the special behavior.
28948 * This handler has no effect on g_error messages.
28955 * g_test_maximized_result:
28956 * @maximized_quantity: the reported value
28957 * @format: the format string of the report message
28958 * @...: arguments to pass to the printf() function
28960 * Report the result of a performance or measurement test.
28961 * The test should generally strive to maximize the reported
28962 * quantities (larger values are better than smaller ones),
28963 * this and @maximized_quantity can determine sorting
28964 * order for test result reports.
28972 * @format: the format string
28973 * @...: printf-like arguments to @format
28975 * Add a message to the test report.
28982 * g_test_minimized_result:
28983 * @minimized_quantity: the reported value
28984 * @format: the format string of the report message
28985 * @...: arguments to pass to the printf() function
28987 * Report the result of a performance or measurement test.
28988 * The test should generally strive to minimize the reported
28989 * quantities (smaller values are better than larger ones),
28990 * this and @minimized_quantity can determine sorting
28991 * order for test result reports.
29000 * Returns %TRUE if tests are run in performance mode.
29002 * Returns: %TRUE if in performance mode
29007 * g_test_queue_destroy:
29008 * @destroy_func: Destroy callback for teardown phase.
29009 * @destroy_data: Destroy callback data.
29011 * This function enqueus a callback @destroy_func to be executed
29012 * during the next test case teardown phase. This is most useful
29013 * to auto destruct allocted test resources at the end of a test run.
29014 * Resources are released in reverse queue order, that means enqueueing
29015 * callback A before callback B will cause B() to be called before
29016 * A() during teardown.
29023 * g_test_queue_free:
29024 * @gfree_pointer: the pointer to be stored.
29026 * Enqueue a pointer to be released with g_free() during the next
29027 * teardown phase. This is equivalent to calling g_test_queue_destroy()
29028 * with a destroy callback of g_free().
29035 * g_test_queue_unref:
29036 * @gobject: the object to unref
29038 * Enqueue an object to be released with g_object_unref() during
29039 * the next teardown phase. This is equivalent to calling
29040 * g_test_queue_destroy() with a destroy callback of g_object_unref().
29049 * Returns %TRUE if tests are run in quick mode.
29050 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
29051 * there is no "medium speed".
29053 * Returns: %TRUE if in quick mode
29060 * Returns %TRUE if tests are run in quiet mode.
29061 * The default is neither g_test_verbose() nor g_test_quiet().
29063 * Returns: %TRUE if in quiet mode
29070 * Get a reproducible random bit (0 or 1), see g_test_rand_int()
29071 * for details on test case random numbers.
29078 * g_test_rand_double:
29080 * Get a reproducible random floating point number,
29081 * see g_test_rand_int() for details on test case random numbers.
29083 * Returns: a random number from the seeded random number generator.
29089 * g_test_rand_double_range:
29090 * @range_start: the minimum value returned by this function
29091 * @range_end: the minimum value not returned by this function
29093 * Get a reproducible random floating pointer number out of a specified range,
29094 * see g_test_rand_int() for details on test case random numbers.
29096 * Returns: a number with @range_start <= number < @range_end.
29104 * Get a reproducible random integer number.
29106 * The random numbers generated by the g_test_rand_*() family of functions
29107 * change with every new test program start, unless the --seed option is
29108 * given when starting test programs.
29110 * For individual test cases however, the random number generator is
29111 * reseeded, to avoid dependencies between tests and to make --seed
29112 * effective for all test cases.
29114 * Returns: a random number from the seeded random number generator.
29120 * g_test_rand_int_range:
29121 * @begin: the minimum value returned by this function
29122 * @end: the smallest value not to be returned by this function
29124 * Get a reproducible random integer number out of a specified range,
29125 * see g_test_rand_int() for details on test case random numbers.
29127 * Returns: a number with @begin <= number < @end.
29135 * Runs all tests under the toplevel suite which can be retrieved
29136 * with g_test_get_root(). Similar to g_test_run_suite(), the test
29137 * cases to be run are filtered according to
29138 * test path arguments (-p <replaceable>testpath</replaceable>) as
29139 * parsed by g_test_init().
29140 * g_test_run_suite() or g_test_run() may only be called once
29143 * Returns: 0 on success
29149 * g_test_run_suite:
29150 * @suite: a #GTestSuite
29152 * Execute the tests within @suite and all nested #GTestSuites.
29153 * The test suites to be executed are filtered according to
29154 * test path arguments (-p <replaceable>testpath</replaceable>)
29155 * as parsed by g_test_init().
29156 * g_test_run_suite() or g_test_run() may only be called once
29159 * Returns: 0 on success
29165 * g_test_set_nonfatal_assertions:
29167 * Changes the behaviour of g_assert_cmpstr(), g_assert_cmpint(),
29168 * g_assert_cmpuint(), g_assert_cmphex(), g_assert_cmpfloat(),
29169 * g_assert_true(), g_assert_false(), g_assert_null(), g_assert_no_error(),
29170 * g_assert_error(), g_test_assert_expected_messages() and the various
29171 * g_test_trap_assert_*() macros to not abort to program, but instead
29172 * call g_test_fail() and continue.
29174 * Note that the g_assert_not_reached() and g_assert() are not
29175 * affected by this.
29177 * This function can only be called after g_test_init().
29185 * @msg: (allow-none): explanation
29187 * Indicates that a test was skipped.
29189 * Calling this function will not stop the test from running, you
29190 * need to return from the test function yourself. So you can
29191 * produce additional diagnostic messages or even continue running
29194 * If not called from inside a test, this function does nothing.
29203 * Returns %TRUE if tests are run in slow mode.
29204 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
29205 * there is no "medium speed".
29207 * Returns: the opposite of g_test_quick()
29212 * g_test_subprocess:
29214 * Returns %TRUE (after g_test_init() has been called) if the test
29215 * program is running under g_test_trap_subprocess().
29217 * Returns: %TRUE if the test program is running under
29218 * g_test_trap_subprocess().
29224 * g_test_suite_add:
29225 * @suite: a #GTestSuite
29226 * @test_case: a #GTestCase
29228 * Adds @test_case to @suite.
29235 * g_test_suite_add_suite:
29236 * @suite: a #GTestSuite
29237 * @nestedsuite: another #GTestSuite
29239 * Adds @nestedsuite to @suite.
29248 * Returns %TRUE if tests are run in thorough mode, equivalent to
29251 * Returns: the same thing as g_test_slow()
29256 * g_test_timer_elapsed:
29258 * Get the time since the last start of the timer with g_test_timer_start().
29260 * Returns: the time since the last start of the timer, as a double
29266 * g_test_timer_last:
29268 * Report the last result of g_test_timer_elapsed().
29270 * Returns: the last result of g_test_timer_elapsed(), as a double
29276 * g_test_timer_start:
29278 * Start a timing test. Call g_test_timer_elapsed() when the task is supposed
29279 * to be done. Call this function again to restart the timer.
29286 * g_test_trap_assert_failed:
29288 * Assert that the last test subprocess failed.
29289 * See g_test_trap_subprocess().
29291 * This is sometimes used to test situations that are formally considered to
29292 * be undefined behaviour, like inputs that fail a g_return_if_fail()
29293 * check. In these situations you should skip the entire test, including the
29294 * call to g_test_trap_subprocess(), unless g_test_undefined() returns %TRUE
29295 * to indicate that undefined behaviour may be tested.
29302 * g_test_trap_assert_passed:
29304 * Assert that the last test subprocess passed.
29305 * See g_test_trap_subprocess().
29312 * g_test_trap_assert_stderr:
29313 * @serrpattern: a glob-style
29314 * <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29316 * Assert that the stderr output of the last test subprocess
29317 * matches @serrpattern. See g_test_trap_subprocess().
29319 * This is sometimes used to test situations that are formally
29320 * considered to be undefined behaviour, like code that hits a
29321 * g_assert() or g_error(). In these situations you should skip the
29322 * entire test, including the call to g_test_trap_subprocess(), unless
29323 * g_test_undefined() returns %TRUE to indicate that undefined
29324 * behaviour may be tested.
29331 * g_test_trap_assert_stderr_unmatched:
29332 * @serrpattern: a glob-style
29333 * <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29335 * Assert that the stderr output of the last test subprocess
29336 * does not match @serrpattern. See g_test_trap_subprocess().
29343 * g_test_trap_assert_stdout:
29344 * @soutpattern: a glob-style
29345 * <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29347 * Assert that the stdout output of the last test subprocess matches
29348 * @soutpattern. See g_test_trap_subprocess().
29355 * g_test_trap_assert_stdout_unmatched:
29356 * @soutpattern: a glob-style
29357 * <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29359 * Assert that the stdout output of the last test subprocess
29360 * does not match @soutpattern. See g_test_trap_subprocess().
29367 * g_test_trap_fork:
29368 * @usec_timeout: Timeout for the forked test in micro seconds.
29369 * @test_trap_flags: Flags to modify forking behaviour.
29371 * Fork the current test program to execute a test case that might
29372 * not return or that might abort.
29374 * If @usec_timeout is non-0, the forked test case is aborted and
29375 * considered failing if its run time exceeds it.
29377 * The forking behavior can be configured with the #GTestTrapFlags flags.
29379 * In the following example, the test code forks, the forked child
29380 * process produces some sample output and exits successfully.
29381 * The forking parent process then asserts successful child program
29382 * termination and validates child program outputs.
29386 * test_fork_patterns (void)
29388 * if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
29390 * g_print ("some stdout text: somagic17\n");
29391 * g_printerr ("some stderr text: semagic43\n");
29392 * exit (0); /* successful test run */
29394 * g_test_trap_assert_passed ();
29395 * g_test_trap_assert_stdout ("*somagic17*");
29396 * g_test_trap_assert_stderr ("*semagic43*");
29400 * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
29402 * Deprecated: This function is implemented only on Unix platforms,
29403 * and is not always reliable due to problems inherent in
29404 * fork-without-exec. Use g_test_trap_subprocess() instead.
29409 * g_test_trap_has_passed:
29411 * Check the result of the last g_test_trap_subprocess() call.
29413 * Returns: %TRUE if the last test subprocess terminated successfully.
29419 * g_test_trap_reached_timeout:
29421 * Check the result of the last g_test_trap_subprocess() call.
29423 * Returns: %TRUE if the last test subprocess got killed due to a timeout.
29429 * g_test_trap_subprocess:
29430 * @test_path: Test to run in a subprocess
29431 * @usec_timeout: Timeout for the subprocess test in micro seconds.
29432 * @test_flags: Flags to modify subprocess behaviour.
29434 * Respawns the test program to run only @test_path in a subprocess.
29435 * This can be used for a test case that might not return, or that
29436 * might abort. @test_path will normally be the name of the parent
29437 * test, followed by "<literal>/subprocess/</literal>" and then a name
29438 * for the specific subtest (or just ending with
29439 * "<literal>/subprocess</literal>" if the test only has one child
29440 * test); tests with names of this form will automatically be skipped
29441 * in the parent process.
29443 * If @usec_timeout is non-0, the test subprocess is aborted and
29444 * considered failing if its run time exceeds it.
29446 * The subprocess behavior can be configured with the
29447 * #GTestSubprocessFlags flags.
29449 * You can use methods such as g_test_trap_assert_passed(),
29450 * g_test_trap_assert_failed(), and g_test_trap_assert_stderr() to
29451 * check the results of the subprocess. (But note that
29452 * g_test_trap_assert_stdout() and g_test_trap_assert_stderr()
29453 * cannot be used if @test_flags specifies that the child should
29454 * inherit the parent stdout/stderr.)
29456 * If your <literal>main ()</literal> needs to behave differently in
29457 * the subprocess, you can call g_test_subprocess() (after calling
29458 * g_test_init()) to see whether you are in a subprocess.
29460 * The following example tests that calling
29461 * <literal>my_object_new(1000000)</literal> will abort with an error
29466 * test_create_large_object_subprocess (void)
29468 * my_object_new (1000000);
29472 * test_create_large_object (void)
29474 * g_test_trap_subprocess ("/myobject/create_large_object/subprocess", 0, 0);
29475 * g_test_trap_assert_failed ();
29476 * g_test_trap_assert_stderr ("*ERROR*too large*");
29480 * main (int argc, char **argv)
29482 * g_test_init (&argc, &argv, NULL);
29484 * g_test_add_func ("/myobject/create_large_object",
29485 * test_create_large_object);
29486 * /* Because of the '/subprocess' in the name, this test will
29487 * * not be run by the g_test_run () call below.
29489 * g_test_add_func ("/myobject/create_large_object/subprocess",
29490 * test_create_large_object_subprocess);
29492 * return g_test_run ();
29501 * g_test_undefined:
29503 * Returns %TRUE if tests may provoke assertions and other formally-undefined
29504 * behaviour, to verify that appropriate warnings are given. It might, in some
29505 * cases, be useful to turn this off if running tests under valgrind.
29507 * Returns: %TRUE if tests may provoke programming errors
29514 * Returns %TRUE if tests are run in verbose mode.
29515 * The default is neither g_test_verbose() nor g_test_quiet().
29517 * Returns: %TRUE if in verbose mode
29523 * @retval: the return value of this thread
29525 * Terminates the current thread.
29527 * If another thread is waiting for us using g_thread_join() then the
29528 * waiting thread will be woken up and get @retval as the return value
29529 * of g_thread_join().
29531 * Calling <literal>g_thread_exit (retval)</literal> is equivalent to
29532 * returning @retval from the function @func, as given to g_thread_new().
29535 * You must only call g_thread_exit() from a thread that you created
29536 * yourself with g_thread_new() or related APIs. You must not call
29537 * this function from a thread created with another threading library
29538 * or or from within a #GThreadPool.
29545 * @thread: a #GThread
29547 * Waits until @thread finishes, i.e. the function @func, as
29548 * given to g_thread_new(), returns or g_thread_exit() is called.
29549 * If @thread has already terminated, then g_thread_join()
29550 * returns immediately.
29552 * Any thread can wait for any other thread by calling g_thread_join(),
29553 * not just its 'creator'. Calling g_thread_join() from multiple threads
29554 * for the same @thread leads to undefined behaviour.
29556 * The value returned by @func or given to g_thread_exit() is
29557 * returned by this function.
29559 * g_thread_join() consumes the reference to the passed-in @thread.
29560 * This will usually cause the #GThread struct and associated resources
29561 * to be freed. Use g_thread_ref() to obtain an extra reference if you
29562 * want to keep the GThread alive beyond the g_thread_join() call.
29564 * Returns: the return value of the thread
29570 * @name: (allow-none): an (optional) name for the new thread
29571 * @func: a function to execute in the new thread
29572 * @data: an argument to supply to the new thread
29574 * This function creates a new thread. The new thread starts by invoking
29575 * @func with the argument data. The thread will run until @func returns
29576 * or until g_thread_exit() is called from the new thread. The return value
29577 * of @func becomes the return value of the thread, which can be obtained
29578 * with g_thread_join().
29580 * The @name can be useful for discriminating threads in a debugger.
29581 * It is not used for other purposes and does not have to be unique.
29582 * Some systems restrict the length of @name to 16 bytes.
29584 * If the thread can not be created the program aborts. See
29585 * g_thread_try_new() if you want to attempt to deal with failures.
29587 * To free the struct returned by this function, use g_thread_unref().
29588 * Note that g_thread_join() implicitly unrefs the #GThread as well.
29590 * Returns: the new #GThread
29596 * g_thread_pool_free:
29597 * @pool: a #GThreadPool
29598 * @immediate: should @pool shut down immediately?
29599 * @wait_: should the function wait for all tasks to be finished?
29601 * Frees all resources allocated for @pool.
29603 * If @immediate is %TRUE, no new task is processed for @pool.
29604 * Otherwise @pool is not freed before the last task is processed.
29605 * Note however, that no thread of this pool is interrupted while
29606 * processing a task. Instead at least all still running threads
29607 * can finish their tasks before the @pool is freed.
29609 * If @wait_ is %TRUE, the functions does not return before all
29610 * tasks to be processed (dependent on @immediate, whether all
29611 * or only the currently running) are ready.
29612 * Otherwise the function returns immediately.
29614 * After calling this function @pool must not be used anymore.
29619 * g_thread_pool_get_max_idle_time:
29621 * This function will return the maximum @interval that a
29622 * thread will wait in the thread pool for new tasks before
29625 * If this function returns 0, threads waiting in the thread
29626 * pool for new work are not stopped.
29628 * Returns: the maximum @interval (milliseconds) to wait
29629 * for new tasks in the thread pool before stopping the
29636 * g_thread_pool_get_max_threads:
29637 * @pool: a #GThreadPool
29639 * Returns the maximal number of threads for @pool.
29641 * Returns: the maximal number of threads
29646 * g_thread_pool_get_max_unused_threads:
29648 * Returns the maximal allowed number of unused threads.
29650 * Returns: the maximal number of unused threads
29655 * g_thread_pool_get_num_threads:
29656 * @pool: a #GThreadPool
29658 * Returns the number of threads currently running in @pool.
29660 * Returns: the number of threads currently running
29665 * g_thread_pool_get_num_unused_threads:
29667 * Returns the number of currently unused threads.
29669 * Returns: the number of currently unused threads
29674 * g_thread_pool_new:
29675 * @func: a function to execute in the threads of the new thread pool
29676 * @user_data: user data that is handed over to @func every time it
29678 * @max_threads: the maximal number of threads to execute concurrently
29679 * in the new thread pool, -1 means no limit
29680 * @exclusive: should this thread pool be exclusive?
29681 * @error: return location for error, or %NULL
29683 * This function creates a new thread pool.
29685 * Whenever you call g_thread_pool_push(), either a new thread is
29686 * created or an unused one is reused. At most @max_threads threads
29687 * are running concurrently for this thread pool. @max_threads = -1
29688 * allows unlimited threads to be created for this thread pool. The
29689 * newly created or reused thread now executes the function @func
29690 * with the two arguments. The first one is the parameter to
29691 * g_thread_pool_push() and the second one is @user_data.
29693 * The parameter @exclusive determines whether the thread pool owns
29694 * all threads exclusive or shares them with other thread pools.
29695 * If @exclusive is %TRUE, @max_threads threads are started
29696 * immediately and they will run exclusively for this thread pool
29697 * until it is destroyed by g_thread_pool_free(). If @exclusive is
29698 * %FALSE, threads are created when needed and shared between all
29699 * non-exclusive thread pools. This implies that @max_threads may
29700 * not be -1 for exclusive thread pools.
29702 * @error can be %NULL to ignore errors, or non-%NULL to report
29703 * errors. An error can only occur when @exclusive is set to %TRUE
29704 * and not all @max_threads threads could be created.
29706 * Returns: the new #GThreadPool
29711 * g_thread_pool_push:
29712 * @pool: a #GThreadPool
29713 * @data: a new task for @pool
29714 * @error: return location for error, or %NULL
29716 * Inserts @data into the list of tasks to be executed by @pool.
29718 * When the number of currently running threads is lower than the
29719 * maximal allowed number of threads, a new thread is started (or
29720 * reused) with the properties given to g_thread_pool_new().
29721 * Otherwise, @data stays in the queue until a thread in this pool
29722 * finishes its previous task and processes @data.
29724 * @error can be %NULL to ignore errors, or non-%NULL to report
29725 * errors. An error can only occur when a new thread couldn't be
29726 * created. In that case @data is simply appended to the queue of
29729 * Before version 2.32, this function did not return a success status.
29731 * Returns: %TRUE on success, %FALSE if an error occurred
29736 * g_thread_pool_set_max_idle_time:
29737 * @interval: the maximum @interval (in milliseconds)
29738 * a thread can be idle
29740 * This function will set the maximum @interval that a thread
29741 * waiting in the pool for new tasks can be idle for before
29742 * being stopped. This function is similar to calling
29743 * g_thread_pool_stop_unused_threads() on a regular timeout,
29744 * except this is done on a per thread basis.
29746 * By setting @interval to 0, idle threads will not be stopped.
29748 * The default value is 15000 (15 seconds).
29755 * g_thread_pool_set_max_threads:
29756 * @pool: a #GThreadPool
29757 * @max_threads: a new maximal number of threads for @pool,
29758 * or -1 for unlimited
29759 * @error: return location for error, or %NULL
29761 * Sets the maximal allowed number of threads for @pool.
29762 * A value of -1 means that the maximal number of threads
29763 * is unlimited. If @pool is an exclusive thread pool, setting
29764 * the maximal number of threads to -1 is not allowed.
29766 * Setting @max_threads to 0 means stopping all work for @pool.
29767 * It is effectively frozen until @max_threads is set to a non-zero
29770 * A thread is never terminated while calling @func, as supplied by
29771 * g_thread_pool_new(). Instead the maximal number of threads only
29772 * has effect for the allocation of new threads in g_thread_pool_push().
29773 * A new thread is allocated, whenever the number of currently
29774 * running threads in @pool is smaller than the maximal number.
29776 * @error can be %NULL to ignore errors, or non-%NULL to report
29777 * errors. An error can only occur when a new thread couldn't be
29780 * Before version 2.32, this function did not return a success status.
29782 * Returns: %TRUE on success, %FALSE if an error occurred
29787 * g_thread_pool_set_max_unused_threads:
29788 * @max_threads: maximal number of unused threads
29790 * Sets the maximal number of unused threads to @max_threads.
29791 * If @max_threads is -1, no limit is imposed on the number
29792 * of unused threads.
29794 * The default value is 2.
29799 * g_thread_pool_set_sort_function:
29800 * @pool: a #GThreadPool
29801 * @func: the #GCompareDataFunc used to sort the list of tasks.
29802 * This function is passed two tasks. It should return
29803 * 0 if the order in which they are handled does not matter,
29804 * a negative value if the first task should be processed before
29805 * the second or a positive value if the second task should be
29807 * @user_data: user data passed to @func
29809 * Sets the function used to sort the list of tasks. This allows the
29810 * tasks to be processed by a priority determined by @func, and not
29811 * just in the order in which they were added to the pool.
29813 * Note, if the maximum number of threads is more than 1, the order
29814 * that threads are executed cannot be guaranteed 100%. Threads are
29815 * scheduled by the operating system and are executed at random. It
29816 * cannot be assumed that threads are executed in the order they are
29824 * g_thread_pool_stop_unused_threads:
29826 * Stops all currently unused threads. This does not change the
29827 * maximal number of unused threads. This function can be used to
29828 * regularly stop all unused threads e.g. from g_timeout_add().
29833 * g_thread_pool_unprocessed:
29834 * @pool: a #GThreadPool
29836 * Returns the number of tasks still unprocessed in @pool.
29838 * Returns: the number of unprocessed tasks
29844 * @thread: a #GThread
29846 * Increase the reference count on @thread.
29848 * Returns: a new reference to @thread
29856 * This functions returns the #GThread corresponding to the
29857 * current thread. Note that this function does not increase
29858 * the reference count of the returned struct.
29860 * This function will return a #GThread even for threads that
29861 * were not created by GLib (i.e. those created by other threading
29862 * APIs). This may be useful for thread identification purposes
29863 * (i.e. comparisons) but you must not use GLib functions (such
29864 * as g_thread_join()) on these threads.
29866 * Returns: the #GThread representing the current thread
29871 * g_thread_supported:
29873 * This macro returns %TRUE if the thread system is initialized,
29874 * and %FALSE if it is not.
29876 * For language bindings, g_thread_get_initialized() provides
29877 * the same functionality as a function.
29879 * Returns: %TRUE, if the thread system is initialized
29884 * g_thread_try_new:
29885 * @name: (allow-none): an (optional) name for the new thread
29886 * @func: a function to execute in the new thread
29887 * @data: an argument to supply to the new thread
29888 * @error: return location for error, or %NULL
29890 * This function is the same as g_thread_new() except that
29891 * it allows for the possibility of failure.
29893 * If a thread can not be created (due to resource limits),
29894 * @error is set and %NULL is returned.
29896 * Returns: the new #GThread, or %NULL if an error occurred
29903 * @thread: a #GThread
29905 * Decrease the reference count on @thread, possibly freeing all
29906 * resources associated with it.
29908 * Note that each thread holds a reference to its #GThread while
29909 * it is running, so it is safe to drop your own reference to it
29910 * if you don't need it anymore.
29919 * Causes the calling thread to voluntarily relinquish the CPU, so
29920 * that other threads can run.
29922 * This function is often used as a method to make busy wait less evil.
29928 * @time_: a #GTimeVal
29929 * @microseconds: number of microseconds to add to @time
29931 * Adds the given number of microseconds to @time_. @microseconds can
29932 * also be negative to decrease the value of @time_.
29937 * g_time_val_from_iso8601:
29938 * @iso_date: an ISO 8601 encoded date string
29939 * @time_: (out): a #GTimeVal
29941 * Converts a string containing an ISO 8601 encoded date and time
29942 * to a #GTimeVal and puts it into @time_.
29944 * @iso_date must include year, month, day, hours, minutes, and
29945 * seconds. It can optionally include fractions of a second and a time
29946 * zone indicator. (In the absence of any time zone indication, the
29947 * timestamp is assumed to be in local time.)
29949 * Returns: %TRUE if the conversion was successful.
29955 * g_time_val_to_iso8601:
29956 * @time_: a #GTimeVal
29958 * Converts @time_ into an RFC 3339 encoded string, relative to the
29959 * Coordinated Universal Time (UTC). This is one of the many formats
29960 * allowed by ISO 8601.
29962 * ISO 8601 allows a large number of date/time formats, with or without
29963 * punctuation and optional elements. The format returned by this function
29964 * is a complete date and time, with optional punctuation included, the
29965 * UTC time zone represented as "Z", and the @tv_usec part included if
29966 * and only if it is nonzero, i.e. either
29967 * "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
29969 * This corresponds to the Internet date/time format defined by
29970 * <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
29971 * to either of the two most-precise formats defined by
29972 * <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
29973 * "Date and Time Formats"</ulink>. Both of these documents are profiles of
29976 * Use g_date_time_format() or g_strdup_printf() if a different
29977 * variation of ISO 8601 format is required.
29979 * Returns: a newly allocated string containing an ISO 8601 date
29985 * g_time_zone_adjust_time:
29986 * @tz: a #GTimeZone
29987 * @type: the #GTimeType of @time_
29988 * @time_: a pointer to a number of seconds since January 1, 1970
29990 * Finds an interval within @tz that corresponds to the given @time_,
29991 * possibly adjusting @time_ if required to fit into an interval.
29992 * The meaning of @time_ depends on @type.
29994 * This function is similar to g_time_zone_find_interval(), with the
29995 * difference that it always succeeds (by making the adjustments
29996 * described below).
29998 * In any of the cases where g_time_zone_find_interval() succeeds then
29999 * this function returns the same value, without modifying @time_.
30001 * This function may, however, modify @time_ in order to deal with
30002 * non-existent times. If the non-existent local @time_ of 02:30 were
30003 * requested on March 14th 2010 in Toronto then this function would
30004 * adjust @time_ to be 03:00 and return the interval containing the
30007 * Returns: the interval containing @time_, never -1
30013 * g_time_zone_find_interval:
30014 * @tz: a #GTimeZone
30015 * @type: the #GTimeType of @time_
30016 * @time_: a number of seconds since January 1, 1970
30018 * Finds an the interval within @tz that corresponds to the given @time_.
30019 * The meaning of @time_ depends on @type.
30021 * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
30022 * succeed (since universal time is monotonic and continuous).
30024 * Otherwise @time_ is treated is local time. The distinction between
30025 * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
30026 * the case that the given @time_ is ambiguous. In Toronto, for example,
30027 * 01:30 on November 7th 2010 occurred twice (once inside of daylight
30028 * savings time and the next, an hour later, outside of daylight savings
30029 * time). In this case, the different value of @type would result in a
30030 * different interval being returned.
30032 * It is still possible for this function to fail. In Toronto, for
30033 * example, 02:00 on March 14th 2010 does not exist (due to the leap
30034 * forward to begin daylight savings time). -1 is returned in that
30037 * Returns: the interval containing @time_, or -1 in case of failure
30043 * g_time_zone_get_abbreviation:
30044 * @tz: a #GTimeZone
30045 * @interval: an interval within the timezone
30047 * Determines the time zone abbreviation to be used during a particular
30048 * @interval of time in the time zone @tz.
30050 * For example, in Toronto this is currently "EST" during the winter
30051 * months and "EDT" during the summer months when daylight savings time
30054 * Returns: the time zone abbreviation, which belongs to @tz
30060 * g_time_zone_get_offset:
30061 * @tz: a #GTimeZone
30062 * @interval: an interval within the timezone
30064 * Determines the offset to UTC in effect during a particular @interval
30065 * of time in the time zone @tz.
30067 * The offset is the number of seconds that you add to UTC time to
30068 * arrive at local time for @tz (ie: negative numbers for time zones
30069 * west of GMT, positive numbers for east).
30071 * Returns: the number of seconds that should be added to UTC to get the
30072 * local time in @tz
30078 * g_time_zone_is_dst:
30079 * @tz: a #GTimeZone
30080 * @interval: an interval within the timezone
30082 * Determines if daylight savings time is in effect during a particular
30083 * @interval of time in the time zone @tz.
30085 * Returns: %TRUE if daylight savings time is in effect
30092 * @identifier: (allow-none): a timezone identifier
30094 * Creates a #GTimeZone corresponding to @identifier.
30096 * @identifier can either be an RFC3339/ISO 8601 time offset or
30097 * something that would pass as a valid value for the
30098 * <varname>TZ</varname> environment variable (including %NULL).
30100 * In Windows, @identifier can also be the unlocalized name of a time
30101 * zone for standard time, for example "Pacific Standard Time".
30103 * Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
30104 * <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
30105 * <literal>"±hhmm"</literal> and <literal>"±hh"</literal>. Offsets are
30106 * time values to be added to Coordinated Universal Time (UTC) to get
30109 * In Unix, the <varname>TZ</varname> environment variable typically
30110 * corresponds to the name of a file in the zoneinfo database, or
30111 * string in "std offset [dst [offset],start[/time],end[/time]]"
30112 * (POSIX) format. There are no spaces in the specification. The
30113 * name of standard and daylight savings time zone must be three or more
30114 * alphabetic characters. Offsets are time values to be added to local
30115 * time to get Coordinated Universal Time (UTC) and should be
30116 * <literal>"[±]hh[[:]mm[:ss]]"</literal>. Dates are either
30117 * <literal>"Jn"</literal> (Julian day with n between 1 and 365, leap
30118 * years not counted), <literal>"n"</literal> (zero-based Julian day
30119 * with n between 0 and 365) or <literal>"Mm.w.d"</literal> (day d
30120 * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
30121 * 0 is a Sunday). Times are in local wall clock time, the default is
30124 * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
30125 * accepts POSIX format. The Windows format uses US rules for all time
30126 * zones; daylight savings time is 60 minutes behind the standard time
30127 * with date and time of change taken from Pacific Standard Time.
30128 * Offsets are time values to be added to the local time to get
30129 * Coordinated Universal Time (UTC).
30131 * g_time_zone_new_local() calls this function with the value of the
30132 * <varname>TZ</varname> environment variable. This function itself is
30133 * independent of the value of <varname>TZ</varname>, but if @identifier
30134 * is %NULL then <filename>/etc/localtime</filename> will be consulted
30135 * to discover the correct time zone on Unix and the registry will be
30136 * consulted or GetTimeZoneInformation() will be used to get the local
30137 * time zone on Windows.
30139 * If intervals are not available, only time zone rules from
30140 * <varname>TZ</varname> environment variable or other means, then they
30141 * will be computed from year 1900 to 2037. If the maximum year for the
30142 * rules is available and it is greater than 2037, then it will followed
30146 * url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
30147 * §5.6</ulink> for a precise definition of valid RFC3339 time offsets
30148 * (the <varname>time-offset</varname> expansion) and ISO 8601 for the
30149 * full list of valid time offsets. See <ulink
30150 * url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
30151 * GNU C Library manual</ulink> for an explanation of the possible
30152 * values of the <varname>TZ</varname> environment variable. See <ulink
30153 * url='http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx'>
30154 * Microsoft Time Zone Index Values</ulink> for the list of time zones
30157 * You should release the return value by calling g_time_zone_unref()
30158 * when you are done with it.
30160 * Returns: the requested timezone
30166 * g_time_zone_new_local:
30168 * Creates a #GTimeZone corresponding to local time. The local time
30169 * zone may change between invocations to this function; for example,
30170 * if the system administrator changes it.
30172 * This is equivalent to calling g_time_zone_new() with the value of the
30173 * <varname>TZ</varname> environment variable (including the possibility
30176 * You should release the return value by calling g_time_zone_unref()
30177 * when you are done with it.
30179 * Returns: the local timezone
30185 * g_time_zone_new_utc:
30187 * Creates a #GTimeZone corresponding to UTC.
30189 * This is equivalent to calling g_time_zone_new() with a value like
30190 * "Z", "UTC", "+00", etc.
30192 * You should release the return value by calling g_time_zone_unref()
30193 * when you are done with it.
30195 * Returns: the universal timezone
30202 * @tz: a #GTimeZone
30204 * Increases the reference count on @tz.
30206 * Returns: a new reference to @tz.
30212 * g_time_zone_unref:
30213 * @tz: a #GTimeZone
30215 * Decreases the reference count on @tz.
30223 * @interval: the time between calls to the function, in milliseconds
30224 * (1/1000ths of a second)
30225 * @function: function to call
30226 * @data: data to pass to @function
30228 * Sets a function to be called at regular intervals, with the default
30229 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
30230 * until it returns %FALSE, at which point the timeout is automatically
30231 * destroyed and the function will not be called again. The first call
30232 * to the function will be at the end of the first @interval.
30234 * Note that timeout functions may be delayed, due to the processing of other
30235 * event sources. Thus they should not be relied on for precise timing.
30236 * After each call to the timeout function, the time of the next
30237 * timeout is recalculated based on the current time and the given interval
30238 * (it does not try to 'catch up' time lost in delays).
30240 * If you want to have a timer in the "seconds" range and do not care
30241 * about the exact time of the first call of the timer, use the
30242 * g_timeout_add_seconds() function; this function allows for more
30243 * optimizations and more efficient system power usage.
30245 * This internally creates a main loop source using g_timeout_source_new()
30246 * and attaches it to the main loop context using g_source_attach(). You can
30247 * do these steps manually if you need greater control.
30249 * The interval given is in terms of monotonic time, not wall clock
30250 * time. See g_get_monotonic_time().
30252 * Returns: the ID (greater than 0) of the event source.
30257 * g_timeout_add_full: (rename-to g_timeout_add)
30258 * @priority: the priority of the timeout source. Typically this will be in
30259 * the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30260 * @interval: the time between calls to the function, in milliseconds
30261 * (1/1000ths of a second)
30262 * @function: function to call
30263 * @data: data to pass to @function
30264 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
30266 * Sets a function to be called at regular intervals, with the given
30267 * priority. The function is called repeatedly until it returns
30268 * %FALSE, at which point the timeout is automatically destroyed and
30269 * the function will not be called again. The @notify function is
30270 * called when the timeout is destroyed. The first call to the
30271 * function will be at the end of the first @interval.
30273 * Note that timeout functions may be delayed, due to the processing of other
30274 * event sources. Thus they should not be relied on for precise timing.
30275 * After each call to the timeout function, the time of the next
30276 * timeout is recalculated based on the current time and the given interval
30277 * (it does not try to 'catch up' time lost in delays).
30279 * This internally creates a main loop source using g_timeout_source_new()
30280 * and attaches it to the main loop context using g_source_attach(). You can
30281 * do these steps manually if you need greater control.
30283 * The interval given in terms of monotonic time, not wall clock time.
30284 * See g_get_monotonic_time().
30286 * Returns: the ID (greater than 0) of the event source.
30291 * g_timeout_add_seconds:
30292 * @interval: the time between calls to the function, in seconds
30293 * @function: function to call
30294 * @data: data to pass to @function
30296 * Sets a function to be called at regular intervals with the default
30297 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
30298 * it returns %FALSE, at which point the timeout is automatically destroyed
30299 * and the function will not be called again.
30301 * This internally creates a main loop source using
30302 * g_timeout_source_new_seconds() and attaches it to the main loop context
30303 * using g_source_attach(). You can do these steps manually if you need
30304 * greater control. Also see g_timeout_add_seconds_full().
30306 * Note that the first call of the timer may not be precise for timeouts
30307 * of one second. If you need finer precision and have such a timeout,
30308 * you may want to use g_timeout_add() instead.
30310 * The interval given is in terms of monotonic time, not wall clock
30311 * time. See g_get_monotonic_time().
30313 * Returns: the ID (greater than 0) of the event source.
30319 * g_timeout_add_seconds_full: (rename-to g_timeout_add_seconds)
30320 * @priority: the priority of the timeout source. Typically this will be in
30321 * the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30322 * @interval: the time between calls to the function, in seconds
30323 * @function: function to call
30324 * @data: data to pass to @function
30325 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
30327 * Sets a function to be called at regular intervals, with @priority.
30328 * The function is called repeatedly until it returns %FALSE, at which
30329 * point the timeout is automatically destroyed and the function will
30330 * not be called again.
30332 * Unlike g_timeout_add(), this function operates at whole second granularity.
30333 * The initial starting point of the timer is determined by the implementation
30334 * and the implementation is expected to group multiple timers together so that
30335 * they fire all at the same time.
30336 * To allow this grouping, the @interval to the first timer is rounded
30337 * and can deviate up to one second from the specified interval.
30338 * Subsequent timer iterations will generally run at the specified interval.
30340 * Note that timeout functions may be delayed, due to the processing of other
30341 * event sources. Thus they should not be relied on for precise timing.
30342 * After each call to the timeout function, the time of the next
30343 * timeout is recalculated based on the current time and the given @interval
30345 * If you want timing more precise than whole seconds, use g_timeout_add()
30348 * The grouping of timers to fire at the same time results in a more power
30349 * and CPU efficient behavior so if your timer is in multiples of seconds
30350 * and you don't require the first timer exactly one second from now, the
30351 * use of g_timeout_add_seconds() is preferred over g_timeout_add().
30353 * This internally creates a main loop source using
30354 * g_timeout_source_new_seconds() and attaches it to the main loop context
30355 * using g_source_attach(). You can do these steps manually if you need
30358 * The interval given is in terms of monotonic time, not wall clock
30359 * time. See g_get_monotonic_time().
30361 * Returns: the ID (greater than 0) of the event source.
30367 * g_timeout_source_new:
30368 * @interval: the timeout interval in milliseconds.
30370 * Creates a new timeout source.
30372 * The source will not initially be associated with any #GMainContext
30373 * and must be added to one with g_source_attach() before it will be
30376 * The interval given is in terms of monotonic time, not wall clock
30377 * time. See g_get_monotonic_time().
30379 * Returns: the newly-created timeout source
30384 * g_timeout_source_new_seconds:
30385 * @interval: the timeout interval in seconds
30387 * Creates a new timeout source.
30389 * The source will not initially be associated with any #GMainContext
30390 * and must be added to one with g_source_attach() before it will be
30393 * The scheduling granularity/accuracy of this timeout source will be
30396 * The interval given in terms of monotonic time, not wall clock time.
30397 * See g_get_monotonic_time().
30399 * Returns: the newly-created timeout source
30405 * g_timer_continue:
30406 * @timer: a #GTimer.
30408 * Resumes a timer that has previously been stopped with
30409 * g_timer_stop(). g_timer_stop() must be called before using this
30418 * @timer: a #GTimer to destroy.
30420 * Destroys a timer, freeing associated resources.
30426 * @timer: a #GTimer.
30427 * @microseconds: return location for the fractional part of seconds
30428 * elapsed, in microseconds (that is, the total number
30429 * of microseconds elapsed, modulo 1000000), or %NULL
30431 * If @timer has been started but not stopped, obtains the time since
30432 * the timer was started. If @timer has been stopped, obtains the
30433 * elapsed time between the time it was started and the time it was
30434 * stopped. The return value is the number of seconds elapsed,
30435 * including any fractional part. The @microseconds out parameter is
30436 * essentially useless.
30438 * Returns: seconds elapsed as a floating point value, including any
30446 * Creates a new timer, and starts timing (i.e. g_timer_start() is
30447 * implicitly called for you).
30449 * Returns: a new #GTimer.
30455 * @timer: a #GTimer.
30457 * This function is useless; it's fine to call g_timer_start() on an
30458 * already-started timer to reset the start time, so g_timer_reset()
30459 * serves no purpose.
30465 * @timer: a #GTimer.
30467 * Marks a start time, so that future calls to g_timer_elapsed() will
30468 * report the time since g_timer_start() was called. g_timer_new()
30469 * automatically marks the start time, so no need to call
30470 * g_timer_start() immediately after creating the timer.
30476 * @timer: a #GTimer.
30478 * Marks an end time, so calls to g_timer_elapsed() will return the
30479 * difference between this end time and the start time.
30484 * g_trash_stack_height:
30485 * @stack_p: a #GTrashStack
30487 * Returns the height of a #GTrashStack.
30489 * Note that execution of this function is of O(N) complexity
30490 * where N denotes the number of items on the stack.
30492 * Returns: the height of the stack
30497 * g_trash_stack_peek:
30498 * @stack_p: a #GTrashStack
30500 * Returns the element at the top of a #GTrashStack
30501 * which may be %NULL.
30503 * Returns: the element at the top of the stack
30508 * g_trash_stack_pop:
30509 * @stack_p: a #GTrashStack
30511 * Pops a piece of memory off a #GTrashStack.
30513 * Returns: the element at the top of the stack
30518 * g_trash_stack_push:
30519 * @stack_p: a #GTrashStack
30520 * @data_p: the piece of memory to push on the stack
30522 * Pushes a piece of memory onto a #GTrashStack.
30530 * Removes all keys and values from the #GTree and decreases its
30531 * reference count by one. If keys and/or values are dynamically
30532 * allocated, you should either free them first or create the #GTree
30533 * using g_tree_new_full(). In the latter case the destroy functions
30534 * you supplied will be called on all keys and values before destroying
30542 * @func: the function to call for each node visited.
30543 * If this function returns %TRUE, the traversal is stopped.
30544 * @user_data: user data to pass to the function.
30546 * Calls the given function for each of the key/value pairs in the #GTree.
30547 * The function is passed the key and value of each pair, and the given
30548 * @data parameter. The tree is traversed in sorted order.
30550 * The tree may not be modified while iterating over it (you can't
30551 * add/remove items). To remove all items matching a predicate, you need
30552 * to add each item to a list in your #GTraverseFunc as you walk over
30553 * the tree, then walk the list and remove each item.
30561 * Gets the height of a #GTree.
30563 * If the #GTree contains no nodes, the height is 0.
30564 * If the #GTree contains only one root node the height is 1.
30565 * If the root node has children the height is 2, etc.
30567 * Returns: the height of the #GTree.
30574 * @key: the key to insert.
30575 * @value: the value corresponding to the key.
30577 * Inserts a key/value pair into a #GTree. If the given key already exists
30578 * in the #GTree its corresponding value is set to the new value. If you
30579 * supplied a value_destroy_func when creating the #GTree, the old value is
30580 * freed using that function. If you supplied a @key_destroy_func when
30581 * creating the #GTree, the passed key is freed using that function.
30583 * The tree is automatically 'balanced' as new key/value pairs are added,
30584 * so that the distance from the root to every leaf is as small as possible.
30591 * @key: the key to look up.
30593 * Gets the value corresponding to the given key. Since a #GTree is
30594 * automatically balanced as key/value pairs are added, key lookup is very
30597 * Returns: the value corresponding to the key, or %NULL if the key was
30603 * g_tree_lookup_extended:
30605 * @lookup_key: the key to look up.
30606 * @orig_key: returns the original key.
30607 * @value: returns the value associated with the key.
30609 * Looks up a key in the #GTree, returning the original key and the
30610 * associated value and a #gboolean which is %TRUE if the key was found. This
30611 * is useful if you need to free the memory allocated for the original key,
30612 * for example before calling g_tree_remove().
30614 * Returns: %TRUE if the key was found in the #GTree.
30620 * @key_compare_func: the function used to order the nodes in the #GTree.
30621 * It should return values similar to the standard strcmp() function -
30622 * 0 if the two arguments are equal, a negative value if the first argument
30623 * comes before the second, or a positive value if the first argument comes
30624 * after the second.
30626 * Creates a new #GTree.
30628 * Returns: a new #GTree.
30634 * @key_compare_func: qsort()-style comparison function.
30635 * @key_compare_data: data to pass to comparison function.
30636 * @key_destroy_func: a function to free the memory allocated for the key
30637 * used when removing the entry from the #GTree or %NULL if you don't
30638 * want to supply such a function.
30639 * @value_destroy_func: a function to free the memory allocated for the
30640 * value used when removing the entry from the #GTree or %NULL if you
30641 * don't want to supply such a function.
30643 * Creates a new #GTree like g_tree_new() and allows to specify functions
30644 * to free the memory allocated for the key and value that get called when
30645 * removing the entry from the #GTree.
30647 * Returns: a new #GTree.
30652 * g_tree_new_with_data:
30653 * @key_compare_func: qsort()-style comparison function.
30654 * @key_compare_data: data to pass to comparison function.
30656 * Creates a new #GTree with a comparison function that accepts user data.
30657 * See g_tree_new() for more details.
30659 * Returns: a new #GTree.
30667 * Gets the number of nodes in a #GTree.
30669 * Returns: the number of nodes in the #GTree.
30677 * Increments the reference count of @tree by one. It is safe to call
30678 * this function from any thread.
30680 * Returns: the passed in #GTree.
30688 * @key: the key to remove.
30690 * Removes a key/value pair from a #GTree.
30692 * If the #GTree was created using g_tree_new_full(), the key and value
30693 * are freed using the supplied destroy functions, otherwise you have to
30694 * make sure that any dynamically allocated values are freed yourself.
30695 * If the key does not exist in the #GTree, the function does nothing.
30697 * Returns: %TRUE if the key was found (prior to 2.8, this function returned
30705 * @key: the key to insert.
30706 * @value: the value corresponding to the key.
30708 * Inserts a new key and value into a #GTree similar to g_tree_insert().
30709 * The difference is that if the key already exists in the #GTree, it gets
30710 * replaced by the new key. If you supplied a @value_destroy_func when
30711 * creating the #GTree, the old value is freed using that function. If you
30712 * supplied a @key_destroy_func when creating the #GTree, the old key is
30713 * freed using that function.
30715 * The tree is automatically 'balanced' as new key/value pairs are added,
30716 * so that the distance from the root to every leaf is as small as possible.
30723 * @search_func: a function used to search the #GTree
30724 * @user_data: the data passed as the second argument to @search_func
30726 * Searches a #GTree using @search_func.
30728 * The @search_func is called with a pointer to the key of a key/value
30729 * pair in the tree, and the passed in @user_data. If @search_func returns
30730 * 0 for a key/value pair, then the corresponding value is returned as
30731 * the result of g_tree_search(). If @search_func returns -1, searching
30732 * will proceed among the key/value pairs that have a smaller key; if
30733 * @search_func returns 1, searching will proceed among the key/value
30734 * pairs that have a larger key.
30736 * Returns: the value corresponding to the found key, or %NULL if
30737 * the key was not found.
30744 * @key: the key to remove.
30746 * Removes a key and its associated value from a #GTree without calling
30747 * the key and value destroy functions.
30749 * If the key does not exist in the #GTree, the function does nothing.
30751 * Returns: %TRUE if the key was found (prior to 2.8, this function returned
30759 * @traverse_func: the function to call for each node visited. If this
30760 * function returns %TRUE, the traversal is stopped.
30761 * @traverse_type: the order in which nodes are visited, one of %G_IN_ORDER,
30762 * %G_PRE_ORDER and %G_POST_ORDER.
30763 * @user_data: user data to pass to the function.
30765 * Calls the given function for each node in the #GTree.
30767 * Deprecated: 2.2: The order of a balanced tree is somewhat arbitrary. If you
30768 * just want to visit all nodes in sorted order, use g_tree_foreach()
30769 * instead. If you really need to visit nodes in a different order, consider
30770 * using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
30778 * Decrements the reference count of @tree by one. If the reference count
30779 * drops to 0, all keys and values will be destroyed (if destroy
30780 * functions were specified) and all memory allocated by @tree will be
30783 * It is safe to call this function from any thread.
30791 * @n_bytes: number of bytes to allocate.
30793 * Attempts to allocate @n_bytes, and returns %NULL on failure.
30794 * Contrast with g_malloc(), which aborts the program on failure.
30796 * Returns: the allocated memory, or %NULL.
30802 * @n_bytes: number of bytes to allocate
30804 * Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
30805 * failure. Contrast with g_malloc0(), which aborts the program on failure.
30808 * Returns: the allocated memory, or %NULL
30814 * @n_blocks: the number of blocks to allocate
30815 * @n_block_bytes: the size of each block in bytes
30817 * This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
30818 * but care is taken to detect possible overflow during multiplication.
30821 * Returns: the allocated memory, or %NULL
30827 * @n_blocks: the number of blocks to allocate
30828 * @n_block_bytes: the size of each block in bytes
30830 * This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
30831 * but care is taken to detect possible overflow during multiplication.
30834 * Returns: the allocated memory, or %NULL.
30840 * @mem: (allow-none): previously-allocated memory, or %NULL.
30841 * @n_bytes: number of bytes to allocate.
30843 * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
30844 * on failure. Contrast with g_realloc(), which aborts the program
30845 * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
30847 * Returns: the allocated memory, or %NULL.
30853 * @mem: (allow-none): previously-allocated memory, or %NULL.
30854 * @n_blocks: the number of blocks to allocate
30855 * @n_block_bytes: the size of each block in bytes
30857 * This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
30858 * but care is taken to detect possible overflow during multiplication.
30861 * Returns: the allocated memory, or %NULL.
30867 * @str: a UCS-4 encoded string
30868 * @len: the maximum length (number of characters) of @str to use.
30869 * If @len < 0, then the string is nul-terminated.
30870 * @items_read: (allow-none): location to store number of bytes read, or %NULL.
30871 * If an error occurs then the index of the invalid input
30873 * @items_written: (allow-none): location to store number of <type>gunichar2</type>
30874 * written, or %NULL. The value stored here does not
30875 * include the trailing 0.
30876 * @error: location to store the error occurring, or %NULL to ignore
30877 * errors. Any of the errors in #GConvertError other than
30878 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
30880 * Convert a string from UCS-4 to UTF-16. A 0 character will be
30881 * added to the result after the converted text.
30883 * Returns: a pointer to a newly allocated UTF-16 string.
30884 * This value must be freed with g_free(). If an
30885 * error occurs, %NULL will be returned and
30892 * @str: a UCS-4 encoded string
30893 * @len: the maximum length (number of characters) of @str to use.
30894 * If @len < 0, then the string is nul-terminated.
30895 * @items_read: (allow-none): location to store number of characters read, or %NULL.
30896 * @items_written: (allow-none): location to store number of bytes written or %NULL.
30897 * The value here stored does not include the trailing 0
30899 * @error: location to store the error occurring, or %NULL to ignore
30900 * errors. Any of the errors in #GConvertError other than
30901 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
30903 * Convert a string from a 32-bit fixed width representation as UCS-4.
30904 * to UTF-8. The result will be terminated with a 0 byte.
30906 * Returns: a pointer to a newly allocated UTF-8 string.
30907 * This value must be freed with g_free(). If an
30908 * error occurs, %NULL will be returned and
30909 * @error set. In that case, @items_read will be
30910 * set to the position of the first invalid input
30916 * g_unichar_break_type:
30917 * @c: a Unicode character
30919 * Determines the break type of @c. @c should be a Unicode character
30920 * (to derive a character from UTF-8 encoded text, use
30921 * g_utf8_get_char()). The break type is used to find word and line
30922 * breaks ("text boundaries"), Pango implements the Unicode boundary
30923 * resolution algorithms and normally you would use a function such
30924 * as pango_break() instead of caring about break types yourself.
30926 * Returns: the break type of @c
30931 * g_unichar_combining_class:
30932 * @uc: a Unicode character
30934 * Determines the canonical combining class of a Unicode character.
30936 * Returns: the combining class of the character
30942 * g_unichar_compose:
30943 * @a: a Unicode character
30944 * @b: a Unicode character
30945 * @ch: return location for the composed character
30947 * Performs a single composition step of the
30948 * Unicode canonical composition algorithm.
30950 * This function includes algorithmic Hangul Jamo composition,
30951 * but it is not exactly the inverse of g_unichar_decompose().
30952 * No composition can have either of @a or @b equal to zero.
30953 * To be precise, this function composes if and only if
30954 * there exists a Primary Composite P which is canonically
30955 * equivalent to the sequence <@a,@b>. See the Unicode
30956 * Standard for the definition of Primary Composite.
30958 * If @a and @b do not compose a new character, @ch is set to zero.
30960 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
30963 * Returns: %TRUE if the characters could be composed
30969 * g_unichar_decompose:
30970 * @ch: a Unicode character
30971 * @a: return location for the first component of @ch
30972 * @b: return location for the second component of @ch
30974 * Performs a single decomposition step of the
30975 * Unicode canonical decomposition algorithm.
30977 * This function does not include compatibility
30978 * decompositions. It does, however, include algorithmic
30979 * Hangul Jamo decomposition, as well as 'singleton'
30980 * decompositions which replace a character by a single
30981 * other character. In the case of singletons *@b will
30984 * If @ch is not decomposable, *@a is set to @ch and *@b
30987 * Note that the way Unicode decomposition pairs are
30988 * defined, it is guaranteed that @b would not decompose
30989 * further, but @a may itself decompose. To get the full
30990 * canonical decomposition for @ch, one would need to
30991 * recursively call this function on @a. Or use
30992 * g_unichar_fully_decompose().
30994 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
30997 * Returns: %TRUE if the character could be decomposed
31003 * g_unichar_digit_value:
31004 * @c: a Unicode character
31006 * Determines the numeric value of a character as a decimal
31009 * Returns: If @c is a decimal digit (according to
31010 * g_unichar_isdigit()), its numeric value. Otherwise, -1.
31015 * g_unichar_fully_decompose:
31016 * @ch: a Unicode character.
31017 * @compat: whether perform canonical or compatibility decomposition
31018 * @result: (allow-none): location to store decomposed result, or %NULL
31019 * @result_len: length of @result
31021 * Computes the canonical or compatibility decomposition of a
31022 * Unicode character. For compatibility decomposition,
31023 * pass %TRUE for @compat; for canonical decomposition
31024 * pass %FALSE for @compat.
31026 * The decomposed sequence is placed in @result. Only up to
31027 * @result_len characters are written into @result. The length
31028 * of the full decomposition (irrespective of @result_len) is
31029 * returned by the function. For canonical decomposition,
31030 * currently all decompositions are of length at most 4, but
31031 * this may change in the future (very unlikely though).
31032 * At any rate, Unicode does guarantee that a buffer of length
31033 * 18 is always enough for both compatibility and canonical
31034 * decompositions, so that is the size recommended. This is provided
31035 * as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
31037 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
31040 * Returns: the length of the full decomposition.
31046 * g_unichar_get_mirror_char:
31047 * @ch: a Unicode character
31048 * @mirrored_ch: location to store the mirrored character
31050 * In Unicode, some characters are <firstterm>mirrored</firstterm>. This
31051 * means that their images are mirrored horizontally in text that is laid
31052 * out from right to left. For instance, "(" would become its mirror image,
31053 * ")", in right-to-left text.
31055 * If @ch has the Unicode mirrored property and there is another unicode
31056 * character that typically has a glyph that is the mirror image of @ch's
31057 * glyph and @mirrored_ch is set, it puts that character in the address
31058 * pointed to by @mirrored_ch. Otherwise the original character is put.
31060 * Returns: %TRUE if @ch has a mirrored character, %FALSE otherwise
31066 * g_unichar_get_script:
31067 * @ch: a Unicode character
31069 * Looks up the #GUnicodeScript for a particular character (as defined
31070 * by Unicode Standard Annex \#24). No check is made for @ch being a
31071 * valid Unicode character; if you pass in invalid character, the
31072 * result is undefined.
31074 * This function is equivalent to pango_script_for_unichar() and the
31075 * two are interchangeable.
31077 * Returns: the #GUnicodeScript for the character.
31083 * g_unichar_isalnum:
31084 * @c: a Unicode character
31086 * Determines whether a character is alphanumeric.
31087 * Given some UTF-8 text, obtain a character value
31088 * with g_utf8_get_char().
31090 * Returns: %TRUE if @c is an alphanumeric character
31095 * g_unichar_isalpha:
31096 * @c: a Unicode character
31098 * Determines whether a character is alphabetic (i.e. a letter).
31099 * Given some UTF-8 text, obtain a character value with
31100 * g_utf8_get_char().
31102 * Returns: %TRUE if @c is an alphabetic character
31107 * g_unichar_iscntrl:
31108 * @c: a Unicode character
31110 * Determines whether a character is a control character.
31111 * Given some UTF-8 text, obtain a character value with
31112 * g_utf8_get_char().
31114 * Returns: %TRUE if @c is a control character
31119 * g_unichar_isdefined:
31120 * @c: a Unicode character
31122 * Determines if a given character is assigned in the Unicode
31125 * Returns: %TRUE if the character has an assigned value
31130 * g_unichar_isdigit:
31131 * @c: a Unicode character
31133 * Determines whether a character is numeric (i.e. a digit). This
31134 * covers ASCII 0-9 and also digits in other languages/scripts. Given
31135 * some UTF-8 text, obtain a character value with g_utf8_get_char().
31137 * Returns: %TRUE if @c is a digit
31142 * g_unichar_isgraph:
31143 * @c: a Unicode character
31145 * Determines whether a character is printable and not a space
31146 * (returns %FALSE for control characters, format characters, and
31147 * spaces). g_unichar_isprint() is similar, but returns %TRUE for
31148 * spaces. Given some UTF-8 text, obtain a character value with
31149 * g_utf8_get_char().
31151 * Returns: %TRUE if @c is printable unless it's a space
31156 * g_unichar_islower:
31157 * @c: a Unicode character
31159 * Determines whether a character is a lowercase letter.
31160 * Given some UTF-8 text, obtain a character value with
31161 * g_utf8_get_char().
31163 * Returns: %TRUE if @c is a lowercase letter
31168 * g_unichar_ismark:
31169 * @c: a Unicode character
31171 * Determines whether a character is a mark (non-spacing mark,
31172 * combining mark, or enclosing mark in Unicode speak).
31173 * Given some UTF-8 text, obtain a character value
31174 * with g_utf8_get_char().
31176 * Note: in most cases where isalpha characters are allowed,
31177 * ismark characters should be allowed to as they are essential
31178 * for writing most European languages as well as many non-Latin
31181 * Returns: %TRUE if @c is a mark character
31187 * g_unichar_isprint:
31188 * @c: a Unicode character
31190 * Determines whether a character is printable.
31191 * Unlike g_unichar_isgraph(), returns %TRUE for spaces.
31192 * Given some UTF-8 text, obtain a character value with
31193 * g_utf8_get_char().
31195 * Returns: %TRUE if @c is printable
31200 * g_unichar_ispunct:
31201 * @c: a Unicode character
31203 * Determines whether a character is punctuation or a symbol.
31204 * Given some UTF-8 text, obtain a character value with
31205 * g_utf8_get_char().
31207 * Returns: %TRUE if @c is a punctuation or symbol character
31212 * g_unichar_isspace:
31213 * @c: a Unicode character
31215 * Determines whether a character is a space, tab, or line separator
31216 * (newline, carriage return, etc.). Given some UTF-8 text, obtain a
31217 * character value with g_utf8_get_char().
31219 * (Note: don't use this to do word breaking; you have to use
31220 * Pango or equivalent to get word breaking right, the algorithm
31221 * is fairly complex.)
31223 * Returns: %TRUE if @c is a space character
31228 * g_unichar_istitle:
31229 * @c: a Unicode character
31231 * Determines if a character is titlecase. Some characters in
31232 * Unicode which are composites, such as the DZ digraph
31233 * have three case variants instead of just two. The titlecase
31234 * form is used at the beginning of a word where only the
31235 * first letter is capitalized. The titlecase form of the DZ
31236 * digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
31238 * Returns: %TRUE if the character is titlecase
31243 * g_unichar_isupper:
31244 * @c: a Unicode character
31246 * Determines if a character is uppercase.
31248 * Returns: %TRUE if @c is an uppercase character
31253 * g_unichar_iswide:
31254 * @c: a Unicode character
31256 * Determines if a character is typically rendered in a double-width
31259 * Returns: %TRUE if the character is wide
31264 * g_unichar_iswide_cjk:
31265 * @c: a Unicode character
31267 * Determines if a character is typically rendered in a double-width
31268 * cell under legacy East Asian locales. If a character is wide according to
31269 * g_unichar_iswide(), then it is also reported wide with this function, but
31270 * the converse is not necessarily true. See the
31271 * <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
31272 * Annex #11</ulink> for details.
31274 * If a character passes the g_unichar_iswide() test then it will also pass
31275 * this test, but not the other way around. Note that some characters may
31276 * pas both this test and g_unichar_iszerowidth().
31278 * Returns: %TRUE if the character is wide in legacy East Asian locales
31284 * g_unichar_isxdigit:
31285 * @c: a Unicode character.
31287 * Determines if a character is a hexidecimal digit.
31289 * Returns: %TRUE if the character is a hexadecimal digit
31294 * g_unichar_iszerowidth:
31295 * @c: a Unicode character
31297 * Determines if a given character typically takes zero width when rendered.
31298 * The return value is %TRUE for all non-spacing and enclosing marks
31299 * (e.g., combining accents), format characters, zero-width
31300 * space, but not U+00AD SOFT HYPHEN.
31302 * A typical use of this function is with one of g_unichar_iswide() or
31303 * g_unichar_iswide_cjk() to determine the number of cells a string occupies
31304 * when displayed on a grid display (terminals). However, note that not all
31305 * terminals support zero-width rendering of zero-width marks.
31307 * Returns: %TRUE if the character has zero width
31313 * g_unichar_to_utf8:
31314 * @c: a Unicode character code
31315 * @outbuf: output buffer, must have at least 6 bytes of space.
31316 * If %NULL, the length will be computed and returned
31317 * and nothing will be written to @outbuf.
31319 * Converts a single character to UTF-8.
31321 * Returns: number of bytes written
31326 * g_unichar_tolower:
31327 * @c: a Unicode character.
31329 * Converts a character to lower case.
31331 * Returns: the result of converting @c to lower case.
31332 * If @c is not an upperlower or titlecase character,
31333 * or has no lowercase equivalent @c is returned unchanged.
31338 * g_unichar_totitle:
31339 * @c: a Unicode character
31341 * Converts a character to the titlecase.
31343 * Returns: the result of converting @c to titlecase.
31344 * If @c is not an uppercase or lowercase character,
31345 * @c is returned unchanged.
31350 * g_unichar_toupper:
31351 * @c: a Unicode character
31353 * Converts a character to uppercase.
31355 * Returns: the result of converting @c to uppercase.
31356 * If @c is not an lowercase or titlecase character,
31357 * or has no upper case equivalent @c is returned unchanged.
31363 * @c: a Unicode character
31365 * Classifies a Unicode character by type.
31367 * Returns: the type of the character.
31372 * g_unichar_validate:
31373 * @ch: a Unicode character
31375 * Checks whether @ch is a valid Unicode character. Some possible
31376 * integer values of @ch will not be valid. 0 is considered a valid
31377 * character, though it's normally a string terminator.
31379 * Returns: %TRUE if @ch is a valid Unicode character
31384 * g_unichar_xdigit_value:
31385 * @c: a Unicode character
31387 * Determines the numeric value of a character as a hexidecimal
31390 * Returns: If @c is a hex digit (according to
31391 * g_unichar_isxdigit()), its numeric value. Otherwise, -1.
31396 * g_unicode_canonical_decomposition:
31397 * @ch: a Unicode character.
31398 * @result_len: location to store the length of the return value.
31400 * Computes the canonical decomposition of a Unicode character.
31402 * Returns: a newly allocated string of Unicode characters.
31403 * @result_len is set to the resulting length of the string.
31404 * Deprecated: 2.30: Use the more flexible g_unichar_fully_decompose()
31410 * g_unicode_canonical_ordering:
31411 * @string: a UCS-4 encoded string.
31412 * @len: the maximum length of @string to use.
31414 * Computes the canonical ordering of a string in-place.
31415 * This rearranges decomposed characters in the string
31416 * according to their combining classes. See the Unicode
31417 * manual for more information.
31422 * g_unicode_script_from_iso15924:
31423 * @iso15924: a Unicode script
31425 * Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
31426 * codes to scripts. For example, the code for Arabic is 'Arab'.
31427 * This function accepts four letter codes encoded as a @guint32 in a
31428 * big-endian fashion. That is, the code expected for Arabic is
31429 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
31431 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
31432 * representation of names of scripts</ulink> for details.
31434 * Returns: the Unicode script for @iso15924, or
31435 * of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
31436 * %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
31442 * g_unicode_script_to_iso15924:
31443 * @script: a Unicode script
31445 * Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
31446 * codes to scripts. For example, the code for Arabic is 'Arab'. The
31447 * four letter codes are encoded as a @guint32 by this function in a
31448 * big-endian fashion. That is, the code returned for Arabic is
31449 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
31451 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
31452 * representation of names of scripts</ulink> for details.
31454 * Returns: the ISO 15924 code for @script, encoded as an integer,
31455 * of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
31456 * ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
31463 * @fd: a file descriptor
31464 * @condition: IO conditions to watch for on @fd
31465 * @function: a #GPollFDFunc
31466 * @user_data: data to pass to @function
31468 * Sets a function to be called when the IO condition, as specified by
31469 * @condition becomes true for @fd.
31471 * @function will be called when the specified IO condition becomes
31472 * %TRUE. The function is expected to clear whatever event caused the
31473 * IO condition to become true and return %TRUE in order to be notified
31474 * when it happens again. If @function returns %FALSE then the watch
31475 * will be cancelled.
31477 * The return value of this function can be passed to g_source_remove()
31478 * to cancel the watch at any time that it exists.
31480 * The source will never close the fd -- you must do it yourself.
31482 * Returns: the ID (greater than 0) of the event source
31488 * g_unix_fd_add_full:
31489 * @priority: the priority of the source
31490 * @fd: a file descriptor
31491 * @condition: IO conditions to watch for on @fd
31492 * @function: a #GUnixFDSourceFunc
31493 * @user_data: data to pass to @function
31494 * @notify: function to call when the idle is removed, or %NULL
31496 * Sets a function to be called when the IO condition, as specified by
31497 * @condition becomes true for @fd.
31499 * This is the same as g_unix_fd_add(), except that it allows you to
31500 * specify a non-default priority and a provide a #GDestroyNotify for
31503 * Returns: the ID (greater than 0) of the event source
31509 * g_unix_fd_source_new:
31510 * @fd: a file descriptor
31511 * @condition: IO conditions to watch for on @fd
31513 * Creates a #GSource to watch for a particular IO condition on a file
31516 * The source will never close the fd -- you must do it yourself.
31518 * Returns: the newly created #GSource
31524 * g_unix_open_pipe:
31525 * @fds: Array of two integers
31526 * @flags: Bitfield of file descriptor flags, see "man 2 fcntl"
31527 * @error: a #GError
31529 * Similar to the UNIX pipe() call, but on modern systems like Linux
31530 * uses the pipe2() system call, which atomically creates a pipe with
31531 * the configured flags. The only supported flag currently is
31532 * <literal>FD_CLOEXEC</literal>. If for example you want to configure
31533 * <literal>O_NONBLOCK</literal>, that must still be done separately with
31536 * <note>This function does *not* take <literal>O_CLOEXEC</literal>, it takes
31537 * <literal>FD_CLOEXEC</literal> as if for fcntl(); these are
31538 * different on Linux/glibc.</note>
31540 * Returns: %TRUE on success, %FALSE if not (and errno will be set).
31546 * g_unix_set_fd_nonblocking:
31547 * @fd: A file descriptor
31548 * @nonblock: If %TRUE, set the descriptor to be non-blocking
31549 * @error: a #GError
31551 * Control the non-blocking state of the given file descriptor,
31552 * according to @nonblock. On most systems this uses <literal>O_NONBLOCK</literal>, but
31553 * on some older ones may use <literal>O_NDELAY</literal>.
31555 * Returns: %TRUE if successful
31561 * g_unix_signal_add:
31562 * @signum: Signal number
31563 * @handler: Callback
31564 * @user_data: Data for @handler
31566 * A convenience function for g_unix_signal_source_new(), which
31567 * attaches to the default #GMainContext. You can remove the watch
31568 * using g_source_remove().
31570 * Returns: An ID (greater than 0) for the event source
31576 * g_unix_signal_add_full: (rename-to g_unix_signal_add)
31577 * @priority: the priority of the signal source. Typically this will be in
31578 * the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
31579 * @signum: Signal number
31580 * @handler: Callback
31581 * @user_data: Data for @handler
31582 * @notify: #GDestroyNotify for @handler
31584 * A convenience function for g_unix_signal_source_new(), which
31585 * attaches to the default #GMainContext. You can remove the watch
31586 * using g_source_remove().
31588 * Returns: An ID (greater than 0) for the event source
31594 * g_unix_signal_source_new:
31595 * @signum: A signal number
31597 * Create a #GSource that will be dispatched upon delivery of the UNIX
31598 * signal @signum. In GLib versions before 2.36, only
31599 * <literal>SIGHUP</literal>, <literal>SIGINT</literal>,
31600 * <literal>SIGTERM</literal> can be monitored. In GLib 2.36,
31601 * <literal>SIGUSR1</literal> and <literal>SIGUSR2</literal> were
31604 * Note that unlike the UNIX default, all sources which have created a
31605 * watch will be dispatched, regardless of which underlying thread
31606 * invoked g_unix_signal_source_new().
31608 * For example, an effective use of this function is to handle <literal>SIGTERM</literal>
31609 * cleanly; flushing any outstanding files, and then calling
31610 * g_main_loop_quit (). It is not safe to do any of this a regular
31611 * UNIX signal handler; your handler may be invoked while malloc() or
31612 * another library function is running, causing reentrancy if you
31613 * attempt to use it from the handler. None of the GLib/GObject API
31614 * is safe against this kind of reentrancy.
31616 * The interaction of this source when combined with native UNIX
31617 * functions like sigprocmask() is not defined.
31619 * The source will not initially be associated with any #GMainContext
31620 * and must be added to one with g_source_attach() before it will be
31623 * Returns: A newly created #GSource
31630 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
31632 * A wrapper for the POSIX unlink() function. The unlink() function
31633 * deletes a name from the filesystem. If this was the last link to the
31634 * file and no processes have it opened, the diskspace occupied by the
31637 * See your C library manual for more details about unlink(). Note
31638 * that on Windows, it is in general not possible to delete files that
31639 * are open to some process, or mapped into memory.
31641 * Returns: 0 if the name was successfully deleted, -1 if an error
31649 * @variable: the environment variable to remove, must not contain '='
31651 * Removes an environment variable from the environment.
31653 * Note that on some systems, when variables are overwritten, the
31654 * memory used for the previous variables and its value isn't reclaimed.
31657 * Environment variable handling in UNIX is not thread-safe, and your
31658 * program may crash if one thread calls g_unsetenv() while another
31659 * thread is calling getenv(). (And note that many functions, such as
31660 * gettext(), call getenv() internally.) This function is only safe
31661 * to use at the very start of your program, before creating any other
31662 * threads (or creating objects that create worker threads of their
31665 * If you need to set up the environment for a child process, you can
31666 * use g_get_environ() to get an environment array, modify that with
31667 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
31668 * array directly to execvpe(), g_spawn_async(), or the like.
31669 * </para></warning>
31676 * g_uri_escape_string:
31677 * @unescaped: the unescaped input string.
31678 * @reserved_chars_allowed: (allow-none): a string of reserved characters that
31679 * are allowed to be used, or %NULL.
31680 * @allow_utf8: %TRUE if the result can include UTF-8 characters.
31682 * Escapes a string for use in a URI.
31684 * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
31685 * characters plus dash, dot, underscore and tilde) are escaped.
31686 * But if you specify characters in @reserved_chars_allowed they are not
31687 * escaped. This is useful for the "reserved" characters in the URI
31688 * specification, since those are allowed unescaped in some portions of
31691 * Returns: an escaped version of @unescaped. The returned string should be
31692 * freed when no longer needed.
31698 * g_uri_list_extract_uris:
31699 * @uri_list: an URI list
31701 * Splits an URI list conforming to the text/uri-list
31702 * mime type defined in RFC 2483 into individual URIs,
31703 * discarding any comments. The URIs are not validated.
31705 * Returns: (transfer full): a newly allocated %NULL-terminated list
31706 * of strings holding the individual URIs. The array should be freed
31707 * with g_strfreev().
31713 * g_uri_parse_scheme:
31714 * @uri: a valid URI.
31716 * Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
31718 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
31719 * </programlisting>
31720 * Common schemes include "file", "http", "svn+ssh", etc.
31722 * Returns: The "Scheme" component of the URI, or %NULL on error.
31723 * The returned string should be freed when no longer needed.
31729 * g_uri_unescape_segment:
31730 * @escaped_string: (allow-none): A string, may be %NULL
31731 * @escaped_string_end: (allow-none): Pointer to end of @escaped_string, may be %NULL
31732 * @illegal_characters: (allow-none): An optional string of illegal characters not to be allowed, may be %NULL
31734 * Unescapes a segment of an escaped string.
31736 * If any of the characters in @illegal_characters or the character zero appears
31737 * as an escaped character in @escaped_string then that is an error and %NULL
31738 * will be returned. This is useful it you want to avoid for instance having a
31739 * slash being expanded in an escaped path element, which might confuse pathname
31742 * Returns: an unescaped version of @escaped_string or %NULL on error.
31743 * The returned string should be freed when no longer needed. As a
31744 * special case if %NULL is given for @escaped_string, this function
31745 * will return %NULL.
31751 * g_uri_unescape_string:
31752 * @escaped_string: an escaped string to be unescaped.
31753 * @illegal_characters: (allow-none): a string of illegal characters not to be
31754 * allowed, or %NULL.
31756 * Unescapes a whole escaped string.
31758 * If any of the characters in @illegal_characters or the character zero appears
31759 * as an escaped character in @escaped_string then that is an error and %NULL
31760 * will be returned. This is useful it you want to avoid for instance having a
31761 * slash being expanded in an escaped path element, which might confuse pathname
31764 * Returns: an unescaped version of @escaped_string. The returned string
31765 * should be freed when no longer needed.
31772 * @microseconds: number of microseconds to pause
31774 * Pauses the current thread for the given number of microseconds.
31776 * There are 1 million microseconds per second (represented by the
31777 * #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
31778 * depending on hardware and operating system; don't rely on the exact
31779 * length of the sleep.
31785 * @str: a UTF-16 encoded string
31786 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
31787 * If @len < 0, then the string is nul-terminated.
31788 * @items_read: (allow-none): location to store number of words read, or %NULL.
31789 * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
31790 * returned in case @str contains a trailing partial
31791 * character. If an error occurs then the index of the
31792 * invalid input is stored here.
31793 * @items_written: (allow-none): location to store number of characters written, or %NULL.
31794 * The value stored here does not include the trailing
31796 * @error: location to store the error occurring, or %NULL to ignore
31797 * errors. Any of the errors in #GConvertError other than
31798 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
31800 * Convert a string from UTF-16 to UCS-4. The result will be
31803 * Returns: a pointer to a newly allocated UCS-4 string.
31804 * This value must be freed with g_free(). If an
31805 * error occurs, %NULL will be returned and
31812 * @str: a UTF-16 encoded string
31813 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
31814 * If @len < 0, then the string is nul-terminated.
31815 * @items_read: (allow-none): location to store number of words read, or %NULL.
31816 * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
31817 * returned in case @str contains a trailing partial
31818 * character. If an error occurs then the index of the
31819 * invalid input is stored here.
31820 * @items_written: (allow-none): location to store number of bytes written, or %NULL.
31821 * The value stored here does not include the trailing
31823 * @error: location to store the error occurring, or %NULL to ignore
31824 * errors. Any of the errors in #GConvertError other than
31825 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
31827 * Convert a string from UTF-16 to UTF-8. The result will be
31828 * terminated with a 0 byte.
31830 * Note that the input is expected to be already in native endianness,
31831 * an initial byte-order-mark character is not handled specially.
31832 * g_convert() can be used to convert a byte buffer of UTF-16 data of
31833 * ambiguous endianess.
31835 * Further note that this function does not validate the result
31836 * string; it may e.g. include embedded NUL characters. The only
31837 * validation done by this function is to ensure that the input can
31838 * be correctly interpreted as UTF-16, i.e. it doesn't contain
31839 * things unpaired surrogates.
31841 * Returns: a pointer to a newly allocated UTF-8 string.
31842 * This value must be freed with g_free(). If an
31843 * error occurs, %NULL will be returned and
31850 * @str: a UTF-8 encoded string
31851 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31853 * Converts a string into a form that is independent of case. The
31854 * result will not correspond to any particular case, but can be
31855 * compared for equality or ordered with the results of calling
31856 * g_utf8_casefold() on other strings.
31858 * Note that calling g_utf8_casefold() followed by g_utf8_collate() is
31859 * only an approximation to the correct linguistic case insensitive
31860 * ordering, though it is a fairly good one. Getting this exactly
31861 * right would require a more sophisticated collation function that
31862 * takes case sensitivity into account. GLib does not currently
31863 * provide such a function.
31865 * Returns: a newly allocated string, that is a
31866 * case independent form of @str.
31872 * @str1: a UTF-8 encoded string
31873 * @str2: a UTF-8 encoded string
31875 * Compares two strings for ordering using the linguistically
31876 * correct rules for the <link linkend="setlocale">current locale</link>.
31877 * When sorting a large number of strings, it will be significantly
31878 * faster to obtain collation keys with g_utf8_collate_key() and
31879 * compare the keys with strcmp() when sorting instead of sorting
31880 * the original strings.
31882 * Returns: < 0 if @str1 compares before @str2,
31883 * 0 if they compare equal, > 0 if @str1 compares after @str2.
31888 * g_utf8_collate_key:
31889 * @str: a UTF-8 encoded string.
31890 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31892 * Converts a string into a collation key that can be compared
31893 * with other collation keys produced by the same function using
31896 * The results of comparing the collation keys of two strings
31897 * with strcmp() will always be the same as comparing the two
31898 * original keys with g_utf8_collate().
31900 * Note that this function depends on the
31901 * <link linkend="setlocale">current locale</link>.
31903 * Returns: a newly allocated string. This string should
31904 * be freed with g_free() when you are done with it.
31909 * g_utf8_collate_key_for_filename:
31910 * @str: a UTF-8 encoded string.
31911 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31913 * Converts a string into a collation key that can be compared
31914 * with other collation keys produced by the same function using strcmp().
31916 * In order to sort filenames correctly, this function treats the dot '.'
31917 * as a special case. Most dictionary orderings seem to consider it
31918 * insignificant, thus producing the ordering "event.c" "eventgenerator.c"
31919 * "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
31920 * would like to treat numbers intelligently so that "file1" "file10" "file5"
31921 * is sorted as "file1" "file5" "file10".
31923 * Note that this function depends on the
31924 * <link linkend="setlocale">current locale</link>.
31926 * Returns: a newly allocated string. This string should
31927 * be freed with g_free() when you are done with it.
31933 * g_utf8_find_next_char:
31934 * @p: a pointer to a position within a UTF-8 encoded string
31935 * @end: a pointer to the byte following the end of the string,
31936 * or %NULL to indicate that the string is nul-terminated.
31938 * Finds the start of the next UTF-8 character in the string after @p.
31940 * @p does not have to be at the beginning of a UTF-8 character. No check
31941 * is made to see if the character found is actually valid other than
31942 * it starts with an appropriate byte.
31944 * Returns: a pointer to the found character or %NULL
31949 * g_utf8_find_prev_char:
31950 * @str: pointer to the beginning of a UTF-8 encoded string
31951 * @p: pointer to some position within @str
31953 * Given a position @p with a UTF-8 encoded string @str, find the start
31954 * of the previous UTF-8 character starting before @p. Returns %NULL if no
31955 * UTF-8 characters are present in @str before @p.
31957 * @p does not have to be at the beginning of a UTF-8 character. No check
31958 * is made to see if the character found is actually valid other than
31959 * it starts with an appropriate byte.
31961 * Returns: a pointer to the found character or %NULL.
31967 * @p: a pointer to Unicode character encoded as UTF-8
31969 * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
31970 * If @p does not point to a valid UTF-8 encoded character, results are
31971 * undefined. If you are not sure that the bytes are complete
31972 * valid Unicode characters, you should use g_utf8_get_char_validated()
31975 * Returns: the resulting character
31980 * g_utf8_get_char_validated:
31981 * @p: a pointer to Unicode character encoded as UTF-8
31982 * @max_len: the maximum number of bytes to read, or -1, for no maximum or
31983 * if @p is nul-terminated
31985 * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
31986 * This function checks for incomplete characters, for invalid characters
31987 * such as characters that are out of the range of Unicode, and for
31988 * overlong encodings of valid characters.
31990 * Returns: the resulting character. If @p points to a partial
31991 * sequence at the end of a string that could begin a valid
31992 * character (or if @max_len is zero), returns (gunichar)-2;
31993 * otherwise, if @p does not point to a valid UTF-8 encoded
31994 * Unicode character, returns (gunichar)-1.
31999 * g_utf8_normalize:
32000 * @str: a UTF-8 encoded string.
32001 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32002 * @mode: the type of normalization to perform.
32004 * Converts a string into canonical form, standardizing
32005 * such issues as whether a character with an accent
32006 * is represented as a base character and combining
32007 * accent or as a single precomposed character. The
32008 * string has to be valid UTF-8, otherwise %NULL is
32009 * returned. You should generally call g_utf8_normalize()
32010 * before comparing two Unicode strings.
32012 * The normalization mode %G_NORMALIZE_DEFAULT only
32013 * standardizes differences that do not affect the
32014 * text content, such as the above-mentioned accent
32015 * representation. %G_NORMALIZE_ALL also standardizes
32016 * the "compatibility" characters in Unicode, such
32017 * as SUPERSCRIPT THREE to the standard forms
32018 * (in this case DIGIT THREE). Formatting information
32019 * may be lost but for most text operations such
32020 * characters should be considered the same.
32022 * %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
32023 * are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
32024 * but returned a result with composed forms rather
32025 * than a maximally decomposed form. This is often
32026 * useful if you intend to convert the string to
32027 * a legacy encoding or pass it to a system with
32028 * less capable Unicode handling.
32030 * Returns: a newly allocated string, that is the
32031 * normalized form of @str, or %NULL if @str is not
32037 * g_utf8_offset_to_pointer:
32038 * @str: a UTF-8 encoded string
32039 * @offset: a character offset within @str
32041 * Converts from an integer character offset to a pointer to a position
32042 * within the string.
32044 * Since 2.10, this function allows to pass a negative @offset to
32045 * step backwards. It is usually worth stepping backwards from the end
32046 * instead of forwards if @offset is in the last fourth of the string,
32047 * since moving forward is about 3 times faster than moving backward.
32050 * This function doesn't abort when reaching the end of @str. Therefore
32051 * you should be sure that @offset is within string boundaries before
32052 * calling that function. Call g_utf8_strlen() when unsure.
32054 * This limitation exists as this function is called frequently during
32055 * text rendering and therefore has to be as fast as possible.
32058 * Returns: the resulting pointer
32063 * g_utf8_pointer_to_offset:
32064 * @str: a UTF-8 encoded string
32065 * @pos: a pointer to a position within @str
32067 * Converts from a pointer to position within a string to a integer
32068 * character offset.
32070 * Since 2.10, this function allows @pos to be before @str, and returns
32071 * a negative offset in this case.
32073 * Returns: the resulting character offset
32078 * g_utf8_prev_char:
32079 * @p: a pointer to a position within a UTF-8 encoded string
32081 * Finds the previous UTF-8 character in the string before @p.
32083 * @p does not have to be at the beginning of a UTF-8 character. No check
32084 * is made to see if the character found is actually valid other than
32085 * it starts with an appropriate byte. If @p might be the first
32086 * character of the string, you must use g_utf8_find_prev_char() instead.
32088 * Returns: a pointer to the found character.
32094 * @p: a nul-terminated UTF-8 encoded string
32095 * @len: the maximum length of @p
32096 * @c: a Unicode character
32098 * Finds the leftmost occurrence of the given Unicode character
32099 * in a UTF-8 encoded string, while limiting the search to @len bytes.
32100 * If @len is -1, allow unbounded search.
32102 * Returns: %NULL if the string does not contain the character,
32103 * otherwise, a pointer to the start of the leftmost occurrence of
32104 * the character in the string.
32110 * @str: a UTF-8 encoded string
32111 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32113 * Converts all Unicode characters in the string that have a case
32114 * to lowercase. The exact manner that this is done depends
32115 * on the current locale, and may result in the number of
32116 * characters in the string changing.
32118 * Returns: a newly allocated string, with all characters
32119 * converted to lowercase.
32125 * @p: pointer to the start of a UTF-8 encoded string
32126 * @max: the maximum number of bytes to examine. If @max
32127 * is less than 0, then the string is assumed to be
32128 * nul-terminated. If @max is 0, @p will not be examined and
32129 * may be %NULL. If @max is greater than 0, up to @max
32130 * bytes are examined
32132 * Computes the length of the string in characters, not including
32133 * the terminating nul character. If the @max'th byte falls in the
32134 * middle of a character, the last (partial) character is not counted.
32136 * Returns: the length of the string in characters
32142 * @dest: buffer to fill with characters from @src
32143 * @src: UTF-8 encoded string
32144 * @n: character count
32146 * Like the standard C strncpy() function, but
32147 * copies a given number of characters instead of a given number of
32148 * bytes. The @src string must be valid UTF-8 encoded text.
32149 * (Use g_utf8_validate() on all text before trying to use UTF-8
32150 * utility functions with it.)
32158 * @p: a nul-terminated UTF-8 encoded string
32159 * @len: the maximum length of @p
32160 * @c: a Unicode character
32162 * Find the rightmost occurrence of the given Unicode character
32163 * in a UTF-8 encoded string, while limiting the search to @len bytes.
32164 * If @len is -1, allow unbounded search.
32166 * Returns: %NULL if the string does not contain the character,
32167 * otherwise, a pointer to the start of the rightmost occurrence of the
32168 * character in the string.
32173 * g_utf8_strreverse:
32174 * @str: a UTF-8 encoded string
32175 * @len: the maximum length of @str to use, in bytes. If @len < 0,
32176 * then the string is nul-terminated.
32178 * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
32179 * (Use g_utf8_validate() on all text before trying to use UTF-8
32180 * utility functions with it.)
32182 * This function is intended for programmatic uses of reversed strings.
32183 * It pays no attention to decomposed characters, combining marks, byte
32184 * order marks, directional indicators (LRM, LRO, etc) and similar
32185 * characters which might need special handling when reversing a string
32186 * for display purposes.
32188 * Note that unlike g_strreverse(), this function returns
32189 * newly-allocated memory, which should be freed with g_free() when
32190 * no longer needed.
32192 * Returns: a newly-allocated string which is the reverse of @str.
32199 * @str: a UTF-8 encoded string
32200 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32202 * Converts all Unicode characters in the string that have a case
32203 * to uppercase. The exact manner that this is done depends
32204 * on the current locale, and may result in the number of
32205 * characters in the string increasing. (For instance, the
32206 * German ess-zet will be changed to SS.)
32208 * Returns: a newly allocated string, with all characters
32209 * converted to uppercase.
32214 * g_utf8_substring:
32215 * @str: a UTF-8 encoded string
32216 * @start_pos: a character offset within @str
32217 * @end_pos: another character offset within @str
32219 * Copies a substring out of a UTF-8 encoded string.
32220 * The substring will contain @end_pos - @start_pos
32223 * Returns: a newly allocated copy of the requested
32224 * substring. Free with g_free() when no longer needed.
32231 * @str: a UTF-8 encoded string
32232 * @len: the maximum length of @str to use, in bytes. If @len < 0,
32233 * then the string is nul-terminated.
32234 * @items_read: (allow-none): location to store number of bytes read, or %NULL.
32235 * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
32236 * returned in case @str contains a trailing partial
32237 * character. If an error occurs then the index of the
32238 * invalid input is stored here.
32239 * @items_written: (allow-none): location to store number of characters written or %NULL.
32240 * The value here stored does not include the trailing 0
32242 * @error: location to store the error occurring, or %NULL to ignore
32243 * errors. Any of the errors in #GConvertError other than
32244 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
32246 * Convert a string from UTF-8 to a 32-bit fixed width
32247 * representation as UCS-4. A trailing 0 character will be added to the
32248 * string after the converted text.
32250 * Returns: a pointer to a newly allocated UCS-4 string.
32251 * This value must be freed with g_free(). If an
32252 * error occurs, %NULL will be returned and
32258 * g_utf8_to_ucs4_fast:
32259 * @str: a UTF-8 encoded string
32260 * @len: the maximum length of @str to use, in bytes. If @len < 0,
32261 * then the string is nul-terminated.
32262 * @items_written: (allow-none): location to store the number of characters in the
32263 * result, or %NULL.
32265 * Convert a string from UTF-8 to a 32-bit fixed width
32266 * representation as UCS-4, assuming valid UTF-8 input.
32267 * This function is roughly twice as fast as g_utf8_to_ucs4()
32268 * but does no error checking on the input. A trailing 0 character
32269 * will be added to the string after the converted text.
32271 * Returns: a pointer to a newly allocated UCS-4 string.
32272 * This value must be freed with g_free().
32278 * @str: a UTF-8 encoded string
32279 * @len: the maximum length (number of bytes) of @str to use.
32280 * If @len < 0, then the string is nul-terminated.
32281 * @items_read: (allow-none): location to store number of bytes read, or %NULL.
32282 * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
32283 * returned in case @str contains a trailing partial
32284 * character. If an error occurs then the index of the
32285 * invalid input is stored here.
32286 * @items_written: (allow-none): location to store number of <type>gunichar2</type> written,
32288 * The value stored here does not include the trailing 0.
32289 * @error: location to store the error occurring, or %NULL to ignore
32290 * errors. Any of the errors in #GConvertError other than
32291 * %G_CONVERT_ERROR_NO_CONVERSION may occur.
32293 * Convert a string from UTF-8 to UTF-16. A 0 character will be
32294 * added to the result after the converted text.
32296 * Returns: a pointer to a newly allocated UTF-16 string.
32297 * This value must be freed with g_free(). If an
32298 * error occurs, %NULL will be returned and
32305 * @str: (array length=max_len) (element-type guint8): a pointer to character data
32306 * @max_len: max bytes to validate, or -1 to go until NUL
32307 * @end: (allow-none) (out) (transfer none): return location for end of valid data
32309 * Validates UTF-8 encoded text. @str is the text to validate;
32310 * if @str is nul-terminated, then @max_len can be -1, otherwise
32311 * @max_len should be the number of bytes to validate.
32312 * If @end is non-%NULL, then the end of the valid range
32313 * will be stored there (i.e. the start of the first invalid
32314 * character if some bytes were invalid, or the end of the text
32315 * being validated otherwise).
32317 * Note that g_utf8_validate() returns %FALSE if @max_len is
32318 * positive and any of the @max_len bytes are NUL.
32320 * Returns %TRUE if all of @str was valid. Many GLib and GTK+
32321 * routines <emphasis>require</emphasis> valid UTF-8 as input;
32322 * so data read from a file or the network should be checked
32323 * with g_utf8_validate() before doing anything else with it.
32325 * Returns: %TRUE if the text was valid UTF-8
32331 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
32332 * @utb: a pointer to a struct utimbuf.
32334 * A wrapper for the POSIX utime() function. The utime() function
32335 * sets the access and modification timestamps of a file.
32337 * See your C library manual for more details about how utime() works
32340 * Returns: 0 if the operation was successful, -1 if an error
32347 * g_variant_builder_add: (skp)
32348 * @builder: a #GVariantBuilder
32349 * @format_string: a #GVariant varargs format string
32350 * @...: arguments, as per @format_string
32352 * Adds to a #GVariantBuilder.
32354 * This call is a convenience wrapper that is exactly equivalent to
32355 * calling g_variant_new() followed by g_variant_builder_add_value().
32357 * This function might be used as follows:
32361 * make_pointless_dictionary (void)
32363 * GVariantBuilder *builder;
32366 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
32367 * for (i = 0; i < 16; i++)
32371 * sprintf (buf, "%d", i);
32372 * g_variant_builder_add (builder, "{is}", i, buf);
32375 * return g_variant_builder_end (builder);
32377 * </programlisting>
32384 * g_variant_builder_add_parsed:
32385 * @builder: a #GVariantBuilder
32386 * @format: a text format #GVariant
32387 * @...: arguments as per @format
32389 * Adds to a #GVariantBuilder.
32391 * This call is a convenience wrapper that is exactly equivalent to
32392 * calling g_variant_new_parsed() followed by
32393 * g_variant_builder_add_value().
32395 * This function might be used as follows:
32399 * make_pointless_dictionary (void)
32401 * GVariantBuilder *builder;
32404 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
32405 * g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
32406 * g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
32407 * g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
32408 * return g_variant_builder_end (builder);
32410 * </programlisting>
32417 * g_variant_builder_add_value:
32418 * @builder: a #GVariantBuilder
32419 * @value: a #GVariant
32421 * Adds @value to @builder.
32423 * It is an error to call this function in any way that would create an
32424 * inconsistent value to be constructed. Some examples of this are
32425 * putting different types of items into an array, putting the wrong
32426 * types or number of items in a tuple, putting more than one value into
32429 * If @value is a floating reference (see g_variant_ref_sink()),
32430 * the @builder instance takes ownership of @value.
32437 * g_variant_builder_clear: (skip)
32438 * @builder: a #GVariantBuilder
32440 * Releases all memory associated with a #GVariantBuilder without
32441 * freeing the #GVariantBuilder structure itself.
32443 * It typically only makes sense to do this on a stack-allocated
32444 * #GVariantBuilder if you want to abort building the value part-way
32445 * through. This function need not be called if you call
32446 * g_variant_builder_end() and it also doesn't need to be called on
32447 * builders allocated with g_variant_builder_new (see
32448 * g_variant_builder_unref() for that).
32450 * This function leaves the #GVariantBuilder structure set to all-zeros.
32451 * It is valid to call this function on either an initialised
32452 * #GVariantBuilder or one that is set to all-zeros but it is not valid
32453 * to call this function on uninitialised memory.
32460 * g_variant_builder_close:
32461 * @builder: a #GVariantBuilder
32463 * Closes the subcontainer inside the given @builder that was opened by
32464 * the most recent call to g_variant_builder_open().
32466 * It is an error to call this function in any way that would create an
32467 * inconsistent value to be constructed (ie: too few values added to the
32475 * g_variant_builder_end:
32476 * @builder: a #GVariantBuilder
32478 * Ends the builder process and returns the constructed value.
32480 * It is not permissible to use @builder in any way after this call
32481 * except for reference counting operations (in the case of a
32482 * heap-allocated #GVariantBuilder) or by reinitialising it with
32483 * g_variant_builder_init() (in the case of stack-allocated).
32485 * It is an error to call this function in any way that would create an
32486 * inconsistent value to be constructed (ie: insufficient number of
32487 * items added to a container with a specific number of children
32488 * required). It is also an error to call this function if the builder
32489 * was created with an indefinite array or maybe type and no children
32490 * have been added; in this case it is impossible to infer the type of
32493 * Returns: (transfer none): a new, floating, #GVariant
32499 * g_variant_builder_init: (skip)
32500 * @builder: a #GVariantBuilder
32501 * @type: a container type
32503 * Initialises a #GVariantBuilder structure.
32505 * @type must be non-%NULL. It specifies the type of container to
32506 * construct. It can be an indefinite type such as
32507 * %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
32508 * Maybe, array, tuple, dictionary entry and variant-typed values may be
32511 * After the builder is initialised, values are added using
32512 * g_variant_builder_add_value() or g_variant_builder_add().
32514 * After all the child values are added, g_variant_builder_end() frees
32515 * the memory associated with the builder and returns the #GVariant that
32518 * This function completely ignores the previous contents of @builder.
32519 * On one hand this means that it is valid to pass in completely
32520 * uninitialised memory. On the other hand, this means that if you are
32521 * initialising over top of an existing #GVariantBuilder you need to
32522 * first call g_variant_builder_clear() in order to avoid leaking
32525 * You must not call g_variant_builder_ref() or
32526 * g_variant_builder_unref() on a #GVariantBuilder that was initialised
32527 * with this function. If you ever pass a reference to a
32528 * #GVariantBuilder outside of the control of your own code then you
32529 * should assume that the person receiving that reference may try to use
32530 * reference counting; you should use g_variant_builder_new() instead of
32538 * g_variant_builder_new:
32539 * @type: a container type
32541 * Allocates and initialises a new #GVariantBuilder.
32543 * You should call g_variant_builder_unref() on the return value when it
32544 * is no longer needed. The memory will not be automatically freed by
32547 * In most cases it is easier to place a #GVariantBuilder directly on
32548 * the stack of the calling function and initialise it with
32549 * g_variant_builder_init().
32551 * Returns: (transfer full): a #GVariantBuilder
32557 * g_variant_builder_open:
32558 * @builder: a #GVariantBuilder
32559 * @type: a #GVariantType
32561 * Opens a subcontainer inside the given @builder. When done adding
32562 * items to the subcontainer, g_variant_builder_close() must be called.
32564 * It is an error to call this function in any way that would cause an
32565 * inconsistent value to be constructed (ie: adding too many values or
32566 * a value of an incorrect type).
32573 * g_variant_builder_ref:
32574 * @builder: a #GVariantBuilder allocated by g_variant_builder_new()
32576 * Increases the reference count on @builder.
32578 * Don't call this on stack-allocated #GVariantBuilder instances or bad
32579 * things will happen.
32581 * Returns: (transfer full): a new reference to @builder
32587 * g_variant_builder_unref:
32588 * @builder: (transfer full): a #GVariantBuilder allocated by g_variant_builder_new()
32590 * Decreases the reference count on @builder.
32592 * In the event that there are no more references, releases all memory
32593 * associated with the #GVariantBuilder.
32595 * Don't call this on stack-allocated #GVariantBuilder instances or bad
32596 * things will happen.
32603 * g_variant_byteswap:
32604 * @value: a #GVariant
32606 * Performs a byteswapping operation on the contents of @value. The
32607 * result is that all multi-byte numeric data contained in @value is
32608 * byteswapped. That includes 16, 32, and 64bit signed and unsigned
32609 * integers as well as file handles and double precision floating point
32612 * This function is an identity mapping on any value that does not
32613 * contain multi-byte numeric data. That include strings, booleans,
32614 * bytes and containers containing only these things (recursively).
32616 * The returned value is always in normal form and is marked as trusted.
32618 * Returns: (transfer full): the byteswapped form of @value
32624 * g_variant_check_format_string:
32625 * @value: a #GVariant
32626 * @format_string: a valid #GVariant format string
32627 * @copy_only: %TRUE to ensure the format string makes deep copies
32629 * Checks if calling g_variant_get() with @format_string on @value would
32630 * be valid from a type-compatibility standpoint. @format_string is
32631 * assumed to be a valid format string (from a syntactic standpoint).
32633 * If @copy_only is %TRUE then this function additionally checks that it
32634 * would be safe to call g_variant_unref() on @value immediately after
32635 * the call to g_variant_get() without invalidating the result. This is
32636 * only possible if deep copies are made (ie: there are no pointers to
32637 * the data inside of the soon-to-be-freed #GVariant instance). If this
32638 * check fails then a g_critical() is printed and %FALSE is returned.
32640 * This function is meant to be used by functions that wish to provide
32641 * varargs accessors to #GVariant values of uncertain values (eg:
32642 * g_variant_lookup() or g_menu_model_get_item_attribute()).
32644 * Returns: %TRUE if @format_string is safe to use
32650 * g_variant_classify:
32651 * @value: a #GVariant
32653 * Classifies @value according to its top-level type.
32655 * Returns: the #GVariantClass of @value
32661 * g_variant_compare:
32662 * @one: (type GVariant): a basic-typed #GVariant instance
32663 * @two: (type GVariant): a #GVariant instance of the same type
32665 * Compares @one and @two.
32667 * The types of @one and @two are #gconstpointer only to allow use of
32668 * this function with #GTree, #GPtrArray, etc. They must each be a
32671 * Comparison is only defined for basic types (ie: booleans, numbers,
32672 * strings). For booleans, %FALSE is less than %TRUE. Numbers are
32673 * ordered in the usual way. Strings are in ASCII lexographical order.
32675 * It is a programmer error to attempt to compare container values or
32676 * two values that have types that are not exactly equal. For example,
32677 * you cannot compare a 32-bit signed integer with a 32-bit unsigned
32678 * integer. Also note that this function is not particularly
32679 * well-behaved when it comes to comparison of doubles; in particular,
32680 * the handling of incomparable values (ie: NaN) is undefined.
32682 * If you only require an equality comparison, g_variant_equal() is more
32685 * Returns: negative value if a < b;
32687 * positive value if a > b.
32693 * g_variant_dup_bytestring:
32694 * @value: an array-of-bytes #GVariant instance
32695 * @length: (out) (allow-none) (default NULL): a pointer to a #gsize, to store
32696 * the length (not including the nul terminator)
32698 * Similar to g_variant_get_bytestring() except that instead of
32699 * returning a constant string, the string is duplicated.
32701 * The return value must be freed using g_free().
32703 * Returns: (transfer full) (array zero-terminated=1 length=length) (element-type guint8):
32704 * a newly allocated string
32710 * g_variant_dup_bytestring_array:
32711 * @value: an array of array of bytes #GVariant ('aay')
32712 * @length: (out) (allow-none): the length of the result, or %NULL
32714 * Gets the contents of an array of array of bytes #GVariant. This call
32715 * makes a deep copy; the return result should be released with
32718 * If @length is non-%NULL then the number of elements in the result is
32719 * stored there. In any case, the resulting array will be
32720 * %NULL-terminated.
32722 * For an empty array, @length will be set to 0 and a pointer to a
32723 * %NULL pointer will be returned.
32725 * Returns: (array length=length) (transfer full): an array of strings
32731 * g_variant_dup_objv:
32732 * @value: an array of object paths #GVariant
32733 * @length: (out) (allow-none): the length of the result, or %NULL
32735 * Gets the contents of an array of object paths #GVariant. This call
32736 * makes a deep copy; the return result should be released with
32739 * If @length is non-%NULL then the number of elements in the result
32740 * is stored there. In any case, the resulting array will be
32741 * %NULL-terminated.
32743 * For an empty array, @length will be set to 0 and a pointer to a
32744 * %NULL pointer will be returned.
32746 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
32752 * g_variant_dup_string:
32753 * @value: a string #GVariant instance
32754 * @length: (out): a pointer to a #gsize, to store the length
32756 * Similar to g_variant_get_string() except that instead of returning
32757 * a constant string, the string is duplicated.
32759 * The string will always be utf8 encoded.
32761 * The return value must be freed using g_free().
32763 * Returns: (transfer full): a newly allocated string, utf8 encoded
32769 * g_variant_dup_strv:
32770 * @value: an array of strings #GVariant
32771 * @length: (out) (allow-none): the length of the result, or %NULL
32773 * Gets the contents of an array of strings #GVariant. This call
32774 * makes a deep copy; the return result should be released with
32777 * If @length is non-%NULL then the number of elements in the result
32778 * is stored there. In any case, the resulting array will be
32779 * %NULL-terminated.
32781 * For an empty array, @length will be set to 0 and a pointer to a
32782 * %NULL pointer will be returned.
32784 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
32791 * @one: (type GVariant): a #GVariant instance
32792 * @two: (type GVariant): a #GVariant instance
32794 * Checks if @one and @two have the same type and value.
32796 * The types of @one and @two are #gconstpointer only to allow use of
32797 * this function with #GHashTable. They must each be a #GVariant.
32799 * Returns: %TRUE if @one and @two are equal
32805 * g_variant_get: (skip)
32806 * @value: a #GVariant instance
32807 * @format_string: a #GVariant format string
32808 * @...: arguments, as per @format_string
32810 * Deconstructs a #GVariant instance.
32812 * Think of this function as an analogue to scanf().
32814 * The arguments that are expected by this function are entirely
32815 * determined by @format_string. @format_string also restricts the
32816 * permissible types of @value. It is an error to give a value with
32817 * an incompatible type. See the section on <link
32818 * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
32819 * Please note that the syntax of the format string is very likely to be
32820 * extended in the future.
32822 * @format_string determines the C types that are used for unpacking
32823 * the values and also determines if the values are copied or borrowed,
32824 * see the section on
32825 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32832 * g_variant_get_boolean:
32833 * @value: a boolean #GVariant instance
32835 * Returns the boolean value of @value.
32837 * It is an error to call this function with a @value of any type
32838 * other than %G_VARIANT_TYPE_BOOLEAN.
32840 * Returns: %TRUE or %FALSE
32846 * g_variant_get_byte:
32847 * @value: a byte #GVariant instance
32849 * Returns the byte value of @value.
32851 * It is an error to call this function with a @value of any type
32852 * other than %G_VARIANT_TYPE_BYTE.
32854 * Returns: a #guchar
32860 * g_variant_get_bytestring:
32861 * @value: an array-of-bytes #GVariant instance
32863 * Returns the string value of a #GVariant instance with an
32864 * array-of-bytes type. The string has no particular encoding.
32866 * If the array does not end with a nul terminator character, the empty
32867 * string is returned. For this reason, you can always trust that a
32868 * non-%NULL nul-terminated string will be returned by this function.
32870 * If the array contains a nul terminator character somewhere other than
32871 * the last byte then the returned string is the string, up to the first
32872 * such nul character.
32874 * It is an error to call this function with a @value that is not an
32877 * The return value remains valid as long as @value exists.
32879 * Returns: (transfer none) (array zero-terminated=1) (element-type guint8):
32880 * the constant string
32886 * g_variant_get_bytestring_array:
32887 * @value: an array of array of bytes #GVariant ('aay')
32888 * @length: (out) (allow-none): the length of the result, or %NULL
32890 * Gets the contents of an array of array of bytes #GVariant. This call
32891 * makes a shallow copy; the return result should be released with
32892 * g_free(), but the individual strings must not be modified.
32894 * If @length is non-%NULL then the number of elements in the result is
32895 * stored there. In any case, the resulting array will be
32896 * %NULL-terminated.
32898 * For an empty array, @length will be set to 0 and a pointer to a
32899 * %NULL pointer will be returned.
32901 * Returns: (array length=length) (transfer container): an array of constant strings
32907 * g_variant_get_child: (skip)
32908 * @value: a container #GVariant
32909 * @index_: the index of the child to deconstruct
32910 * @format_string: a #GVariant format string
32911 * @...: arguments, as per @format_string
32913 * Reads a child item out of a container #GVariant instance and
32914 * deconstructs it according to @format_string. This call is
32915 * essentially a combination of g_variant_get_child_value() and
32918 * @format_string determines the C types that are used for unpacking
32919 * the values and also determines if the values are copied or borrowed,
32920 * see the section on
32921 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32928 * g_variant_get_child_value:
32929 * @value: a container #GVariant
32930 * @index_: the index of the child to fetch
32932 * Reads a child item out of a container #GVariant instance. This
32933 * includes variants, maybes, arrays, tuples and dictionary
32934 * entries. It is an error to call this function on any other type of
32937 * It is an error if @index_ is greater than the number of child items
32938 * in the container. See g_variant_n_children().
32940 * The returned value is never floating. You should free it with
32941 * g_variant_unref() when you're done with it.
32943 * This function is O(1).
32945 * Returns: (transfer full): the child at the specified index
32951 * g_variant_get_data:
32952 * @value: a #GVariant instance
32954 * Returns a pointer to the serialised form of a #GVariant instance.
32955 * The returned data may not be in fully-normalised form if read from an
32956 * untrusted source. The returned data must not be freed; it remains
32957 * valid for as long as @value exists.
32959 * If @value is a fixed-sized value that was deserialised from a
32960 * corrupted serialised container then %NULL may be returned. In this
32961 * case, the proper thing to do is typically to use the appropriate
32962 * number of nul bytes in place of @value. If @value is not fixed-sized
32963 * then %NULL is never returned.
32965 * In the case that @value is already in serialised form, this function
32966 * is O(1). If the value is not already in serialised form,
32967 * serialisation occurs implicitly and is approximately O(n) in the size
32970 * To deserialise the data returned by this function, in addition to the
32971 * serialised data, you must know the type of the #GVariant, and (if the
32972 * machine might be different) the endianness of the machine that stored
32973 * it. As a result, file formats or network messages that incorporate
32974 * serialised #GVariant<!---->s must include this information either
32975 * implicitly (for instance "the file always contains a
32976 * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
32977 * explicitly (by storing the type and/or endianness in addition to the
32978 * serialised data).
32980 * Returns: (transfer none): the serialised form of @value, or %NULL
32986 * g_variant_get_data_as_bytes:
32987 * @value: a #GVariant
32989 * Returns a pointer to the serialised form of a #GVariant instance.
32990 * The semantics of this function are exactly the same as
32991 * g_variant_get_data(), except that the returned #GBytes holds
32992 * a reference to the variant data.
32994 * Returns: (transfer full): A new #GBytes representing the variant data
33000 * g_variant_get_double:
33001 * @value: a double #GVariant instance
33003 * Returns the double precision floating point value of @value.
33005 * It is an error to call this function with a @value of any type
33006 * other than %G_VARIANT_TYPE_DOUBLE.
33008 * Returns: a #gdouble
33014 * g_variant_get_fixed_array:
33015 * @value: a #GVariant array with fixed-sized elements
33016 * @n_elements: (out): a pointer to the location to store the number of items
33017 * @element_size: the size of each element
33019 * Provides access to the serialised data for an array of fixed-sized
33022 * @value must be an array with fixed-sized elements. Numeric types are
33023 * fixed-size, as are tuples containing only other fixed-sized types.
33025 * @element_size must be the size of a single element in the array,
33026 * as given by the section on
33027 * <link linkend='gvariant-serialised-data-memory'>Serialised Data
33030 * In particular, arrays of these fixed-sized types can be interpreted
33031 * as an array of the given C type, with @element_size set to
33032 * <code>sizeof</code> the appropriate type:
33035 * <tgroup cols='2'>
33036 * <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
33038 * <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
33039 * <entry>#gint16 (etc.)</entry></row>
33040 * <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
33041 * <entry>#guchar (not #gboolean!)</entry></row>
33042 * <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
33043 * <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
33044 * <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
33049 * For example, if calling this function for an array of 32 bit integers,
33050 * you might say <code>sizeof (gint32)</code>. This value isn't used
33051 * except for the purpose of a double-check that the form of the
33052 * serialised data matches the caller's expectation.
33054 * @n_elements, which must be non-%NULL is set equal to the number of
33055 * items in the array.
33057 * Returns: (array length=n_elements) (transfer none): a pointer to
33064 * g_variant_get_handle:
33065 * @value: a handle #GVariant instance
33067 * Returns the 32-bit signed integer value of @value.
33069 * It is an error to call this function with a @value of any type other
33070 * than %G_VARIANT_TYPE_HANDLE.
33072 * By convention, handles are indexes into an array of file descriptors
33073 * that are sent alongside a D-Bus message. If you're not interacting
33074 * with D-Bus, you probably don't need them.
33076 * Returns: a #gint32
33082 * g_variant_get_int16:
33083 * @value: a int16 #GVariant instance
33085 * Returns the 16-bit signed integer value of @value.
33087 * It is an error to call this function with a @value of any type
33088 * other than %G_VARIANT_TYPE_INT16.
33090 * Returns: a #gint16
33096 * g_variant_get_int32:
33097 * @value: a int32 #GVariant instance
33099 * Returns the 32-bit signed integer value of @value.
33101 * It is an error to call this function with a @value of any type
33102 * other than %G_VARIANT_TYPE_INT32.
33104 * Returns: a #gint32
33110 * g_variant_get_int64:
33111 * @value: a int64 #GVariant instance
33113 * Returns the 64-bit signed integer value of @value.
33115 * It is an error to call this function with a @value of any type
33116 * other than %G_VARIANT_TYPE_INT64.
33118 * Returns: a #gint64
33124 * g_variant_get_maybe:
33125 * @value: a maybe-typed value
33127 * Given a maybe-typed #GVariant instance, extract its value. If the
33128 * value is Nothing, then this function returns %NULL.
33130 * Returns: (allow-none) (transfer full): the contents of @value, or %NULL
33136 * g_variant_get_normal_form:
33137 * @value: a #GVariant
33139 * Gets a #GVariant instance that has the same value as @value and is
33140 * trusted to be in normal form.
33142 * If @value is already trusted to be in normal form then a new
33143 * reference to @value is returned.
33145 * If @value is not already trusted, then it is scanned to check if it
33146 * is in normal form. If it is found to be in normal form then it is
33147 * marked as trusted and a new reference to it is returned.
33149 * If @value is found not to be in normal form then a new trusted
33150 * #GVariant is created with the same value as @value.
33152 * It makes sense to call this function if you've received #GVariant
33153 * data from untrusted sources and you want to ensure your serialised
33154 * output is definitely in normal form.
33156 * Returns: (transfer full): a trusted #GVariant
33162 * g_variant_get_objv:
33163 * @value: an array of object paths #GVariant
33164 * @length: (out) (allow-none): the length of the result, or %NULL
33166 * Gets the contents of an array of object paths #GVariant. This call
33167 * makes a shallow copy; the return result should be released with
33168 * g_free(), but the individual strings must not be modified.
33170 * If @length is non-%NULL then the number of elements in the result
33171 * is stored there. In any case, the resulting array will be
33172 * %NULL-terminated.
33174 * For an empty array, @length will be set to 0 and a pointer to a
33175 * %NULL pointer will be returned.
33177 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
33183 * g_variant_get_size:
33184 * @value: a #GVariant instance
33186 * Determines the number of bytes that would be required to store @value
33187 * with g_variant_store().
33189 * If @value has a fixed-sized type then this function always returned
33192 * In the case that @value is already in serialised form or the size has
33193 * already been calculated (ie: this function has been called before)
33194 * then this function is O(1). Otherwise, the size is calculated, an
33195 * operation which is approximately O(n) in the number of values
33198 * Returns: the serialised size of @value
33204 * g_variant_get_string:
33205 * @value: a string #GVariant instance
33206 * @length: (allow-none) (default 0) (out): a pointer to a #gsize,
33207 * to store the length
33209 * Returns the string value of a #GVariant instance with a string
33210 * type. This includes the types %G_VARIANT_TYPE_STRING,
33211 * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
33213 * The string will always be utf8 encoded.
33215 * If @length is non-%NULL then the length of the string (in bytes) is
33216 * returned there. For trusted values, this information is already
33217 * known. For untrusted values, a strlen() will be performed.
33219 * It is an error to call this function with a @value of any type
33220 * other than those three.
33222 * The return value remains valid as long as @value exists.
33224 * Returns: (transfer none): the constant string, utf8 encoded
33230 * g_variant_get_strv:
33231 * @value: an array of strings #GVariant
33232 * @length: (out) (allow-none): the length of the result, or %NULL
33234 * Gets the contents of an array of strings #GVariant. This call
33235 * makes a shallow copy; the return result should be released with
33236 * g_free(), but the individual strings must not be modified.
33238 * If @length is non-%NULL then the number of elements in the result
33239 * is stored there. In any case, the resulting array will be
33240 * %NULL-terminated.
33242 * For an empty array, @length will be set to 0 and a pointer to a
33243 * %NULL pointer will be returned.
33245 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
33251 * g_variant_get_type:
33252 * @value: a #GVariant
33254 * Determines the type of @value.
33256 * The return value is valid for the lifetime of @value and must not
33259 * Returns: a #GVariantType
33265 * g_variant_get_type_string:
33266 * @value: a #GVariant
33268 * Returns the type string of @value. Unlike the result of calling
33269 * g_variant_type_peek_string(), this string is nul-terminated. This
33270 * string belongs to #GVariant and must not be freed.
33272 * Returns: the type string for the type of @value
33278 * g_variant_get_uint16:
33279 * @value: a uint16 #GVariant instance
33281 * Returns the 16-bit unsigned integer value of @value.
33283 * It is an error to call this function with a @value of any type
33284 * other than %G_VARIANT_TYPE_UINT16.
33286 * Returns: a #guint16
33292 * g_variant_get_uint32:
33293 * @value: a uint32 #GVariant instance
33295 * Returns the 32-bit unsigned integer value of @value.
33297 * It is an error to call this function with a @value of any type
33298 * other than %G_VARIANT_TYPE_UINT32.
33300 * Returns: a #guint32
33306 * g_variant_get_uint64:
33307 * @value: a uint64 #GVariant instance
33309 * Returns the 64-bit unsigned integer value of @value.
33311 * It is an error to call this function with a @value of any type
33312 * other than %G_VARIANT_TYPE_UINT64.
33314 * Returns: a #guint64
33320 * g_variant_get_va: (skip)
33321 * @value: a #GVariant
33322 * @format_string: a string that is prefixed with a format string
33323 * @endptr: (allow-none) (default NULL): location to store the end pointer,
33325 * @app: a pointer to a #va_list
33327 * This function is intended to be used by libraries based on #GVariant
33328 * that want to provide g_variant_get()-like functionality to their
33331 * The API is more general than g_variant_get() to allow a wider range
33332 * of possible uses.
33334 * @format_string must still point to a valid format string, but it only
33335 * need to be nul-terminated if @endptr is %NULL. If @endptr is
33336 * non-%NULL then it is updated to point to the first character past the
33337 * end of the format string.
33339 * @app is a pointer to a #va_list. The arguments, according to
33340 * @format_string, are collected from this #va_list and the list is left
33341 * pointing to the argument following the last.
33343 * These two generalisations allow mixing of multiple calls to
33344 * g_variant_new_va() and g_variant_get_va() within a single actual
33345 * varargs call by the user.
33347 * @format_string determines the C types that are used for unpacking
33348 * the values and also determines if the values are copied or borrowed,
33349 * see the section on
33350 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33357 * g_variant_get_variant:
33358 * @value: a variant #GVariant instance
33360 * Unboxes @value. The result is the #GVariant instance that was
33361 * contained in @value.
33363 * Returns: (transfer full): the item contained in the variant
33370 * @value: (type GVariant): a basic #GVariant value as a #gconstpointer
33372 * Generates a hash value for a #GVariant instance.
33374 * The output of this function is guaranteed to be the same for a given
33375 * value only per-process. It may change between different processor
33376 * architectures or even different versions of GLib. Do not use this
33377 * function as a basis for building protocols or file formats.
33379 * The type of @value is #gconstpointer only to allow use of this
33380 * function with #GHashTable. @value must be a #GVariant.
33382 * Returns: a hash value corresponding to @value
33388 * g_variant_is_container:
33389 * @value: a #GVariant instance
33391 * Checks if @value is a container.
33393 * Returns: %TRUE if @value is a container
33399 * g_variant_is_floating:
33400 * @value: a #GVariant
33402 * Checks whether @value has a floating reference count.
33404 * This function should only ever be used to assert that a given variant
33405 * is or is not floating, or for debug purposes. To acquire a reference
33406 * to a variant that might be floating, always use g_variant_ref_sink()
33407 * or g_variant_take_ref().
33409 * See g_variant_ref_sink() for more information about floating reference
33412 * Returns: whether @value is floating
33418 * g_variant_is_normal_form:
33419 * @value: a #GVariant instance
33421 * Checks if @value is in normal form.
33423 * The main reason to do this is to detect if a given chunk of
33424 * serialised data is in normal form: load the data into a #GVariant
33425 * using g_variant_new_from_data() and then use this function to
33428 * If @value is found to be in normal form then it will be marked as
33429 * being trusted. If the value was already marked as being trusted then
33430 * this function will immediately return %TRUE.
33432 * Returns: %TRUE if @value is in normal form
33438 * g_variant_is_object_path:
33439 * @string: a normal C nul-terminated string
33441 * Determines if a given string is a valid D-Bus object path. You
33442 * should ensure that a string is a valid D-Bus object path before
33443 * passing it to g_variant_new_object_path().
33445 * A valid object path starts with '/' followed by zero or more
33446 * sequences of characters separated by '/' characters. Each sequence
33447 * must contain only the characters "[A-Z][a-z][0-9]_". No sequence
33448 * (including the one following the final '/' character) may be empty.
33450 * Returns: %TRUE if @string is a D-Bus object path
33456 * g_variant_is_of_type:
33457 * @value: a #GVariant instance
33458 * @type: a #GVariantType
33460 * Checks if a value has a type matching the provided type.
33462 * Returns: %TRUE if the type of @value matches @type
33468 * g_variant_is_signature:
33469 * @string: a normal C nul-terminated string
33471 * Determines if a given string is a valid D-Bus type signature. You
33472 * should ensure that a string is a valid D-Bus type signature before
33473 * passing it to g_variant_new_signature().
33475 * D-Bus type signatures consist of zero or more definite #GVariantType
33476 * strings in sequence.
33478 * Returns: %TRUE if @string is a D-Bus type signature
33484 * g_variant_iter_copy:
33485 * @iter: a #GVariantIter
33487 * Creates a new heap-allocated #GVariantIter to iterate over the
33488 * container that was being iterated over by @iter. Iteration begins on
33489 * the new iterator from the current position of the old iterator but
33490 * the two copies are independent past that point.
33492 * Use g_variant_iter_free() to free the return value when you no longer
33495 * A reference is taken to the container that @iter is iterating over
33496 * and will be releated only when g_variant_iter_free() is called.
33498 * Returns: (transfer full): a new heap-allocated #GVariantIter
33504 * g_variant_iter_free:
33505 * @iter: (transfer full): a heap-allocated #GVariantIter
33507 * Frees a heap-allocated #GVariantIter. Only call this function on
33508 * iterators that were returned by g_variant_iter_new() or
33509 * g_variant_iter_copy().
33516 * g_variant_iter_init: (skip)
33517 * @iter: a pointer to a #GVariantIter
33518 * @value: a container #GVariant
33520 * Initialises (without allocating) a #GVariantIter. @iter may be
33521 * completely uninitialised prior to this call; its old value is
33524 * The iterator remains valid for as long as @value exists, and need not
33525 * be freed in any way.
33527 * Returns: the number of items in @value
33533 * g_variant_iter_loop: (skip)
33534 * @iter: a #GVariantIter
33535 * @format_string: a GVariant format string
33536 * @...: the arguments to unpack the value into
33538 * Gets the next item in the container and unpacks it into the variable
33539 * argument list according to @format_string, returning %TRUE.
33541 * If no more items remain then %FALSE is returned.
33543 * On the first call to this function, the pointers appearing on the
33544 * variable argument list are assumed to point at uninitialised memory.
33545 * On the second and later calls, it is assumed that the same pointers
33546 * will be given and that they will point to the memory as set by the
33547 * previous call to this function. This allows the previous values to
33548 * be freed, as appropriate.
33550 * This function is intended to be used with a while loop as
33551 * demonstrated in the following example. This function can only be
33552 * used when iterating over an array. It is only valid to call this
33553 * function with a string constant for the format string and the same
33554 * string constant must be used each time. Mixing calls to this
33555 * function and g_variant_iter_next() or g_variant_iter_next_value() on
33556 * the same iterator causes undefined behavior.
33558 * If you break out of a such a while loop using g_variant_iter_loop() then
33559 * you must free or unreference all the unpacked values as you would with
33560 * g_variant_get(). Failure to do so will cause a memory leak.
33562 * See the section on <link linkend='gvariant-format-strings'>GVariant
33563 * Format Strings</link>.
33566 * <title>Memory management with g_variant_iter_loop()</title>
33568 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
33570 * iterate_dictionary (GVariant *dictionary)
33572 * GVariantIter iter;
33576 * g_variant_iter_init (&iter, dictionary);
33577 * while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
33579 * g_print ("Item '%s' has type '%s'\n", key,
33580 * g_variant_get_type_string (value));
33582 * /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
33583 * /<!-- -->* unless breaking out of this loop *<!-- -->/
33586 * </programlisting>
33589 * For most cases you should use g_variant_iter_next().
33591 * This function is really only useful when unpacking into #GVariant or
33592 * #GVariantIter in order to allow you to skip the call to
33593 * g_variant_unref() or g_variant_iter_free().
33595 * For example, if you are only looping over simple integer and string
33596 * types, g_variant_iter_next() is definitely preferred. For string
33597 * types, use the '&' prefix to avoid allocating any memory at all (and
33598 * thereby avoiding the need to free anything as well).
33600 * @format_string determines the C types that are used for unpacking
33601 * the values and also determines if the values are copied or borrowed,
33602 * see the section on
33603 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33605 * Returns: %TRUE if a value was unpacked, or %FALSE if there was no
33612 * g_variant_iter_n_children:
33613 * @iter: a #GVariantIter
33615 * Queries the number of child items in the container that we are
33616 * iterating over. This is the total number of items -- not the number
33617 * of items remaining.
33619 * This function might be useful for preallocation of arrays.
33621 * Returns: the number of children in the container
33627 * g_variant_iter_new:
33628 * @value: a container #GVariant
33630 * Creates a heap-allocated #GVariantIter for iterating over the items
33633 * Use g_variant_iter_free() to free the return value when you no longer
33636 * A reference is taken to @value and will be released only when
33637 * g_variant_iter_free() is called.
33639 * Returns: (transfer full): a new heap-allocated #GVariantIter
33645 * g_variant_iter_next: (skip)
33646 * @iter: a #GVariantIter
33647 * @format_string: a GVariant format string
33648 * @...: the arguments to unpack the value into
33650 * Gets the next item in the container and unpacks it into the variable
33651 * argument list according to @format_string, returning %TRUE.
33653 * If no more items remain then %FALSE is returned.
33655 * All of the pointers given on the variable arguments list of this
33656 * function are assumed to point at uninitialised memory. It is the
33657 * responsibility of the caller to free all of the values returned by
33658 * the unpacking process.
33660 * See the section on <link linkend='gvariant-format-strings'>GVariant
33661 * Format Strings</link>.
33664 * <title>Memory management with g_variant_iter_next()</title>
33666 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
33668 * iterate_dictionary (GVariant *dictionary)
33670 * GVariantIter iter;
33674 * g_variant_iter_init (&iter, dictionary);
33675 * while (g_variant_iter_next (&iter, "{sv}", &key, &value))
33677 * g_print ("Item '%s' has type '%s'\n", key,
33678 * g_variant_get_type_string (value));
33680 * /<!-- -->* must free data for ourselves *<!-- -->/
33681 * g_variant_unref (value);
33685 * </programlisting>
33688 * For a solution that is likely to be more convenient to C programmers
33689 * when dealing with loops, see g_variant_iter_loop().
33691 * @format_string determines the C types that are used for unpacking
33692 * the values and also determines if the values are copied or borrowed,
33693 * see the section on
33694 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33696 * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value
33702 * g_variant_iter_next_value:
33703 * @iter: a #GVariantIter
33705 * Gets the next item in the container. If no more items remain then
33706 * %NULL is returned.
33708 * Use g_variant_unref() to drop your reference on the return value when
33709 * you no longer need it.
33712 * <title>Iterating with g_variant_iter_next_value()</title>
33714 * /<!-- -->* recursively iterate a container *<!-- -->/
33716 * iterate_container_recursive (GVariant *container)
33718 * GVariantIter iter;
33721 * g_variant_iter_init (&iter, container);
33722 * while ((child = g_variant_iter_next_value (&iter)))
33724 * g_print ("type '%s'\n", g_variant_get_type_string (child));
33726 * if (g_variant_is_container (child))
33727 * iterate_container_recursive (child);
33729 * g_variant_unref (child);
33732 * </programlisting>
33735 * Returns: (allow-none) (transfer full): a #GVariant, or %NULL
33741 * g_variant_lookup: (skip)
33742 * @dictionary: a dictionary #GVariant
33743 * @key: the key to lookup in the dictionary
33744 * @format_string: a GVariant format string
33745 * @...: the arguments to unpack the value into
33747 * Looks up a value in a dictionary #GVariant.
33749 * This function is a wrapper around g_variant_lookup_value() and
33750 * g_variant_get(). In the case that %NULL would have been returned,
33751 * this function returns %FALSE. Otherwise, it unpacks the returned
33752 * value and returns %TRUE.
33754 * @format_string determines the C types that are used for unpacking
33755 * the values and also determines if the values are copied or borrowed,
33756 * see the section on
33757 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33759 * Returns: %TRUE if a value was unpacked
33765 * g_variant_lookup_value:
33766 * @dictionary: a dictionary #GVariant
33767 * @key: the key to lookup in the dictionary
33768 * @expected_type: (allow-none): a #GVariantType, or %NULL
33770 * Looks up a value in a dictionary #GVariant.
33772 * This function works with dictionaries of the type
33773 * <literal>a{s*}</literal> (and equally well with type
33774 * <literal>a{o*}</literal>, but we only further discuss the string case
33775 * for sake of clarity).
33777 * In the event that @dictionary has the type <literal>a{sv}</literal>,
33778 * the @expected_type string specifies what type of value is expected to
33779 * be inside of the variant. If the value inside the variant has a
33780 * different type then %NULL is returned. In the event that @dictionary
33781 * has a value type other than <literal>v</literal> then @expected_type
33782 * must directly match the key type and it is used to unpack the value
33783 * directly or an error occurs.
33785 * In either case, if @key is not found in @dictionary, %NULL is
33788 * If the key is found and the value has the correct type, it is
33789 * returned. If @expected_type was specified then any non-%NULL return
33790 * value will have this type.
33792 * Returns: (transfer full): the value of the dictionary key, or %NULL
33798 * g_variant_n_children:
33799 * @value: a container #GVariant
33801 * Determines the number of children in a container #GVariant instance.
33802 * This includes variants, maybes, arrays, tuples and dictionary
33803 * entries. It is an error to call this function on any other type of
33806 * For variants, the return value is always 1. For values with maybe
33807 * types, it is always zero or one. For arrays, it is the length of the
33808 * array. For tuples it is the number of tuple items (which depends
33809 * only on the type). For dictionary entries, it is always 2
33811 * This function is O(1).
33813 * Returns: the number of children in the container
33819 * g_variant_new: (skip)
33820 * @format_string: a #GVariant format string
33821 * @...: arguments, as per @format_string
33823 * Creates a new #GVariant instance.
33825 * Think of this function as an analogue to g_strdup_printf().
33827 * The type of the created instance and the arguments that are
33828 * expected by this function are determined by @format_string. See the
33829 * section on <link linkend='gvariant-format-strings'>GVariant Format
33830 * Strings</link>. Please note that the syntax of the format string is
33831 * very likely to be extended in the future.
33833 * The first character of the format string must not be '*' '?' '@' or
33834 * 'r'; in essence, a new #GVariant must always be constructed by this
33835 * function (and not merely passed through it unmodified).
33837 * Returns: a new floating #GVariant instance
33843 * g_variant_new_array:
33844 * @child_type: (allow-none): the element type of the new array
33845 * @children: (allow-none) (array length=n_children): an array of
33846 * #GVariant pointers, the children
33847 * @n_children: the length of @children
33849 * Creates a new #GVariant array from @children.
33851 * @child_type must be non-%NULL if @n_children is zero. Otherwise, the
33852 * child type is determined by inspecting the first element of the
33853 * @children array. If @child_type is non-%NULL then it must be a
33856 * The items of the array are taken from the @children array. No entry
33857 * in the @children array may be %NULL.
33859 * All items in the array must have the same type, which must be the
33860 * same as @child_type, if given.
33862 * If the @children are floating references (see g_variant_ref_sink()), the
33863 * new instance takes ownership of them as if via g_variant_ref_sink().
33865 * Returns: (transfer none): a floating reference to a new #GVariant array
33871 * g_variant_new_boolean:
33872 * @value: a #gboolean value
33874 * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
33876 * Returns: (transfer none): a floating reference to a new boolean #GVariant instance
33882 * g_variant_new_byte:
33883 * @value: a #guint8 value
33885 * Creates a new byte #GVariant instance.
33887 * Returns: (transfer none): a floating reference to a new byte #GVariant instance
33893 * g_variant_new_bytestring:
33894 * @string: (array zero-terminated=1) (element-type guint8): a normal
33895 * nul-terminated string in no particular encoding
33897 * Creates an array-of-bytes #GVariant with the contents of @string.
33898 * This function is just like g_variant_new_string() except that the
33899 * string need not be valid utf8.
33901 * The nul terminator character at the end of the string is stored in
33904 * Returns: (transfer none): a floating reference to a new bytestring #GVariant instance
33910 * g_variant_new_bytestring_array:
33911 * @strv: (array length=length): an array of strings
33912 * @length: the length of @strv, or -1
33914 * Constructs an array of bytestring #GVariant from the given array of
33917 * If @length is -1 then @strv is %NULL-terminated.
33919 * Returns: (transfer none): a new floating #GVariant instance
33925 * g_variant_new_dict_entry: (constructor)
33926 * @key: a basic #GVariant, the key
33927 * @value: a #GVariant, the value
33929 * Creates a new dictionary entry #GVariant. @key and @value must be
33930 * non-%NULL. @key must be a value of a basic type (ie: not a container).
33932 * If the @key or @value are floating references (see g_variant_ref_sink()),
33933 * the new instance takes ownership of them as if via g_variant_ref_sink().
33935 * Returns: (transfer none): a floating reference to a new dictionary entry #GVariant
33941 * g_variant_new_double:
33942 * @value: a #gdouble floating point value
33944 * Creates a new double #GVariant instance.
33946 * Returns: (transfer none): a floating reference to a new double #GVariant instance
33952 * g_variant_new_fixed_array:
33953 * @element_type: the #GVariantType of each element
33954 * @elements: a pointer to the fixed array of contiguous elements
33955 * @n_elements: the number of elements
33956 * @element_size: the size of each element
33958 * Provides access to the serialised data for an array of fixed-sized
33961 * @value must be an array with fixed-sized elements. Numeric types are
33962 * fixed-size as are tuples containing only other fixed-sized types.
33964 * @element_size must be the size of a single element in the array. For
33965 * example, if calling this function for an array of 32 bit integers,
33966 * you might say <code>sizeof (gint32)</code>. This value isn't used
33967 * except for the purpose of a double-check that the form of the
33968 * serialised data matches the caller's expectation.
33970 * @n_elements, which must be non-%NULL is set equal to the number of
33971 * items in the array.
33973 * Returns: (transfer none): a floating reference to a new array #GVariant instance
33979 * g_variant_new_from_bytes:
33980 * @type: a #GVariantType
33981 * @bytes: a #GBytes
33982 * @trusted: if the contents of @bytes are trusted
33984 * Constructs a new serialised-mode #GVariant instance. This is the
33985 * inner interface for creation of new serialised values that gets
33986 * called from various functions in gvariant.c.
33988 * A reference is taken on @bytes.
33990 * Returns: (transfer none): a new #GVariant with a floating reference
33996 * g_variant_new_from_data:
33997 * @type: a definite #GVariantType
33998 * @data: (array length=size) (element-type guint8): the serialised data
33999 * @size: the size of @data
34000 * @trusted: %TRUE if @data is definitely in normal form
34001 * @notify: (scope async): function to call when @data is no longer needed
34002 * @user_data: data for @notify
34004 * Creates a new #GVariant instance from serialised data.
34006 * @type is the type of #GVariant instance that will be constructed.
34007 * The interpretation of @data depends on knowing the type.
34009 * @data is not modified by this function and must remain valid with an
34010 * unchanging value until such a time as @notify is called with
34011 * @user_data. If the contents of @data change before that time then
34012 * the result is undefined.
34014 * If @data is trusted to be serialised data in normal form then
34015 * @trusted should be %TRUE. This applies to serialised data created
34016 * within this process or read from a trusted location on the disk (such
34017 * as a file installed in /usr/lib alongside your application). You
34018 * should set trusted to %FALSE if @data is read from the network, a
34019 * file in the user's home directory, etc.
34021 * If @data was not stored in this machine's native endianness, any multi-byte
34022 * numeric values in the returned variant will also be in non-native
34023 * endianness. g_variant_byteswap() can be used to recover the original values.
34025 * @notify will be called with @user_data when @data is no longer
34026 * needed. The exact time of this call is unspecified and might even be
34027 * before this function returns.
34029 * Returns: (transfer none): a new floating #GVariant of type @type
34035 * g_variant_new_handle:
34036 * @value: a #gint32 value
34038 * Creates a new handle #GVariant instance.
34040 * By convention, handles are indexes into an array of file descriptors
34041 * that are sent alongside a D-Bus message. If you're not interacting
34042 * with D-Bus, you probably don't need them.
34044 * Returns: (transfer none): a floating reference to a new handle #GVariant instance
34050 * g_variant_new_int16:
34051 * @value: a #gint16 value
34053 * Creates a new int16 #GVariant instance.
34055 * Returns: (transfer none): a floating reference to a new int16 #GVariant instance
34061 * g_variant_new_int32:
34062 * @value: a #gint32 value
34064 * Creates a new int32 #GVariant instance.
34066 * Returns: (transfer none): a floating reference to a new int32 #GVariant instance
34072 * g_variant_new_int64:
34073 * @value: a #gint64 value
34075 * Creates a new int64 #GVariant instance.
34077 * Returns: (transfer none): a floating reference to a new int64 #GVariant instance
34083 * g_variant_new_maybe:
34084 * @child_type: (allow-none): the #GVariantType of the child, or %NULL
34085 * @child: (allow-none): the child value, or %NULL
34087 * Depending on if @child is %NULL, either wraps @child inside of a
34088 * maybe container or creates a Nothing instance for the given @type.
34090 * At least one of @child_type and @child must be non-%NULL.
34091 * If @child_type is non-%NULL then it must be a definite type.
34092 * If they are both non-%NULL then @child_type must be the type
34095 * If @child is a floating reference (see g_variant_ref_sink()), the new
34096 * instance takes ownership of @child.
34098 * Returns: (transfer none): a floating reference to a new #GVariant maybe instance
34104 * g_variant_new_object_path:
34105 * @object_path: a normal C nul-terminated string
34107 * Creates a D-Bus object path #GVariant with the contents of @string.
34108 * @string must be a valid D-Bus object path. Use
34109 * g_variant_is_object_path() if you're not sure.
34111 * Returns: (transfer none): a floating reference to a new object path #GVariant instance
34117 * g_variant_new_objv:
34118 * @strv: (array length=length) (element-type utf8): an array of strings
34119 * @length: the length of @strv, or -1
34121 * Constructs an array of object paths #GVariant from the given array of
34124 * Each string must be a valid #GVariant object path; see
34125 * g_variant_is_object_path().
34127 * If @length is -1 then @strv is %NULL-terminated.
34129 * Returns: (transfer none): a new floating #GVariant instance
34135 * g_variant_new_parsed:
34136 * @format: a text format #GVariant
34137 * @...: arguments as per @format
34139 * Parses @format and returns the result.
34141 * @format must be a text format #GVariant with one extension: at any
34142 * point that a value may appear in the text, a '%' character followed
34143 * by a GVariant format string (as per g_variant_new()) may appear. In
34144 * that case, the same arguments are collected from the argument list as
34145 * g_variant_new() would have collected.
34147 * Consider this simple example:
34149 * <informalexample><programlisting>
34150 * g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
34151 * </programlisting></informalexample>
34153 * In the example, the variable argument parameters are collected and
34154 * filled in as if they were part of the original string to produce the
34155 * result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
34157 * This function is intended only to be used with @format as a string
34158 * literal. Any parse error is fatal to the calling process. If you
34159 * want to parse data from untrusted sources, use g_variant_parse().
34161 * You may not use this function to return, unmodified, a single
34162 * #GVariant pointer from the argument list. ie: @format may not solely
34163 * be anything along the lines of "%*", "%?", "\%r", or anything starting
34166 * Returns: a new floating #GVariant instance
34171 * g_variant_new_parsed_va:
34172 * @format: a text format #GVariant
34173 * @app: a pointer to a #va_list
34175 * Parses @format and returns the result.
34177 * This is the version of g_variant_new_parsed() intended to be used
34180 * The return value will be floating if it was a newly created GVariant
34181 * instance. In the case that @format simply specified the collection
34182 * of a #GVariant pointer (eg: @format was "%*") then the collected
34183 * #GVariant pointer will be returned unmodified, without adding any
34184 * additional references.
34186 * In order to behave correctly in all cases it is necessary for the
34187 * calling function to g_variant_ref_sink() the return result before
34188 * returning control to the user that originally provided the pointer.
34189 * At this point, the caller will have their own full reference to the
34190 * result. This can also be done by adding the result to a container,
34191 * or by passing it to another g_variant_new() call.
34193 * Returns: a new, usually floating, #GVariant
34198 * g_variant_new_printf: (skip)
34199 * @format_string: a printf-style format string
34200 * @...: arguments for @format_string
34202 * Creates a string-type GVariant using printf formatting.
34204 * This is similar to calling g_strdup_printf() and then
34205 * g_variant_new_string() but it saves a temporary variable and an
34206 * unnecessary copy.
34208 * Returns: (transfer none): a floating reference to a new string
34209 * #GVariant instance
34215 * g_variant_new_signature:
34216 * @signature: a normal C nul-terminated string
34218 * Creates a D-Bus type signature #GVariant with the contents of
34219 * @string. @string must be a valid D-Bus type signature. Use
34220 * g_variant_is_signature() if you're not sure.
34222 * Returns: (transfer none): a floating reference to a new signature #GVariant instance
34228 * g_variant_new_string:
34229 * @string: a normal utf8 nul-terminated string
34231 * Creates a string #GVariant with the contents of @string.
34233 * @string must be valid utf8.
34235 * Returns: (transfer none): a floating reference to a new string #GVariant instance
34241 * g_variant_new_strv:
34242 * @strv: (array length=length) (element-type utf8): an array of strings
34243 * @length: the length of @strv, or -1
34245 * Constructs an array of strings #GVariant from the given array of
34248 * If @length is -1 then @strv is %NULL-terminated.
34250 * Returns: (transfer none): a new floating #GVariant instance
34256 * g_variant_new_take_string: (skip)
34257 * @string: a normal utf8 nul-terminated string
34259 * Creates a string #GVariant with the contents of @string.
34261 * @string must be valid utf8.
34263 * This function consumes @string. g_free() will be called on @string
34264 * when it is no longer required.
34266 * You must not modify or access @string in any other way after passing
34267 * it to this function. It is even possible that @string is immediately
34270 * Returns: (transfer none): a floating reference to a new string
34271 * #GVariant instance
34277 * g_variant_new_tuple:
34278 * @children: (array length=n_children): the items to make the tuple out of
34279 * @n_children: the length of @children
34281 * Creates a new tuple #GVariant out of the items in @children. The
34282 * type is determined from the types of @children. No entry in the
34283 * @children array may be %NULL.
34285 * If @n_children is 0 then the unit tuple is constructed.
34287 * If the @children are floating references (see g_variant_ref_sink()), the
34288 * new instance takes ownership of them as if via g_variant_ref_sink().
34290 * Returns: (transfer none): a floating reference to a new #GVariant tuple
34296 * g_variant_new_uint16:
34297 * @value: a #guint16 value
34299 * Creates a new uint16 #GVariant instance.
34301 * Returns: (transfer none): a floating reference to a new uint16 #GVariant instance
34307 * g_variant_new_uint32:
34308 * @value: a #guint32 value
34310 * Creates a new uint32 #GVariant instance.
34312 * Returns: (transfer none): a floating reference to a new uint32 #GVariant instance
34318 * g_variant_new_uint64:
34319 * @value: a #guint64 value
34321 * Creates a new uint64 #GVariant instance.
34323 * Returns: (transfer none): a floating reference to a new uint64 #GVariant instance
34329 * g_variant_new_va: (skip)
34330 * @format_string: a string that is prefixed with a format string
34331 * @endptr: (allow-none) (default NULL): location to store the end pointer,
34333 * @app: a pointer to a #va_list
34335 * This function is intended to be used by libraries based on
34336 * #GVariant that want to provide g_variant_new()-like functionality
34339 * The API is more general than g_variant_new() to allow a wider range
34340 * of possible uses.
34342 * @format_string must still point to a valid format string, but it only
34343 * needs to be nul-terminated if @endptr is %NULL. If @endptr is
34344 * non-%NULL then it is updated to point to the first character past the
34345 * end of the format string.
34347 * @app is a pointer to a #va_list. The arguments, according to
34348 * @format_string, are collected from this #va_list and the list is left
34349 * pointing to the argument following the last.
34351 * These two generalisations allow mixing of multiple calls to
34352 * g_variant_new_va() and g_variant_get_va() within a single actual
34353 * varargs call by the user.
34355 * The return value will be floating if it was a newly created GVariant
34356 * instance (for example, if the format string was "(ii)"). In the case
34357 * that the format_string was '*', '?', 'r', or a format starting with
34358 * '@' then the collected #GVariant pointer will be returned unmodified,
34359 * without adding any additional references.
34361 * In order to behave correctly in all cases it is necessary for the
34362 * calling function to g_variant_ref_sink() the return result before
34363 * returning control to the user that originally provided the pointer.
34364 * At this point, the caller will have their own full reference to the
34365 * result. This can also be done by adding the result to a container,
34366 * or by passing it to another g_variant_new() call.
34368 * Returns: a new, usually floating, #GVariant
34374 * g_variant_new_variant: (constructor)
34375 * @value: a #GVariant instance
34377 * Boxes @value. The result is a #GVariant instance representing a
34378 * variant containing the original value.
34380 * If @child is a floating reference (see g_variant_ref_sink()), the new
34381 * instance takes ownership of @child.
34383 * Returns: (transfer none): a floating reference to a new variant #GVariant instance
34390 * @type: (allow-none): a #GVariantType, or %NULL
34391 * @text: a string containing a GVariant in text form
34392 * @limit: (allow-none): a pointer to the end of @text, or %NULL
34393 * @endptr: (allow-none): a location to store the end pointer, or %NULL
34394 * @error: (allow-none): a pointer to a %NULL #GError pointer, or %NULL
34396 * Parses a #GVariant from a text representation.
34398 * A single #GVariant is parsed from the content of @text.
34400 * The format is described <link linkend='gvariant-text'>here</link>.
34402 * The memory at @limit will never be accessed and the parser behaves as
34403 * if the character at @limit is the nul terminator. This has the
34404 * effect of bounding @text.
34406 * If @endptr is non-%NULL then @text is permitted to contain data
34407 * following the value that this function parses and @endptr will be
34408 * updated to point to the first character past the end of the text
34409 * parsed by this function. If @endptr is %NULL and there is extra data
34410 * then an error is returned.
34412 * If @type is non-%NULL then the value will be parsed to have that
34413 * type. This may result in additional parse errors (in the case that
34414 * the parsed value doesn't fit the type) but may also result in fewer
34415 * errors (in the case that the type would have been ambiguous, such as
34416 * with empty arrays).
34418 * In the event that the parsing is successful, the resulting #GVariant
34421 * In case of any error, %NULL will be returned. If @error is non-%NULL
34422 * then it will be set to reflect the error that occurred.
34424 * Officially, the language understood by the parser is "any string
34425 * produced by g_variant_print()".
34427 * Returns: a reference to a #GVariant, or %NULL
34433 * @value: a #GVariant
34434 * @type_annotate: %TRUE if type information should be included in
34437 * Pretty-prints @value in the format understood by g_variant_parse().
34439 * The format is described <link linkend='gvariant-text'>here</link>.
34441 * If @type_annotate is %TRUE, then type information is included in
34444 * Returns: (transfer full): a newly-allocated string holding the result.
34450 * g_variant_print_string: (skip)
34451 * @value: a #GVariant
34452 * @string: (allow-none) (default NULL): a #GString, or %NULL
34453 * @type_annotate: %TRUE if type information should be included in
34456 * Behaves as g_variant_print(), but operates on a #GString.
34458 * If @string is non-%NULL then it is appended to and returned. Else,
34459 * a new empty #GString is allocated and it is returned.
34461 * Returns: a #GString containing the string
34468 * @value: a #GVariant
34470 * Increases the reference count of @value.
34472 * Returns: the same @value
34478 * g_variant_ref_sink:
34479 * @value: a #GVariant
34481 * #GVariant uses a floating reference count system. All functions with
34482 * names starting with <literal>g_variant_new_</literal> return floating
34485 * Calling g_variant_ref_sink() on a #GVariant with a floating reference
34486 * will convert the floating reference into a full reference. Calling
34487 * g_variant_ref_sink() on a non-floating #GVariant results in an
34488 * additional normal reference being added.
34490 * In other words, if the @value is floating, then this call "assumes
34491 * ownership" of the floating reference, converting it to a normal
34492 * reference. If the @value is not floating, then this call adds a
34493 * new normal reference increasing the reference count by one.
34495 * All calls that result in a #GVariant instance being inserted into a
34496 * container will call g_variant_ref_sink() on the instance. This means
34497 * that if the value was just created (and has only its floating
34498 * reference) then the container will assume sole ownership of the value
34499 * at that point and the caller will not need to unreference it. This
34500 * makes certain common styles of programming much easier while still
34501 * maintaining normal refcounting semantics in situations where values
34502 * are not floating.
34504 * Returns: the same @value
34511 * @value: the #GVariant to store
34512 * @data: the location to store the serialised data at
34514 * Stores the serialised form of @value at @data. @data should be
34515 * large enough. See g_variant_get_size().
34517 * The stored data is in machine native byte order but may not be in
34518 * fully-normalised form if read from an untrusted source. See
34519 * g_variant_get_normal_form() for a solution.
34521 * As with g_variant_get_data(), to be able to deserialise the
34522 * serialised variant successfully, its type and (if the destination
34523 * machine might be different) its endianness must also be available.
34525 * This function is approximately O(n) in the size of @data.
34532 * g_variant_take_ref:
34533 * @value: a #GVariant
34535 * If @value is floating, sink it. Otherwise, do nothing.
34537 * Typically you want to use g_variant_ref_sink() in order to
34538 * automatically do the correct thing with respect to floating or
34539 * non-floating references, but there is one specific scenario where
34540 * this function is helpful.
34542 * The situation where this function is helpful is when creating an API
34543 * that allows the user to provide a callback function that returns a
34544 * #GVariant. We certainly want to allow the user the flexibility to
34545 * return a non-floating reference from this callback (for the case
34546 * where the value that is being returned already exists).
34548 * At the same time, the style of the #GVariant API makes it likely that
34549 * for newly-created #GVariant instances, the user can be saved some
34550 * typing if they are allowed to return a #GVariant with a floating
34553 * Using this function on the return value of the user's callback allows
34554 * the user to do whichever is more convenient for them. The caller
34555 * will alway receives exactly one full reference to the value: either
34556 * the one that was returned in the first place, or a floating reference
34557 * that has been converted to a full reference.
34559 * This function has an odd interaction when combined with
34560 * g_variant_ref_sink() running at the same time in another thread on
34561 * the same #GVariant instance. If g_variant_ref_sink() runs first then
34562 * the result will be that the floating reference is converted to a hard
34563 * reference. If g_variant_take_ref() runs first then the result will
34564 * be that the floating reference is converted to a hard reference and
34565 * an additional reference on top of that one is added. It is best to
34566 * avoid this situation.
34568 * Returns: the same @value
34573 * g_variant_type_copy:
34574 * @type: a #GVariantType
34576 * Makes a copy of a #GVariantType. It is appropriate to call
34577 * g_variant_type_free() on the return value. @type may not be %NULL.
34579 * Returns: (transfer full): a new #GVariantType
34586 * g_variant_type_dup_string:
34587 * @type: a #GVariantType
34589 * Returns a newly-allocated copy of the type string corresponding to
34590 * @type. The returned string is nul-terminated. It is appropriate to
34591 * call g_free() on the return value.
34593 * Returns: (transfer full): the corresponding type string
34600 * g_variant_type_element:
34601 * @type: an array or maybe #GVariantType
34603 * Determines the element type of an array or maybe type.
34605 * This function may only be used with array or maybe types.
34607 * Returns: (transfer none): the element type of @type
34614 * g_variant_type_equal:
34615 * @type1: (type GVariantType): a #GVariantType
34616 * @type2: (type GVariantType): a #GVariantType
34618 * Compares @type1 and @type2 for equality.
34620 * Only returns %TRUE if the types are exactly equal. Even if one type
34621 * is an indefinite type and the other is a subtype of it, %FALSE will
34622 * be returned if they are not exactly equal. If you want to check for
34623 * subtypes, use g_variant_type_is_subtype_of().
34625 * The argument types of @type1 and @type2 are only #gconstpointer to
34626 * allow use with #GHashTable without function pointer casting. For
34627 * both arguments, a valid #GVariantType must be provided.
34629 * Returns: %TRUE if @type1 and @type2 are exactly equal
34636 * g_variant_type_first:
34637 * @type: a tuple or dictionary entry #GVariantType
34639 * Determines the first item type of a tuple or dictionary entry
34642 * This function may only be used with tuple or dictionary entry types,
34643 * but must not be used with the generic tuple type
34644 * %G_VARIANT_TYPE_TUPLE.
34646 * In the case of a dictionary entry type, this returns the type of
34649 * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
34651 * This call, together with g_variant_type_next() provides an iterator
34652 * interface over tuple and dictionary entry types.
34654 * Returns: (transfer none): the first item type of @type, or %NULL
34661 * g_variant_type_free:
34662 * @type: (allow-none): a #GVariantType, or %NULL
34664 * Frees a #GVariantType that was allocated with
34665 * g_variant_type_copy(), g_variant_type_new() or one of the container
34666 * type constructor functions.
34668 * In the case that @type is %NULL, this function does nothing.
34675 * g_variant_type_get_string_length:
34676 * @type: a #GVariantType
34678 * Returns the length of the type string corresponding to the given
34679 * @type. This function must be used to determine the valid extent of
34680 * the memory region returned by g_variant_type_peek_string().
34682 * Returns: the length of the corresponding type string
34689 * g_variant_type_hash:
34690 * @type: (type GVariantType): a #GVariantType
34694 * The argument type of @type is only #gconstpointer to allow use with
34695 * #GHashTable without function pointer casting. A valid
34696 * #GVariantType must be provided.
34698 * Returns: the hash value
34705 * g_variant_type_is_array:
34706 * @type: a #GVariantType
34708 * Determines if the given @type is an array type. This is true if the
34709 * type string for @type starts with an 'a'.
34711 * This function returns %TRUE for any indefinite type for which every
34712 * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
34715 * Returns: %TRUE if @type is an array type
34722 * g_variant_type_is_basic:
34723 * @type: a #GVariantType
34725 * Determines if the given @type is a basic type.
34727 * Basic types are booleans, bytes, integers, doubles, strings, object
34728 * paths and signatures.
34730 * Only a basic type may be used as the key of a dictionary entry.
34732 * This function returns %FALSE for all indefinite types except
34733 * %G_VARIANT_TYPE_BASIC.
34735 * Returns: %TRUE if @type is a basic type
34742 * g_variant_type_is_container:
34743 * @type: a #GVariantType
34745 * Determines if the given @type is a container type.
34747 * Container types are any array, maybe, tuple, or dictionary
34748 * entry types plus the variant type.
34750 * This function returns %TRUE for any indefinite type for which every
34751 * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
34754 * Returns: %TRUE if @type is a container type
34761 * g_variant_type_is_definite:
34762 * @type: a #GVariantType
34764 * Determines if the given @type is definite (ie: not indefinite).
34766 * A type is definite if its type string does not contain any indefinite
34767 * type characters ('*', '?', or 'r').
34769 * A #GVariant instance may not have an indefinite type, so calling
34770 * this function on the result of g_variant_get_type() will always
34771 * result in %TRUE being returned. Calling this function on an
34772 * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
34773 * %FALSE being returned.
34775 * Returns: %TRUE if @type is definite
34782 * g_variant_type_is_dict_entry:
34783 * @type: a #GVariantType
34785 * Determines if the given @type is a dictionary entry type. This is
34786 * true if the type string for @type starts with a '{'.
34788 * This function returns %TRUE for any indefinite type for which every
34789 * definite subtype is a dictionary entry type --
34790 * %G_VARIANT_TYPE_DICT_ENTRY, for example.
34792 * Returns: %TRUE if @type is a dictionary entry type
34799 * g_variant_type_is_maybe:
34800 * @type: a #GVariantType
34802 * Determines if the given @type is a maybe type. This is true if the
34803 * type string for @type starts with an 'm'.
34805 * This function returns %TRUE for any indefinite type for which every
34806 * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
34809 * Returns: %TRUE if @type is a maybe type
34816 * g_variant_type_is_subtype_of:
34817 * @type: a #GVariantType
34818 * @supertype: a #GVariantType
34820 * Checks if @type is a subtype of @supertype.
34822 * This function returns %TRUE if @type is a subtype of @supertype. All
34823 * types are considered to be subtypes of themselves. Aside from that,
34824 * only indefinite types can have subtypes.
34826 * Returns: %TRUE if @type is a subtype of @supertype
34833 * g_variant_type_is_tuple:
34834 * @type: a #GVariantType
34836 * Determines if the given @type is a tuple type. This is true if the
34837 * type string for @type starts with a '(' or if @type is
34838 * %G_VARIANT_TYPE_TUPLE.
34840 * This function returns %TRUE for any indefinite type for which every
34841 * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
34844 * Returns: %TRUE if @type is a tuple type
34851 * g_variant_type_is_variant:
34852 * @type: a #GVariantType
34854 * Determines if the given @type is the variant type.
34856 * Returns: %TRUE if @type is the variant type
34863 * g_variant_type_key:
34864 * @type: a dictionary entry #GVariantType
34866 * Determines the key type of a dictionary entry type.
34868 * This function may only be used with a dictionary entry type. Other
34869 * than the additional restriction, this call is equivalent to
34870 * g_variant_type_first().
34872 * Returns: (transfer none): the key type of the dictionary entry
34879 * g_variant_type_n_items:
34880 * @type: a tuple or dictionary entry #GVariantType
34882 * Determines the number of items contained in a tuple or
34883 * dictionary entry type.
34885 * This function may only be used with tuple or dictionary entry types,
34886 * but must not be used with the generic tuple type
34887 * %G_VARIANT_TYPE_TUPLE.
34889 * In the case of a dictionary entry type, this function will always
34892 * Returns: the number of items in @type
34899 * g_variant_type_new:
34900 * @type_string: a valid GVariant type string
34902 * Creates a new #GVariantType corresponding to the type string given
34903 * by @type_string. It is appropriate to call g_variant_type_free() on
34904 * the return value.
34906 * It is a programmer error to call this function with an invalid type
34907 * string. Use g_variant_type_string_is_valid() if you are unsure.
34909 * Returns: (transfer full): a new #GVariantType
34915 * g_variant_type_new_array: (constructor)
34916 * @element: a #GVariantType
34918 * Constructs the type corresponding to an array of elements of the
34921 * It is appropriate to call g_variant_type_free() on the return value.
34923 * Returns: (transfer full): a new array #GVariantType
34930 * g_variant_type_new_dict_entry: (constructor)
34931 * @key: a basic #GVariantType
34932 * @value: a #GVariantType
34934 * Constructs the type corresponding to a dictionary entry with a key
34935 * of type @key and a value of type @value.
34937 * It is appropriate to call g_variant_type_free() on the return value.
34939 * Returns: (transfer full): a new dictionary entry #GVariantType
34946 * g_variant_type_new_maybe: (constructor)
34947 * @element: a #GVariantType
34949 * Constructs the type corresponding to a maybe instance containing
34950 * type @type or Nothing.
34952 * It is appropriate to call g_variant_type_free() on the return value.
34954 * Returns: (transfer full): a new maybe #GVariantType
34961 * g_variant_type_new_tuple:
34962 * @items: (array length=length): an array of #GVariantTypes, one for each item
34963 * @length: the length of @items, or -1
34965 * Constructs a new tuple type, from @items.
34967 * @length is the number of items in @items, or -1 to indicate that
34968 * @items is %NULL-terminated.
34970 * It is appropriate to call g_variant_type_free() on the return value.
34972 * Returns: (transfer full): a new tuple #GVariantType
34979 * g_variant_type_next:
34980 * @type: a #GVariantType from a previous call
34982 * Determines the next item type of a tuple or dictionary entry
34985 * @type must be the result of a previous call to
34986 * g_variant_type_first() or g_variant_type_next().
34988 * If called on the key type of a dictionary entry then this call
34989 * returns the value type. If called on the value type of a dictionary
34990 * entry then this call returns %NULL.
34992 * For tuples, %NULL is returned when @type is the last item in a tuple.
34994 * Returns: (transfer none): the next #GVariantType after @type, or %NULL
35001 * g_variant_type_peek_string: (skip)
35002 * @type: a #GVariantType
35004 * Returns the type string corresponding to the given @type. The
35005 * result is not nul-terminated; in order to determine its length you
35006 * must call g_variant_type_get_string_length().
35008 * To get a nul-terminated string, see g_variant_type_dup_string().
35010 * Returns: the corresponding type string (not nul-terminated)
35017 * g_variant_type_string_is_valid:
35018 * @type_string: a pointer to any string
35020 * Checks if @type_string is a valid GVariant type string. This call is
35021 * equivalent to calling g_variant_type_string_scan() and confirming
35022 * that the following character is a nul terminator.
35024 * Returns: %TRUE if @type_string is exactly one valid type string
35031 * g_variant_type_string_scan:
35032 * @string: a pointer to any string
35033 * @limit: (allow-none): the end of @string, or %NULL
35034 * @endptr: (out) (allow-none): location to store the end pointer, or %NULL
35036 * Scan for a single complete and valid GVariant type string in @string.
35037 * The memory pointed to by @limit (or bytes beyond it) is never
35040 * If a valid type string is found, @endptr is updated to point to the
35041 * first character past the end of the string that was found and %TRUE
35044 * If there is no valid type string starting at @string, or if the type
35045 * string does not end before @limit then %FALSE is returned.
35047 * For the simple case of checking if a string is a valid type string,
35048 * see g_variant_type_string_is_valid().
35050 * Returns: %TRUE if a valid type string was found
35056 * g_variant_type_value:
35057 * @type: a dictionary entry #GVariantType
35059 * Determines the value type of a dictionary entry type.
35061 * This function may only be used with a dictionary entry type.
35063 * Returns: (transfer none): the value type of the dictionary entry
35071 * @value: a #GVariant
35073 * Decreases the reference count of @value. When its reference count
35074 * drops to 0, the memory used by the variant is freed.
35082 * @string: the return location for the newly-allocated string.
35083 * @format: a standard printf() format string, but notice
35084 * <link linkend="string-precision">string precision pitfalls</link>.
35085 * @args: the list of arguments to insert in the output.
35087 * An implementation of the GNU vasprintf() function which supports
35088 * positional parameters, as specified in the Single Unix Specification.
35089 * This function is similar to g_vsprintf(), except that it allocates a
35090 * string to hold the output, instead of putting the output in a buffer
35091 * you allocate in advance.
35093 * Returns: the number of bytes printed.
35100 * @file: the stream to write to.
35101 * @format: a standard printf() format string, but notice
35102 * <link linkend="string-precision">string precision pitfalls</link>.
35103 * @args: the list of arguments to insert in the output.
35105 * An implementation of the standard fprintf() function which supports
35106 * positional parameters, as specified in the Single Unix Specification.
35108 * Returns: the number of bytes printed.
35115 * @format: a standard printf() format string, but notice
35116 * <link linkend="string-precision">string precision pitfalls</link>.
35117 * @args: the list of arguments to insert in the output.
35119 * An implementation of the standard vprintf() function which supports
35120 * positional parameters, as specified in the Single Unix Specification.
35122 * Returns: the number of bytes printed.
35129 * @string: the buffer to hold the output.
35130 * @n: the maximum number of bytes to produce (including the
35131 * terminating nul character).
35132 * @format: a standard printf() format string, but notice
35133 * <link linkend="string-precision">string precision pitfalls</link>.
35134 * @args: the list of arguments to insert in the output.
35136 * A safer form of the standard vsprintf() function. The output is guaranteed
35137 * to not exceed @n characters (including the terminating nul character), so
35138 * it is easy to ensure that a buffer overflow cannot occur.
35140 * See also g_strdup_vprintf().
35142 * In versions of GLib prior to 1.2.3, this function may return -1 if the
35143 * output was truncated, and the truncated string may not be nul-terminated.
35144 * In versions prior to 1.3.12, this function returns the length of the output
35147 * The return value of g_vsnprintf() conforms to the vsnprintf() function
35148 * as standardized in ISO C99. Note that this is different from traditional
35149 * vsnprintf(), which returns the length of the output string.
35151 * The format string may contain positional parameters, as specified in
35152 * the Single Unix Specification.
35154 * Returns: the number of bytes which would be produced if the buffer
35155 * was large enough.
35161 * @string: the buffer to hold the output.
35162 * @format: a standard printf() format string, but notice
35163 * <link linkend="string-precision">string precision pitfalls</link>.
35164 * @args: the list of arguments to insert in the output.
35166 * An implementation of the standard vsprintf() function which supports
35167 * positional parameters, as specified in the Single Unix Specification.
35169 * Returns: the number of bytes printed.
35175 * g_wakeup_acknowledge:
35176 * @wakeup: a #GWakeup
35178 * Acknowledges receipt of a wakeup signal on @wakeup.
35180 * You must call this after @wakeup polls as ready. If not, it will
35181 * continue to poll as ready until you do so.
35183 * If you call this function and @wakeup is not signaled, nothing
35192 * @wakeup: a #GWakeup
35196 * You must not currently be polling on the #GPollFD returned by
35197 * g_wakeup_get_pollfd(), or the result is undefined.
35202 * g_wakeup_get_pollfd:
35203 * @wakeup: a #GWakeup
35204 * @poll_fd: a #GPollFD
35206 * Prepares a @poll_fd such that polling on it will succeed when
35207 * g_wakeup_signal() has been called on @wakeup.
35209 * @poll_fd is valid until @wakeup is freed.
35218 * Creates a new #GWakeup.
35220 * You should use g_wakeup_free() to free it when you are done.
35222 * Returns: a new #GWakeup
35229 * @wakeup: a #GWakeup
35233 * Any future (or present) polling on the #GPollFD returned by
35234 * g_wakeup_get_pollfd() will immediately succeed until such a time as
35235 * g_wakeup_acknowledge() is called.
35237 * This function is safe to call from a UNIX signal handler.
35245 * @...: format string, followed by parameters to insert
35246 * into the format string (as with printf())
35248 * A convenience function/macro to log a warning message.
35250 * You can make warnings fatal at runtime by setting the
35251 * <envar>G_DEBUG</envar> environment variable (see
35252 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
35254 * If g_log_default_handler() is used as the log handler function, a new-line
35255 * character will automatically be appended to @..., and need not be entered
35261 * g_win32_error_message:
35262 * @error: error code.
35264 * Translate a Win32 error code (as returned by GetLastError()) into
35265 * the corresponding message. The message is either language neutral,
35266 * or in the thread's language, or the user's language, the system's
35267 * language, or US English (see docs for FormatMessage()). The
35268 * returned string is in UTF-8. It should be deallocated with
35271 * Returns: newly-allocated error message
35276 * g_win32_get_package_installation_directory:
35277 * @package: (allow-none): You should pass %NULL for this.
35278 * @dll_name: (allow-none): The name of a DLL that a package provides in UTF-8, or %NULL.
35280 * Try to determine the installation directory for a software package.
35282 * This function is deprecated. Use
35283 * g_win32_get_package_installation_directory_of_module() instead.
35285 * The use of @package is deprecated. You should always pass %NULL. A
35286 * warning is printed if non-NULL is passed as @package.
35288 * The original intended use of @package was for a short identifier of
35289 * the package, typically the same identifier as used for
35290 * <literal>GETTEXT_PACKAGE</literal> in software configured using GNU
35291 * autotools. The function first looks in the Windows Registry for the
35292 * value <literal>#InstallationDirectory</literal> in the key
35293 * <literal>#HKLM\Software\@package</literal>, and if that value
35294 * exists and is a string, returns that.
35296 * It is strongly recommended that packagers of GLib-using libraries
35297 * for Windows do not store installation paths in the Registry to be
35298 * used by this function as that interfers with having several
35299 * parallel installations of the library. Enabling multiple
35300 * installations of different versions of some GLib-using library, or
35301 * GLib itself, is desirable for various reasons.
35303 * For this reason it is recommeded to always pass %NULL as
35304 * @package to this function, to avoid the temptation to use the
35305 * Registry. In version 2.20 of GLib the @package parameter
35306 * will be ignored and this function won't look in the Registry at all.
35308 * If @package is %NULL, or the above value isn't found in the
35309 * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
35310 * into the current process. Typically that would be the name of the
35311 * DLL calling this function, looking for its installation
35312 * directory. The function then asks Windows what directory that DLL
35313 * was loaded from. If that directory's last component is "bin" or
35314 * "lib", the parent directory is returned, otherwise the directory
35315 * itself. If that DLL isn't loaded, the function proceeds as if
35316 * @dll_name was %NULL.
35318 * If both @package and @dll_name are %NULL, the directory from where
35319 * the main executable of the process was loaded is used instead in
35320 * the same way as above.
35322 * Returns: a string containing the installation directory for
35323 * @package. The string is in the GLib file name encoding,
35324 * i.e. UTF-8. The return value should be freed with g_free() when not
35325 * needed any longer. If the function fails %NULL is returned.
35326 * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to
35327 * g_win32_get_package_installation_directory_of_module() instead.
35332 * g_win32_get_package_installation_directory_of_module:
35333 * @hmodule: (allow-none): The Win32 handle for a DLL loaded into the current process, or %NULL
35335 * This function tries to determine the installation directory of a
35336 * software package based on the location of a DLL of the software
35339 * @hmodule should be the handle of a loaded DLL or %NULL. The
35340 * function looks up the directory that DLL was loaded from. If
35341 * @hmodule is NULL, the directory the main executable of the current
35342 * process is looked up. If that directory's last component is "bin"
35343 * or "lib", its parent directory is returned, otherwise the directory
35346 * It thus makes sense to pass only the handle to a "public" DLL of a
35347 * software package to this function, as such DLLs typically are known
35348 * to be installed in a "bin" or occasionally "lib" subfolder of the
35349 * installation folder. DLLs that are of the dynamically loaded module
35350 * or plugin variety are often located in more private locations
35351 * deeper down in the tree, from which it is impossible for GLib to
35352 * deduce the root of the package installation.
35354 * The typical use case for this function is to have a DllMain() that
35355 * saves the handle for the DLL. Then when code in the DLL needs to
35356 * construct names of files in the installation tree it calls this
35357 * function passing the DLL handle.
35359 * Returns: a string containing the guessed installation directory for
35360 * the software package @hmodule is from. The string is in the GLib
35361 * file name encoding, i.e. UTF-8. The return value should be freed
35362 * with g_free() when not needed any longer. If the function fails
35363 * %NULL is returned.
35369 * g_win32_get_package_installation_subdirectory:
35370 * @package: (allow-none): You should pass %NULL for this.
35371 * @dll_name: (allow-none): The name of a DLL that a package provides, in UTF-8, or %NULL.
35372 * @subdir: A subdirectory of the package installation directory, also in UTF-8
35374 * This function is deprecated. Use
35375 * g_win32_get_package_installation_directory_of_module() and
35376 * g_build_filename() instead.
35378 * Returns a newly-allocated string containing the path of the
35379 * subdirectory @subdir in the return value from calling
35380 * g_win32_get_package_installation_directory() with the @package and
35381 * @dll_name parameters. See the documentation for
35382 * g_win32_get_package_installation_directory() for more details. In
35383 * particular, note that it is deprecated to pass anything except NULL
35386 * Returns: a string containing the complete path to @subdir inside
35387 * the installation directory of @package. The returned string is in
35388 * the GLib file name encoding, i.e. UTF-8. The return value should be
35389 * freed with g_free() when no longer needed. If something goes wrong,
35390 * %NULL is returned.
35391 * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to
35392 * g_win32_get_package_installation_directory_of_module() instead, and
35393 * then construct a subdirectory pathname with g_build_filename().
35398 * g_win32_get_windows_version:
35400 * Returns version information for the Windows operating system the
35401 * code is running on. See MSDN documentation for the GetVersion()
35402 * function. To summarize, the most significant bit is one on Win9x,
35403 * and zero on NT-based systems. Since version 2.14, GLib works only
35404 * on NT-based systems, so checking whether your are running on Win9x
35405 * in your own software is moot. The least significant byte is 4 on
35406 * Windows NT 4, and 5 on Windows XP. Software that needs really
35407 * detailed version and feature information should use Win32 API like
35408 * GetVersionEx() and VerifyVersionInfo().
35410 * Returns: The version information.
35416 * g_win32_getlocale:
35418 * The setlocale() function in the Microsoft C library uses locale
35419 * names of the form "English_United States.1252" etc. We want the
35420 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
35421 * current thread locale from Windows - without any encoding info -
35422 * and returns it as a string of the above form for use in forming
35423 * file names etc. The returned string should be deallocated with
35426 * Returns: newly-allocated locale name.
35431 * g_win32_locale_filename_from_utf8:
35432 * @utf8filename: a UTF-8 encoded filename.
35434 * Converts a filename from UTF-8 to the system codepage.
35436 * On NT-based Windows, on NTFS file systems, file names are in
35437 * Unicode. It is quite possible that Unicode file names contain
35438 * characters not representable in the system codepage. (For instance,
35439 * Greek or Cyrillic characters on Western European or US Windows
35440 * installations, or various less common CJK characters on CJK Windows
35443 * In such a case, and if the filename refers to an existing file, and
35444 * the file system stores alternate short (8.3) names for directory
35445 * entries, the short form of the filename is returned. Note that the
35446 * "short" name might in fact be longer than the Unicode name if the
35447 * Unicode name has very short pathname components containing
35448 * non-ASCII characters. If no system codepage name for the file is
35449 * possible, %NULL is returned.
35451 * The return value is dynamically allocated and should be freed with
35452 * g_free() when no longer needed.
35454 * Returns: The converted filename, or %NULL on conversion
35455 * failure and lack of short names.
35463 * A standard boolean type.
35464 * Variables of this type should only contain the value
35472 * Corresponds to the standard C <type>char</type> type.
35479 * An untyped pointer to constant data.
35480 * The data pointed to should not be changed.
35482 * This is typically used in function prototypes to indicate
35483 * that the data pointed to will not be altered by the function.
35490 * Corresponds to the standard C <type>double</type> type.
35491 * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
35498 * Corresponds to the standard C <type>float</type> type.
35499 * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
35506 * Corresponds to the standard C <type>int</type> type.
35507 * Values of this type can range from #G_MININT to #G_MAXINT.
35514 * A signed integer guaranteed to be 16 bits on all platforms.
35515 * Values of this type can range from #G_MININT16 (= -32,768) to
35516 * #G_MAXINT16 (= 32,767).
35518 * To print or scan values of this type, use
35519 * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
35526 * A signed integer guaranteed to be 32 bits on all platforms.
35527 * Values of this type can range from #G_MININT32 (= -2,147,483,648)
35528 * to #G_MAXINT32 (= 2,147,483,647).
35530 * To print or scan values of this type, use
35531 * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
35538 * A signed integer guaranteed to be 64 bits on all platforms.
35539 * Values of this type can range from #G_MININT64
35540 * (= -9,223,372,036,854,775,808) to #G_MAXINT64
35541 * (= 9,223,372,036,854,775,807).
35543 * To print or scan values of this type, use
35544 * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
35551 * A signed integer guaranteed to be 8 bits on all platforms.
35552 * Values of this type can range from #G_MININT8 (= -128) to
35553 * #G_MAXINT8 (= 127).
35560 * Corresponds to the C99 type <type>intptr_t</type>,
35561 * a signed integer type that can hold any pointer.
35563 * To print or scan values of this type, use
35564 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
35572 * @arg: Do not use this argument
35574 * Do not call this function; it is used to share private
35575 * API between glib, gobject, and gio.
35580 * glib_check_version:
35581 * @required_major: the required major version.
35582 * @required_minor: the required minor version.
35583 * @required_micro: the required micro version.
35585 * Checks that the GLib library in use is compatible with the
35586 * given version. Generally you would pass in the constants
35587 * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
35588 * as the three arguments to this function; that produces
35589 * a check that the library in use is compatible with
35590 * the version of GLib the application or module was compiled
35593 * Compatibility is defined by two things: first the version
35594 * of the running library is newer than the version
35595 * @required_major.required_minor.@required_micro. Second
35596 * the running library must be binary compatible with the
35597 * version @required_major.required_minor.@required_micro
35598 * (same major version.)
35600 * Returns: %NULL if the GLib library is compatible with the
35601 * given version, or a string describing the version mismatch.
35602 * The returned string is owned by GLib and must not be modified
35610 * @str: The string to be translated
35612 * Returns the translated string from the glib translations.
35613 * This is an internal function and should only be used by
35614 * the internals of glib (such as libgio).
35616 * Returns: the transation of @str to the current locale
35621 * glib_mem_profiler_table:
35623 * A #GMemVTable containing profiling variants of the memory
35624 * allocation functions. Use them together with g_mem_profile()
35625 * in order to get information about the memory allocation pattern
35632 * @msgctxtid: a combined message context and message id, separated
35633 * by a \004 character
35634 * @msgidoffset: the offset of the message id in @msgctxid
35636 * This function is a variant of glib_gettext() which supports
35637 * a disambiguating message context. See g_dpgettext() for full
35640 * This is an internal function and should only be used by
35641 * the internals of glib (such as libgio).
35643 * Returns: the translation of @str to the current locale
35650 * Corresponds to the standard C <type>long</type> type.
35651 * Values of this type can range from #G_MINLONG to #G_MAXLONG.
35658 * A signed integer type that is used for file offsets,
35659 * corresponding to the C99 type <type>off64_t</type>.
35660 * Values of this type can range from #G_MINOFFSET to
35663 * To print or scan values of this type, use
35664 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
35673 * An untyped pointer.
35674 * #gpointer looks better and is easier to use
35675 * than <type>void*</type>.
35682 * Corresponds to the standard C <type>short</type> type.
35683 * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
35690 * An unsigned integer type of the result of the sizeof operator,
35691 * corresponding to the <type>size_t</type> type defined in C99.
35692 * This type is wide enough to hold the numeric value of a pointer,
35693 * so it is usually 32bit wide on a 32bit platform and 64bit wide
35694 * on a 64bit platform. Values of this type can range from 0 to
35697 * To print or scan values of this type, use
35698 * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
35705 * A signed variant of #gsize, corresponding to the
35706 * <type>ssize_t</type> defined on most platforms.
35707 * Values of this type can range from #G_MINSSIZE
35710 * To print or scan values of this type, use
35711 * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
35718 * Corresponds to the standard C <type>unsigned char</type> type.
35725 * Corresponds to the standard C <type>unsigned int</type> type.
35726 * Values of this type can range from 0 to #G_MAXUINT.
35733 * An unsigned integer guaranteed to be 16 bits on all platforms.
35734 * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
35736 * To print or scan values of this type, use
35737 * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
35744 * An unsigned integer guaranteed to be 32 bits on all platforms.
35745 * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
35747 * To print or scan values of this type, use
35748 * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
35755 * An unsigned integer guaranteed to be 64 bits on all platforms.
35756 * Values of this type can range from 0 to #G_MAXUINT64
35757 * (= 18,446,744,073,709,551,615).
35759 * To print or scan values of this type, use
35760 * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
35767 * An unsigned integer guaranteed to be 8 bits on all platforms.
35768 * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
35775 * Corresponds to the C99 type <type>uintptr_t</type>,
35776 * an unsigned integer type that can hold any pointer.
35778 * To print or scan values of this type, use
35779 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
35788 * Corresponds to the standard C <type>unsigned long</type> type.
35789 * Values of this type can range from 0 to #G_MAXULONG.
35796 * Corresponds to the standard C <type>unsigned short</type> type.
35797 * Values of this type can range from 0 to #G_MAXUSHORT.
35802 /************************************************************/
35803 /* THIS FILE IS GENERATED DO NOT EDIT */
35804 /************************************************************/