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 elements are added to the #GArray.
72 * @len: the number of elements in the #GArray not including the possible terminating zero element.
74 * Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
81 * The GAsyncQueue struct is an opaque data structure which represents
82 * an asynchronous queue. It should only be accessed through the
83 * <function>g_async_queue_*</function> functions.
89 * @data: a pointer to the element data. The data may be moved as elements are added to the #GByteArray.
90 * @len: the number of elements in the #GByteArray.
92 * The <structname>GByteArray</structname> struct allows access to the
93 * public fields of a <structname>GByteArray</structname>.
100 * A simple refcounted data type representing an immutable byte sequence
101 * from an unspecified origin.
103 * The purpose of a #GBytes is to keep the memory region that it holds
104 * alive for as long as anyone holds a reference to the bytes. When
105 * the last reference count is dropped, the memory is released. Multiple
106 * unrelated callers can use byte data in the #GBytes without coordinating
107 * their activities, resting assured that the byte data will not change or
108 * move while they hold a reference.
110 * A #GBytes can come from many different origins that may have
111 * different procedures for freeing the memory region. Examples are
112 * memory from g_malloc(), from memory slices, from a #GMappedFile or
113 * memory from other allocators.
115 * #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
116 * g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
117 * #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
118 * function to g_tree_new().
120 * The data pointed to by this bytes must not be modified. For a mutable
121 * array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
122 * mutable array for a #GBytes sequence. To create an immutable #GBytes from
123 * a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
132 * @b: a value to compare with.
133 * @user_data: user data to pass to comparison function.
135 * Specifies the type of a comparison function used to compare two
136 * values. The function should return a negative integer if the first
137 * value comes before the second, 0 if they are equal, or a positive
138 * integer if the first value comes after the second.
140 * Returns: negative value if @a < @b; zero if @a = @b; positive value if @a > @b.
147 * @b: a value to compare with.
149 * Specifies the type of a comparison function used to compare two
150 * values. The function should return a negative integer if the first
151 * value comes before the second, 0 if they are equal, or a positive
152 * integer if the first value comes after the second.
154 * Returns: negative value if @a < @b; zero if @a = @b; positive value if @a > @b.
161 * The #GCond struct is an opaque data structure that represents a
162 * condition. Threads can block on a #GCond if they find a certain
163 * condition to be false. If other threads change the state of this
164 * condition they signal the #GCond, and that causes the waiting
165 * threads to be woken up.
167 * Consider the following example of a shared variable. One or more
168 * threads can wait for data to be published to the variable and when
169 * another thread publishes the data, it can signal one of the waiting
170 * threads to wake up to collect the data.
174 * Using GCond to block a thread until a condition is satisfied
177 * gpointer current_data = NULL;
182 * push_data (gpointer data)
184 * g_mutex_lock (&data_mutex);
185 * current_data = data;
186 * g_cond_signal (&data_cond);
187 * g_mutex_unlock (&data_mutex);
195 * g_mutex_lock (&data_mutex);
196 * while (!current_data)
197 * g_cond_wait (&data_cond, &data_mutex);
198 * data = current_data;
199 * current_data = NULL;
200 * g_mutex_unlock (&data_mutex);
207 * Whenever a thread calls pop_data() now, it will wait until
208 * current_data is non-%NULL, i.e. until some other thread
209 * has called push_data().
211 * The example shows that use of a condition variable must always be
212 * paired with a mutex. Without the use of a mutex, there would be a
213 * race between the check of <varname>current_data</varname> by the
214 * while loop in <function>pop_data</function> and waiting.
215 * Specifically, another thread could set <varname>pop_data</varname>
216 * after the check, and signal the cond (with nobody waiting on it)
217 * before the first thread goes to sleep. #GCond is specifically useful
218 * for its ability to release the mutex and go to sleep atomically.
220 * It is also important to use the g_cond_wait() and g_cond_wait_until()
221 * functions only inside a loop which checks for the condition to be
222 * true. See g_cond_wait() for an explanation of why the condition may
223 * not be true even after it returns.
225 * If a #GCond is allocated in static storage then it can be used
226 * without initialisation. Otherwise, you should call g_cond_init() on
227 * it and g_cond_clear() when done.
229 * A #GCond should only be accessed via the <function>g_cond_</function>
237 * The #GData struct is an opaque data structure to represent a <link
238 * linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
239 * only be accessed via the following functions.
245 * @key_id: the #GQuark id to identifying the data element.
246 * @data: the data element.
247 * @user_data: user data passed to g_dataset_foreach().
249 * Specifies the type of function passed to g_dataset_foreach(). It is
250 * called with each #GQuark id and associated data element, together
251 * with the @user_data parameter supplied to g_dataset_foreach().
257 * @julian_days: the Julian representation of the date
258 * @julian: this bit is set if @julian_days is valid
259 * @dmy: this is set if @day, @month and @year are valid
260 * @day: the day of the day-month-year representation of the date, as a number between 1 and 31
261 * @month: the day of the day-month-year representation of the date, as a number between 1 and 12
262 * @year: the day of the day-month-year representation of the date
264 * Represents a day between January 1, Year 1 and a few thousand years in
265 * the future. None of its members should be accessed directly. If the
266 * <structname>GDate</structname> is obtained from g_date_new(), it will
267 * be safe to mutate but invalid and thus not safe for calendrical
268 * computations. If it's declared on the stack, it will contain garbage
269 * so must be initialized with g_date_clear(). g_date_clear() makes the
270 * date invalid but sane. An invalid date doesn't represent a day, it's
271 * "empty." A date becomes valid after you set it to a Julian day or you
272 * set a day, month, and year.
279 * @G_DATE_MONTH: a month
280 * @G_DATE_YEAR: a year
282 * This enumeration isn't used in the API, but may be useful if you need
283 * to mark a number as a day, month, or year.
290 * Integer representing a day of the month; between 1 and
291 * 31. #G_DATE_BAD_DAY represents an invalid day of the month.
297 * @G_DATE_BAD_MONTH: invalid value
298 * @G_DATE_JANUARY: January
299 * @G_DATE_FEBRUARY: February
300 * @G_DATE_MARCH: March
301 * @G_DATE_APRIL: April
305 * @G_DATE_AUGUST: August
306 * @G_DATE_SEPTEMBER: September
307 * @G_DATE_OCTOBER: October
308 * @G_DATE_NOVEMBER: November
309 * @G_DATE_DECEMBER: December
311 * Enumeration representing a month; values are #G_DATE_JANUARY,
312 * #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
318 * @G_DATE_BAD_WEEKDAY: invalid value
319 * @G_DATE_MONDAY: Monday
320 * @G_DATE_TUESDAY: Tuesday
321 * @G_DATE_WEDNESDAY: Wednesday
322 * @G_DATE_THURSDAY: Thursday
323 * @G_DATE_FRIDAY: Friday
324 * @G_DATE_SATURDAY: Saturday
325 * @G_DATE_SUNDAY: Sunday
327 * Enumeration representing a day of the week; #G_DATE_MONDAY,
328 * #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
335 * Integer representing a year; #G_DATE_BAD_YEAR is the invalid
336 * value. The year must be 1 or higher; negative (BC) years are not
337 * allowed. The year is represented with four digits.
343 * @data: the data element.
345 * Specifies the type of function which is called when a data element
346 * is destroyed. It is passed the pointer to the data element and
347 * should free any memory and resources allocated for it.
354 * An opaque structure representing an opened directory.
360 * @v_double: the double value
362 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
363 * mantissa and exponent of IEEE floats and doubles. These unions are defined
364 * as appropriate for a given platform. IEEE floats and doubles are supported
365 * (used for storage) by at least Intel, PPC and Sparc.
371 * @data: the data to duplicate
372 * @user_data: user data that was specified in g_datalist_id_dup_data()
374 * The type of functions that are used to 'duplicate' an object.
375 * What this means depends on the context, it could just be
376 * incrementing the reference count, if @data is a ref-counted
379 * Returns: a duplicate of data
386 * @b: a value to compare with
388 * Specifies the type of a function used to test two values for
389 * equality. The function should return %TRUE if both values are equal
390 * and %FALSE otherwise.
392 * Returns: %TRUE if @a = @b; %FALSE otherwise
398 * @G_ERR_UNKNOWN: unknown error
399 * @G_ERR_UNEXP_EOF: unexpected end of file
400 * @G_ERR_UNEXP_EOF_IN_STRING: unterminated string constant
401 * @G_ERR_UNEXP_EOF_IN_COMMENT: unterminated comment
402 * @G_ERR_NON_DIGIT_IN_CONST: non-digit character in a number
403 * @G_ERR_DIGIT_RADIX: digit beyond radix in a number
404 * @G_ERR_FLOAT_RADIX: non-decimal floating point number
405 * @G_ERR_FLOAT_MALFORMED: malformed floating point number
407 * The possible errors, used in the @v_error field
408 * of #GTokenValue, when the token is a %G_TOKEN_ERROR.
414 * @G_FILE_ERROR_EXIST: Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
415 * @G_FILE_ERROR_ISDIR: File is a directory; you cannot open a directory for writing, or create or remove hard links to it.
416 * @G_FILE_ERROR_ACCES: Permission denied; the file permissions do not allow the attempted operation.
417 * @G_FILE_ERROR_NAMETOOLONG: Filename too long.
418 * @G_FILE_ERROR_NOENT: No such file or directory. This is a "file doesn't exist" error for ordinary files that are referenced in contexts where they are expected to already exist.
419 * @G_FILE_ERROR_NOTDIR: A file that isn't a directory was specified when a directory is required.
420 * @G_FILE_ERROR_NXIO: No such device or address. The system tried to use the device represented by a file you specified, and it couldn't find the device. This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer.
421 * @G_FILE_ERROR_NODEV: The underlying file system of the specified file does not support memory mapping.
422 * @G_FILE_ERROR_ROFS: The directory containing the new link can't be modified because it's on a read-only file system.
423 * @G_FILE_ERROR_TXTBSY: Text file busy.
424 * @G_FILE_ERROR_FAULT: You passed in a pointer to bad memory. (GLib won't reliably return this, don't pass in pointers to bad memory.)
425 * @G_FILE_ERROR_LOOP: Too many levels of symbolic links were encountered in looking up a file name. This often indicates a cycle of symbolic links.
426 * @G_FILE_ERROR_NOSPC: No space left on device; write operation on a file failed because the disk is full.
427 * @G_FILE_ERROR_NOMEM: No memory available. The system cannot allocate more virtual memory because its capacity is full.
428 * @G_FILE_ERROR_MFILE: The current process has too many files open and can't open any more. Duplicate descriptors do count toward this limit.
429 * @G_FILE_ERROR_NFILE: There are too many distinct file openings in the entire system.
430 * @G_FILE_ERROR_BADF: Bad file descriptor; for example, I/O on a descriptor that has been closed or reading from a descriptor open only for writing (or vice versa).
431 * @G_FILE_ERROR_INVAL: Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function.
432 * @G_FILE_ERROR_PIPE: Broken pipe; there is no process reading from the other end of a pipe. Every library function that returns this error code also generates a `SIGPIPE' signal; this signal terminates the program if not handled or blocked. Thus, your program will never actually see this code unless it has handled or blocked `SIGPIPE'.
433 * @G_FILE_ERROR_AGAIN: Resource temporarily unavailable; the call might work if you try again later.
434 * @G_FILE_ERROR_INTR: Interrupted function call; an asynchronous signal occurred and prevented completion of the call. When this happens, you should try the call again.
435 * @G_FILE_ERROR_IO: Input/output error; usually used for physical read or write errors. i.e. the disk or other physical device hardware is returning errors.
436 * @G_FILE_ERROR_PERM: Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
437 * @G_FILE_ERROR_NOSYS: Function not implemented; this indicates that the system is missing some functionality.
438 * @G_FILE_ERROR_FAILED: Does not correspond to a UNIX error code; this is the standard "failed for unspecified reason" error code present in all #GError error code enumerations. Returned if no specific code applies.
440 * Values corresponding to @errno codes returned from file operations
441 * on UNIX. Unlike @errno codes, GFileError values are available on
442 * all systems, even Windows. The exact meaning of each code depends
443 * on what sort of file operation you were performing; the UNIX
444 * documentation gives more details. The following error code descriptions
445 * come from the GNU C Library manual, and are under the copyright
448 * It's not very portable to make detailed assumptions about exactly
449 * which errors will be returned from a given operation. Some errors
450 * don't occur on some systems, etc., sometimes there are subtle
451 * differences in when a system will report a given error, etc.
457 * @G_FILE_TEST_IS_REGULAR: %TRUE if the file is a regular file (not a directory). Note that this test will also return %TRUE if the tested file is a symlink to a regular file.
458 * @G_FILE_TEST_IS_SYMLINK: %TRUE if the file is a symlink.
459 * @G_FILE_TEST_IS_DIR: %TRUE if the file is a directory.
460 * @G_FILE_TEST_IS_EXECUTABLE: %TRUE if the file is executable.
461 * @G_FILE_TEST_EXISTS: %TRUE if the file exists. It may or may not be a regular file.
463 * A test to perform on a file using g_file_test().
469 * @v_float: the double value
471 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
472 * mantissa and exponent of IEEE floats and doubles. These unions are defined
473 * as appropriate for a given platform. IEEE floats and doubles are supported
474 * (used for storage) by at least Intel, PPC and Sparc.
480 * @G_FORMAT_SIZE_DEFAULT: behave the same as g_format_size()
481 * @G_FORMAT_SIZE_LONG_FORMAT: include the exact number of bytes as part of the returned string. For example, "45.6 kB (45,612 bytes)".
482 * @G_FORMAT_SIZE_IEC_UNITS: use IEC (base 1024) units with "KiB"-style suffixes. IEC units should only be used for reporting things with a strong "power of 2" basis, like RAM sizes or RAID stripe sizes. Network and storage sizes should be reported in the normal SI units.
484 * Flags to modify the format of the string returned by g_format_size_full().
490 * @data: the element's data.
491 * @user_data: user data passed to g_list_foreach() or g_slist_foreach().
493 * Specifies the type of functions passed to g_list_foreach() and
501 * @value: the value corresponding to the key
502 * @user_data: user data passed to g_hash_table_foreach()
504 * Specifies the type of the function passed to g_hash_table_foreach().
505 * It is called with each key/value pair, together with the @user_data
506 * parameter which is passed to g_hash_table_foreach().
513 * @value: the value associated with the key
514 * @user_data: user data passed to g_hash_table_remove()
516 * Specifies the type of the function passed to
517 * g_hash_table_foreach_remove(). It is called with each key/value
518 * pair, together with the @user_data parameter passed to
519 * g_hash_table_foreach_remove(). It should return %TRUE if the
520 * key/value pair should be removed from the #GHashTable.
522 * Returns: %TRUE if the key/value pair should be removed from the #GHashTable
530 * Specifies the type of the hash function which is passed to
531 * g_hash_table_new() when a #GHashTable is created.
533 * The function is passed a key and should return a #guint hash value.
534 * The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
535 * hash functions which can be used when the key is a #gpointer, #gint*,
536 * and #gchar* respectively.
538 * g_direct_hash() is also the appropriate hash function for keys
539 * of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
541 * <!-- FIXME: Need more here. --> A good hash functions should produce
542 * hash values that are evenly distributed over a fairly large range.
543 * The modulus is taken with the hash table size (a prime number) to
544 * find the 'bucket' to place each key into. The function should also
545 * be very fast, since it is called for each key lookup.
547 * Note that the hash functions provided by GLib have these qualities,
548 * but are not particularly robust against manufactured keys that
549 * cause hash collisions. Therefore, you should consider choosing
550 * a more secure hash function when using a GHashTable with keys
551 * that originate in untrusted data (such as HTTP requests).
552 * Using g_str_hash() in that situation might make your application
553 * vulerable to <ulink url="https://lwn.net/Articles/474912/">Algorithmic Complexity Attacks</ulink>.
555 * The key to choosing a good hash is unpredictability. Even
556 * cryptographic hashes are very easy to find collisions for when the
557 * remainder is taken modulo a somewhat predictable prime number. There
558 * must be an element of randomness that an attacker is unable to guess.
560 * Returns: the hash value corresponding to the key
567 * The #GHashTable struct is an opaque data structure to represent a
568 * <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
569 * accessed via the following functions.
576 * A GHashTableIter structure represents an iterator that can be used
577 * to iterate over the elements of a #GHashTable. GHashTableIter
578 * structures are typically allocated on the stack and then initialized
579 * with g_hash_table_iter_init().
585 * @data: data which is passed to func when this hook is invoked
586 * @next: pointer to the next hook in the list
587 * @prev: pointer to the previous hook in the list
588 * @ref_count: the reference count of this hook
589 * @hook_id: the id of this hook, which is unique within its list
590 * @flags: flags which are set for this hook. See #GHookFlagMask for predefined flags
591 * @func: the function to call when this hook is invoked. The possible signatures for this function are #GHookFunc and #GHookCheckFunc
592 * @destroy: the default @finalize_hook function of a #GHookList calls this member of the hook that is being finalized
594 * The <structname>GHook</structname> struct represents a single hook
595 * function in a #GHookList.
601 * @data: the data field of the #GHook is passed to the hook function here
603 * Defines the type of a hook function that can be invoked
604 * by g_hook_list_invoke_check().
606 * Returns: %FALSE if the #GHook should be destroyed
611 * GHookCheckMarshaller:
613 * @marshal_data: user data
615 * Defines the type of function used by g_hook_list_marshal_check().
617 * Returns: %FALSE if @hook should be destroyed
623 * @new_hook: the #GHook being inserted
624 * @sibling: the #GHook to compare with @new_hook
626 * Defines the type of function used to compare #GHook elements in
627 * g_hook_insert_sorted().
629 * Returns: a value <= 0 if @new_hook should be before @sibling
635 * @hook_list: a #GHookList
636 * @hook: the hook in @hook_list that gets finalized
638 * Defines the type of function to be called when a hook in a
639 * list of hooks gets finalized.
646 * @data: user data passed to g_hook_find_func()
648 * Defines the type of the function passed to g_hook_find().
650 * Returns: %TRUE if the required #GHook has been found
656 * @G_HOOK_FLAG_ACTIVE: set if the hook has not been destroyed
657 * @G_HOOK_FLAG_IN_CALL: set if the hook is currently being run
658 * @G_HOOK_FLAG_MASK: A mask covering all bits reserved for hook flags; see %G_HOOK_FLAG_USER_SHIFT
660 * Flags used internally in the #GHook implementation.
666 * @data: the data field of the #GHook is passed to the hook function here
668 * Defines the type of a hook function that can be invoked
669 * by g_hook_list_invoke().
675 * @seq_id: the next free #GHook id
676 * @hook_size: the size of the #GHookList elements, in bytes
677 * @is_setup: 1 if the #GHookList has been initialized
678 * @hooks: the first #GHook element in the list
680 * @finalize_hook: the function to call to finalize a #GHook element. The default behaviour is to call the hooks @destroy function
683 * The <structname>GHookList</structname> struct represents a
684 * list of hook functions.
691 * @marshal_data: user data
693 * Defines the type of function used by g_hook_list_marshal().
699 * @val: a #gint16 value in big-endian byte order
701 * Converts a #gint16 value from big-endian to host byte order.
703 * Returns: @val converted to host byte order
709 * @val: a #gint16 value in little-endian byte order
711 * Converts a #gint16 value from little-endian to host byte order.
713 * Returns: @val converted to host byte order
719 * @val: a #gint16 value in host byte order
721 * Converts a #gint16 value from host byte order to big-endian.
723 * Returns: @val converted to big-endian
729 * @val: a #gint16 value in host byte order
731 * Converts a #gint16 value from host byte order to little-endian.
733 * Returns: @val converted to little-endian
739 * @val: a #gint32 value in big-endian byte order
741 * Converts a #gint32 value from big-endian to host byte order.
743 * Returns: @val converted to host byte order
749 * @val: a #gint32 value in little-endian byte order
751 * Converts a #gint32 value from little-endian to host byte order.
753 * Returns: @val converted to host byte order
759 * @val: a #gint32 value in host byte order
761 * Converts a #gint32 value from host byte order to big-endian.
763 * Returns: @val converted to big-endian
769 * @val: a #gint32 value in host byte order
771 * Converts a #gint32 value from host byte order to little-endian.
773 * Returns: @val converted to little-endian
779 * @val: a #gint64 value in big-endian byte order
781 * Converts a #gint64 value from big-endian to host byte order.
783 * Returns: @val converted to host byte order
789 * @val: a #gint64 value in little-endian byte order
791 * Converts a #gint64 value from little-endian to host byte order.
793 * Returns: @val converted to host byte order
799 * @val: a #gint64 value in host byte order
801 * Converts a #gint64 value from host byte order to big-endian.
803 * Returns: @val converted to big-endian
809 * @val: a #gint64 value in host byte order
811 * Converts a #gint64 value from host byte order to little-endian.
813 * Returns: @val converted to little-endian
819 * @val: a #gint value in big-endian byte order
821 * Converts a #gint value from big-endian to host byte order.
823 * Returns: @val converted to host byte order
829 * @val: a #gint value in little-endian byte order
831 * Converts a #gint value from little-endian to host byte order.
833 * Returns: @val converted to host byte order
839 * @val: a #gint value in host byte order
841 * Converts a #gint value from host byte order to big-endian.
843 * Returns: @val converted to big-endian byte order
849 * @val: a #gint value in host byte order
851 * Converts a #gint value from host byte order to little-endian.
853 * Returns: @val converted to little-endian byte order
859 * @i: integer to stuff into a pointer
861 * Stuffs an integer into a pointer type.
863 * Remember, you may not store pointers in integers. This is not portable
864 * in any way, shape or form. These macros <emphasis>only</emphasis> allow
865 * storing integers in pointers, and only preserve 32 bits of the
866 * integer; values outside the range of a 32-bit integer will be mangled.
873 * A data structure representing an IO Channel. The fields should be
874 * considered private and should only be accessed with the following
881 * @G_IO_CHANNEL_ERROR_FBIG: File too large.
882 * @G_IO_CHANNEL_ERROR_INVAL: Invalid argument.
883 * @G_IO_CHANNEL_ERROR_IO: IO error.
884 * @G_IO_CHANNEL_ERROR_ISDIR: File is a directory.
885 * @G_IO_CHANNEL_ERROR_NOSPC: No space left on device.
886 * @G_IO_CHANNEL_ERROR_NXIO: No such device or address.
887 * @G_IO_CHANNEL_ERROR_OVERFLOW: Value too large for defined datatype.
888 * @G_IO_CHANNEL_ERROR_PIPE: Broken pipe.
889 * @G_IO_CHANNEL_ERROR_FAILED: Some other error.
891 * Error codes returned by #GIOChannel operations.
897 * @G_IO_IN: There is data to read.
898 * @G_IO_OUT: Data can be written (without blocking).
899 * @G_IO_PRI: There is urgent data to read.
900 * @G_IO_ERR: Error condition.
901 * @G_IO_HUP: Hung up (the connection has been broken, usually for pipes and sockets).
902 * @G_IO_NVAL: Invalid request. The file descriptor is not open.
904 * A bitwise combination representing a condition to watch for on an
911 * @G_IO_ERROR_NONE: no error
912 * @G_IO_ERROR_AGAIN: an EAGAIN error occurred
913 * @G_IO_ERROR_INVAL: an EINVAL error occurred
914 * @G_IO_ERROR_UNKNOWN: another error occurred
916 * #GIOError is only used by the deprecated functions
917 * g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
923 * @G_IO_FLAG_APPEND: turns on append mode, corresponds to <literal>O_APPEND</literal> (see the documentation of the UNIX open() syscall).
924 * @G_IO_FLAG_NONBLOCK: turns on nonblocking mode, corresponds to <literal>O_NONBLOCK</literal>/<literal>O_NDELAY</literal> (see the documentation of the UNIX open() syscall).
925 * @G_IO_FLAG_IS_READABLE: indicates that the io channel is readable. This flag cannot be changed.
926 * @G_IO_FLAG_IS_WRITABLE: indicates that the io channel is writable. This flag cannot be changed.
927 * @G_IO_FLAG_IS_SEEKABLE: indicates that the io channel is seekable, i.e. that g_io_channel_seek_position() can be used on it. This flag cannot be changed.
928 * @G_IO_FLAG_MASK: the mask that specifies all the valid flags.
929 * @G_IO_FLAG_GET_MASK: the mask of the flags that are returned from g_io_channel_get_flags().
930 * @G_IO_FLAG_SET_MASK: the mask of the flags that the user can modify with g_io_channel_set_flags().
932 * Specifies properties of a #GIOChannel. Some of the flags can only be
933 * read with g_io_channel_get_flags(), but not changed with
934 * g_io_channel_set_flags().
940 * @source: the #GIOChannel event source
941 * @condition: the condition which has been satisfied
942 * @data: user data set in g_io_add_watch() or g_io_add_watch_full()
944 * Specifies the type of function passed to g_io_add_watch() or
945 * g_io_add_watch_full(), which is called when the requested condition
946 * on a #GIOChannel is satisfied.
948 * Returns: the function should return %FALSE if the event source should be removed
954 * @io_read: reads raw bytes from the channel. This is called from various functions such as g_io_channel_read_chars() to read raw bytes from the channel. Encoding and buffering issues are dealt with at a higher level.
955 * @io_write: writes raw bytes to the channel. This is called from various functions such as g_io_channel_write_chars() to write raw bytes to the channel. Encoding and buffering issues are dealt with at a higher level.
956 * @io_seek: (optional) seeks the channel. This is called from g_io_channel_seek() on channels that support it.
957 * @io_close: closes the channel. This is called from g_io_channel_close() after flushing the buffers.
958 * @io_create_watch: creates a watch on the channel. This call corresponds directly to g_io_create_watch().
959 * @io_free: called from g_io_channel_unref() when the channel needs to be freed. This function must free the memory associated with the channel, including freeing the #GIOChannel structure itself. The channel buffers have been flushed and possibly @io_close has been called by the time this function is called.
960 * @io_set_flags: sets the #GIOFlags on the channel. This is called from g_io_channel_set_flags() with all flags except for %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK masked out.
961 * @io_get_flags: gets the #GIOFlags for the channel. This function need only return the %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK flags; g_io_channel_get_flags() automatically adds the others as appropriate.
963 * A table of functions used to handle different types of #GIOChannel
970 * @G_IO_STATUS_ERROR: An error occurred.
971 * @G_IO_STATUS_NORMAL: Success.
972 * @G_IO_STATUS_EOF: End of file.
973 * @G_IO_STATUS_AGAIN: Resource temporarily unavailable.
975 * Stati returned by most of the #GIOFuncs functions.
982 * The GKeyFile struct contains only private data
983 * and should not be accessed directly.
989 * @G_KEY_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was in an unknown encoding
990 * @G_KEY_FILE_ERROR_PARSE: document was ill-formed
991 * @G_KEY_FILE_ERROR_NOT_FOUND: the file was not found
992 * @G_KEY_FILE_ERROR_KEY_NOT_FOUND: a requested key was not found
993 * @G_KEY_FILE_ERROR_GROUP_NOT_FOUND: a requested group was not found
994 * @G_KEY_FILE_ERROR_INVALID_VALUE: a value could not be parsed
996 * Error codes returned by key file parsing.
1002 * @G_KEY_FILE_NONE: No flags, default behaviour
1003 * @G_KEY_FILE_KEEP_COMMENTS: Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise all comments will be lost when the key file is written back.
1004 * @G_KEY_FILE_KEEP_TRANSLATIONS: Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise only the translations for the current language will be written back.
1006 * Flags which influence the parsing.
1011 * GLIB_CHECK_VERSION:
1012 * @major: the major version to check for
1013 * @minor: the minor version to check for
1014 * @micro: the micro version to check for
1016 * Checks the version of the GLib library that is being compiled
1020 * <title>Checking the version of the GLib library</title>
1022 * if (!GLIB_CHECK_VERSION (1, 2, 0))
1023 * g_error ("GLib version 1.2.0 or above is needed");
1027 * See glib_check_version() for a runtime check.
1029 * Returns: %TRUE if the version of the GLib header files is the same as or newer than the passed-in version.
1034 * GLIB_DISABLE_DEPRECATION_WARNINGS:
1036 * A macro that should be defined before including the glib.h header.
1037 * If it is defined, no compiler warnings will be produced for uses
1038 * of deprecated GLib APIs.
1043 * GLIB_MAJOR_VERSION:
1045 * The major version number of the GLib library.
1047 * Like #glib_major_version, but from the headers used at
1048 * application compile time, rather than from the library
1049 * linked against at application run time.
1054 * GLIB_MICRO_VERSION:
1056 * The micro version number of the GLib library.
1058 * Like #gtk_micro_version, but from the headers used at
1059 * application compile time, rather than from the library
1060 * linked against at application run time.
1065 * GLIB_MINOR_VERSION:
1067 * The minor version number of the GLib library.
1069 * Like #gtk_minor_version, but from the headers used at
1070 * application compile time, rather than from the library
1071 * linked against at application run time.
1077 * @val: a #glong value in big-endian byte order
1079 * Converts a #glong value from big-endian to the host byte order.
1081 * Returns: @val converted to host byte order
1087 * @val: a #glong value in little-endian byte order
1089 * Converts a #glong value from little-endian to host byte order.
1091 * Returns: @val converted to host byte order
1097 * @val: a #glong value in host byte order
1099 * Converts a #glong value from host byte order to big-endian.
1101 * Returns: @val converted to big-endian byte order
1107 * @val: a #glong value in host byte order
1109 * Converts a #glong value from host byte order to little-endian.
1111 * Returns: @val converted to little-endian
1117 * @data: holds the element's data, which can be a pointer to any kind of data, or any integer value using the <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
1118 * @next: contains the link to the next element in the list.
1119 * @prev: contains the link to the previous element in the list.
1121 * The #GList struct is used for each element in a doubly-linked list.
1127 * @log_domain: the log domain of the message
1128 * @log_level: the log level of the message (including the fatal and recursion flags)
1129 * @message: the message to process
1130 * @user_data: user data, set in g_log_set_handler()
1132 * Specifies the prototype of log handler functions.
1138 * @G_LOG_FLAG_RECURSION: internal flag
1139 * @G_LOG_FLAG_FATAL: internal flag
1140 * @G_LOG_LEVEL_ERROR: log level for errors, see g_error(). This level is also used for messages produced by g_assert().
1141 * @G_LOG_LEVEL_CRITICAL: log level for critical messages, see g_critical(). This level is also used for messages produced by g_return_if_fail() and g_return_val_if_fail().
1142 * @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
1143 * @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
1144 * @G_LOG_LEVEL_INFO: log level for informational messages
1145 * @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
1146 * @G_LOG_LEVEL_MASK: a mask including all log levels
1148 * Flags specifying the level of log messages.
1150 * It is possible to change how GLib treats messages of the various
1151 * levels using g_log_set_handler() and g_log_set_fatal_mask().
1158 * The #GMappedFile represents a file mapping created with
1159 * g_mapped_file_new(). It has only private members and should
1160 * not be accessed directly.
1165 * GMarkupCollectType:
1166 * @G_MARKUP_COLLECT_INVALID: used to terminate the list of attributes to collect
1167 * @G_MARKUP_COLLECT_STRING: collect the string pointer directly from the attribute_values[] array. Expects a parameter of type (const char **). If %G_MARKUP_COLLECT_OPTIONAL is specified and the attribute isn't present then the pointer will be set to %NULL
1168 * @G_MARKUP_COLLECT_STRDUP: as with %G_MARKUP_COLLECT_STRING, but expects a parameter of type (char **) and g_strdup()s the returned pointer. The pointer must be freed with g_free()
1169 * @G_MARKUP_COLLECT_BOOLEAN: expects a parameter of type (gboolean *) and parses the attribute value as a boolean. Sets %FALSE if the attribute isn't present. Valid boolean values consist of (case-insensitive) "false", "f", "no", "n", "0" and "true", "t", "yes", "y", "1"
1170 * @G_MARKUP_COLLECT_TRISTATE: as with %G_MARKUP_COLLECT_BOOLEAN, but in the case of a missing attribute a value is set that compares equal to neither %FALSE nor %TRUE G_MARKUP_COLLECT_OPTIONAL is implied
1171 * @G_MARKUP_COLLECT_OPTIONAL: can be bitwise ORed with the other fields. If present, allows the attribute not to appear. A default value is set depending on what value type is used
1173 * A mixed enumerated type and flags field. You must specify one type
1174 * (string, strdup, boolean, tristate). Additionally, you may optionally
1175 * bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
1177 * It is likely that this enum will be extended in the future to
1178 * support other types.
1185 * The #GMutex struct is an opaque data structure to represent a mutex
1186 * (mutual exclusion). It can be used to protect data against shared
1187 * access. Take for example the following function:
1190 * <title>A function which will not work in a threaded environment</title>
1193 * give_me_next_number (void)
1195 * static int current_number = 0;
1197 * /<!-- -->* now do a very complicated calculation to calculate the new
1198 * * number, this might for example be a random number generator
1200 * current_number = calc_next_number (current_number);
1202 * return current_number;
1207 * It is easy to see that this won't work in a multi-threaded
1208 * application. There current_number must be protected against shared
1209 * access. A #GMutex can be used as a solution to this problem:
1212 * <title>Using GMutex to protected a shared variable</title>
1215 * give_me_next_number (void)
1217 * static GMutex mutex;
1218 * static int current_number = 0;
1221 * g_mutex_lock (&mutex);
1222 * ret_val = current_number = calc_next_number (current_number);
1223 * g_mutex_unlock (&mutex);
1230 * Notice that the #GMutex is not initialised to any particular value.
1231 * Its placement in static storage ensures that it will be initialised
1232 * to all-zeros, which is appropriate.
1234 * If a #GMutex is placed in other contexts (eg: embedded in a struct)
1235 * then it must be explicitly initialised using g_mutex_init().
1237 * A #GMutex should only be accessed via <function>g_mutex_</function>
1244 * @data: contains the actual data of the node.
1245 * @next: points to the node's next sibling (a sibling is another #GNode with the same parent).
1246 * @prev: points to the node's previous sibling.
1247 * @parent: points to the parent of the #GNode, or is %NULL if the #GNode is the root of the tree.
1248 * @children: points to the first child of the #GNode. The other children are accessed by using the @next pointer of each child.
1250 * The #GNode struct represents one node in a
1251 * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
1258 * @data: user data passed to g_node_children_foreach().
1260 * Specifies the type of function passed to g_node_children_foreach().
1261 * The function is called with each child node, together with the user
1262 * data passed to g_node_children_foreach().
1267 * GNodeTraverseFunc:
1269 * @data: user data passed to g_node_traverse().
1271 * Specifies the type of function passed to g_node_traverse(). The
1272 * function is called with each of the nodes visited, together with the
1273 * user data passed to g_node_traverse(). If the function returns
1274 * %TRUE, then the traversal is stopped.
1276 * Returns: %TRUE to stop the traversal.
1282 * @status: the status of the #GOnce
1283 * @retval: the value returned by the call to the function, if @status is %G_ONCE_STATUS_READY
1285 * A #GOnce struct controls a one-time initialization function. Any
1286 * one-time initialization function must have its own unique #GOnce
1295 * @G_ONCE_STATUS_NOTCALLED: the function has not been called yet.
1296 * @G_ONCE_STATUS_PROGRESS: the function call is currently in progress.
1297 * @G_ONCE_STATUS_READY: the function has been called.
1299 * The possible statuses of a one-time initialization function
1300 * controlled by a #GOnce struct.
1308 * @p: pointer containing an integer
1310 * Extracts an integer from a pointer. The integer must have
1311 * been stored in the pointer with GINT_TO_POINTER().
1313 * Remember, you may not store pointers in integers. This is not portable
1314 * in any way, shape or form. These macros <emphasis>only</emphasis> allow
1315 * storing integers in pointers, and only preserve 32 bits of the
1316 * integer; values outside the range of a 32-bit integer will be mangled.
1322 * @p: pointer to extract a #gsize from
1324 * Extracts a #gsize from a pointer. The #gsize must have
1325 * been stored in the pointer with GSIZE_TO_POINTER().
1331 * @p: pointer to extract an unsigned integer from
1333 * Extracts an unsigned integer from a pointer. The integer must have
1334 * been stored in the pointer with GUINT_TO_POINTER().
1341 * A <structname>GPatternSpec</structname> is the 'compiled' form of a
1342 * pattern. This structure is opaque and its fields cannot be accessed
1350 * The #GPrivate struct is an opaque data structure to represent a
1351 * thread-local data key. It is approximately equivalent to the
1352 * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
1353 * TlsSetValue()/TlsGetValue() on Windows.
1355 * If you don't already know why you might want this functionality,
1356 * then you probably don't need it.
1358 * #GPrivate is a very limited resource (as far as 128 per program,
1359 * shared between all libraries). It is also not possible to destroy a
1360 * #GPrivate after it has been used. As such, it is only ever acceptable
1361 * to use #GPrivate in static scope, and even then sparingly so.
1363 * See G_PRIVATE_INIT() for a couple of examples.
1365 * The #GPrivate structure should be considered opaque. It should only
1366 * be accessed via the <function>g_private_</function> functions.
1372 * @pdata: points to the array of pointers, which may be moved when the array grows.
1373 * @len: number of pointers in the array.
1375 * Contains the public fields of a pointer array.
1382 * A GQuark is a non-zero integer which uniquely identifies a
1383 * particular string. A GQuark value of zero is associated to %NULL.
1390 * The GRWLock struct is an opaque data structure to represent a
1391 * reader-writer lock. It is similar to a #GMutex in that it allows
1392 * multiple threads to coordinate access to a shared resource.
1394 * The difference to a mutex is that a reader-writer lock discriminates
1395 * between read-only ('reader') and full ('writer') access. While only
1396 * one thread at a time is allowed write access (by holding the 'writer'
1397 * lock via g_rw_lock_writer_lock()), multiple threads can gain
1398 * simultaneous read-only access (by holding the 'reader' lock via
1399 * g_rw_lock_reader_lock()).
1402 * <title>An array with access functions</title>
1408 * my_array_get (guint index)
1410 * gpointer retval = NULL;
1415 * g_rw_lock_reader_lock (&lock);
1416 * if (index < array->len)
1417 * retval = g_ptr_array_index (array, index);
1418 * g_rw_lock_reader_unlock (&lock);
1424 * my_array_set (guint index, gpointer data)
1426 * g_rw_lock_writer_lock (&lock);
1429 * array = g_ptr_array_new (<!-- -->);
1431 * if (index >= array->len)
1432 * g_ptr_array_set_size (array, index+1);
1433 * g_ptr_array_index (array, index) = data;
1435 * g_rw_lock_writer_unlock (&lock);
1439 * This example shows an array which can be accessed by many readers
1440 * (the <function>my_array_get()</function> function) simultaneously,
1441 * whereas the writers (the <function>my_array_set()</function>
1442 * function) will only be allowed once at a time and only if no readers
1443 * currently access the array. This is because of the potentially
1444 * dangerous resizing of the array. Using these functions is fully
1445 * multi-thread safe now.
1449 * If a #GRWLock is allocated in static storage then it can be used
1450 * without initialisation. Otherwise, you should call
1451 * g_rw_lock_init() on it and g_rw_lock_clear() when done.
1453 * A GRWLock should only be accessed with the
1454 * <function>g_rw_lock_</function> functions.
1463 * The #GRand struct is an opaque data structure. It should only be
1464 * accessed through the <function>g_rand_*</function> functions.
1471 * The GRecMutex struct is an opaque data structure to represent a
1472 * recursive mutex. It is similar to a #GMutex with the difference
1473 * that it is possible to lock a GRecMutex multiple times in the same
1474 * thread without deadlock. When doing so, care has to be taken to
1475 * unlock the recursive mutex as often as it has been locked.
1477 * If a #GRecMutex is allocated in static storage then it can be used
1478 * without initialisation. Otherwise, you should call
1479 * g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
1481 * A GRecMutex should only be accessed with the
1482 * <function>g_rec_mutex_</function> functions.
1490 * @val: a #gsize value in big-endian byte order
1492 * Converts a #gsize value from big-endian to the host byte order.
1494 * Returns: @val converted to host byte order
1500 * @val: a #gsize value in little-endian byte order
1502 * Converts a #gsize value from little-endian to host byte order.
1504 * Returns: @val converted to host byte order
1510 * @val: a #gsize value in host byte order
1512 * Converts a #gsize value from host byte order to big-endian.
1514 * Returns: @val converted to big-endian byte order
1520 * @val: a #gsize value in host byte order
1522 * Converts a #gsize value from host byte order to little-endian.
1524 * Returns: @val converted to little-endian
1530 * @s: #gsize to stuff into the pointer
1532 * Stuffs a #gsize into a pointer type.
1538 * @data: holds the element's data, which can be a pointer to any kind of data, or any integer value using the <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
1539 * @next: contains the link to the next element in the list.
1541 * The #GSList struct is used for each element in the singly-linked
1548 * @val: a #gssize value in big-endian byte order
1550 * Converts a #gssize value from big-endian to host byte order.
1552 * Returns: @val converted to host byte order
1558 * @val: a #gssize value in little-endian byte order
1560 * Converts a #gssize value from little-endian to host byte order.
1562 * Returns: @val converted to host byte order
1568 * @val: a #gssize value in host byte order
1570 * Converts a #gssize value from host byte order to big-endian.
1572 * Returns: @val converted to big-endian
1578 * @val: a #gssize value in host byte order
1580 * Converts a #gssize value from host byte order to little-endian.
1582 * Returns: @val converted to little-endian
1588 * @user_data: unused
1589 * @max_parse_errors: unused
1590 * @parse_errors: g_scanner_error() increments this field
1591 * @input_name: name of input stream, featured by the default message handler
1592 * @qdata: quarked data
1593 * @config: link into the scanner configuration
1594 * @token: token parsed by the last g_scanner_get_next_token()
1595 * @value: value of the last token from g_scanner_get_next_token()
1596 * @line: line number of the last token from g_scanner_get_next_token()
1597 * @position: char number of the last token from g_scanner_get_next_token()
1598 * @next_token: token parsed by the last g_scanner_peek_next_token()
1599 * @next_value: value of the last token from g_scanner_peek_next_token()
1600 * @next_line: line number of the last token from g_scanner_peek_next_token()
1601 * @next_position: char number of the last token from g_scanner_peek_next_token()
1602 * @msg_handler: handler function for _warn and _error
1604 * The data structure representing a lexical scanner.
1606 * You should set @input_name after creating the scanner, since
1607 * it is used by the default message handler when displaying
1608 * warnings and errors. If you are scanning a file, the filename
1609 * would be a good choice.
1611 * The @user_data and @max_parse_errors fields are not used.
1612 * If you need to associate extra data with the scanner you
1613 * can place them here.
1615 * If you want to use your own message handler you can set the
1616 * @msg_handler field. The type of the message handler function
1617 * is declared by #GScannerMsgFunc.
1623 * @cset_skip_characters: specifies which characters should be skipped by the scanner (the default is the whitespace characters: space, tab, carriage-return and line-feed).
1624 * @cset_identifier_first: specifies the characters which can start identifiers (the default is #G_CSET_a_2_z, "_", and #G_CSET_A_2_Z).
1625 * @cset_identifier_nth: specifies the characters which can be used in identifiers, after the first character (the default is #G_CSET_a_2_z, "_0123456789", #G_CSET_A_2_Z, #G_CSET_LATINS, #G_CSET_LATINC).
1626 * @cpair_comment_single: specifies the characters at the start and end of single-line comments. The default is "#\n" which means that single-line comments start with a '#' and continue until a '\n' (end of line).
1627 * @case_sensitive: specifies if symbols are case sensitive (the default is %FALSE).
1628 * @skip_comment_multi: specifies if multi-line comments are skipped and not returned as tokens (the default is %TRUE).
1629 * @skip_comment_single: specifies if single-line comments are skipped and not returned as tokens (the default is %TRUE).
1630 * @scan_comment_multi: specifies if multi-line comments are recognized (the default is %TRUE).
1631 * @scan_identifier: specifies if identifiers are recognized (the default is %TRUE).
1632 * @scan_identifier_1char: specifies if single-character identifiers are recognized (the default is %FALSE).
1633 * @scan_identifier_NULL: specifies if %NULL is reported as %G_TOKEN_IDENTIFIER_NULL (the default is %FALSE).
1634 * @scan_symbols: specifies if symbols are recognized (the default is %TRUE).
1635 * @scan_binary: specifies if binary numbers are recognized (the default is %FALSE).
1636 * @scan_octal: specifies if octal numbers are recognized (the default is %TRUE).
1637 * @scan_float: specifies if floating point numbers are recognized (the default is %TRUE).
1638 * @scan_hex: specifies if hexadecimal numbers are recognized (the default is %TRUE).
1639 * @scan_hex_dollar: specifies if '$' is recognized as a prefix for hexadecimal numbers (the default is %FALSE).
1640 * @scan_string_sq: specifies if strings can be enclosed in single quotes (the default is %TRUE).
1641 * @scan_string_dq: specifies if strings can be enclosed in double quotes (the default is %TRUE).
1642 * @numbers_2_int: specifies if binary, octal and hexadecimal numbers are reported as #G_TOKEN_INT (the default is %TRUE).
1643 * @int_2_float: specifies if all numbers are reported as %G_TOKEN_FLOAT (the default is %FALSE).
1644 * @identifier_2_string: specifies if identifiers are reported as strings (the default is %FALSE).
1645 * @char_2_token: specifies if characters are reported by setting <literal>token = ch</literal> or as %G_TOKEN_CHAR (the default is %TRUE).
1646 * @symbol_2_token: specifies if symbols are reported by setting <literal>token = v_symbol</literal> or as %G_TOKEN_SYMBOL (the default is %FALSE).
1647 * @scope_0_fallback: specifies if a symbol is searched for in the default scope in addition to the current scope (the default is %FALSE).
1648 * @store_int64: use value.v_int64 rather than v_int
1650 * Specifies the #GScanner parser configuration. Most settings can
1651 * be changed during the parsing phase and will affect the lexical
1652 * parsing of the next unpeeked token.
1658 * @scanner: a #GScanner
1659 * @message: the message
1660 * @error: %TRUE if the message signals an error, %FALSE if it signals a warning.
1662 * Specifies the type of the message handler function.
1668 * @G_SEEK_CUR: the current position in the file.
1669 * @G_SEEK_SET: the start of the file.
1670 * @G_SEEK_END: the end of the file.
1672 * An enumeration specifying the base position for a
1673 * g_io_channel_seek_position() operation.
1680 * The #GSequence struct is an opaque data type representing a
1681 * <link linkend="glib-Sequences">Sequence</link> data type.
1688 * The #GSequenceIter struct is an opaque data type representing an
1689 * iterator pointing into a #GSequence.
1694 * GSequenceIterCompareFunc:
1695 * @a: a #GSequenceIter
1696 * @b: a #GSequenceIter
1699 * A #GSequenceIterCompareFunc is a function used to compare iterators.
1700 * It must return zero if the iterators compare equal, a negative value
1701 * if @a comes before @b, and a positive value if @b comes before @a.
1703 * Returns: zero if the iterators are equal, a negative value if @a comes before @b, and a positive value if @b comes before @a.
1709 * @G_SHELL_ERROR_BAD_QUOTING: Mismatched or otherwise mangled quoting.
1710 * @G_SHELL_ERROR_EMPTY_STRING: String to be parsed was empty.
1711 * @G_SHELL_ERROR_FAILED: Some other error.
1713 * Error codes returned by shell functions.
1720 * A type corresponding to the appropriate struct type for the stat
1721 * system call, depending on the platform and/or compiler being used.
1723 * See g_stat() for more information.
1729 * @str: points to the character data. It may move as text is added. The @str field is null-terminated and so can be used as an ordinary C string.
1730 * @len: contains the length of the string, not including the terminating nul byte.
1731 * @allocated_len: the number of bytes that can be stored in the string before it needs to be reallocated. May be larger than @len.
1733 * The GString struct contains the public fields of a GString.
1740 * An opaque data structure representing String Chunks.
1741 * It should only be accessed by using the following functions.
1748 * An opaque structure representing a test case.
1754 * @user_data: the data provided when registering the test
1756 * The type used for test case functions that take an extra pointer
1765 * @fixture: the test fixture
1766 * @user_data: the data provided when registering the test
1768 * The type used for functions that operate on test fixtures. This is
1769 * used for the fixture setup and teardown functions as well as for the
1770 * testcases themselves.
1772 * @user_data is a pointer to the data that was given when registering
1775 * @fixture will be a pointer to the area of memory allocated by the
1776 * test framework, of the size requested. If the requested size was
1777 * zero then @fixture will be equal to @user_data.
1786 * The type used for test case functions.
1795 * An opaque structure representing a test suite.
1801 * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to <filename>/dev/null</filename> so it cannot be observed on the console during test runs. The actual output is still captured though to allow later tests with g_test_trap_assert_stdout().
1802 * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to <filename>/dev/null</filename> so it cannot be observed on the console during test runs. The actual output is still captured though to allow later tests with g_test_trap_assert_stderr().
1803 * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the forked child process is shared with stdin of its parent process. It is redirected to <filename>/dev/null</filename> otherwise.
1805 * Test traps are guards around forked tests.
1806 * These flags determine what traps to set.
1813 * The #GThread struct represents a running thread. This struct
1814 * is returned by g_thread_new() or g_thread_try_new(). You can
1815 * obtain the #GThread struct representing the current thead by
1816 * calling g_thread_self().
1818 * GThread is refcounted, see g_thread_ref() and g_thread_unref().
1819 * The thread represented by it holds a reference while it is running,
1820 * and g_thread_join() consumes the reference that it is given, so
1821 * it is normally not necessary to manage GThread references
1824 * The structure is opaque -- none of its fields may be directly
1831 * @G_THREAD_ERROR_AGAIN: a thread couldn't be created due to resource shortage. Try again later.
1833 * Possible errors of thread related functions.
1839 * @data: data passed to the thread
1841 * Specifies the type of the @func functions passed to g_thread_new()
1842 * or g_thread_try_new().
1844 * Returns: the return value of the thread
1850 * @func: the function to execute in the threads of this pool
1851 * @user_data: the user data for the threads of this pool
1852 * @exclusive: are all threads exclusive to this pool
1854 * The #GThreadPool struct represents a thread pool. It has three
1855 * public read-only members, but the underlying struct is bigger,
1856 * so you must not copy this struct.
1863 * Simply a replacement for <type>time_t</type>. It has been deprecated
1864 * since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
1865 * on 64-bit platforms with a 64-bit <type>time_t</type>.
1866 * Unrelated to #GTimer.
1868 * Note that <type>GTime</type> is defined to always be a 32bit integer,
1869 * unlike <type>time_t</type> which may be 64bit on some systems.
1870 * Therefore, <type>GTime</type> will overflow in the year 2038, and
1871 * you cannot use the address of a <type>GTime</type> variable as argument
1872 * to the UNIX time() function. Instead, do the following:
1877 * time (&ttime);
1878 * gtime = (GTime)ttime;
1886 * @tv_usec: microseconds
1888 * Represents a precise time, with seconds and microseconds.
1889 * Similar to the <structname>struct timeval</structname> returned by
1890 * the gettimeofday() UNIX system call.
1892 * GLib is attempting to unify around the use of 64bit integers to
1893 * represent microsecond-precision time. As such, this type will be
1894 * removed from a future version of GLib.
1901 * #GDateTime is an opaque structure whose members cannot be accessed
1911 * Opaque datatype that records a start time.
1917 * @G_TOKEN_EOF: the end of the file
1918 * @G_TOKEN_LEFT_PAREN: a '(' character
1919 * @G_TOKEN_LEFT_CURLY: a '{' character
1920 * @G_TOKEN_LEFT_BRACE: a '[' character
1921 * @G_TOKEN_RIGHT_CURLY: a '}' character
1922 * @G_TOKEN_RIGHT_PAREN: a ')' character
1923 * @G_TOKEN_RIGHT_BRACE: a ']' character
1924 * @G_TOKEN_EQUAL_SIGN: a '=' character
1925 * @G_TOKEN_COMMA: a ',' character
1926 * @G_TOKEN_NONE: not a token
1927 * @G_TOKEN_ERROR: an error occurred
1928 * @G_TOKEN_CHAR: a character
1929 * @G_TOKEN_BINARY: a binary integer
1930 * @G_TOKEN_OCTAL: an octal integer
1931 * @G_TOKEN_INT: an integer
1932 * @G_TOKEN_HEX: a hex integer
1933 * @G_TOKEN_FLOAT: a floating point number
1934 * @G_TOKEN_STRING: a string
1935 * @G_TOKEN_SYMBOL: a symbol
1936 * @G_TOKEN_IDENTIFIER: an identifier
1937 * @G_TOKEN_IDENTIFIER_NULL: a null identifier
1938 * @G_TOKEN_COMMENT_SINGLE: one line comment
1939 * @G_TOKEN_COMMENT_MULTI: multi line comment
1941 * The possible types of token returned from each
1942 * g_scanner_get_next_token() call.
1948 * @v_symbol: token symbol value
1949 * @v_identifier: token identifier value
1950 * @v_binary: token binary integer value
1951 * @v_octal: octal integer value
1952 * @v_int: integer value
1953 * @v_int64: 64-bit integer value
1954 * @v_float: floating point value
1955 * @v_hex: hex integer value
1956 * @v_string: string value
1957 * @v_comment: comment value
1958 * @v_char: character value
1959 * @v_error: error value
1961 * A union holding the value of the token.
1967 * @next: pointer to the previous element of the stack, gets stored in the first <literal>sizeof (gpointer)</literal> bytes of the element
1969 * Each piece of memory that is pushed onto the stack
1970 * is cast to a <structname>GTrashStack*</structname>.
1976 * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has been introduced in 2.6, for older version use %G_TRAVERSE_LEAFS.
1977 * @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This name has been introduced in 2.6, for older version use %G_TRAVERSE_NON_LEAFS.
1978 * @G_TRAVERSE_ALL: all nodes should be visited.
1979 * @G_TRAVERSE_MASK: a mask of all traverse flags.
1980 * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
1981 * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
1983 * Specifies which nodes are visited during several of the tree
1984 * functions, including g_node_traverse() and g_node_find().
1990 * @key: a key of a #GTree node.
1991 * @value: the value corresponding to the key.
1992 * @data: user data passed to g_tree_traverse().
1994 * Specifies the type of function passed to g_tree_traverse(). It is
1995 * passed the key and value of each node, together with the @user_data
1996 * parameter passed to g_tree_traverse(). If the function returns
1997 * %TRUE, the traversal is stopped.
1999 * Returns: %TRUE to stop the traversal.
2005 * @G_IN_ORDER: vists a node's left child first, then the node itself, then its right child. This is the one to use if you want the output sorted according to the compare function.
2006 * @G_PRE_ORDER: visits a node, then its children.
2007 * @G_POST_ORDER: visits the node's children, then the node itself.
2008 * @G_LEVEL_ORDER: is not implemented for <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Trees</link>. For <link linkend="glib-N-ary-Trees">N-ary Trees</link>, it vists the root node first, then its children, then its grandchildren, and so on. Note that this is less efficient than the other orders.
2010 * Specifies the type of traveral performed by g_tree_traverse(),
2011 * g_node_traverse() and g_node_find().
2018 * The <structname>GTree</structname> struct is an opaque data
2019 * structure representing a <link
2020 * linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
2021 * should be accessed only by using the following functions.
2027 * @val: a #guint16 value in big-endian byte order
2029 * Converts a #guint16 value from big-endian to host byte order.
2031 * Returns: @val converted to host byte order
2037 * @val: a #guint16 value in little-endian byte order
2039 * Converts a #guint16 value from little-endian to host byte order.
2041 * Returns: @val converted to host byte order
2046 * GUINT16_SWAP_BE_PDP:
2047 * @val: a #guint16 value in big-endian or pdp-endian byte order
2049 * Converts a #guint16 value between big-endian and pdp-endian byte order.
2050 * The conversion is symmetric so it can be used both ways.
2052 * Returns: @val converted to the opposite byte order
2057 * GUINT16_SWAP_LE_BE:
2058 * @val: a #guint16 value in little-endian or big-endian byte order
2060 * Converts a #guint16 value between little-endian and big-endian byte order.
2061 * The conversion is symmetric so it can be used both ways.
2063 * Returns: @val converted to the opposite byte order
2068 * GUINT16_SWAP_LE_PDP:
2069 * @val: a #guint16 value in little-endian or pdp-endian byte order
2071 * Converts a #guint16 value between little-endian and pdp-endian byte order.
2072 * The conversion is symmetric so it can be used both ways.
2074 * Returns: @val converted to the opposite byte order
2080 * @val: a #guint16 value in host byte order
2082 * Converts a #guint16 value from host byte order to big-endian.
2084 * Returns: @val converted to big-endian
2090 * @val: a #guint16 value in host byte order
2092 * Converts a #guint16 value from host byte order to little-endian.
2094 * Returns: @val converted to little-endian
2100 * @val: a #guint32 value in big-endian byte order
2102 * Converts a #guint32 value from big-endian to host byte order.
2104 * Returns: @val converted to host byte order
2110 * @val: a #guint32 value in little-endian byte order
2112 * Converts a #guint32 value from little-endian to host byte order.
2114 * Returns: @val converted to host byte order
2119 * GUINT32_SWAP_BE_PDP:
2120 * @val: a #guint32 value in big-endian or pdp-endian byte order
2122 * Converts a #guint32 value between big-endian and pdp-endian byte order.
2123 * The conversion is symmetric so it can be used both ways.
2125 * Returns: @val converted to the opposite byte order
2130 * GUINT32_SWAP_LE_BE:
2131 * @val: a #guint32 value in little-endian or big-endian byte order
2133 * Converts a #guint32 value between little-endian and big-endian byte order.
2134 * The conversion is symmetric so it can be used both ways.
2136 * Returns: @val converted to the opposite byte order
2141 * GUINT32_SWAP_LE_PDP:
2142 * @val: a #guint32 value in little-endian or pdp-endian byte order
2144 * Converts a #guint32 value between little-endian and pdp-endian byte order.
2145 * The conversion is symmetric so it can be used both ways.
2147 * Returns: @val converted to the opposite byte order
2153 * @val: a #guint32 value in host byte order
2155 * Converts a #guint32 value from host byte order to big-endian.
2157 * Returns: @val converted to big-endian
2163 * @val: a #guint32 value in host byte order
2165 * Converts a #guint32 value from host byte order to little-endian.
2167 * Returns: @val converted to little-endian
2173 * @val: a #guint64 value in big-endian byte order
2175 * Converts a #guint64 value from big-endian to host byte order.
2177 * Returns: @val converted to host byte order
2183 * @val: a #guint64 value in little-endian byte order
2185 * Converts a #guint64 value from little-endian to host byte order.
2187 * Returns: @val converted to host byte order
2192 * GUINT64_SWAP_LE_BE:
2193 * @val: a #guint64 value in little-endian or big-endian byte order
2195 * Converts a #guint64 value between little-endian and big-endian byte order.
2196 * The conversion is symmetric so it can be used both ways.
2198 * Returns: @val converted to the opposite byte order
2204 * @val: a #guint64 value in host byte order
2206 * Converts a #guint64 value from host byte order to big-endian.
2208 * Returns: @val converted to big-endian
2214 * @val: a #guint64 value in host byte order
2216 * Converts a #guint64 value from host byte order to little-endian.
2218 * Returns: @val converted to little-endian
2224 * @val: a #guint value in big-endian byte order
2226 * Converts a #guint value from big-endian to host byte order.
2228 * Returns: @val converted to host byte order
2234 * @val: a #guint value in little-endian byte order
2236 * Converts a #guint value from little-endian to host byte order.
2238 * Returns: @val converted to host byte order
2244 * @val: a #guint value in host byte order
2246 * Converts a #guint value from host byte order to big-endian.
2248 * Returns: @val converted to big-endian byte order
2254 * @val: a #guint value in host byte order
2256 * Converts a #guint value from host byte order to little-endian.
2258 * Returns: @val converted to little-endian byte order.
2264 * @u: unsigned integer to stuff into the pointer
2266 * Stuffs an unsigned integer into a pointer type.
2272 * @val: a #gulong value in big-endian byte order
2274 * Converts a #gulong value from big-endian to host byte order.
2276 * Returns: @val converted to host byte order
2282 * @val: a #gulong value in little-endian byte order
2284 * Converts a #gulong value from little-endian to host byte order.
2286 * Returns: @val converted to host byte order
2292 * @val: a #gulong value in host byte order
2294 * Converts a #gulong value from host byte order to big-endian.
2296 * Returns: @val converted to big-endian
2302 * @val: a #gulong value in host byte order
2304 * Converts a #gulong value from host byte order to little-endian.
2306 * Returns: @val converted to little-endian
2313 * #GVariant is an opaque data structure and can only be accessed
2314 * using the following functions.
2323 * A utility type for constructing container-type #GVariant instances.
2325 * This is an opaque structure and may only be accessed using the
2326 * following functions.
2328 * #GVariantBuilder is not threadsafe in any way. Do not attempt to
2329 * access it from more than one thread.
2335 * @G_VARIANT_CLASS_BOOLEAN: The #GVariant is a boolean.
2336 * @G_VARIANT_CLASS_BYTE: The #GVariant is a byte.
2337 * @G_VARIANT_CLASS_INT16: The #GVariant is a signed 16 bit integer.
2338 * @G_VARIANT_CLASS_UINT16: The #GVariant is an unsigned 16 bit integer.
2339 * @G_VARIANT_CLASS_INT32: The #GVariant is a signed 32 bit integer.
2340 * @G_VARIANT_CLASS_UINT32: The #GVariant is an unsigned 32 bit integer.
2341 * @G_VARIANT_CLASS_INT64: The #GVariant is a signed 64 bit integer.
2342 * @G_VARIANT_CLASS_UINT64: The #GVariant is an unsigned 64 bit integer.
2343 * @G_VARIANT_CLASS_HANDLE: The #GVariant is a file handle index.
2344 * @G_VARIANT_CLASS_DOUBLE: The #GVariant is a double precision floating point value.
2345 * @G_VARIANT_CLASS_STRING: The #GVariant is a normal string.
2346 * @G_VARIANT_CLASS_OBJECT_PATH: The #GVariant is a D-Bus object path string.
2347 * @G_VARIANT_CLASS_SIGNATURE: The #GVariant is a D-Bus signature string.
2348 * @G_VARIANT_CLASS_VARIANT: The #GVariant is a variant.
2349 * @G_VARIANT_CLASS_MAYBE: The #GVariant is a maybe-typed value.
2350 * @G_VARIANT_CLASS_ARRAY: The #GVariant is an array.
2351 * @G_VARIANT_CLASS_TUPLE: The #GVariant is a tuple.
2352 * @G_VARIANT_CLASS_DICT_ENTRY: The #GVariant is a dictionary entry.
2354 * The range of possible top-level types of #GVariant instances.
2361 * GVariantIter: (skip)
2363 * #GVariantIter is an opaque data structure and can only be accessed
2364 * using the following functions.
2369 * GVariantParseError:
2370 * @G_VARIANT_PARSE_ERROR_FAILED: generic error (unused)
2371 * @G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED: a non-basic #GVariantType was given where a basic type was expected
2372 * @G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE: cannot infer the #GVariantType
2373 * @G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED: an indefinite #GVariantType was given where a definite type was expected
2374 * @G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END: extra data after parsing finished
2375 * @G_VARIANT_PARSE_ERROR_INVALID_CHARACTER: invalid character in number or unicode escape
2376 * @G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING: not a valid #GVariant format string
2377 * @G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH: not a valid object path
2378 * @G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE: not a valid type signature
2379 * @G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING: not a valid #GVariant type string
2380 * @G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE: could not find a common type for array entries
2381 * @G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE: the numerical value is out of range of the given type
2382 * @G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG: the numerical value is out of range for any type
2383 * @G_VARIANT_PARSE_ERROR_TYPE_ERROR: cannot parse as variant of the specified type
2384 * @G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN: an unexpected token was encountered
2385 * @G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD: an unknown keyword was encountered
2386 * @G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT: unterminated string constant
2387 * @G_VARIANT_PARSE_ERROR_VALUE_EXPECTED: no value given
2389 * Error codes returned by parsing text-format GVariants.
2394 * G_ASCII_DTOSTR_BUF_SIZE:
2396 * A good size for a buffer to be passed into g_ascii_dtostr().
2397 * It is guaranteed to be enough for all output of that function
2398 * on systems with 64bit IEEE-compatible doubles.
2400 * The typical usage would be something like:
2402 * char buf[G_ASCII_DTOSTR_BUF_SIZE];
2404 * fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
2410 * G_ATOMIC_LOCK_FREE:
2412 * This macro is defined if the atomic operations of GLib are
2413 * implemented using real hardware atomic operations. This means that
2414 * the GLib atomic API can be used between processes and safely mixed
2415 * with other (hardware) atomic APIs.
2417 * If this macro is not defined, the atomic operations may be
2418 * emulated using a mutex. In that case, the GLib atomic operations are
2419 * only atomic relative to themselves and within a single process.
2426 * Used (along with #G_END_DECLS) to bracket header files. If the
2427 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2428 * around the header.
2435 * Specifies one of the possible types of byte order.
2436 * See #G_BYTE_ORDER.
2443 * The host byte order.
2444 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
2445 * #G_PDP_ENDIAN may be added in future.)
2452 * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
2453 * to nothing. By default, the macro expands to <literal>const</literal>.
2454 * The macro should be used in place of <literal>const</literal> for
2455 * functions that return a value that should not be modified. The
2456 * purpose of this macro is to allow us to turn on <literal>const</literal>
2457 * for returned constant strings by default, while allowing programmers
2458 * who find that annoying to turn it off. This macro should only be used
2459 * for return values and for <emphasis>out</emphasis> parameters, it doesn't
2460 * make sense for <emphasis>in</emphasis> parameters.
2462 * Deprecated: 2.30: API providers should replace all existing uses with <literal>const</literal> and API consumers should adjust their code accordingly
2469 * The set of uppercase ASCII alphabet characters.
2470 * Used for specifying valid identifier characters
2471 * in #GScannerConfig.
2478 * The set of uppercase ISO 8859-1 alphabet characters
2479 * which are not ASCII characters.
2480 * Used for specifying valid identifier characters
2481 * in #GScannerConfig.
2488 * The set of lowercase ISO 8859-1 alphabet characters
2489 * which are not ASCII characters.
2490 * Used for specifying valid identifier characters
2491 * in #GScannerConfig.
2498 * The set of lowercase ASCII alphabet characters.
2499 * Used for specifying valid identifier characters
2500 * in #GScannerConfig.
2507 * Represents an invalid #GDateDay.
2512 * G_DATE_BAD_JULIAN:
2514 * Represents an invalid Julian day number.
2521 * Represents an invalid year.
2527 * @QN: the name to return a #GQuark for
2528 * @q_n: prefix for the function name
2530 * A convenience macro which defines a function returning the
2531 * #GQuark for the name @QN. The function will be named
2532 * @q_n<!-- -->_quark().
2533 * Note that the quark name will be stringified automatically in the
2534 * macro, so you shouldn't use double quotes.
2543 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2544 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2545 * meant to be portable across different compilers and must be placed
2546 * before the function declaration.
2554 * @f: the name of the function that this function was deprecated for
2556 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2557 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2558 * meant to be portable across different compilers and must be placed
2559 * before the function declaration.
2568 * The directory separator character.
2569 * This is '/' on UNIX machines and '\' under Windows.
2574 * G_DIR_SEPARATOR_S:
2576 * The directory separator as a string.
2577 * This is "/" on UNIX machines and "\" under Windows.
2584 * The base of natural logarithms.
2591 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
2592 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2593 * around the header.
2600 * Error domain for file operations. Errors in this domain will
2601 * be from the #GFileError enumeration. See #GError for information
2609 * This is the platform dependent conversion specifier for scanning and
2610 * printing values of type #gint16. It is a string literal, but doesn't
2611 * include the percent-sign, such that you can add precision and length
2612 * modifiers between percent-sign and conversion specifier.
2617 * sscanf ("42", "%" G_GINT16_FORMAT, &in)
2619 * g_print ("%" G_GINT32_FORMAT, out);
2625 * G_GINT16_MODIFIER:
2627 * The platform dependent length modifier for conversion specifiers
2628 * for scanning and printing values of type #gint16 or #guint16. It
2629 * is a string literal, but doesn't include the percent-sign, such
2630 * that you can add precision and length modifiers between percent-sign
2631 * and conversion specifier and append a conversion specifier.
2633 * The following example prints "0x7b";
2635 * gint16 value = 123;
2636 * g_print ("%#" G_GINT16_MODIFIER "x", value);
2646 * This is the platform dependent conversion specifier for scanning
2647 * and printing values of type #gint32. See also #G_GINT16_FORMAT.
2652 * G_GINT32_MODIFIER:
2654 * The platform dependent length modifier for conversion specifiers
2655 * for scanning and printing values of type #gint32 or #guint32. It
2656 * is a string literal. See also #G_GINT16_MODIFIER.
2663 * G_GINT64_CONSTANT:
2664 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
2666 * This macro is used to insert 64-bit integer literals
2667 * into the source code.
2674 * This is the platform dependent conversion specifier for scanning
2675 * and printing values of type #gint64. See also #G_GINT16_FORMAT.
2678 * Some platforms do not support scanning and printing 64 bit integers,
2679 * even though the types are supported. On such platforms #G_GINT64_FORMAT
2680 * is not defined. Note that scanf() may not support 64 bit integers, even
2681 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
2682 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
2689 * G_GINT64_MODIFIER:
2691 * The platform dependent length modifier for conversion specifiers
2692 * for scanning and printing values of type #gint64 or #guint64.
2693 * It is a string literal.
2696 * Some platforms do not support printing 64 bit integers, even
2697 * though the types are supported. On such platforms #G_GINT64_MODIFIER
2708 * This is the platform dependent conversion specifier for scanning
2709 * and printing values of type #gintptr.
2716 * G_GINTPTR_MODIFIER:
2718 * The platform dependent length modifier for conversion specifiers
2719 * for scanning and printing values of type #gintptr or #guintptr.
2720 * It is a string literal.
2727 * G_GNUC_ALLOC_SIZE:
2728 * @x: the index of the argument specifying the allocation size
2730 * Expands to the GNU C <literal>alloc_size</literal> function attribute
2731 * if the compiler is a new enough <command>gcc</command>. This attribute
2732 * tells the compiler that the function returns a pointer to memory of a
2733 * size that is specified by the @x<!-- -->th function parameter.
2735 * Place the attribute after the function declaration, just before the
2738 * See the GNU C documentation for more details.
2745 * G_GNUC_ALLOC_SIZE2:
2746 * @x: the index of the argument specifying one factor of the allocation size
2747 * @y: the index of the argument specifying the second factor of the allocation size
2749 * Expands to the GNU C <literal>alloc_size</literal> function attribute
2750 * if the compiler is a new enough <command>gcc</command>. This attribute
2751 * tells the compiler that the function returns a pointer to memory of a
2752 * size that is specified by the product of two function parameters.
2754 * Place the attribute after the function declaration, just before the
2757 * See the GNU C documentation for more details.
2764 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2766 * Tells <command>gcc</command> (if it is a new enough version) to
2767 * temporarily stop emitting warnings when functions marked with
2768 * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
2769 * useful for when you have one deprecated function calling another
2770 * one, or when you still have regression tests for deprecated
2773 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2774 * are not compiling with <literal>-Wdeprecated-declarations</literal>
2775 * then neither macro has any effect.)
2777 * This macro can be used either inside or outside of a function body,
2778 * but must appear on a line by itself.
2787 * Expands to the GNU C <literal>const</literal> function attribute if
2788 * the compiler is <command>gcc</command>. Declaring a function as const
2789 * enables better optimization of calls to the function. A const function
2790 * doesn't examine any values except its parameters, and has no effects
2791 * except its return value.
2793 * Place the attribute after the declaration, just before the semicolon.
2795 * See the GNU C documentation for more details.
2798 * A function that has pointer arguments and examines the data pointed to
2799 * must <emphasis>not</emphasis> be declared const. Likewise, a function
2800 * that calls a non-const function usually must not be const. It doesn't
2801 * make sense for a const function to return void.
2807 * G_GNUC_DEPRECATED:
2809 * Expands to the GNU C <literal>deprecated</literal> attribute if the
2810 * compiler is <command>gcc</command>. It can be used to mark typedefs,
2811 * variables and functions as deprecated. When called with the
2812 * <option>-Wdeprecated-declarations</option> option, the compiler will
2813 * generate warnings when deprecated interfaces are used.
2815 * Place the attribute after the declaration, just before the semicolon.
2817 * See the GNU C documentation for more details.
2824 * G_GNUC_DEPRECATED_FOR:
2825 * @f: the intended replacement for the deprecated symbol, such as the name of a function
2827 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
2828 * deprecated symbol if the version of <command>gcc</command> in use is
2829 * new enough to support custom deprecation messages.
2831 * Place the attribute after the declaration, just before the semicolon.
2833 * See the GNU C documentation for more details.
2835 * Note that if @f is a macro, it will be expanded in the warning message.
2836 * You can enclose it in quotes to prevent this. (The quotes will show up
2837 * in the warning, but it's better than showing the macro expansion.)
2844 * G_GNUC_END_IGNORE_DEPRECATIONS:
2846 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2847 * <command>gcc</command> to begin outputting warnings again
2848 * (assuming those warnings had been enabled to begin with).
2850 * This macro can be used either inside or outside of a function body,
2851 * but must appear on a line by itself.
2860 * Expands to <literal>__extension__</literal> when <command>gcc</command>
2861 * is used as the compiler. This simply tells <command>gcc</command> not
2862 * to warn about the following non-standard code when compiling with the
2863 * <option>-pedantic</option> option.
2869 * @arg_idx: the index of the argument
2871 * Expands to the GNU C <literal>format_arg</literal> function attribute
2872 * if the compiler is <command>gcc</command>. This function attribute
2873 * specifies that a function takes a format string for a printf(),
2874 * scanf(), strftime() or strfmon() style function and modifies it,
2875 * so that the result can be passed to a printf(), scanf(), strftime()
2876 * or strfmon() style function (with the remaining arguments to the
2877 * format function the same as they would have been for the unmodified
2880 * Place the attribute after the function declaration, just after the
2883 * See the GNU C documentation for more details.
2886 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2894 * Expands to "" on all modern compilers, and to
2895 * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
2898 * Deprecated: 2.16: Use #G_STRFUNC instead
2905 * This attribute can be used for marking library functions as being used
2906 * internally to the library only, which may allow the compiler to handle
2907 * function calls more efficiently. Note that static functions do not need
2908 * to be marked as internal in this way. See the GNU C documentation for
2911 * When using a compiler that supports the GNU C hidden visibility attribute,
2912 * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
2913 * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
2915 * Note that for portability, the attribute should be placed before the
2916 * function declaration. While GCC allows the macro after the declaration,
2917 * Sun Studio does not.
2921 * void _g_log_fallback_handler (const gchar *log_domain,
2922 * GLogLevelFlags log_level,
2923 * const gchar *message,
2924 * gpointer unused_data);
2934 * Expands to the GNU C <literal>malloc</literal> function attribute if the
2935 * compiler is <command>gcc</command>. Declaring a function as malloc enables
2936 * better optimization of the function. A function can have the malloc
2937 * attribute if it returns a pointer which is guaranteed to not alias with
2938 * any other pointer when the function returns (in practice, this means newly
2939 * allocated memory).
2941 * Place the attribute after the declaration, just before the semicolon.
2943 * See the GNU C documentation for more details.
2952 * Expands to the GNU C <literal>may_alias</literal> type attribute
2953 * if the compiler is <command>gcc</command>. Types with this attribute
2954 * will not be subjected to type-based alias analysis, but are assumed
2955 * to alias with any other type, just like char.
2956 * See the GNU C documentation for details.
2965 * Expands to the GNU C <literal>noreturn</literal> function attribute
2966 * if the compiler is <command>gcc</command>. It is used for declaring
2967 * functions which never return. It enables optimization of the function,
2968 * and avoids possible compiler warnings.
2970 * Place the attribute after the declaration, just before the semicolon.
2972 * See the GNU C documentation for more details.
2977 * G_GNUC_NO_INSTRUMENT:
2979 * Expands to the GNU C <literal>no_instrument_function</literal> function
2980 * attribute if the compiler is <command>gcc</command>. Functions with this
2981 * attribute will not be instrumented for profiling, when the compiler is
2982 * called with the <option>-finstrument-functions</option> option.
2984 * Place the attribute after the declaration, just before the semicolon.
2986 * See the GNU C documentation for more details.
2991 * G_GNUC_NULL_TERMINATED:
2993 * Expands to the GNU C <literal>sentinel</literal> function attribute
2994 * if the compiler is <command>gcc</command>, or "" if it isn't. This
2995 * function attribute only applies to variadic functions and instructs
2996 * the compiler to check that the argument list is terminated with an
2999 * Place the attribute after the declaration, just before the semicolon.
3001 * See the GNU C documentation for more details.
3008 * G_GNUC_PRETTY_FUNCTION:
3010 * Expands to "" on all modern compilers, and to
3011 * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
3012 * version 2.x. Don't use it.
3014 * Deprecated: 2.16: Use #G_STRFUNC instead
3020 * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3021 * @arg_idx: the index of the first of the format arguments
3023 * Expands to the GNU C <literal>format</literal> function attribute
3024 * if the compiler is <command>gcc</command>. This is used for declaring
3025 * functions which take a variable number of arguments, with the same
3026 * syntax as printf(). It allows the compiler to type-check the arguments
3027 * passed to the function.
3029 * Place the attribute after the function declaration, just before the
3032 * See the GNU C documentation for more details.
3035 * gint g_snprintf (gchar *string,
3037 * gchar const *format,
3038 * ...) G_GNUC_PRINTF (3, 4);
3046 * Expands to the GNU C <literal>pure</literal> function attribute if the
3047 * compiler is <command>gcc</command>. Declaring a function as pure enables
3048 * better optimization of calls to the function. A pure function has no
3049 * effects except its return value and the return value depends only on
3050 * the parameters and/or global variables.
3052 * Place the attribute after the declaration, just before the semicolon.
3054 * See the GNU C documentation for more details.
3060 * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3061 * @arg_idx: the index of the first of the format arguments
3063 * Expands to the GNU C <literal>format</literal> function attribute
3064 * if the compiler is <command>gcc</command>. This is used for declaring
3065 * functions which take a variable number of arguments, with the same
3066 * syntax as scanf(). It allows the compiler to type-check the arguments
3067 * passed to the function. See the GNU C documentation for details.
3074 * Expands to the GNU C <literal>unused</literal> function attribute if
3075 * the compiler is <command>gcc</command>. It is used for declaring
3076 * functions and arguments which may never be used. It avoids possible compiler
3079 * For functions, place the attribute after the declaration, just before the
3080 * semicolon. For arguments, place the attribute at the beginning of the
3081 * argument declaration.
3084 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
3085 * gint other_argument) G_GNUC_UNUSED;
3088 * See the GNU C documentation for more details.
3093 * G_GNUC_WARN_UNUSED_RESULT:
3095 * Expands to the GNU C <literal>warn_unused_result</literal> function
3096 * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
3097 * This function attribute makes the compiler emit a warning if the result
3098 * of a function call is ignored.
3100 * Place the attribute after the declaration, just before the semicolon.
3102 * See the GNU C documentation for more details.
3109 * G_GOFFSET_CONSTANT:
3110 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
3112 * This macro is used to insert #goffset 64-bit integer literals
3113 * into the source code.
3115 * See also #G_GINT64_CONSTANT.
3124 * This is the platform dependent conversion specifier for scanning
3125 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
3132 * G_GOFFSET_MODIFIER:
3134 * The platform dependent length modifier for conversion specifiers
3135 * for scanning and printing values of type #goffset. It is a string
3136 * literal. See also #G_GINT64_MODIFIER.
3145 * This is the platform dependent conversion specifier for scanning
3146 * and printing values of type #gsize. See also #G_GINT16_FORMAT.
3155 * The platform dependent length modifier for conversion specifiers
3156 * for scanning and printing values of type #gsize or #gssize. It
3157 * is a string literal.
3166 * This is the platform dependent conversion specifier for scanning
3167 * and printing values of type #gssize. See also #G_GINT16_FORMAT.
3176 * This is the platform dependent conversion specifier for scanning
3177 * and printing values of type #guint16. See also #G_GINT16_FORMAT
3184 * This is the platform dependent conversion specifier for scanning
3185 * and printing values of type #guint32. See also #G_GINT16_FORMAT.
3190 * G_GUINT64_CONSTANT:
3191 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
3193 * This macro is used to insert 64-bit unsigned integer
3194 * literals into the source code.
3203 * This is the platform dependent conversion specifier for scanning
3204 * and printing values of type #guint64. See also #G_GINT16_FORMAT.
3207 * Some platforms do not support scanning and printing 64 bit integers,
3208 * even though the types are supported. On such platforms #G_GUINT64_FORMAT
3209 * is not defined. Note that scanf() may not support 64 bit integers, even
3210 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
3211 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
3218 * G_GUINTPTR_FORMAT:
3220 * This is the platform dependent conversion specifier
3221 * for scanning and printing values of type #guintptr.
3231 * Casts a pointer to a <literal>GHook*</literal>.
3239 * Returns %TRUE if the #GHook is active, which is normally the case
3240 * until the #GHook is destroyed.
3242 * Returns: %TRUE if the #GHook is active
3250 * Gets the flags of a hook.
3255 * G_HOOK_FLAG_USER_SHIFT:
3257 * The position of the first bit which is not reserved for internal
3258 * use be the #GHook implementation, i.e.
3259 * <literal>1 << G_HOOK_FLAG_USER_SHIFT</literal> is the first
3260 * bit which can be used for application-defined flags.
3268 * Returns %TRUE if the #GHook function is currently executing.
3270 * Returns: %TRUE if the #GHook function is currently executing
3275 * G_HOOK_IS_UNLINKED:
3278 * Returns %TRUE if the #GHook is not in a #GHookList.
3280 * Returns: %TRUE if the #GHook is not in a #GHookList
3288 * Returns %TRUE if the #GHook is valid, i.e. it is in a #GHookList,
3289 * it is active and it has not been destroyed.
3291 * Returns: %TRUE if the #GHook is valid
3296 * G_IEEE754_DOUBLE_BIAS:
3298 * The bias by which exponents in double-precision floats are offset.
3303 * G_IEEE754_FLOAT_BIAS:
3305 * The bias by which exponents in single-precision floats are offset.
3312 * This macro is used to export function prototypes so they can be linked
3313 * with an external version when no inlining is performed. The file which
3314 * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
3315 * before including the headers which contain %G_INLINE_FUNC declarations.
3316 * Since inlining is very compiler-dependent using these macros correctly
3317 * is very difficult. Their use is strongly discouraged.
3319 * This macro is often mistaken for a replacement for the inline keyword;
3320 * inline is already declared in a portable manner in the GLib headers
3321 * and can be used normally.
3326 * G_IO_CHANNEL_ERROR:
3328 * Error domain for #GIOChannel operations. Errors in this domain will
3329 * be from the #GIOChannelError enumeration. See #GError for
3330 * information on error domains.
3335 * G_IO_FLAG_IS_WRITEABLE:
3337 * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
3338 * before the spelling was fixed in GLib 2.30. It is kept here for
3339 * compatibility reasons.
3341 * Deprecated: 2.30:Use G_IO_FLAG_IS_WRITABLE instead.
3346 * G_IS_DIR_SEPARATOR:
3349 * Checks whether a character is a directory
3350 * separator. It returns %TRUE for '/' on UNIX
3351 * machines and for '\' or '/' under Windows.
3358 * G_KEY_FILE_DESKTOP_GROUP:
3360 * The name of the main group of a desktop entry file, as defined in the
3361 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
3362 * Entry Specification</ulink>. Consult the specification for more
3363 * details about the meanings of the keys below.
3370 * G_KEY_FILE_DESKTOP_KEY_CATEGORIES:
3372 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3373 * of strings giving the categories in which the desktop entry
3374 * should be shown in a menu.
3381 * G_KEY_FILE_DESKTOP_KEY_COMMENT:
3383 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3384 * string giving the tooltip for the desktop entry.
3391 * G_KEY_FILE_DESKTOP_KEY_EXEC:
3393 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3394 * giving the command line to execute. It is only valid for desktop
3395 * entries with the <literal>Application</literal> type.
3402 * G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME:
3404 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3405 * string giving the generic name of the desktop entry.
3412 * G_KEY_FILE_DESKTOP_KEY_HIDDEN:
3414 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3415 * stating whether the desktop entry has been deleted by the user.
3422 * G_KEY_FILE_DESKTOP_KEY_ICON:
3424 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3425 * string giving the name of the icon to be displayed for the desktop
3433 * G_KEY_FILE_DESKTOP_KEY_MIME_TYPE:
3435 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3436 * of strings giving the MIME types supported by this desktop entry.
3443 * G_KEY_FILE_DESKTOP_KEY_NAME:
3445 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3446 * string giving the specific name of the desktop entry.
3453 * G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN:
3455 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3456 * strings identifying the environments that should not display the
3464 * G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY:
3466 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3467 * stating whether the desktop entry should be shown in menus.
3474 * G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN:
3476 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3477 * strings identifying the environments that should display the
3485 * G_KEY_FILE_DESKTOP_KEY_PATH:
3487 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3488 * containing the working directory to run the program in. It is only
3489 * valid for desktop entries with the <literal>Application</literal> type.
3496 * G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY:
3498 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3499 * stating whether the application supports the <ulink
3500 * url="http://www.freedesktop.org/Standards/startup-notification-spec">Startup
3501 * Notification Protocol Specification</ulink>.
3508 * G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS:
3510 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is string
3511 * identifying the WM class or name hint of a window that the application
3512 * will create, which can be used to emulate Startup Notification with
3513 * older applications.
3520 * G_KEY_FILE_DESKTOP_KEY_TERMINAL:
3522 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3523 * stating whether the program should be run in a terminal window.
3524 * It is only valid for desktop entries with the
3525 * <literal>Application</literal> type.
3532 * G_KEY_FILE_DESKTOP_KEY_TRY_EXEC:
3534 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3535 * giving the file name of a binary on disk used to determine if the
3536 * program is actually installed. It is only valid for desktop entries
3537 * with the <literal>Application</literal> type.
3544 * G_KEY_FILE_DESKTOP_KEY_TYPE:
3546 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3547 * giving the type of the desktop entry. Usually
3548 * #G_KEY_FILE_DESKTOP_TYPE_APPLICATION,
3549 * #G_KEY_FILE_DESKTOP_TYPE_LINK, or
3550 * #G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.
3557 * G_KEY_FILE_DESKTOP_KEY_URL:
3559 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3560 * giving the URL to access. It is only valid for desktop entries
3561 * with the <literal>Link</literal> type.
3568 * G_KEY_FILE_DESKTOP_KEY_VERSION:
3570 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3571 * giving the version of the Desktop Entry Specification used for
3572 * the desktop entry file.
3579 * G_KEY_FILE_DESKTOP_TYPE_APPLICATION:
3581 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3582 * entries representing applications.
3589 * G_KEY_FILE_DESKTOP_TYPE_DIRECTORY:
3591 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3592 * entries representing directories.
3599 * G_KEY_FILE_DESKTOP_TYPE_LINK:
3601 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3602 * entries representing links to documents.
3611 * Error domain for key file parsing. Errors in this domain will
3612 * be from the #GKeyFileError enumeration.
3614 * See #GError for information on error domains.
3620 * @expr: the expression
3622 * Hints the compiler that the expression is likely to evaluate to
3623 * a true value. The compiler may use this information for optimizations.
3626 * if (G_LIKELY (random () != 1))
3627 * g_print ("not one");
3630 * Returns: the value of @expr
3638 * Specifies one of the possible types of byte order.
3639 * See #G_BYTE_ORDER.
3646 * The natural logarithm of 10.
3653 * The natural logarithm of 2.
3659 * @name: the name of the lock
3661 * Works like g_mutex_lock(), but for a lock defined with
3668 * @name: the name of the lock
3670 * The <literal>G_LOCK_*</literal> macros provide a convenient interface to #GMutex.
3671 * #G_LOCK_DEFINE defines a lock. It can appear in any place where
3672 * variable definitions may appear in programs, i.e. in the first block
3673 * of a function or outside of functions. The @name parameter will be
3674 * mangled to get the name of the #GMutex. This means that you
3675 * can use names of existing variables as the parameter - e.g. the name
3676 * of the variable you intend to protect with the lock. Look at our
3677 * <function>give_me_next_number()</function> example using the
3678 * <literal>G_LOCK_*</literal> macros:
3681 * <title>Using the <literal>G_LOCK_*</literal> convenience macros</title>
3683 * G_LOCK_DEFINE (current_number);
3686 * give_me_next_number (void)
3688 * static int current_number = 0;
3691 * G_LOCK (current_number);
3692 * ret_val = current_number = calc_next_number (current_number);
3693 * G_UNLOCK (current_number);
3703 * G_LOCK_DEFINE_STATIC:
3704 * @name: the name of the lock
3706 * This works like #G_LOCK_DEFINE, but it creates a static object.
3712 * @name: the name of the lock
3714 * This declares a lock, that is defined with #G_LOCK_DEFINE in another
3722 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
3729 * Defines the log domain.
3731 * For applications, this is typically left as the default %NULL
3732 * (or "") domain. Libraries should define this so that any messages
3733 * which they log can be differentiated from messages from other
3734 * libraries and application code. But be careful not to define
3735 * it in any public header files.
3737 * For example, GTK+ uses this in its Makefile.am:
3739 * INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
3747 * GLib log levels that are considered fatal by default.
3754 * The maximum value which can be held in a #gdouble.
3761 * The maximum value which can be held in a #gfloat.
3768 * The maximum value which can be held in a #gint.
3775 * The maximum value which can be held in a #gint16.
3784 * The maximum value which can be held in a #gint32.
3793 * The maximum value which can be held in a #gint64.
3800 * The maximum value which can be held in a #gint8.
3809 * The maximum value which can be held in a #glong.
3816 * The maximum value which can be held in a #goffset.
3823 * The maximum value which can be held in a #gshort.
3830 * The maximum value which can be held in a #gsize.
3839 * The maximum value which can be held in a #gssize.
3848 * The maximum value which can be held in a #guint.
3855 * The maximum value which can be held in a #guint16.
3864 * The maximum value which can be held in a #guint32.
3873 * The maximum value which can be held in a #guint64.
3880 * The maximum value which can be held in a #guint8.
3889 * The maximum value which can be held in a #gulong.
3896 * The maximum value which can be held in a #gushort.
3903 * The minimum positive value which can be held in a #gdouble.
3905 * If you are interested in the smallest value which can be held
3906 * in a #gdouble, use -G_MAXDOUBLE.
3913 * The minimum positive value which can be held in a #gfloat.
3915 * If you are interested in the smallest value which can be held
3916 * in a #gfloat, use -G_MAXFLOAT.
3923 * The minimum value which can be held in a #gint.
3930 * The minimum value which can be held in a #gint16.
3939 * The minimum value which can be held in a #gint32.
3948 * The minimum value which can be held in a #gint64.
3955 * The minimum value which can be held in a #gint8.
3964 * The minimum value which can be held in a #glong.
3971 * The minimum value which can be held in a #goffset.
3978 * The minimum value which can be held in a #gshort.
3985 * The minimum value which can be held in a #gssize.
3995 * Determines the number of elements in an array. The array must be
3996 * declared so the compiler knows its size at compile-time; this
3997 * macro will not work on an array allocated on the heap, only static
3998 * arrays or arrays on the stack.
4005 * A #GOnce must be initialized with this macro before it can be used.
4008 * GOnce my_once = G_ONCE_INIT;
4018 * This macro is defined only on BeOS. So you can bracket
4019 * BeOS-specific code in "#ifdef G_OS_BEOS".
4026 * This macro is defined only on UNIX. So you can bracket
4027 * UNIX-specific code in "#ifdef G_OS_UNIX".
4034 * This macro is defined only on Windows. So you can bracket
4035 * Windows-specific code in "#ifdef G_OS_WIN32".
4041 * @identifier1: an identifier
4042 * @identifier2: an identifier
4044 * Yields a new preprocessor pasted identifier
4045 * <code>identifier1identifier2</code> from its expanded
4046 * arguments @identifier1 and @identifier2. For example,
4047 * the following code:
4049 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
4050 * const gchar *name = GET (traveller, name);
4051 * const gchar *quest = GET (traveller, quest);
4052 * GdkColor *favourite = GET (traveller, favourite_colour);
4055 * is transformed by the preprocessor into:
4057 * const gchar *name = traveller_get_name (traveller);
4058 * const gchar *quest = traveller_get_quest (traveller);
4059 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
4069 * Specifies one of the possible types of byte order
4070 * (currently unused). See #G_BYTE_ORDER.
4077 * The value of pi (ratio of circle's circumference to its diameter).
4097 * @notify: a #GDestroyNotify
4099 * A macro to assist with the static initialisation of a #GPrivate.
4101 * This macro is useful for the case that a #GDestroyNotify function
4102 * should be associated the key. This is needed when the key will be
4103 * used to point at memory that should be deallocated when the thread
4106 * Additionally, the #GDestroyNotify will also be called on the previous
4107 * value stored in the key when g_private_replace() is used.
4109 * If no #GDestroyNotify is needed, then use of this macro is not
4110 * required -- if the #GPrivate is declared in static scope then it will
4111 * be properly initialised by default (ie: to all zeros). See the
4115 * static GPrivate name_key = G_PRIVATE_INIT (g_free);
4117 * // return value should not be freed
4119 * get_local_name (void)
4121 * return g_private_get (&name_key);
4125 * set_local_name (const gchar *name)
4127 * g_private_replace (&name_key, g_strdup (name));
4131 * static GPrivate count_key; // no free function
4134 * get_local_count (void)
4136 * return GPOINTER_TO_INT (g_private_get (&count_key));
4140 * set_local_count (gint count)
4142 * g_private_set (&count_key, GINT_TO_POINTER (count));
4151 * G_SEARCHPATH_SEPARATOR:
4153 * The search path separator character.
4154 * This is ':' on UNIX machines and ';' under Windows.
4159 * G_SEARCHPATH_SEPARATOR_S:
4161 * The search path separator as a string.
4162 * This is ":" on UNIX machines and ";" under Windows.
4169 * Error domain for shell functions. Errors in this domain will be from
4170 * the #GShellError enumeration. See #GError for information on error
4178 * The square root of two.
4184 * @expr: a constant expression
4186 * The G_STATIC_ASSERT macro lets the programmer check
4187 * a condition at compile time, the condition needs to
4188 * be compile time computable. The macro can be used in
4189 * any place where a <literal>typedef</literal> is valid.
4192 * A <literal>typedef</literal> is generally allowed in
4193 * exactly the same places that a variable declaration is
4194 * allowed. For this reason, you should not use
4195 * <literal>G_STATIC_ASSERT</literal> in the middle of
4199 * The macro should only be used once per source code line.
4206 * G_STATIC_ASSERT_EXPR:
4207 * @expr: a constant expression
4209 * The G_STATIC_ASSERT_EXPR macro lets the programmer check
4210 * a condition at compile time. The condition needs to be
4211 * compile time computable.
4213 * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
4214 * evaluates to an expression and, as such, can be used in
4215 * the middle of other expressions. Its value should be
4216 * ignored. This can be accomplished by placing it as
4217 * the first argument of a comma expression.
4220 * #define ADD_ONE_TO_INT(x) \
4221 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
4231 * Used within multi-statement macros so that they can be used in places
4232 * where only one statement is expected by the compiler.
4239 * Used within multi-statement macros so that they can be used in places
4240 * where only one statement is expected by the compiler.
4247 * Expands to a string identifying the current function.
4255 * @macro_or_string: a macro or a string
4257 * Accepts a macro or a string and converts it into a string after
4258 * preprocessor argument expansion. For example, the following code:
4262 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
4265 * is transformed by the preprocessor into (code equivalent to):
4268 * const gchar *greeting = "27 today!";
4276 * Expands to a string identifying the current code position.
4282 * @member_type: the type of the struct field
4283 * @struct_p: a pointer to a struct
4284 * @struct_offset: the offset of the field from the start of the struct, in bytes
4286 * Returns a member of a structure at a given offset, using the given type.
4288 * Returns: the struct member
4293 * G_STRUCT_MEMBER_P:
4294 * @struct_p: a pointer to a struct
4295 * @struct_offset: the offset from the start of the struct, in bytes
4297 * Returns an untyped pointer to a given offset of a struct.
4299 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
4305 * @struct_type: a structure type, e.g. <structname>GtkWidget</structname>
4306 * @member: a field in the structure, e.g. <structfield>window</structfield>
4308 * Returns the offset, in bytes, of a member of a struct.
4310 * Returns: the offset of @member from the start of @struct_type
4317 * The standard delimiters, used in g_strdelimit().
4324 * The error domain of the GLib thread subsystem.
4330 * @name: the name of the lock
4332 * Works like g_mutex_trylock(), but for a lock defined with
4335 * Returns: %TRUE, if the lock could be locked.
4341 * @maj: the major version that introduced the symbol
4342 * @min: the minor version that introduced the symbol
4344 * This macro can be used to mark a function declaration as unavailable.
4345 * It must be placed before the function declaration. Use of a function
4346 * that has been annotated with this macros will produce a compiler warning.
4354 * @expr: the expression
4356 * Hints the compiler that the expression is unlikely to evaluate to
4357 * a true value. The compiler may use this information for optimizations.
4360 * if (G_UNLIKELY (random () == 1))
4361 * g_print ("a random one");
4364 * Returns: the value of @expr
4371 * @name: the name of the lock
4373 * Works like g_mutex_unlock(), but for a lock defined with
4381 * Number of microseconds in one second (1 million).
4382 * This macro is provided for code readability.
4387 * G_VARIANT_PARSE_ERROR:
4389 * Error domain for GVariant text format parsing. Specific error codes
4390 * are not currently defined for this domain. See #GError for
4391 * information on error domains.
4397 * @ap1: the <type>va_list</type> variable to place a copy of @ap2 in
4398 * @ap2: a <type>va_list</type>
4400 * Portable way to copy <type>va_list</type> variables.
4402 * In order to use this function, you must include
4403 * <filename>string.h</filename> yourself, because this macro may
4404 * use memmove() and GLib does not include <filename>string.h</filename>
4410 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
4411 * @static: empty or "static"
4412 * @dll_name: the name of the (pointer to the) char array where the DLL name will be stored. If this is used, you must also include <filename>windows.h</filename>. If you need a more complex DLL entry point function, you cannot use this
4414 * On Windows, this macro defines a DllMain() function that stores
4415 * the actual DLL name that the code being compiled will be included in.
4417 * On non-Windows platforms, expands to nothing.
4422 * G_WIN32_HAVE_WIDECHAR_API:
4424 * On Windows, this macro defines an expression which evaluates to
4425 * %TRUE if the code is running on a version of Windows where the wide
4426 * character versions of the Win32 API functions, and the wide character
4427 * versions of the C library functions work. (They are always present in
4428 * the DLLs, but don't work on Windows 9x and Me.)
4430 * On non-Windows platforms, it is not defined.
4437 * G_WIN32_IS_NT_BASED:
4439 * On Windows, this macro defines an expression which evaluates to
4440 * %TRUE if the code is running on an NT-based Windows operating system.
4442 * On non-Windows platforms, it is not defined.
4450 * @a: a numeric value
4451 * @b: a numeric value
4453 * Calculates the maximum of @a and @b.
4455 * Returns: the maximum of @a and @b.
4462 * Provided for UNIX emulation on Windows; equivalent to UNIX
4463 * macro %MAXPATHLEN, which is the maximum length of a filename
4464 * (including full path).
4470 * @a: a numeric value
4471 * @b: a numeric value
4473 * Calculates the minimum of @a and @b.
4475 * Returns: the minimum of @a and @b.
4481 * @Context: a message context, must be a string literal
4482 * @String: a message id, must be a string literal
4484 * Only marks a string for translation, with context.
4485 * This is useful in situations where the translated strings can't
4486 * be directly used, e.g. in string array initializers. To get the
4487 * translated string, you should call g_dpgettext2() at runtime.
4491 * static const char *messages[] = {
4492 * NC_("some context", "some very meaningful message"),
4493 * NC_("some context", "and another one")
4495 * const char *string;
4498 * = index > 1 ? g_dpgettext2 (NULL, "some context", "a default message")
4499 * : g_dpgettext2 (NULL, "some context", messages[index]);
4506 * <note><para>If you are using the NC_() macro, you need to make sure
4507 * that you pass <option>--keyword=NC_:1c,2</option> to xgettext when
4508 * extracting messages. Note that this only works with GNU gettext >= 0.15.
4509 * Intltool has support for the NC_() macro since version 0.40.1.
4519 * Defines the standard %NULL pointer.
4525 * @String: the string to be translated
4527 * Only marks a string for translation. This is useful in situations
4528 * where the translated strings can't be directly used, e.g. in string
4529 * array initializers. To get the translated string, call gettext()
4533 * static const char *messages[] = {
4534 * N_("some very meaningful message"),
4535 * N_("and another one")
4537 * const char *string;
4540 * = index > 1 ? _("a default message") : gettext (messages[index]);
4553 * @String: the string to be translated, with a '|'-separated prefix which must not be translated
4555 * Like _(), but handles context in message ids. This has the advantage
4556 * that the string can be adorned with a prefix to guarantee uniqueness
4557 * and provide context to the translator.
4559 * One use case given in the gettext manual is GUI translation, where one
4560 * could e.g. disambiguate two "Open" menu entries as "File|Open" and
4561 * "Printer|Open". Another use case is the string "Russian" which may
4562 * have to be translated differently depending on whether it's the name
4563 * of a character set or a language. This could be solved by using
4564 * "charset|Russian" and "language|Russian".
4566 * See the C_() macro for a different way to mark up translatable strings
4569 * <note><para>If you are using the Q_() macro, you need to make sure
4570 * that you pass <option>--keyword=Q_</option> to xgettext when extracting
4571 * messages. If you are using GNU gettext >= 0.15, you can also use
4572 * <option>--keyword=Q_:1g</option> to let xgettext split the context
4573 * string off into a msgctxt line in the po file.</para></note>
4575 * Returns: the translated message
4583 * @short_description: arrays of arbitrary elements which grow automatically as elements are added
4585 * Arrays are similar to standard C arrays, except that they grow
4586 * automatically as elements are added.
4588 * Array elements can be of any size (though all elements of one array
4589 * are the same size), and the array can be automatically cleared to
4590 * '0's and zero-terminated.
4592 * To create a new array use g_array_new().
4594 * To add elements to an array, use g_array_append_val(),
4595 * g_array_append_vals(), g_array_prepend_val(), and
4596 * g_array_prepend_vals().
4598 * To access an element of an array, use g_array_index().
4600 * To set the size of an array, use g_array_set_size().
4602 * To free an array, use g_array_free().
4605 * <title>Using a #GArray to store #gint values</title>
4609 * /<!-- -->* We create a new array to store gint values.
4610 * We don't want it zero-terminated or cleared to 0's. *<!-- -->/
4611 * garray = g_array_new (FALSE, FALSE, sizeof (gint));
4612 * for (i = 0; i < 10000; i++)
4613 * g_array_append_val (garray, i);
4614 * for (i = 0; i < 10000; i++)
4615 * if (g_array_index (garray, gint, i) != i)
4616 * g_print ("ERROR: got %d instead of %d\n",
4617 * g_array_index (garray, gint, i), i);
4618 * g_array_free (garray, TRUE);
4625 * SECTION:arrays_byte
4626 * @title: Byte Arrays
4627 * @short_description: arrays of bytes
4629 * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
4630 * of bytes which grow automatically as elements are added.
4632 * To create a new #GByteArray use g_byte_array_new(). To add elements to a
4633 * #GByteArray, use g_byte_array_append(), and g_byte_array_prepend().
4635 * To set the size of a #GByteArray, use g_byte_array_set_size().
4637 * To free a #GByteArray, use g_byte_array_free().
4640 * <title>Using a #GByteArray</title>
4642 * GByteArray *gbarray;
4645 * gbarray = g_byte_array_new (<!-- -->);
4646 * for (i = 0; i < 10000; i++)
4647 * g_byte_array_append (gbarray, (guint8*) "abcd", 4);
4649 * for (i = 0; i < 10000; i++)
4651 * g_assert (gbarray->data[4*i] == 'a');
4652 * g_assert (gbarray->data[4*i+1] == 'b');
4653 * g_assert (gbarray->data[4*i+2] == 'c');
4654 * g_assert (gbarray->data[4*i+3] == 'd');
4657 * g_byte_array_free (gbarray, TRUE);
4661 * See #GBytes if you are interested in an immutable object representing a
4662 * sequence of bytes.
4667 * SECTION:arrays_pointer
4668 * @title: Pointer Arrays
4669 * @short_description: arrays of pointers to any type of data, which grow automatically as new elements are added
4671 * Pointer Arrays are similar to Arrays but are used only for storing
4674 * <note><para>If you remove elements from the array, elements at the
4675 * end of the array are moved into the space previously occupied by the
4676 * removed element. This means that you should not rely on the index of
4677 * particular elements remaining the same. You should also be careful
4678 * when deleting elements while iterating over the array.</para></note>
4680 * To create a pointer array, use g_ptr_array_new().
4682 * To add elements to a pointer array, use g_ptr_array_add().
4684 * To remove elements from a pointer array, use g_ptr_array_remove(),
4685 * g_ptr_array_remove_index() or g_ptr_array_remove_index_fast().
4687 * To access an element of a pointer array, use g_ptr_array_index().
4689 * To set the size of a pointer array, use g_ptr_array_set_size().
4691 * To free a pointer array, use g_ptr_array_free().
4694 * <title>Using a #GPtrArray</title>
4696 * GPtrArray *gparray;
4697 * gchar *string1 = "one", *string2 = "two", *string3 = "three";
4699 * gparray = g_ptr_array_new (<!-- -->);
4700 * g_ptr_array_add (gparray, (gpointer) string1);
4701 * g_ptr_array_add (gparray, (gpointer) string2);
4702 * g_ptr_array_add (gparray, (gpointer) string3);
4704 * if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
4705 * g_print ("ERROR: got %p instead of %p\n",
4706 * g_ptr_array_index (gparray, 0), string1);
4708 * g_ptr_array_free (gparray, TRUE);
4715 * SECTION:async_queues
4716 * @title: Asynchronous Queues
4717 * @short_description: asynchronous communication between threads
4718 * @see_also: #GThreadPool
4720 * Often you need to communicate between different threads. In general
4721 * it's safer not to do this by shared memory, but by explicit message
4722 * passing. These messages only make sense asynchronously for
4723 * multi-threaded applications though, as a synchronous operation could
4724 * as well be done in the same thread.
4726 * Asynchronous queues are an exception from most other GLib data
4727 * structures, as they can be used simultaneously from multiple threads
4728 * without explicit locking and they bring their own builtin reference
4729 * counting. This is because the nature of an asynchronous queue is that
4730 * it will always be used by at least 2 concurrent threads.
4732 * For using an asynchronous queue you first have to create one with
4733 * g_async_queue_new(). #GAsyncQueue structs are reference counted,
4734 * use g_async_queue_ref() and g_async_queue_unref() to manage your
4737 * A thread which wants to send a message to that queue simply calls
4738 * g_async_queue_push() to push the message to the queue.
4740 * A thread which is expecting messages from an asynchronous queue
4741 * simply calls g_async_queue_pop() for that queue. If no message is
4742 * available in the queue at that point, the thread is now put to sleep
4743 * until a message arrives. The message will be removed from the queue
4744 * and returned. The functions g_async_queue_try_pop() and
4745 * g_async_queue_timeout_pop() can be used to only check for the presence
4746 * of messages or to only wait a certain time for messages respectively.
4748 * For almost every function there exist two variants, one that locks
4749 * the queue and one that doesn't. That way you can hold the queue lock
4750 * (acquire it with g_async_queue_lock() and release it with
4751 * g_async_queue_unlock()) over multiple queue accessing instructions.
4752 * This can be necessary to ensure the integrity of the queue, but should
4753 * only be used when really necessary, as it can make your life harder
4754 * if used unwisely. Normally you should only use the locking function
4755 * variants (those without the _unlocked suffix).
4757 * In many cases, it may be more convenient to use #GThreadPool when
4758 * you need to distribute work to a set of worker threads instead of
4759 * using #GAsyncQueue manually. #GThreadPool uses a GAsyncQueue
4765 * SECTION:atomic_operations
4766 * @title: Atomic Operations
4767 * @short_description: basic atomic integer and pointer operations
4768 * @see_also: #GMutex
4770 * The following is a collection of compiler macros to provide atomic
4771 * access to integer and pointer-sized values.
4773 * The macros that have 'int' in the name will operate on pointers to
4774 * #gint and #guint. The macros with 'pointer' in the name will operate
4775 * on pointers to any pointer-sized value, including #gsize. There is
4776 * no support for 64bit operations on platforms with 32bit pointers
4777 * because it is not generally possible to perform these operations
4780 * The get, set and exchange operations for integers and pointers
4781 * nominally operate on #gint and #gpointer, respectively. Of the
4782 * arithmetic operations, the 'add' operation operates on (and returns)
4783 * signed integer values (#gint and #gssize) and the 'and', 'or', and
4784 * 'xor' operations operate on (and return) unsigned integer values
4785 * (#guint and #gsize).
4787 * All of the operations act as a full compiler and (where appropriate)
4788 * hardware memory barrier. Acquire and release or producer and
4789 * consumer barrier semantics are not available through this API.
4791 * It is very important that all accesses to a particular integer or
4792 * pointer be performed using only this API and that different sizes of
4793 * operation are not mixed or used on overlapping memory regions. Never
4794 * read or assign directly from or to a value -- always use this API.
4796 * For simple reference counting purposes you should use
4797 * g_atomic_int_inc() and g_atomic_int_dec_and_test(). Other uses that
4798 * fall outside of simple reference counting patterns are prone to
4799 * subtle bugs and occasionally undefined behaviour. It is also worth
4800 * noting that since all of these operations require global
4801 * synchronisation of the entire machine, they can be quite slow. In
4802 * the case of performing multiple atomic operations it can often be
4803 * faster to simply acquire a mutex lock around the critical area,
4804 * perform the operations normally and then release the lock.
4810 * @title: Base64 Encoding
4811 * @short_description: encodes and decodes data in Base64 format
4813 * Base64 is an encoding that allows a sequence of arbitrary bytes to be
4814 * encoded as a sequence of printable ASCII characters. For the definition
4815 * of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
4816 * 1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
4817 * 2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
4820 * GLib supports incremental encoding using g_base64_encode_step() and
4821 * g_base64_encode_close(). Incremental decoding can be done with
4822 * g_base64_decode_step(). To encode or decode data in one go, use
4823 * g_base64_encode() or g_base64_decode(). To avoid memory allocation when
4824 * decoding, you can use g_base64_decode_inplace().
4826 * Support for Base64 encoding has been added in GLib 2.12.
4831 * SECTION:bookmarkfile
4832 * @title: Bookmark file parser
4833 * @short_description: parses files containing bookmarks
4835 * GBookmarkFile lets you parse, edit or create files containing bookmarks
4836 * to URI, along with some meta-data about the resource pointed by the URI
4837 * like its MIME type, the application that is registering the bookmark and
4838 * the icon that should be used to represent the bookmark. The data is stored
4840 * <ulink url="http://www.gnome.org/~ebassi/bookmark-spec">Desktop Bookmark
4841 * Specification</ulink>.
4843 * The syntax of the bookmark files is described in detail inside the Desktop
4844 * Bookmark Specification, here is a quick summary: bookmark files use a
4845 * sub-class of the <ulink url="">XML Bookmark Exchange Language</ulink>
4846 * specification, consisting of valid UTF-8 encoded XML, under the
4847 * <literal>xbel</literal> root element; each bookmark is stored inside a
4848 * <literal>bookmark</literal> element, using its URI: no relative paths can
4849 * be used inside a bookmark file. The bookmark may have a user defined title
4850 * and description, to be used instead of the URI. Under the
4851 * <literal>metadata</literal> element, with its <literal>owner</literal>
4852 * attribute set to <literal>http://freedesktop.org</literal>, is stored the
4853 * meta-data about a resource pointed by its URI. The meta-data consists of
4854 * the resource's MIME type; the applications that have registered a bookmark;
4855 * the groups to which a bookmark belongs to; a visibility flag, used to set
4856 * the bookmark as "private" to the applications and groups that has it
4857 * registered; the URI and MIME type of an icon, to be used when displaying
4858 * the bookmark inside a GUI.
4859 * |[<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>]|
4861 * A bookmark file might contain more than one bookmark; each bookmark
4862 * is accessed through its URI.
4864 * The important caveat of bookmark files is that when you add a new
4865 * bookmark you must also add the application that is registering it, using
4866 * g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
4867 * If a bookmark has no applications then it won't be dumped when creating
4868 * the on disk representation, using g_bookmark_file_to_data() or
4869 * g_bookmark_file_to_file().
4871 * The #GBookmarkFile parser was added in GLib 2.12.
4876 * SECTION:byte_order
4877 * @title: Byte Order Macros
4878 * @short_description: a portable way to convert between different byte orders
4880 * These macros provide a portable way to determine the host byte order
4881 * and to convert values between different byte orders.
4883 * The byte order is the order in which bytes are stored to create larger
4884 * data types such as the #gint and #glong values.
4885 * The host byte order is the byte order used on the current machine.
4887 * Some processors store the most significant bytes (i.e. the bytes that
4888 * hold the largest part of the value) first. These are known as big-endian
4889 * processors. Other processors (notably the x86 family) store the most
4890 * significant byte last. These are known as little-endian processors.
4892 * Finally, to complicate matters, some other processors store the bytes in
4893 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
4894 * most significant byte is stored first, then the 4th, then the 1st and
4897 * Obviously there is a problem when these different processors communicate
4898 * with each other, for example over networks or by using binary file formats.
4899 * This is where these macros come in. They are typically used to convert
4900 * values into a byte order which has been agreed on for use when
4901 * communicating between different processors. The Internet uses what is
4902 * known as 'network byte order' as the standard byte order (which is in
4903 * fact the big-endian byte order).
4905 * Note that the byte order conversion macros may evaluate their arguments
4906 * multiple times, thus you should not use them with arguments which have
4913 * @title: Data Checksums
4914 * @short_description: computes the checksum for data
4916 * GLib provides a generic API for computing checksums (or "digests")
4917 * for a sequence of arbitrary bytes, using various hashing algorithms
4918 * like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
4919 * environments and specifications.
4921 * GLib supports incremental checksums using the GChecksum data
4922 * structure, by calling g_checksum_update() as long as there's data
4923 * available and then using g_checksum_get_string() or
4924 * g_checksum_get_digest() to compute the checksum and return it either
4925 * as a string in hexadecimal form, or as a raw sequence of bytes. To
4926 * compute the checksum for binary blobs and NUL-terminated strings in
4927 * one go, use the convenience functions g_compute_checksum_for_data()
4928 * and g_compute_checksum_for_string(), respectively.
4930 * Support for checksums has been added in GLib 2.16
4935 * SECTION:conversions
4936 * @title: Character Set Conversion
4937 * @short_description: convert strings between different character sets
4939 * The g_convert() family of function wraps the functionality of iconv(). In
4940 * addition to pure character set conversions, GLib has functions to deal
4941 * with the extra complications of encodings for file names.
4943 * <refsect2 id="file-name-encodings">
4944 * <title>File Name Encodings</title>
4946 * Historically, Unix has not had a defined encoding for file
4947 * names: a file name is valid as long as it does not have path
4948 * separators in it ("/"). However, displaying file names may
4949 * require conversion: from the character set in which they were
4950 * created, to the character set in which the application
4951 * operates. Consider the Spanish file name
4952 * "<filename>Presentación.sxi</filename>". If the
4953 * application which created it uses ISO-8859-1 for its encoding,
4955 * <programlisting id="filename-iso8859-1">
4956 * Character: P r e s e n t a c i ó n . s x i
4957 * Hex code: 50 72 65 73 65 6e 74 61 63 69 f3 6e 2e 73 78 69
4960 * However, if the application use UTF-8, the actual file name on
4961 * disk would look like this:
4963 * <programlisting id="filename-utf-8">
4964 * Character: P r e s e n t a c i ó n . s x i
4965 * Hex code: 50 72 65 73 65 6e 74 61 63 69 c3 b3 6e 2e 73 78 69
4968 * Glib uses UTF-8 for its strings, and GUI toolkits like GTK+
4969 * that use Glib do the same thing. If you get a file name from
4970 * the file system, for example, from readdir(3) or from g_dir_read_name(),
4971 * and you wish to display the file name to the user, you
4972 * <emphasis>will</emphasis> need to convert it into UTF-8. The
4973 * opposite case is when the user types the name of a file he
4974 * wishes to save: the toolkit will give you that string in
4975 * UTF-8 encoding, and you will need to convert it to the
4976 * character set used for file names before you can create the
4977 * file with open(2) or fopen(3).
4980 * By default, Glib assumes that file names on disk are in UTF-8
4981 * encoding. This is a valid assumption for file systems which
4982 * were created relatively recently: most applications use UTF-8
4983 * encoding for their strings, and that is also what they use for
4984 * the file names they create. However, older file systems may
4985 * still contain file names created in "older" encodings, such as
4986 * ISO-8859-1. In this case, for compatibility reasons, you may
4987 * want to instruct Glib to use that particular encoding for file
4988 * names rather than UTF-8. You can do this by specifying the
4989 * encoding for file names in the <link
4990 * linkend="G_FILENAME_ENCODING"><envar>G_FILENAME_ENCODING</envar></link>
4991 * environment variable. For example, if your installation uses
4992 * ISO-8859-1 for file names, you can put this in your
4993 * <filename>~/.profile</filename>:
4996 * export G_FILENAME_ENCODING=ISO-8859-1
4999 * Glib provides the functions g_filename_to_utf8() and
5000 * g_filename_from_utf8() to perform the necessary conversions. These
5001 * functions convert file names from the encoding specified in
5002 * <envar>G_FILENAME_ENCODING</envar> to UTF-8 and vice-versa.
5003 * <xref linkend="file-name-encodings-diagram"/> illustrates how
5004 * these functions are used to convert between UTF-8 and the
5005 * encoding for file names in the file system.
5007 * <figure id="file-name-encodings-diagram">
5008 * <title>Conversion between File Name Encodings</title>
5009 * <graphic fileref="file-name-encodings.png" format="PNG"/>
5011 * <refsect3 id="file-name-encodings-checklist">
5012 * <title>Checklist for Application Writers</title>
5014 * This section is a practical summary of the detailed
5015 * description above. You can use this as a checklist of
5016 * things to do to make sure your applications process file
5017 * name encodings correctly.
5021 * If you get a file name from the file system from a function
5022 * such as readdir(3) or gtk_file_chooser_get_filename(),
5023 * you do not need to do any conversion to pass that
5024 * file name to functions like open(2), rename(2), or
5025 * fopen(3) — those are "raw" file names which the file
5026 * system understands.
5027 * </para></listitem>
5029 * If you need to display a file name, convert it to UTF-8 first by
5030 * using g_filename_to_utf8(). If conversion fails, display a string like
5031 * "<literal>Unknown file name</literal>". <emphasis>Do not</emphasis>
5032 * convert this string back into the encoding used for file names if you
5033 * wish to pass it to the file system; use the original file name instead.
5034 * For example, the document window of a word processor could display
5035 * "Unknown file name" in its title bar but still let the user save the
5036 * file, as it would keep the raw file name internally. This can happen
5037 * if the user has not set the <envar>G_FILENAME_ENCODING</envar>
5038 * environment variable even though he has files whose names are not
5040 * </para></listitem>
5042 * If your user interface lets the user type a file name for saving or
5043 * renaming, convert it to the encoding used for file names in the file
5044 * system by using g_filename_from_utf8(). Pass the converted file name
5045 * to functions like fopen(3). If conversion fails, ask the user to enter
5046 * a different file name. This can happen if the user types Japanese
5047 * characters when <envar>G_FILENAME_ENCODING</envar> is set to
5048 * <literal>ISO-8859-1</literal>, for example.
5049 * </para></listitem>
5058 * @title: Keyed Data Lists
5059 * @short_description: lists of data elements which are accessible by a string or GQuark identifier
5061 * Keyed data lists provide lists of arbitrary data elements which can
5062 * be accessed either with a string or with a #GQuark corresponding to
5065 * The #GQuark methods are quicker, since the strings have to be
5066 * converted to #GQuarks anyway.
5068 * Data lists are used for associating arbitrary data with #GObjects,
5069 * using g_object_set_data() and related functions.
5071 * To create a datalist, use g_datalist_init().
5073 * To add data elements to a datalist use g_datalist_id_set_data(),
5074 * g_datalist_id_set_data_full(), g_datalist_set_data() and
5075 * g_datalist_set_data_full().
5077 * To get data elements from a datalist use g_datalist_id_get_data()
5078 * and g_datalist_get_data().
5080 * To iterate over all data elements in a datalist use
5081 * g_datalist_foreach() (not thread-safe).
5083 * To remove data elements from a datalist use
5084 * g_datalist_id_remove_data() and g_datalist_remove_data().
5086 * To remove all data elements from a datalist, use g_datalist_clear().
5093 * @short_description: associate groups of data elements with particular memory locations
5095 * Datasets associate groups of data elements with particular memory
5096 * locations. These are useful if you need to associate data with a
5097 * structure returned from an external library. Since you cannot modify
5098 * the structure, you use its location in memory as the key into a
5099 * dataset, where you can associate any number of data elements with it.
5101 * There are two forms of most of the dataset functions. The first form
5102 * uses strings to identify the data elements associated with a
5103 * location. The second form uses #GQuark identifiers, which are
5104 * created with a call to g_quark_from_string() or
5105 * g_quark_from_static_string(). The second form is quicker, since it
5106 * does not require looking up the string in the hash table of #GQuark
5109 * There is no function to create a dataset. It is automatically
5110 * created as soon as you add elements to it.
5112 * To add data elements to a dataset use g_dataset_id_set_data(),
5113 * g_dataset_id_set_data_full(), g_dataset_set_data() and
5114 * g_dataset_set_data_full().
5116 * To get data elements from a dataset use g_dataset_id_get_data() and
5117 * g_dataset_get_data().
5119 * To iterate over all data elements in a dataset use
5120 * g_dataset_foreach() (not thread-safe).
5122 * To remove data elements from a dataset use
5123 * g_dataset_id_remove_data() and g_dataset_remove_data().
5125 * To destroy a dataset, use g_dataset_destroy().
5131 * @title: Date and Time Functions
5132 * @short_description: calendrical calculations and miscellaneous time stuff
5134 * The #GDate data structure represents a day between January 1, Year 1,
5135 * and sometime a few thousand years in the future (right now it will go
5136 * to the year 65535 or so, but g_date_set_parse() only parses up to the
5137 * year 8000 or so - just count on "a few thousand"). #GDate is meant to
5138 * represent everyday dates, not astronomical dates or historical dates
5139 * or ISO timestamps or the like. It extrapolates the current Gregorian
5140 * calendar forward and backward in time; there is no attempt to change
5141 * the calendar to match time periods or locations. #GDate does not store
5142 * time information; it represents a <emphasis>day</emphasis>.
5144 * The #GDate implementation has several nice features; it is only a
5145 * 64-bit struct, so storing large numbers of dates is very efficient. It
5146 * can keep both a Julian and day-month-year representation of the date,
5147 * since some calculations are much easier with one representation or the
5148 * other. A Julian representation is simply a count of days since some
5149 * fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
5150 * ("Julian" dates in the #GDate API aren't really Julian dates in the
5151 * technical sense; technically, Julian dates count from the start of the
5152 * Julian period, Jan 1, 4713 BC).
5154 * #GDate is simple to use. First you need a "blank" date; you can get a
5155 * dynamically allocated date from g_date_new(), or you can declare an
5156 * automatic variable or array and initialize it to a sane state by
5157 * calling g_date_clear(). A cleared date is sane; it's safe to call
5158 * g_date_set_dmy() and the other mutator functions to initialize the
5159 * value of a cleared date. However, a cleared date is initially
5160 * <emphasis>invalid</emphasis>, meaning that it doesn't represent a day
5161 * that exists. It is undefined to call any of the date calculation
5162 * routines on an invalid date. If you obtain a date from a user or other
5163 * unpredictable source, you should check its validity with the
5164 * g_date_valid() predicate. g_date_valid() is also used to check for
5165 * errors with g_date_set_parse() and other functions that can
5166 * fail. Dates can be invalidated by calling g_date_clear() again.
5168 * <emphasis>It is very important to use the API to access the #GDate
5169 * struct.</emphasis> Often only the day-month-year or only the Julian
5170 * representation is valid. Sometimes neither is valid. Use the API.
5172 * GLib also features #GDateTime which represents a precise time.
5179 * @short_description: a structure representing Date and Time
5180 * @see_also: #GTimeZone
5182 * #GDateTime is a structure that combines a Gregorian date and time
5183 * into a single structure. It provides many conversion and methods to
5184 * manipulate dates and times. Time precision is provided down to
5185 * microseconds and the time can range (proleptically) from 0001-01-01
5186 * 00:00:00 to 9999-12-31 23:59:59.999999. #GDateTime follows POSIX
5187 * time in the sense that it is oblivious to leap seconds.
5189 * #GDateTime is an immutable object; once it has been created it cannot
5190 * be modified further. All modifiers will create a new #GDateTime.
5191 * Nearly all such functions can fail due to the date or time going out
5192 * of range, in which case %NULL will be returned.
5194 * #GDateTime is reference counted: the reference count is increased by calling
5195 * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
5196 * reference count drops to 0, the resources allocated by the #GDateTime
5197 * structure are released.
5199 * Many parts of the API may produce non-obvious results. As an
5200 * example, adding two months to January 31st will yield March 31st
5201 * whereas adding one month and then one month again will yield either
5202 * March 28th or March 29th. Also note that adding 24 hours is not
5203 * always the same as adding one day (since days containing daylight
5204 * savings time transitions are either 23 or 25 hours in length).
5206 * #GDateTime is available since GLib 2.26.
5211 * SECTION:error_reporting
5212 * @Title: Error Reporting
5213 * @Short_description: a system for reporting errors
5215 * GLib provides a standard method of reporting errors from a called
5216 * function to the calling code. (This is the same problem solved by
5217 * exceptions in other languages.) It's important to understand that
5218 * this method is both a <emphasis>data type</emphasis> (the #GError
5219 * object) and a <emphasis>set of rules.</emphasis> If you use #GError
5220 * incorrectly, then your code will not properly interoperate with other
5221 * code that uses #GError, and users of your API will probably get confused.
5223 * First and foremost: <emphasis>#GError should only be used to report
5224 * recoverable runtime errors, never to report programming
5225 * errors.</emphasis> If the programmer has screwed up, then you should
5226 * use g_warning(), g_return_if_fail(), g_assert(), g_error(), or some
5227 * similar facility. (Incidentally, remember that the g_error() function
5228 * should <emphasis>only</emphasis> be used for programming errors, it
5229 * should not be used to print any error reportable via #GError.)
5231 * Examples of recoverable runtime errors are "file not found" or
5232 * "failed to parse input." Examples of programming errors are "NULL
5233 * passed to strcmp()" or "attempted to free the same pointer twice."
5234 * These two kinds of errors are fundamentally different: runtime errors
5235 * should be handled or reported to the user, programming errors should
5236 * be eliminated by fixing the bug in the program. This is why most
5237 * functions in GLib and GTK+ do not use the #GError facility.
5239 * Functions that can fail take a return location for a #GError as their
5240 * last argument. For example:
5242 * gboolean g_file_get_contents (const gchar *filename,
5247 * If you pass a non-%NULL value for the <literal>error</literal>
5248 * argument, it should point to a location where an error can be placed.
5252 * GError *err = NULL;
5253 * g_file_get_contents ("foo.txt", &contents, NULL, &err);
5254 * g_assert ((contents == NULL && err != NULL) || (contents != NULL && err == NULL));
5257 * /* Report error to user, and free error */
5258 * g_assert (contents == NULL);
5259 * fprintf (stderr, "Unable to read file: %s\n", err->message);
5260 * g_error_free (err);
5264 * /* Use file contents */
5265 * g_assert (contents != NULL);
5268 * Note that <literal>err != NULL</literal> in this example is a
5269 * <emphasis>reliable</emphasis> indicator of whether
5270 * g_file_get_contents() failed. Additionally, g_file_get_contents()
5271 * returns a boolean which indicates whether it was successful.
5273 * Because g_file_get_contents() returns %FALSE on failure, if you
5274 * are only interested in whether it failed and don't need to display
5275 * an error message, you can pass %NULL for the <literal>error</literal>
5278 * if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /* ignore errors */
5279 * /* no error occurred */ ;
5281 * /* error */ ;
5284 * The #GError object contains three fields: <literal>domain</literal>
5285 * indicates the module the error-reporting function is located in,
5286 * <literal>code</literal> indicates the specific error that occurred,
5287 * and <literal>message</literal> is a user-readable error message with
5288 * as many details as possible. Several functions are provided to deal
5289 * with an error received from a called function: g_error_matches()
5290 * returns %TRUE if the error matches a given domain and code,
5291 * g_propagate_error() copies an error into an error location (so the
5292 * calling function will receive it), and g_clear_error() clears an
5293 * error location by freeing the error and resetting the location to
5294 * %NULL. To display an error to the user, simply display
5295 * <literal>error->message</literal>, perhaps along with additional
5296 * context known only to the calling function (the file being opened,
5297 * or whatever -- though in the g_file_get_contents() case,
5298 * <literal>error->message</literal> already contains a filename).
5300 * When implementing a function that can report errors, the basic
5301 * tool is g_set_error(). Typically, if a fatal error occurs you
5302 * want to g_set_error(), then return immediately. g_set_error()
5303 * does nothing if the error location passed to it is %NULL.
5304 * Here's an example:
5307 * foo_open_file (GError **error)
5311 * fd = open ("file.txt", O_RDONLY);
5315 * g_set_error (error,
5316 * FOO_ERROR, /* error domain */
5317 * FOO_ERROR_BLAH, /* error code */
5318 * "Failed to open file: %s", /* error message format string */
5319 * g_strerror (errno));
5327 * Things are somewhat more complicated if you yourself call another
5328 * function that can report a #GError. If the sub-function indicates
5329 * fatal errors in some way other than reporting a #GError, such as
5330 * by returning %TRUE on success, you can simply do the following:
5333 * my_function_that_can_fail (GError **err)
5335 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5337 * if (!sub_function_that_can_fail (err))
5339 * /* assert that error was set by the sub-function */
5340 * g_assert (err == NULL || *err != NULL);
5344 * /* otherwise continue, no error occurred */
5345 * g_assert (err == NULL || *err == NULL);
5349 * If the sub-function does not indicate errors other than by
5350 * reporting a #GError, you need to create a temporary #GError
5351 * since the passed-in one may be %NULL. g_propagate_error() is
5352 * intended for use in this case.
5355 * my_function_that_can_fail (GError **err)
5357 * GError *tmp_error;
5359 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5362 * sub_function_that_can_fail (&tmp_error);
5364 * if (tmp_error != NULL)
5366 * /* store tmp_error in err, if err != NULL,
5367 * * otherwise call g_error_free() on tmp_error
5369 * g_propagate_error (err, tmp_error);
5373 * /* otherwise continue, no error occurred */
5377 * Error pileups are always a bug. For example, this code is incorrect:
5380 * my_function_that_can_fail (GError **err)
5382 * GError *tmp_error;
5384 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5387 * sub_function_that_can_fail (&tmp_error);
5388 * other_function_that_can_fail (&tmp_error);
5390 * if (tmp_error != NULL)
5392 * g_propagate_error (err, tmp_error);
5397 * <literal>tmp_error</literal> should be checked immediately after
5398 * sub_function_that_can_fail(), and either cleared or propagated
5399 * upward. The rule is: <emphasis>after each error, you must either
5400 * handle the error, or return it to the calling function</emphasis>.
5401 * Note that passing %NULL for the error location is the equivalent
5402 * of handling an error by always doing nothing about it. So the
5403 * following code is fine, assuming errors in sub_function_that_can_fail()
5404 * are not fatal to my_function_that_can_fail():
5407 * my_function_that_can_fail (GError **err)
5409 * GError *tmp_error;
5411 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5413 * sub_function_that_can_fail (NULL); /* ignore errors */
5416 * other_function_that_can_fail (&tmp_error);
5418 * if (tmp_error != NULL)
5420 * g_propagate_error (err, tmp_error);
5426 * Note that passing %NULL for the error location
5427 * <emphasis>ignores</emphasis> errors; it's equivalent to
5428 * <literal>try { sub_function_that_can_fail (); } catch (...) {}</literal>
5429 * in C++. It does <emphasis>not</emphasis> mean to leave errors
5430 * unhandled; it means to handle them by doing nothing.
5432 * Error domains and codes are conventionally named as follows:
5435 * The error domain is called
5436 * <literal><NAMESPACE>_<MODULE>_ERROR</literal>,
5437 * for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
5439 * #define G_SPAWN_ERROR g_spawn_error_quark ()
5442 * g_spawn_error_quark (void)
5444 * return g_quark_from_static_string ("g-spawn-error-quark");
5447 * </para></listitem>
5449 * The quark function for the error domain is called
5450 * <literal><namespace>_<module>_error_quark</literal>,
5451 * for example g_spawn_error_quark() or g_thread_error_quark().
5452 * </para></listitem>
5454 * The error codes are in an enumeration called
5455 * <literal><Namespace><Module>Error</literal>;
5456 * for example,#GThreadError or #GSpawnError.
5457 * </para></listitem>
5459 * Members of the error code enumeration are called
5460 * <literal><NAMESPACE>_<MODULE>_ERROR_<CODE></literal>,
5461 * for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
5462 * </para></listitem>
5464 * If there's a "generic" or "unknown" error code for unrecoverable
5465 * errors it doesn't make sense to distinguish with specific codes,
5466 * it should be called <literal><NAMESPACE>_<MODULE>_ERROR_FAILED</literal>,
5467 * for example %G_SPAWN_ERROR_FAILED.
5468 * </para></listitem>
5471 * Summary of rules for use of #GError:
5474 * Do not report programming errors via #GError.
5475 * </para></listitem>
5477 * The last argument of a function that returns an error should
5478 * be a location where a #GError can be placed (i.e. "#GError** error").
5479 * If #GError is used with varargs, the #GError** should be the last
5480 * argument before the "...".
5481 * </para></listitem>
5483 * The caller may pass %NULL for the #GError** if they are not interested
5484 * in details of the exact error that occurred.
5485 * </para></listitem>
5487 * If %NULL is passed for the #GError** argument, then errors should
5488 * not be returned to the caller, but your function should still
5489 * abort and return if an error occurs. That is, control flow should
5490 * not be affected by whether the caller wants to get a #GError.
5491 * </para></listitem>
5493 * If a #GError is reported, then your function by definition
5494 * <emphasis>had a fatal failure and did not complete whatever
5495 * it was supposed to do</emphasis>. If the failure was not fatal,
5496 * then you handled it and you should not report it. If it was fatal,
5497 * then you must report it and discontinue whatever you were doing
5499 * </para></listitem>
5501 * If a #GError is reported, out parameters are not guaranteed to
5502 * be set to any defined value.
5503 * </para></listitem>
5505 * A #GError* must be initialized to %NULL before passing its address
5506 * to a function that can report errors.
5507 * </para></listitem>
5509 * "Piling up" errors is always a bug. That is, if you assign a
5510 * new #GError to a #GError* that is non-%NULL, thus overwriting
5511 * the previous error, it indicates that you should have aborted
5512 * the operation instead of continuing. If you were able to continue,
5513 * you should have cleared the previous error with g_clear_error().
5514 * g_set_error() will complain if you pile up errors.
5515 * </para></listitem>
5517 * By convention, if you return a boolean value indicating success
5518 * then %TRUE means success and %FALSE means failure. If %FALSE is
5519 * returned, the error <emphasis>must</emphasis> be set to a non-%NULL
5521 * </para></listitem>
5523 * A %NULL return value is also frequently used to mean that an error
5524 * occurred. You should make clear in your documentation whether %NULL
5525 * is a valid return value in non-error cases; if %NULL is a valid value,
5526 * then users must check whether an error was returned to see if the
5527 * function succeeded.
5528 * </para></listitem>
5530 * When implementing a function that can report errors, you may want
5531 * to add a check at the top of your function that the error return
5532 * location is either %NULL or contains a %NULL error (e.g.
5533 * <literal>g_return_if_fail (error == NULL || *error == NULL);</literal>).
5534 * </para></listitem>
5541 * @title: File Utilities
5542 * @short_description: various file-related functions
5544 * There is a group of functions which wrap the common POSIX functions
5545 * dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(),
5546 * g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these
5547 * wrappers is to make it possible to handle file names with any Unicode
5548 * characters in them on Windows without having to use ifdefs and the
5549 * wide character API in the application code.
5551 * The pathname argument should be in the GLib file name encoding.
5552 * On POSIX this is the actual on-disk encoding which might correspond
5553 * to the locale settings of the process (or the
5554 * <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
5556 * On Windows the GLib file name encoding is UTF-8. Note that the
5557 * Microsoft C library does not use UTF-8, but has separate APIs for
5558 * current system code page and wide characters (UTF-16). The GLib
5559 * wrappers call the wide character API if present (on modern Windows
5560 * systems), otherwise convert to/from the system code page.
5562 * Another group of functions allows to open and read directories
5563 * in the GLib file name encoding. These are g_dir_open(),
5564 * g_dir_read_name(), g_dir_rewind(), g_dir_close().
5569 * SECTION:ghostutils
5570 * @short_description: Internet hostname utilities
5572 * Functions for manipulating internet hostnames; in particular, for
5573 * converting between Unicode and ASCII-encoded forms of
5574 * Internationalized Domain Names (IDNs).
5577 * url="http://www.ietf.org/rfc/rfc3490.txt">Internationalized Domain
5578 * Names for Applications (IDNA)</ulink> standards allow for the use
5579 * of Unicode domain names in applications, while providing
5580 * backward-compatibility with the old ASCII-only DNS, by defining an
5581 * ASCII-Compatible Encoding of any given Unicode name, which can be
5582 * used with non-IDN-aware applications and protocols. (For example,
5583 * "Παν語.org" maps to "xn--4wa8awb4637h.org".)
5589 * @title: Perl-compatible regular expressions
5590 * @short_description: matches strings against regular expressions
5591 * @see_also: <xref linkend="glib-regex-syntax"/>
5593 * The <function>g_regex_*()</function> functions implement regular
5594 * expression pattern matching using syntax and semantics similar to
5595 * Perl regular expression.
5597 * Some functions accept a @start_position argument, setting it differs
5598 * from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
5599 * in the case of a pattern that begins with any kind of lookbehind assertion.
5600 * For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
5601 * in the middle of words. ("\B" matches only if the current position in the
5602 * subject is not a word boundary.) When applied to the string "Mississipi"
5603 * from the fourth byte, namely "issipi", it does not match, because "\B" is
5604 * always false at the start of the subject, which is deemed to be a word
5605 * boundary. However, if the entire string is passed , but with
5606 * @start_position set to 4, it finds the second occurrence of "iss" because
5607 * it is able to look behind the starting point to discover that it is
5608 * preceded by a letter.
5610 * Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
5611 * to these functions must be encoded in UTF-8. The lengths and the positions
5612 * inside the strings are in bytes and not in characters, so, for instance,
5613 * "\xc3\xa0" (i.e. "à") is two bytes long but it is treated as a
5614 * single character. If you set #G_REGEX_RAW the strings can be non-valid
5615 * UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
5616 * bytes and two characters long.
5618 * When matching a pattern, "\n" matches only against a "\n" character in
5619 * the string, and "\r" matches only a "\r" character. To match any newline
5620 * sequence use "\R". This particular group matches either the two-character
5621 * sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
5622 * U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
5623 * CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
5624 * separator, U+2028), or PS (paragraph separator, U+2029).
5626 * The behaviour of the dot, circumflex, and dollar metacharacters are
5627 * affected by newline characters, the default is to recognize any newline
5628 * character (the same characters recognized by "\R"). This can be changed
5629 * with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
5630 * compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
5631 * #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
5632 * #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
5633 * relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
5634 * unescaped "#" outside a character class is encountered. This indicates
5635 * a comment that lasts until after the next newline.
5637 * When setting the %G_REGEX_JAVASCRIPT_COMPAT flag, pattern syntax and pattern
5638 * matching is changed to be compatible with the way that regular expressions
5639 * work in JavaScript. More precisely, a lonely ']' character in the pattern
5640 * is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
5641 * you must use the '\u' escape sequence with 4 hex digits to specify a unicode
5642 * codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
5643 * the specified number of hex digits, they match 'x' and 'u' literally; also
5644 * '\U' always matches 'U' instead of being an error in the pattern. Finally,
5645 * pattern matching is modified so that back references to an unset subpattern
5646 * group produces a match with the empty string instead of an error. See
5647 * <ulink>man:pcreapi(3)</ulink> for more information.
5649 * Creating and manipulating the same #GRegex structure from different
5650 * threads is not a problem as #GRegex does not modify its internal
5651 * state between creation and destruction, on the other hand #GMatchInfo
5652 * is not threadsafe.
5654 * The regular expressions low-level functionalities are obtained through
5655 * the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
5656 * written by Philip Hazel.
5662 * @title: UNIX-specific utilities and integration
5663 * @short_description: pipes, signal handling
5664 * @include: glib-unix.h
5666 * Most of GLib is intended to be portable; in contrast, this set of
5667 * functions is designed for programs which explicitly target UNIX,
5668 * or are using it to build higher level abstractions which would be
5669 * conditionally compiled if the platform matches G_OS_UNIX.
5671 * To use these functions, you must explicitly include the
5672 * "glib-unix.h" header.
5678 * @title: URI Functions
5679 * @short_description: manipulating URIs
5681 * Functions for manipulating Universal Resource Identifiers (URIs) as
5682 * defined by <ulink url="http://www.ietf.org/rfc/rfc3986.txt">
5683 * RFC 3986</ulink>. It is highly recommended that you have read and
5684 * understand RFC 3986 for understanding this API.
5691 * @short_description: strongly typed value datatype
5692 * @see_also: GVariantType
5694 * #GVariant is a variant datatype; it stores a value along with
5695 * information about the type of that value. The range of possible
5696 * values is determined by the type. The type system used by #GVariant
5699 * #GVariant instances always have a type and a value (which are given
5700 * at construction time). The type and value of a #GVariant instance
5701 * can never change other than by the #GVariant itself being
5702 * destroyed. A #GVariant cannot contain a pointer.
5704 * #GVariant is reference counted using g_variant_ref() and
5705 * g_variant_unref(). #GVariant also has floating reference counts --
5706 * see g_variant_ref_sink().
5708 * #GVariant is completely threadsafe. A #GVariant instance can be
5709 * concurrently accessed in any way from any number of threads without
5712 * #GVariant is heavily optimised for dealing with data in serialised
5713 * form. It works particularly well with data located in memory-mapped
5714 * files. It can perform nearly all deserialisation operations in a
5715 * small constant time, usually touching only a single memory page.
5716 * Serialised #GVariant data can also be sent over the network.
5718 * #GVariant is largely compatible with D-Bus. Almost all types of
5719 * #GVariant instances can be sent over D-Bus. See #GVariantType for
5720 * exceptions. (However, #GVariant's serialisation format is not the same
5721 * as the serialisation format of a D-Bus message body: use #GDBusMessage,
5722 * in the gio library, for those.)
5724 * For space-efficiency, the #GVariant serialisation format does not
5725 * automatically include the variant's type or endianness, which must
5726 * either be implied from context (such as knowledge that a particular
5727 * file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
5728 * or supplied out-of-band (for instance, a type and/or endianness
5729 * indicator could be placed at the beginning of a file, network message
5730 * or network stream).
5732 * A #GVariant's size is limited mainly by any lower level operating
5733 * system constraints, such as the number of bits in #gsize. For
5734 * example, it is reasonable to have a 2GB file mapped into memory
5735 * with #GMappedFile, and call g_variant_new_from_data() on it.
5737 * For convenience to C programmers, #GVariant features powerful
5738 * varargs-based value construction and destruction. This feature is
5739 * designed to be embedded in other libraries.
5741 * There is a Python-inspired text language for describing #GVariant
5742 * values. #GVariant includes a printer for this language and a parser
5743 * with type inferencing.
5746 * <title>Memory Use</title>
5748 * #GVariant tries to be quite efficient with respect to memory use.
5749 * This section gives a rough idea of how much memory is used by the
5750 * current implementation. The information here is subject to change
5754 * The memory allocated by #GVariant can be grouped into 4 broad
5755 * purposes: memory for serialised data, memory for the type
5756 * information cache, buffer management memory and memory for the
5757 * #GVariant structure itself.
5759 * <refsect3 id="gvariant-serialised-data-memory">
5760 * <title>Serialised Data Memory</title>
5762 * This is the memory that is used for storing GVariant data in
5763 * serialised form. This is what would be sent over the network or
5764 * what would end up on disk.
5767 * The amount of memory required to store a boolean is 1 byte. 16,
5768 * 32 and 64 bit integers and double precision floating point numbers
5769 * use their "natural" size. Strings (including object path and
5770 * signature strings) are stored with a nul terminator, and as such
5771 * use the length of the string plus 1 byte.
5774 * Maybe types use no space at all to represent the null value and
5775 * use the same amount of space (sometimes plus one byte) as the
5776 * equivalent non-maybe-typed value to represent the non-null case.
5779 * Arrays use the amount of space required to store each of their
5780 * members, concatenated. Additionally, if the items stored in an
5781 * array are not of a fixed-size (ie: strings, other arrays, etc)
5782 * then an additional framing offset is stored for each item. The
5783 * size of this offset is either 1, 2 or 4 bytes depending on the
5784 * overall size of the container. Additionally, extra padding bytes
5785 * are added as required for alignment of child values.
5788 * Tuples (including dictionary entries) use the amount of space
5789 * required to store each of their members, concatenated, plus one
5790 * framing offset (as per arrays) for each non-fixed-sized item in
5791 * the tuple, except for the last one. Additionally, extra padding
5792 * bytes are added as required for alignment of child values.
5795 * Variants use the same amount of space as the item inside of the
5796 * variant, plus 1 byte, plus the length of the type string for the
5797 * item inside the variant.
5800 * As an example, consider a dictionary mapping strings to variants.
5801 * In the case that the dictionary is empty, 0 bytes are required for
5802 * the serialisation.
5805 * If we add an item "width" that maps to the int32 value of 500 then
5806 * we will use 4 byte to store the int32 (so 6 for the variant
5807 * containing it) and 6 bytes for the string. The variant must be
5808 * aligned to 8 after the 6 bytes of the string, so that's 2 extra
5809 * bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
5810 * for the dictionary entry. An additional 1 byte is added to the
5811 * array as a framing offset making a total of 15 bytes.
5814 * If we add another entry, "title" that maps to a nullable string
5815 * that happens to have a value of null, then we use 0 bytes for the
5816 * null value (and 3 bytes for the variant to contain it along with
5817 * its type string) plus 6 bytes for the string. Again, we need 2
5818 * padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
5821 * We now require extra padding between the two items in the array.
5822 * After the 14 bytes of the first item, that's 2 bytes required. We
5823 * now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
5824 * + 2 = 29 bytes to encode the entire two-item dictionary.
5828 * <title>Type Information Cache</title>
5830 * For each GVariant type that currently exists in the program a type
5831 * information structure is kept in the type information cache. The
5832 * type information structure is required for rapid deserialisation.
5835 * Continuing with the above example, if a #GVariant exists with the
5836 * type "a{sv}" then a type information struct will exist for
5837 * "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
5838 * will share the same type information. Additionally, all
5839 * single-digit types are stored in read-only static memory and do
5840 * not contribute to the writable memory footprint of a program using
5844 * Aside from the type information structures stored in read-only
5845 * memory, there are two forms of type information. One is used for
5846 * container types where there is a single element type: arrays and
5847 * maybe types. The other is used for container types where there
5848 * are multiple element types: tuples and dictionary entries.
5851 * Array type info structures are 6 * sizeof (void *), plus the
5852 * memory required to store the type string itself. This means that
5853 * on 32bit systems, the cache entry for "a{sv}" would require 30
5854 * bytes of memory (plus malloc overhead).
5857 * Tuple type info structures are 6 * sizeof (void *), plus 4 *
5858 * sizeof (void *) for each item in the tuple, plus the memory
5859 * required to store the type string itself. A 2-item tuple, for
5860 * example, would have a type information structure that consumed
5861 * writable memory in the size of 14 * sizeof (void *) (plus type
5862 * string) This means that on 32bit systems, the cache entry for
5863 * "{sv}" would require 61 bytes of memory (plus malloc overhead).
5866 * This means that in total, for our "a{sv}" example, 91 bytes of
5867 * type information would be allocated.
5870 * The type information cache, additionally, uses a #GHashTable to
5871 * store and lookup the cached items and stores a pointer to this
5872 * hash table in static storage. The hash table is freed when there
5873 * are zero items in the type cache.
5876 * Although these sizes may seem large it is important to remember
5877 * that a program will probably only have a very small number of
5878 * different types of values in it and that only one type information
5879 * structure is required for many different values of the same type.
5883 * <title>Buffer Management Memory</title>
5885 * #GVariant uses an internal buffer management structure to deal
5886 * with the various different possible sources of serialised data
5887 * that it uses. The buffer is responsible for ensuring that the
5888 * correct call is made when the data is no longer in use by
5889 * #GVariant. This may involve a g_free() or a g_slice_free() or
5890 * even g_mapped_file_unref().
5893 * One buffer management structure is used for each chunk of
5894 * serialised data. The size of the buffer management structure is 4
5895 * * (void *). On 32bit systems, that's 16 bytes.
5899 * <title>GVariant structure</title>
5901 * The size of a #GVariant structure is 6 * (void *). On 32 bit
5902 * systems, that's 24 bytes.
5905 * #GVariant structures only exist if they are explicitly created
5906 * with API calls. For example, if a #GVariant is constructed out of
5907 * serialised data for the example given above (with the dictionary)
5908 * then although there are 9 individual values that comprise the
5909 * entire dictionary (two keys, two values, two variants containing
5910 * the values, two dictionary entries, plus the dictionary itself),
5911 * only 1 #GVariant instance exists -- the one referring to the
5915 * If calls are made to start accessing the other values then
5916 * #GVariant instances will exist for those values only for as long
5917 * as they are in use (ie: until you call g_variant_unref()). The
5918 * type information is shared. The serialised data and the buffer
5919 * management structure for that serialised data is shared by the
5924 * <title>Summary</title>
5926 * To put the entire example together, for our dictionary mapping
5927 * strings to variants (with two entries, as given above), we are
5928 * using 91 bytes of memory for type information, 29 byes of memory
5929 * for the serialised data, 16 bytes for buffer management and 24
5930 * bytes for the #GVariant instance, or a total of 160 bytes, plus
5931 * malloc overhead. If we were to use g_variant_get_child_value() to
5932 * access the two dictionary entries, we would use an additional 48
5933 * bytes. If we were to have other dictionaries of the same type, we
5934 * would use more memory for the serialised data and buffer
5935 * management for those dictionaries, but the type information would
5944 * SECTION:gvarianttype
5945 * @title: GVariantType
5946 * @short_description: introduction to the GVariant type system
5947 * @see_also: #GVariantType, #GVariant
5949 * This section introduces the GVariant type system. It is based, in
5950 * large part, on the D-Bus type system, with two major changes and some minor
5951 * lifting of restrictions. The <ulink
5952 * url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
5953 * specification</ulink>, therefore, provides a significant amount of
5954 * information that is useful when working with GVariant.
5956 * The first major change with respect to the D-Bus type system is the
5957 * introduction of maybe (or "nullable") types. Any type in GVariant can be
5958 * converted to a maybe type, in which case, "nothing" (or "null") becomes a
5959 * valid value. Maybe types have been added by introducing the
5960 * character "<literal>m</literal>" to type strings.
5962 * The second major change is that the GVariant type system supports the
5963 * concept of "indefinite types" -- types that are less specific than
5964 * the normal types found in D-Bus. For example, it is possible to speak
5965 * of "an array of any type" in GVariant, where the D-Bus type system
5966 * would require you to speak of "an array of integers" or "an array of
5967 * strings". Indefinite types have been added by introducing the
5968 * characters "<literal>*</literal>", "<literal>?</literal>" and
5969 * "<literal>r</literal>" to type strings.
5971 * Finally, all arbitrary restrictions relating to the complexity of
5972 * types are lifted along with the restriction that dictionary entries
5973 * may only appear nested inside of arrays.
5975 * Just as in D-Bus, GVariant types are described with strings ("type
5976 * strings"). Subject to the differences mentioned above, these strings
5977 * are of the same form as those found in DBus. Note, however: D-Bus
5978 * always works in terms of messages and therefore individual type
5979 * strings appear nowhere in its interface. Instead, "signatures"
5980 * are a concatenation of the strings of the type of each argument in a
5981 * message. GVariant deals with single values directly so GVariant type
5982 * strings always describe the type of exactly one value. This means
5983 * that a D-Bus signature string is generally not a valid GVariant type
5984 * string -- except in the case that it is the signature of a message
5985 * containing exactly one argument.
5987 * An indefinite type is similar in spirit to what may be called an
5988 * abstract type in other type systems. No value can exist that has an
5989 * indefinite type as its type, but values can exist that have types
5990 * that are subtypes of indefinite types. That is to say,
5991 * g_variant_get_type() will never return an indefinite type, but
5992 * calling g_variant_is_of_type() with an indefinite type may return
5993 * %TRUE. For example, you cannot have a value that represents "an
5994 * array of no particular type", but you can have an "array of integers"
5995 * which certainly matches the type of "an array of no particular type",
5996 * since "array of integers" is a subtype of "array of no particular
5999 * This is similar to how instances of abstract classes may not
6000 * directly exist in other type systems, but instances of their
6001 * non-abstract subtypes may. For example, in GTK, no object that has
6002 * the type of #GtkBin can exist (since #GtkBin is an abstract class),
6003 * but a #GtkWindow can certainly be instantiated, and you would say
6004 * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
6007 * A detailed description of GVariant type strings is given here:
6009 * <refsect2 id='gvariant-typestrings'>
6010 * <title>GVariant Type Strings</title>
6012 * A GVariant type string can be any of the following:
6017 * any basic type string (listed below)
6022 * "<literal>v</literal>", "<literal>r</literal>" or
6023 * "<literal>*</literal>"
6028 * one of the characters '<literal>a</literal>' or
6029 * '<literal>m</literal>', followed by another type string
6034 * the character '<literal>(</literal>', followed by a concatenation
6035 * of zero or more other type strings, followed by the character
6036 * '<literal>)</literal>'
6041 * the character '<literal>{</literal>', followed by a basic type
6042 * string (see below), followed by another type string, followed by
6043 * the character '<literal>}</literal>'
6048 * A basic type string describes a basic type (as per
6049 * g_variant_type_is_basic()) and is always a single
6050 * character in length. The valid basic type strings are
6051 * "<literal>b</literal>", "<literal>y</literal>",
6052 * "<literal>n</literal>", "<literal>q</literal>",
6053 * "<literal>i</literal>", "<literal>u</literal>",
6054 * "<literal>x</literal>", "<literal>t</literal>",
6055 * "<literal>h</literal>", "<literal>d</literal>",
6056 * "<literal>s</literal>", "<literal>o</literal>",
6057 * "<literal>g</literal>" and "<literal>?</literal>".
6060 * The above definition is recursive to arbitrary depth.
6061 * "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
6062 * are both valid type strings, as is
6063 * "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
6066 * The meaning of each of the characters is as follows:
6074 * <emphasis role='strong'>Character</emphasis>
6079 * <emphasis role='strong'>Meaning</emphasis>
6086 * <literal>b</literal>
6091 * the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
6098 * <literal>y</literal>
6103 * the type string of %G_VARIANT_TYPE_BYTE; a byte.
6110 * <literal>n</literal>
6115 * the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
6123 * <literal>q</literal>
6128 * the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
6136 * <literal>i</literal>
6141 * the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
6149 * <literal>u</literal>
6154 * the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
6162 * <literal>x</literal>
6167 * the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
6175 * <literal>t</literal>
6180 * the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
6188 * <literal>h</literal>
6193 * the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
6194 * value that, by convention, is used as an index into an array
6195 * of file descriptors that are sent alongside a D-Bus message.
6202 * <literal>d</literal>
6207 * the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
6208 * floating point value.
6215 * <literal>s</literal>
6220 * the type string of %G_VARIANT_TYPE_STRING; a string.
6227 * <literal>o</literal>
6232 * the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
6233 * the form of a D-Bus object path.
6240 * <literal>g</literal>
6245 * the type string of %G_VARIANT_TYPE_STRING; a string in the
6246 * form of a D-Bus type signature.
6253 * <literal>?</literal>
6258 * the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
6259 * that is a supertype of any of the basic types.
6266 * <literal>v</literal>
6271 * the type string of %G_VARIANT_TYPE_VARIANT; a container type
6272 * that contain any other type of value.
6279 * <literal>a</literal>
6284 * used as a prefix on another type string to mean an array of
6285 * that type; the type string "<literal>ai</literal>", for
6286 * example, is the type of an array of 32 bit signed integers.
6293 * <literal>m</literal>
6298 * used as a prefix on another type string to mean a "maybe", or
6299 * "nullable", version of that type; the type string
6300 * "<literal>ms</literal>", for example, is the type of a value
6301 * that maybe contains a string, or maybe contains nothing.
6308 * <literal>()</literal>
6313 * used to enclose zero or more other concatenated type strings
6314 * to create a tuple type; the type string
6315 * "<literal>(is)</literal>", for example, is the type of a pair
6316 * of an integer and a string.
6323 * <literal>r</literal>
6328 * the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
6329 * that is a supertype of any tuple type, regardless of the
6337 * <literal>{}</literal>
6342 * used to enclose a basic type string concatenated with another
6343 * type string to create a dictionary entry type, which usually
6344 * appears inside of an array to form a dictionary; the type
6345 * string "<literal>a{sd}</literal>", for example, is the type of
6346 * a dictionary that maps strings to double precision floating
6350 * The first type (the basic type) is the key type and the second
6351 * type is the value type. The reason that the first type is
6352 * restricted to being a basic type is so that it can easily be
6360 * <literal>*</literal>
6365 * the type string of %G_VARIANT_TYPE_ANY; the indefinite type
6366 * that is a supertype of all types. Note that, as with all type
6367 * strings, this character represents exactly one type. It
6368 * cannot be used inside of tuples to mean "any number of items".
6376 * Any type string of a container that contains an indefinite type is,
6377 * itself, an indefinite type. For example, the type string
6378 * "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
6379 * an indefinite type that is a supertype of every array type.
6380 * "<literal>(*s)</literal>" is a supertype of all tuples that
6381 * contain exactly two items where the second item is a string.
6384 * "<literal>a{?*}</literal>" is an indefinite type that is a
6385 * supertype of all arrays containing dictionary entries where the key
6386 * is any basic type and the value is any type at all. This is, by
6387 * definition, a dictionary, so this type string corresponds to
6388 * %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
6389 * the key of a dictionary entry must be a basic type,
6390 * "<literal>{**}</literal>" is not a valid type string.
6397 * SECTION:hash_tables
6398 * @title: Hash Tables
6399 * @short_description: associations between keys and values so that given a key the value can be found quickly
6401 * A #GHashTable provides associations between keys and values which is
6402 * optimized so that given a key, the associated value can be found
6405 * Note that neither keys nor values are copied when inserted into the
6406 * #GHashTable, so they must exist for the lifetime of the #GHashTable.
6407 * This means that the use of static strings is OK, but temporary
6408 * strings (i.e. those created in buffers and those returned by GTK+
6409 * widgets) should be copied with g_strdup() before being inserted.
6411 * If keys or values are dynamically allocated, you must be careful to
6412 * ensure that they are freed when they are removed from the
6413 * #GHashTable, and also when they are overwritten by new insertions
6414 * into the #GHashTable. It is also not advisable to mix static strings
6415 * and dynamically-allocated strings in a #GHashTable, because it then
6416 * becomes difficult to determine whether the string should be freed.
6418 * To create a #GHashTable, use g_hash_table_new().
6420 * To insert a key and value into a #GHashTable, use
6421 * g_hash_table_insert().
6423 * To lookup a value corresponding to a given key, use
6424 * g_hash_table_lookup() and g_hash_table_lookup_extended().
6426 * g_hash_table_lookup_extended() can also be used to simply
6427 * check if a key is present in the hash table.
6429 * To remove a key and value, use g_hash_table_remove().
6431 * To call a function for each key and value pair use
6432 * g_hash_table_foreach() or use a iterator to iterate over the
6433 * key/value pairs in the hash table, see #GHashTableIter.
6435 * To destroy a #GHashTable use g_hash_table_destroy().
6437 * A common use-case for hash tables is to store information about a
6438 * set of keys, without associating any particular value with each
6439 * key. GHashTable optimizes one way of doing so: If you store only
6440 * key-value pairs where key == value, then GHashTable does not
6441 * allocate memory to store the values, which can be a considerable
6442 * space saving, if your set is large. The functions
6443 * g_hash_table_add() and g_hash_table_contains() are designed to be
6444 * used when using #GHashTable this way.
6450 * @title: Secure HMAC Digests
6451 * @short_description: computes the HMAC for data
6453 * HMACs should be used when producing a cookie or hash based on data
6454 * and a key. Simple mechanisms for using SHA1 and other algorithms to
6455 * digest a key and data together are vulnerable to various security
6456 * issues. <ulink url="http://en.wikipedia.org/wiki/HMAC">HMAC</ulink>
6457 * uses algorithms like SHA1 in a secure way to produce a digest of a
6460 * Both the key and data are arbitrary byte arrays of bytes or characters.
6462 * Support for HMAC Digests has been added in GLib 2.30.
6468 * @title: Hook Functions
6469 * @short_description: support for manipulating lists of hook functions
6471 * The #GHookList, #GHook and their related functions provide support for
6472 * lists of hook functions. Functions can be added and removed from the lists,
6473 * and the list of hook functions can be invoked.
6479 * @title: Internationalization
6480 * @short_description: gettext support macros
6481 * @see_also: the gettext manual
6483 * GLib doesn't force any particular localization method upon its users.
6484 * But since GLib itself is localized using the gettext() mechanism, it seems
6485 * natural to offer the de-facto standard gettext() support macros in an
6488 * In order to use these macros in an application, you must include
6489 * <filename>glib/gi18n.h</filename>. For use in a library, must include
6490 * <filename>glib/gi18n-lib.h</filename> <emphasis>after</emphasis> defining
6491 * the GETTEXT_PACKAGE macro suitably for your library:
6493 * #define GETTEXT_PACKAGE "gtk20"
6494 * #include <glib/gi18n-lib.h>
6496 * Note that you also have to call setlocale() and textdomain() (as well as
6497 * bindtextdomain() and bind_textdomain_codeset()) early on in your main()
6498 * to make gettext() work.
6500 * The gettext manual covers details of how to set up message extraction
6506 * SECTION:iochannels
6507 * @title: IO Channels
6508 * @short_description: portable support for using files, pipes and sockets
6509 * @see_also: <para> <variablelist> <varlistentry> <term>g_io_add_watch(), g_io_add_watch_full(), g_source_remove()</term> <listitem><para> Convenience functions for creating #GIOChannel instances and adding them to the <link linkend="glib-The-Main-Event-Loop">main event loop</link>. </para></listitem> </varlistentry> </variablelist> </para>
6511 * The #GIOChannel data type aims to provide a portable method for
6512 * using file descriptors, pipes, and sockets, and integrating them
6513 * into the <link linkend="glib-The-Main-Event-Loop">main event
6514 * loop</link>. Currently full support is available on UNIX platforms,
6515 * support for Windows is only partially complete.
6517 * To create a new #GIOChannel on UNIX systems use
6518 * g_io_channel_unix_new(). This works for plain file descriptors,
6519 * pipes and sockets. Alternatively, a channel can be created for a
6520 * file in a system independent manner using g_io_channel_new_file().
6522 * Once a #GIOChannel has been created, it can be used in a generic
6523 * manner with the functions g_io_channel_read_chars(),
6524 * g_io_channel_write_chars(), g_io_channel_seek_position(), and
6525 * g_io_channel_shutdown().
6527 * To add a #GIOChannel to the <link
6528 * linkend="glib-The-Main-Event-Loop">main event loop</link> use
6529 * g_io_add_watch() or g_io_add_watch_full(). Here you specify which
6530 * events you are interested in on the #GIOChannel, and provide a
6531 * function to be called whenever these events occur.
6533 * #GIOChannel instances are created with an initial reference count of
6534 * 1. g_io_channel_ref() and g_io_channel_unref() can be used to
6535 * increment or decrement the reference count respectively. When the
6536 * reference count falls to 0, the #GIOChannel is freed. (Though it
6537 * isn't closed automatically, unless it was created using
6538 * g_io_channel_new_file().) Using g_io_add_watch() or
6539 * g_io_add_watch_full() increments a channel's reference count.
6541 * The new functions g_io_channel_read_chars(),
6542 * g_io_channel_read_line(), g_io_channel_read_line_string(),
6543 * g_io_channel_read_to_end(), g_io_channel_write_chars(),
6544 * g_io_channel_seek_position(), and g_io_channel_flush() should not be
6545 * mixed with the deprecated functions g_io_channel_read(),
6546 * g_io_channel_write(), and g_io_channel_seek() on the same channel.
6552 * @title: Key-value file parser
6553 * @short_description: parses .ini-like config files
6555 * #GKeyFile lets you parse, edit or create files containing groups of
6556 * key-value pairs, which we call <firstterm>key files</firstterm> for
6557 * lack of a better name. Several freedesktop.org specifications use
6558 * key files now, e.g the
6559 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6560 * Entry Specification</ulink> and the
6561 * <ulink url="http://freedesktop.org/Standards/icon-theme-spec">Icon
6562 * Theme Specification</ulink>.
6564 * The syntax of key files is described in detail in the
6565 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6566 * Entry Specification</ulink>, here is a quick summary: Key files
6567 * consists of groups of key-value pairs, interspersed with comments.
6570 * # this is just an example
6571 * # there can be comments before the first group
6575 * Name=Key File Example\tthis value shows\nescaping
6577 * # localized strings are stored in multiple key-value pairs
6580 * Welcome[fr_FR]=Bonjour
6582 * Welcome[be@latin]=Hello
6586 * Numbers=2;20;-200;0
6588 * Booleans=true;false;true;true
6591 * Lines beginning with a '#' and blank lines are considered comments.
6593 * Groups are started by a header line containing the group name enclosed
6594 * in '[' and ']', and ended implicitly by the start of the next group or
6595 * the end of the file. Each key-value pair must be contained in a group.
6597 * Key-value pairs generally have the form <literal>key=value</literal>,
6598 * with the exception of localized strings, which have the form
6599 * <literal>key[locale]=value</literal>, with a locale identifier of the
6600 * form <literal>lang_COUNTRY@MODIFIER</literal> where
6601 * <literal>COUNTRY</literal> and <literal>MODIFIER</literal> are optional.
6602 * Space before and after the '=' character are ignored. Newline, tab,
6603 * carriage return and backslash characters in value are escaped as \n,
6604 * \t, \r, and \\, respectively. To preserve leading spaces in values,
6605 * these can also be escaped as \s.
6607 * Key files can store strings (possibly with localized variants), integers,
6608 * booleans and lists of these. Lists are separated by a separator character,
6609 * typically ';' or ','. To use the list separator character in a value in
6610 * a list, it has to be escaped by prefixing it with a backslash.
6612 * This syntax is obviously inspired by the .ini files commonly met
6613 * on Windows, but there are some important differences:
6615 * <listitem>.ini files use the ';' character to begin comments,
6616 * key files use the '#' character.</listitem>
6617 * <listitem>Key files do not allow for ungrouped keys meaning only
6618 * comments can precede the first group.</listitem>
6619 * <listitem>Key files are always encoded in UTF-8.</listitem>
6620 * <listitem>Key and Group names are case-sensitive. For example, a
6621 * group called <literal>[GROUP]</literal> is a different from
6622 * <literal>[group]</literal>.</listitem>
6623 * <listitem>.ini files don't have a strongly typed boolean entry type,
6624 * they only have GetProfileInt(). In key files, only
6625 * <literal>true</literal> and <literal>false</literal> (in lower case)
6626 * are allowed.</listitem>
6629 * Note that in contrast to the
6630 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6631 * Entry Specification</ulink>, groups in key files may contain the same
6632 * key multiple times; the last entry wins. Key files may also contain
6633 * multiple groups with the same name; they are merged together.
6634 * Another difference is that keys and group names in key files are not
6635 * restricted to ASCII characters.
6640 * SECTION:linked_lists_double
6641 * @title: Doubly-Linked Lists
6642 * @short_description: linked lists that can be iterated over in both directions
6644 * The #GList structure and its associated functions provide a standard
6645 * doubly-linked list data structure.
6647 * Each element in the list contains a piece of data, together with
6648 * pointers which link to the previous and next elements in the list.
6649 * Using these pointers it is possible to move through the list in both
6650 * directions (unlike the <link
6651 * linkend="glib-Singly-Linked-Lists">Singly-Linked Lists</link> which
6652 * only allows movement through the list in the forward direction).
6654 * The data contained in each element can be either integer values, by
6655 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6656 * Conversion Macros</link>, or simply pointers to any type of data.
6658 * List elements are allocated from the <link
6659 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6660 * efficient than allocating elements individually.
6662 * Note that most of the #GList functions expect to be passed a pointer
6663 * to the first element in the list. The functions which insert
6664 * elements return the new start of the list, which may have changed.
6666 * There is no function to create a #GList. %NULL is considered to be
6667 * the empty list so you simply set a #GList* to %NULL.
6669 * To add elements, use g_list_append(), g_list_prepend(),
6670 * g_list_insert() and g_list_insert_sorted().
6672 * To remove elements, use g_list_remove().
6674 * To find elements in the list use g_list_first(), g_list_last(),
6675 * g_list_next(), g_list_previous(), g_list_nth(), g_list_nth_data(),
6676 * g_list_find() and g_list_find_custom().
6678 * To find the index of an element use g_list_position() and
6681 * To call a function for each element in the list use g_list_foreach().
6683 * To free the entire list, use g_list_free().
6688 * SECTION:linked_lists_single
6689 * @title: Singly-Linked Lists
6690 * @short_description: linked lists that can be iterated in one direction
6692 * The #GSList structure and its associated functions provide a
6693 * standard singly-linked list data structure.
6695 * Each element in the list contains a piece of data, together with a
6696 * pointer which links to the next element in the list. Using this
6697 * pointer it is possible to move through the list in one direction
6698 * only (unlike the <link
6699 * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
6700 * allow movement in both directions).
6702 * The data contained in each element can be either integer values, by
6703 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6704 * Conversion Macros</link>, or simply pointers to any type of data.
6706 * List elements are allocated from the <link
6707 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6708 * efficient than allocating elements individually.
6710 * Note that most of the #GSList functions expect to be passed a
6711 * pointer to the first element in the list. The functions which insert
6712 * elements return the new start of the list, which may have changed.
6714 * There is no function to create a #GSList. %NULL is considered to be
6715 * the empty list so you simply set a #GSList* to %NULL.
6717 * To add elements, use g_slist_append(), g_slist_prepend(),
6718 * g_slist_insert() and g_slist_insert_sorted().
6720 * To remove elements, use g_slist_remove().
6722 * To find elements in the list use g_slist_last(), g_slist_next(),
6723 * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
6724 * g_slist_find_custom().
6726 * To find the index of an element use g_slist_position() and
6729 * To call a function for each element in the list use
6730 * g_slist_foreach().
6732 * To free the entire list, use g_slist_free().
6738 * @title: Standard Macros
6739 * @short_description: commonly-used macros
6741 * These macros provide a few commonly-used features.
6746 * SECTION:macros_misc
6747 * @title: Miscellaneous Macros
6748 * @short_description: specialized macros which are not used often
6750 * These macros provide more specialized features which are not
6751 * needed so often by application programmers.
6757 * @title: The Main Event Loop
6758 * @short_description: manages all available sources of events
6760 * The main event loop manages all the available sources of events for
6761 * GLib and GTK+ applications. These events can come from any number of
6762 * different types of sources such as file descriptors (plain files,
6763 * pipes or sockets) and timeouts. New types of event sources can also
6764 * be added using g_source_attach().
6766 * To allow multiple independent sets of sources to be handled in
6767 * different threads, each source is associated with a #GMainContext.
6768 * A GMainContext can only be running in a single thread, but
6769 * sources can be added to it and removed from it from other threads.
6771 * Each event source is assigned a priority. The default priority,
6772 * #G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
6773 * Values greater than 0 denote lower priorities. Events from high priority
6774 * sources are always processed before events from lower priority sources.
6776 * Idle functions can also be added, and assigned a priority. These will
6777 * be run whenever no events with a higher priority are ready to be processed.
6779 * The #GMainLoop data type represents a main event loop. A GMainLoop is
6780 * created with g_main_loop_new(). After adding the initial event sources,
6781 * g_main_loop_run() is called. This continuously checks for new events from
6782 * each of the event sources and dispatches them. Finally, the processing of
6783 * an event from one of the sources leads to a call to g_main_loop_quit() to
6784 * exit the main loop, and g_main_loop_run() returns.
6786 * It is possible to create new instances of #GMainLoop recursively.
6787 * This is often used in GTK+ applications when showing modal dialog
6788 * boxes. Note that event sources are associated with a particular
6789 * #GMainContext, and will be checked and dispatched for all main
6790 * loops associated with that GMainContext.
6792 * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
6793 * gtk_main_quit() and gtk_events_pending().
6795 * <refsect2><title>Creating new source types</title>
6796 * <para>One of the unusual features of the #GMainLoop functionality
6797 * is that new types of event source can be created and used in
6798 * addition to the builtin type of event source. A new event source
6799 * type is used for handling GDK events. A new source type is created
6800 * by <firstterm>deriving</firstterm> from the #GSource structure.
6801 * The derived type of source is represented by a structure that has
6802 * the #GSource structure as a first element, and other elements specific
6803 * to the new source type. To create an instance of the new source type,
6804 * call g_source_new() passing in the size of the derived structure and
6805 * a table of functions. These #GSourceFuncs determine the behavior of
6806 * the new source type.</para>
6807 * <para>New source types basically interact with the main context
6808 * in two ways. Their prepare function in #GSourceFuncs can set a timeout
6809 * to determine the maximum amount of time that the main loop will sleep
6810 * before checking the source again. In addition, or as well, the source
6811 * can add file descriptors to the set that the main context checks using
6812 * g_source_add_poll().</para>
6814 * <refsect2><title>Customizing the main loop iteration</title>
6815 * <para>Single iterations of a #GMainContext can be run with
6816 * g_main_context_iteration(). In some cases, more detailed control
6817 * of exactly how the details of the main loop work is desired, for
6818 * instance, when integrating the #GMainLoop with an external main loop.
6819 * In such cases, you can call the component functions of
6820 * g_main_context_iteration() directly. These functions are
6821 * g_main_context_prepare(), g_main_context_query(),
6822 * g_main_context_check() and g_main_context_dispatch().</para>
6823 * <para>The operation of these functions can best be seen in terms
6824 * of a state diagram, as shown in <xref linkend="mainloop-states"/>.</para>
6825 * <figure id="mainloop-states"><title>States of a Main Context</title>
6826 * <graphic fileref="mainloop-states.gif" format="GIF"></graphic>
6830 * On Unix, the GLib mainloop is incompatible with fork(). Any program
6831 * using the mainloop must either exec() or exit() from the child
6832 * without returning to the mainloop.
6838 * @Title: Simple XML Subset Parser
6839 * @Short_description: parses a subset of XML
6840 * @See_also: <ulink url="http://www.w3.org/TR/REC-xml/">XML Specification</ulink>
6842 * The "GMarkup" parser is intended to parse a simple markup format
6843 * that's a subset of XML. This is a small, efficient, easy-to-use
6844 * parser. It should not be used if you expect to interoperate with
6845 * other applications generating full-scale XML. However, it's very
6846 * useful for application data files, config files, etc. where you
6847 * know your application will be the only one writing the file.
6848 * Full-scale XML parsers should be able to parse the subset used by
6849 * GMarkup, so you can easily migrate to full-scale XML at a later
6850 * time if the need arises.
6852 * GMarkup is not guaranteed to signal an error on all invalid XML;
6853 * the parser may accept documents that an XML parser would not.
6854 * However, XML documents which are not well-formed<footnote
6855 * id="wellformed">Being wellformed is a weaker condition than being
6856 * valid. See the <ulink url="http://www.w3.org/TR/REC-xml/">XML
6857 * specification</ulink> for definitions of these terms.</footnote>
6858 * are not considered valid GMarkup documents.
6860 * Simplifications to XML include:
6862 * <listitem>Only UTF-8 encoding is allowed</listitem>
6863 * <listitem>No user-defined entities</listitem>
6864 * <listitem>Processing instructions, comments and the doctype declaration
6865 * are "passed through" but are not interpreted in any way</listitem>
6866 * <listitem>No DTD or validation.</listitem>
6869 * The markup format does support:
6871 * <listitem>Elements</listitem>
6872 * <listitem>Attributes</listitem>
6873 * <listitem>5 standard entities:
6874 * <literal>&amp; &lt; &gt; &quot; &apos;</literal>
6876 * <listitem>Character references</listitem>
6877 * <listitem>Sections marked as CDATA</listitem>
6884 * @Short_Description: general memory-handling
6885 * @Title: Memory Allocation
6887 * These functions provide support for allocating and freeing memory.
6890 * If any call to allocate memory fails, the application is terminated.
6891 * This also means that there is no need to check if the call succeeded.
6895 * It's important to match g_malloc() with g_free(), plain malloc() with free(),
6896 * and (if you're using C++) new with delete and new[] with delete[]. Otherwise
6897 * bad things can happen, since these allocators may use different memory
6898 * pools (and new/delete call constructors and destructors). See also
6899 * g_mem_set_vtable().
6905 * SECTION:memory_slices
6906 * @title: Memory Slices
6907 * @short_description: efficient way to allocate groups of equal-sized chunks of memory
6909 * Memory slices provide a space-efficient and multi-processing scalable
6910 * way to allocate equal-sized pieces of memory, just like the original
6911 * #GMemChunks (from GLib 2.8), while avoiding their excessive
6912 * memory-waste, scalability and performance problems.
6914 * To achieve these goals, the slice allocator uses a sophisticated,
6915 * layered design that has been inspired by Bonwick's slab allocator
6917 * <ulink url="http://citeseer.ist.psu.edu/bonwick94slab.html">[Bonwick94]</ulink> Jeff Bonwick, The slab allocator: An object-caching kernel
6918 * memory allocator. USENIX 1994, and
6919 * <ulink url="http://citeseer.ist.psu.edu/bonwick01magazines.html">[Bonwick01]</ulink> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
6920 * slab allocator to many cpu's and arbitrary resources. USENIX 2001
6921 * </para></footnote>.
6922 * It uses posix_memalign() to optimize allocations of many equally-sized
6923 * chunks, and has per-thread free lists (the so-called magazine layer)
6924 * to quickly satisfy allocation requests of already known structure sizes.
6925 * This is accompanied by extra caching logic to keep freed memory around
6926 * for some time before returning it to the system. Memory that is unused
6927 * due to alignment constraints is used for cache colorization (random
6928 * distribution of chunk addresses) to improve CPU cache utilization. The
6929 * caching layer of the slice allocator adapts itself to high lock contention
6930 * to improve scalability.
6932 * The slice allocator can allocate blocks as small as two pointers, and
6933 * unlike malloc(), it does not reserve extra space per block. For large block
6934 * sizes, g_slice_new() and g_slice_alloc() will automatically delegate to the
6935 * system malloc() implementation. For newly written code it is recommended
6936 * to use the new <literal>g_slice</literal> API instead of g_malloc() and
6937 * friends, as long as objects are not resized during their lifetime and the
6938 * object size used at allocation time is still available when freeing.
6941 * <title>Using the slice allocator</title>
6943 * gchar *mem[10000];
6946 * /* Allocate 10000 blocks. */
6947 * for (i = 0; i < 10000; i++)
6949 * mem[i] = g_slice_alloc (50);
6951 * /* Fill in the memory with some junk. */
6952 * for (j = 0; j < 50; j++)
6953 * mem[i][j] = i * j;
6956 * /* Now free all of the blocks. */
6957 * for (i = 0; i < 10000; i++)
6959 * g_slice_free1 (50, mem[i]);
6961 * </programlisting></example>
6964 * <title>Using the slice allocator with data structures</title>
6966 * GRealArray *array;
6968 * /* Allocate one block, using the g_slice_new() macro. */
6969 * array = g_slice_new (GRealArray);
6971 * /* We can now use array just like a normal pointer to a structure. */
6972 * array->data = NULL;
6975 * array->zero_terminated = (zero_terminated ? 1 : 0);
6976 * array->clear = (clear ? 1 : 0);
6977 * array->elt_size = elt_size;
6979 * /* We can free the block, so it can be reused. */
6980 * g_slice_free (GRealArray, array);
6981 * </programlisting></example>
6987 * @title: Message Logging
6988 * @short_description: versatile support for logging messages with different levels of importance
6990 * These functions provide support for logging error messages
6991 * or messages used for debugging.
6993 * There are several built-in levels of messages, defined in
6994 * #GLogLevelFlags. These can be extended with user-defined levels.
6999 * SECTION:misc_utils
7000 * @title: Miscellaneous Utility Functions
7001 * @short_description: a selection of portable utility functions
7003 * These are portable utility functions.
7009 * @title: Numerical Definitions
7010 * @short_description: mathematical constants, and floating point decomposition
7012 * GLib offers mathematical constants such as #G_PI for the value of pi;
7013 * many platforms have these in the C library, but some don't, the GLib
7014 * versions always exist.
7016 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
7017 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
7018 * defined as appropriate for a given platform. IEEE floats and doubles are
7019 * supported (used for storage) by at least Intel, PPC and Sparc. See
7020 * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
7021 * for more information about IEEE number formats.
7027 * @Short_description: parses commandline options
7028 * @Title: Commandline option parser
7030 * The GOption commandline parser is intended to be a simpler replacement
7031 * for the popt library. It supports short and long commandline options,
7032 * as shown in the following example:
7034 * <literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
7036 * The example demonstrates a number of features of the GOption
7037 * commandline parser
7038 * <itemizedlist><listitem><para>
7039 * Options can be single letters, prefixed by a single dash. Multiple
7040 * short options can be grouped behind a single dash.
7041 * </para></listitem><listitem><para>
7042 * Long options are prefixed by two consecutive dashes.
7043 * </para></listitem><listitem><para>
7044 * Options can have an extra argument, which can be a number, a string or
7045 * a filename. For long options, the extra argument can be appended with
7046 * an equals sign after the option name, which is useful if the extra
7047 * argument starts with a dash, which would otherwise cause it to be
7048 * interpreted as another option.
7049 * </para></listitem><listitem><para>
7050 * Non-option arguments are returned to the application as rest arguments.
7051 * </para></listitem><listitem><para>
7052 * An argument consisting solely of two dashes turns off further parsing,
7053 * any remaining arguments (even those starting with a dash) are returned
7054 * to the application as rest arguments.
7055 * </para></listitem></itemizedlist>
7057 * Another important feature of GOption is that it can automatically
7058 * generate nicely formatted help output. Unless it is explicitly turned
7059 * off with g_option_context_set_help_enabled(), GOption will recognize
7060 * the <option>--help</option>, <option>-?</option>,
7061 * <option>--help-all</option> and
7062 * <option>--help-</option><replaceable>groupname</replaceable> options
7063 * (where <replaceable>groupname</replaceable> is the name of a
7064 * #GOptionGroup) and write a text similar to the one shown in the
7065 * following example to stdout.
7067 * <informalexample><screen>
7069 * testtreemodel [OPTION...] - test tree model performance
7072 * -h, --help Show help options
7073 * --help-all Show all help options
7074 * --help-gtk Show GTK+ Options
7076 * Application Options:
7077 * -r, --repeats=N Average over N repetitions
7078 * -m, --max-size=M Test up to 2^M items
7079 * --display=DISPLAY X display to use
7080 * -v, --verbose Be verbose
7081 * -b, --beep Beep when done
7082 * --rand Randomize the data
7083 * </screen></informalexample>
7085 * GOption groups options in #GOptionGroup<!-- -->s, which makes it easy to
7086 * incorporate options from multiple sources. The intended use for this is
7087 * to let applications collect option groups from the libraries it uses,
7088 * add them to their #GOptionContext, and parse all options by a single call
7089 * to g_option_context_parse(). See gtk_get_option_group() for an example.
7091 * If an option is declared to be of type string or filename, GOption takes
7092 * care of converting it to the right encoding; strings are returned in
7093 * UTF-8, filenames are returned in the GLib filename encoding. Note that
7094 * this only works if setlocale() has been called before
7095 * g_option_context_parse().
7097 * Here is a complete example of setting up GOption to parse the example
7098 * commandline above and produce the example help output.
7100 * <informalexample><programlisting>
7101 * static gint repeats = 2;
7102 * static gint max_size = 8;
7103 * static gboolean verbose = FALSE;
7104 * static gboolean beep = FALSE;
7105 * static gboolean rand = FALSE;
7107 * static GOptionEntry entries[] =
7109 * { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" },
7110 * { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" },
7111 * { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
7112 * { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
7113 * { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL },
7118 * main (int argc, char *argv[])
7120 * GError *error = NULL;
7121 * GOptionContext *context;
7123 * context = g_option_context_new ("- test tree model performance");
7124 * g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
7125 * g_option_context_add_group (context, gtk_get_option_group (TRUE));
7126 * if (!g_option_context_parse (context, &argc, &argv, &error))
7128 * g_print ("option parsing failed: %s\n", error->message);
7135 * </programlisting></informalexample>
7141 * @title: Glob-style pattern matching
7142 * @short_description: matches strings against patterns containing '*' (wildcard) and '?' (joker)
7144 * The <function>g_pattern_match*</function> functions match a string
7145 * against a pattern containing '*' and '?' wildcards with similar
7146 * semantics as the standard glob() function: '*' matches an arbitrary,
7147 * possibly empty, string, '?' matches an arbitrary character.
7149 * Note that in contrast to glob(), the '/' character
7150 * <emphasis>can</emphasis> be matched by the wildcards, there are no
7151 * '[...]' character ranges and '*' and '?' can
7152 * <emphasis>not</emphasis> be escaped to include them literally in a
7155 * When multiple strings must be matched against the same pattern, it
7156 * is better to compile the pattern to a #GPatternSpec using
7157 * g_pattern_spec_new() and use g_pattern_match_string() instead of
7158 * g_pattern_match_simple(). This avoids the overhead of repeated
7159 * pattern compilation.
7166 * @short_description: a 2-way association between a string and a unique integer identifier
7168 * Quarks are associations between strings and integer identifiers.
7169 * Given either the string or the #GQuark identifier it is possible to
7170 * retrieve the other.
7172 * Quarks are used for both <link
7173 * linkend="glib-Datasets">Datasets</link> and <link
7174 * linkend="glib-Keyed-Data-Lists">Keyed Data Lists</link>.
7176 * To create a new quark from a string, use g_quark_from_string() or
7177 * g_quark_from_static_string().
7179 * To find the string corresponding to a given #GQuark, use
7180 * g_quark_to_string().
7182 * To find the #GQuark corresponding to a given string, use
7183 * g_quark_try_string().
7185 * Another use for the string pool maintained for the quark functions
7186 * is string interning, using g_intern_string() or
7187 * g_intern_static_string(). An interned string is a canonical
7188 * representation for a string. One important advantage of interned
7189 * strings is that they can be compared for equality by a simple
7190 * pointer comparison, rather than using strcmp().
7196 * @Title: Double-ended Queues
7197 * @Short_description: double-ended queue data structure
7199 * The #GQueue structure and its associated functions provide a standard
7200 * queue data structure. Internally, GQueue uses the same data structure
7201 * as #GList to store elements.
7203 * The data contained in each element can be either integer values, by
7204 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
7205 * Conversion Macros</link>, or simply pointers to any type of data.
7207 * To create a new GQueue, use g_queue_new().
7209 * To initialize a statically-allocated GQueue, use #G_QUEUE_INIT or
7212 * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
7213 * g_queue_push_tail() and g_queue_push_tail_link().
7215 * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
7217 * To free the entire queue, use g_queue_free().
7222 * SECTION:random_numbers
7223 * @title: Random Numbers
7224 * @short_description: pseudo-random number generator
7226 * The following functions allow you to use a portable, fast and good
7227 * pseudo-random number generator (PRNG). It uses the Mersenne Twister
7228 * PRNG, which was originally developed by Makoto Matsumoto and Takuji
7229 * Nishimura. Further information can be found at
7230 * <ulink url="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
7231 * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</ulink>.
7233 * If you just need a random number, you simply call the
7234 * <function>g_random_*</function> functions, which will create a
7235 * globally used #GRand and use the according
7236 * <function>g_rand_*</function> functions internally. Whenever you
7237 * need a stream of reproducible random numbers, you better create a
7238 * #GRand yourself and use the <function>g_rand_*</function> functions
7239 * directly, which will also be slightly faster. Initializing a #GRand
7240 * with a certain seed will produce exactly the same series of random
7241 * numbers on all platforms. This can thus be used as a seed for e.g.
7244 * The <function>g_rand*_range</function> functions will return high
7245 * quality equally distributed random numbers, whereas for example the
7246 * <literal>(g_random_int()%max)</literal> approach often
7247 * doesn't yield equally distributed numbers.
7249 * GLib changed the seeding algorithm for the pseudo-random number
7250 * generator Mersenne Twister, as used by
7251 * <structname>GRand</structname> and <structname>GRandom</structname>.
7252 * This was necessary, because some seeds would yield very bad
7253 * pseudo-random streams. Also the pseudo-random integers generated by
7254 * <function>g_rand*_int_range()</function> will have a slightly better
7255 * equal distribution with the new version of GLib.
7257 * The original seeding and generation algorithms, as found in GLib
7258 * 2.0.x, can be used instead of the new ones by setting the
7259 * environment variable <envar>G_RANDOM_VERSION</envar> to the value of
7260 * '2.0'. Use the GLib-2.0 algorithms only if you have sequences of
7261 * numbers generated with Glib-2.0 that you need to reproduce exactly.
7267 * @title: Lexical Scanner
7268 * @short_description: a general purpose lexical scanner
7270 * The #GScanner and its associated functions provide a
7271 * general purpose lexical scanner.
7278 * @short_description: scalable lists
7280 * The #GSequence data structure has the API of a list, but is
7281 * implemented internally with a balanced binary tree. This means that
7282 * it is possible to maintain a sorted list of n elements in time O(n
7283 * log n). The data contained in each element can be either integer
7284 * values, by using of the <link
7285 * linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
7286 * or simply pointers to any type of data.
7288 * A #GSequence is accessed through <firstterm>iterators</firstterm>,
7289 * represented by a #GSequenceIter. An iterator represents a position
7290 * between two elements of the sequence. For example, the
7291 * <firstterm>begin</firstterm> iterator represents the gap immediately
7292 * before the first element of the sequence, and the
7293 * <firstterm>end</firstterm> iterator represents the gap immediately
7294 * after the last element. In an empty sequence, the begin and end
7295 * iterators are the same.
7297 * Some methods on #GSequence operate on ranges of items. For example
7298 * g_sequence_foreach_range() will call a user-specified function on
7299 * each element with the given range. The range is delimited by the
7300 * gaps represented by the passed-in iterators, so if you pass in the
7301 * begin and end iterators, the range in question is the entire
7304 * The function g_sequence_get() is used with an iterator to access the
7305 * element immediately following the gap that the iterator represents.
7306 * The iterator is said to <firstterm>point</firstterm> to that element.
7308 * Iterators are stable across most operations on a #GSequence. For
7309 * example an iterator pointing to some element of a sequence will
7310 * continue to point to that element even after the sequence is sorted.
7311 * Even moving an element to another sequence using for example
7312 * g_sequence_move_range() will not invalidate the iterators pointing
7313 * to it. The only operation that will invalidate an iterator is when
7314 * the element it points to is removed from any sequence.
7320 * @title: Shell-related Utilities
7321 * @short_description: shell-like commandline handling
7329 * @Short_description: process launching
7330 * @Title: Spawning Processes
7337 * SECTION:string_chunks
7338 * @title: String Chunks
7339 * @short_description: efficient storage of groups of strings
7341 * String chunks are used to store groups of strings. Memory is
7342 * allocated in blocks, and as strings are added to the #GStringChunk
7343 * they are copied into the next free position in a block. When a block
7344 * is full a new block is allocated.
7346 * When storing a large number of strings, string chunks are more
7347 * efficient than using g_strdup() since fewer calls to malloc() are
7348 * needed, and less memory is wasted in memory allocation overheads.
7350 * By adding strings with g_string_chunk_insert_const() it is also
7351 * possible to remove duplicates.
7353 * To create a new #GStringChunk use g_string_chunk_new().
7355 * To add strings to a #GStringChunk use g_string_chunk_insert().
7357 * To add strings to a #GStringChunk, but without duplicating strings
7358 * which are already in the #GStringChunk, use
7359 * g_string_chunk_insert_const().
7361 * To free the entire #GStringChunk use g_string_chunk_free(). It is
7362 * not possible to free individual strings.
7367 * SECTION:string_utils
7368 * @title: String Utility Functions
7369 * @short_description: various string-related functions
7371 * This section describes a number of utility functions for creating,
7372 * duplicating, and manipulating strings.
7374 * Note that the functions g_printf(), g_fprintf(), g_sprintf(),
7375 * g_snprintf(), g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf()
7376 * are declared in the header <filename>gprintf.h</filename> which is
7377 * <emphasis>not</emphasis> included in <filename>glib.h</filename>
7378 * (otherwise using <filename>glib.h</filename> would drag in
7379 * <filename>stdio.h</filename>), so you'll have to explicitly include
7380 * <literal><glib/gprintf.h></literal> in order to use the GLib
7381 * printf() functions.
7383 * <para id="string-precision">While you may use the printf() functions
7384 * to format UTF-8 strings, notice that the precision of a
7385 * <literal>%Ns</literal> parameter is interpreted as the
7386 * number of <emphasis>bytes</emphasis>, not <emphasis>characters</emphasis>
7387 * to print. On top of that, the GNU libc implementation of the printf()
7388 * functions has the "feature" that it checks that the string given for
7389 * the <literal>%Ns</literal> parameter consists of a whole number
7390 * of characters in the current encoding. So, unless you are sure you are
7391 * always going to be in an UTF-8 locale or your know your text is restricted
7392 * to ASCII, avoid using <literal>%Ns</literal>. If your intention is
7393 * to format strings for a certain number of columns, then
7394 * <literal>%Ns</literal> is not a correct solution anyway, since it
7395 * fails to take wide characters (see g_unichar_iswide()) into account.
7403 * @short_description: text buffers which grow automatically as text is added
7405 * A #GString is an object that handles the memory management of a C
7406 * string for you. The emphasis of #GString is on text, typically
7407 * UTF-8. Crucially, the "str" member of a #GString is guaranteed to
7408 * have a trailing nul character, and it is therefore always safe to
7409 * call functions such as strchr() or g_strdup() on it.
7411 * However, a #GString can also hold arbitrary binary data, because it
7412 * has a "len" member, which includes any possible embedded nul
7413 * characters in the data. Conceptually then, #GString is like a
7414 * #GByteArray with the addition of many convenience methods for text,
7415 * and a guaranteed nul terminator.
7422 * @short_description: a test framework
7423 * @see_also: <link linkend="gtester">gtester</link>, <link linkend="gtester-report">gtester-report</link>
7425 * GLib provides a framework for writing and maintaining unit tests
7426 * in parallel to the code they are testing. The API is designed according
7427 * to established concepts found in the other test frameworks (JUnit, NUnit,
7428 * RUnit), which in turn is based on smalltalk unit testing concepts.
7432 * <term>Test case</term>
7433 * <listitem>Tests (test methods) are grouped together with their
7434 * fixture into test cases.</listitem>
7437 * <term>Fixture</term>
7438 * <listitem>A test fixture consists of fixture data and setup and
7439 * teardown methods to establish the environment for the test
7440 * functions. We use fresh fixtures, i.e. fixtures are newly set
7441 * up and torn down around each test invocation to avoid dependencies
7442 * between tests.</listitem>
7445 * <term>Test suite</term>
7446 * <listitem>Test cases can be grouped into test suites, to allow
7447 * subsets of the available tests to be run. Test suites can be
7448 * grouped into other test suites as well.</listitem>
7451 * The API is designed to handle creation and registration of test suites
7452 * and test cases implicitly. A simple call like
7454 * g_test_add_func ("/misc/assertions", test_assertions);
7456 * creates a test suite called "misc" with a single test case named
7457 * "assertions", which consists of running the test_assertions function.
7459 * In addition to the traditional g_assert(), the test framework provides
7460 * an extended set of assertions for string and numerical comparisons:
7461 * g_assert_cmpfloat(), g_assert_cmpint(), g_assert_cmpuint(),
7462 * g_assert_cmphex(), g_assert_cmpstr(). The advantage of these variants
7463 * over plain g_assert() is that the assertion messages can be more
7464 * elaborate, and include the values of the compared entities.
7466 * GLib ships with two utilities called gtester and gtester-report to
7467 * facilitate running tests and producing nicely formatted test reports.
7472 * SECTION:thread_pools
7473 * @title: Thread Pools
7474 * @short_description: pools of threads to execute work concurrently
7475 * @see_also: #GThread
7477 * Sometimes you wish to asynchronously fork out the execution of work
7478 * and continue working in your own thread. If that will happen often,
7479 * the overhead of starting and destroying a thread each time might be
7480 * too high. In such cases reusing already started threads seems like a
7481 * good idea. And it indeed is, but implementing this can be tedious
7484 * Therefore GLib provides thread pools for your convenience. An added
7485 * advantage is, that the threads can be shared between the different
7486 * subsystems of your program, when they are using GLib.
7488 * To create a new thread pool, you use g_thread_pool_new().
7489 * It is destroyed by g_thread_pool_free().
7491 * If you want to execute a certain task within a thread pool,
7492 * you call g_thread_pool_push().
7494 * To get the current number of running threads you call
7495 * g_thread_pool_get_num_threads(). To get the number of still
7496 * unprocessed tasks you call g_thread_pool_unprocessed(). To control
7497 * the maximal number of threads for a thread pool, you use
7498 * g_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().
7500 * Finally you can control the number of unused threads, that are kept
7501 * alive by GLib for future use. The current number can be fetched with
7502 * g_thread_pool_get_num_unused_threads(). The maximal number can be
7503 * controlled by g_thread_pool_get_max_unused_threads() and
7504 * g_thread_pool_set_max_unused_threads(). All currently unused threads
7505 * can be stopped by calling g_thread_pool_stop_unused_threads().
7512 * @short_description: portable support for threads, mutexes, locks, conditions and thread private data
7513 * @see_also: #GThreadPool, #GAsyncQueue
7515 * Threads act almost like processes, but unlike processes all threads
7516 * of one process share the same memory. This is good, as it provides
7517 * easy communication between the involved threads via this shared
7518 * memory, and it is bad, because strange things (so called
7519 * "Heisenbugs") might happen if the program is not carefully designed.
7520 * In particular, due to the concurrent nature of threads, no
7521 * assumptions on the order of execution of code running in different
7522 * threads can be made, unless order is explicitly forced by the
7523 * programmer through synchronization primitives.
7525 * The aim of the thread-related functions in GLib is to provide a
7526 * portable means for writing multi-threaded software. There are
7527 * primitives for mutexes to protect the access to portions of memory
7528 * (#GMutex, #GRecMutex and #GRWLock). There is a facility to use
7529 * individual bits for locks (g_bit_lock()). There are primitives
7530 * for condition variables to allow synchronization of threads (#GCond).
7531 * There are primitives for thread-private data - data that every
7532 * thread has a private instance of (#GPrivate). There are facilities
7533 * for one-time initialization (#GOnce, g_once_init_enter()). Finally,
7534 * there are primitives to create and manage threads (#GThread).
7536 * The GLib threading system used to be initialized with g_thread_init().
7537 * This is no longer necessary. Since version 2.32, the GLib threading
7538 * system is automatically initialized at the start of your program,
7539 * and all thread-creation functions and synchronization primitives
7540 * are available right away.
7542 * Note that it is not safe to assume that your program has no threads
7543 * even if you don't call g_thread_new() yourself. GLib and GIO can
7544 * and will create threads for their own purposes in some cases, such
7545 * as when using g_unix_signal_source_new() or when using GDBus.
7547 * Originally, UNIX did not have threads, and therefore some traditional
7548 * UNIX APIs are problematic in threaded programs. Some notable examples
7552 * C library functions that return data in statically allocated
7553 * buffers, such as strtok() or strerror(). For many of these,
7554 * there are thread-safe variants with a _r suffix, or you can
7555 * look at corresponding GLib APIs (like g_strsplit() or g_strerror()).
7558 * setenv() and unsetenv() manipulate the process environment in
7559 * a not thread-safe way, and may interfere with getenv() calls
7560 * in other threads. Note that getenv() calls may be
7561 * <quote>hidden</quote> behind other APIs. For example, GNU gettext()
7562 * calls getenv() under the covers. In general, it is best to treat
7563 * the environment as readonly. If you absolutely have to modify the
7564 * environment, do it early in main(), when no other threads are around yet.
7567 * setlocale() changes the locale for the entire process, affecting
7568 * all threads. Temporary changes to the locale are often made to
7569 * change the behavior of string scanning or formatting functions
7570 * like scanf() or printf(). GLib offers a number of string APIs
7571 * (like g_ascii_formatd() or g_ascii_strtod()) that can often be
7572 * used as an alternative. Or you can use the uselocale() function
7573 * to change the locale only for the current thread.
7576 * fork() only takes the calling thread into the child's copy of the
7577 * process image. If other threads were executing in critical
7578 * sections they could have left mutexes locked which could easily
7579 * cause deadlocks in the new child. For this reason, you should
7580 * call exit() or exec() as soon as possible in the child and only
7581 * make signal-safe library calls before that.
7584 * daemon() uses fork() in a way contrary to what is described
7585 * above. It should not be used with GLib programs.
7589 * GLib itself is internally completely thread-safe (all global data is
7590 * automatically locked), but individual data structure instances are
7591 * not automatically locked for performance reasons. For example,
7592 * you must coordinate accesses to the same #GHashTable from multiple
7593 * threads. The two notable exceptions from this rule are #GMainLoop
7594 * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
7595 * need no further application-level locking to be accessed from
7596 * multiple threads. Most refcounting functions such as g_object_ref()
7597 * are also thread-safe.
7604 * @short_description: keep track of elapsed time
7606 * #GTimer records a start time, and counts microseconds elapsed since
7607 * that time. This is done somewhat differently on different platforms,
7608 * and can be tricky to get exactly right, so #GTimer provides a
7609 * portable/convenient interface.
7616 * @short_description: a structure representing a time zone
7617 * @see_also: #GDateTime
7619 * #GTimeZone is a structure that represents a time zone, at no
7620 * particular point in time. It is refcounted and immutable.
7622 * A time zone contains a number of intervals. Each interval has
7623 * an abbreviation to describe it, an offet to UTC and a flag indicating
7624 * if the daylight savings time is in effect during that interval. A
7625 * time zone always has at least one interval -- interval 0.
7627 * Every UTC time is contained within exactly one interval, but a given
7628 * local time may be contained within zero, one or two intervals (due to
7629 * incontinuities associated with daylight savings time).
7631 * An interval may refer to a specific period of time (eg: the duration
7632 * of daylight savings time during 2010) or it may refer to many periods
7633 * of time that share the same properties (eg: all periods of daylight
7634 * savings time). It is also possible (usually for political reasons)
7635 * that some properties (like the abbreviation) change between intervals
7636 * without other properties changing.
7638 * #GTimeZone is available since GLib 2.26.
7643 * SECTION:trash_stack
7644 * @title: Trash Stacks
7645 * @short_description: maintain a stack of unused allocated memory chunks
7647 * A #GTrashStack is an efficient way to keep a stack of unused allocated
7648 * memory chunks. Each memory chunk is required to be large enough to hold
7649 * a #gpointer. This allows the stack to be maintained without any space
7650 * overhead, since the stack pointers can be stored inside the memory chunks.
7652 * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
7653 * is a perfectly valid empty stack.
7658 * SECTION:trees-binary
7659 * @title: Balanced Binary Trees
7660 * @short_description: a sorted collection of key/value pairs optimized for searching and traversing in order
7662 * The #GTree structure and its associated functions provide a sorted
7663 * collection of key/value pairs optimized for searching and traversing
7666 * To create a new #GTree use g_tree_new().
7668 * To insert a key/value pair into a #GTree use g_tree_insert().
7670 * To lookup the value corresponding to a given key, use
7671 * g_tree_lookup() and g_tree_lookup_extended().
7673 * To find out the number of nodes in a #GTree, use g_tree_nnodes(). To
7674 * get the height of a #GTree, use g_tree_height().
7676 * To traverse a #GTree, calling a function for each node visited in
7677 * the traversal, use g_tree_foreach().
7679 * To remove a key/value pair use g_tree_remove().
7681 * To destroy a #GTree, use g_tree_destroy().
7686 * SECTION:trees-nary
7687 * @title: N-ary Trees
7688 * @short_description: trees of data with any number of branches
7690 * The #GNode struct and its associated functions provide a N-ary tree
7691 * data structure, where nodes in the tree can contain arbitrary data.
7693 * To create a new tree use g_node_new().
7695 * To insert a node into a tree use g_node_insert(),
7696 * g_node_insert_before(), g_node_append() and g_node_prepend().
7698 * To create a new node and insert it into a tree use
7699 * g_node_insert_data(), g_node_insert_data_after(),
7700 * g_node_insert_data_before(), g_node_append_data()
7701 * and g_node_prepend_data().
7703 * To reverse the children of a node use g_node_reverse_children().
7705 * To find a node use g_node_get_root(), g_node_find(),
7706 * g_node_find_child(), g_node_child_index(), g_node_child_position(),
7707 * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
7708 * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
7709 * or g_node_last_sibling().
7711 * To get information about a node or tree use G_NODE_IS_LEAF(),
7712 * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
7713 * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
7715 * To traverse a tree, calling a function for each node visited in the
7716 * traversal, use g_node_traverse() or g_node_children_foreach().
7718 * To remove a node or subtree from a tree use g_node_unlink() or
7724 * SECTION:type_conversion
7725 * @title: Type Conversion Macros
7726 * @short_description: portably storing integers in pointer variables
7728 * Many times GLib, GTK+, and other libraries allow you to pass "user
7729 * data" to a callback, in the form of a void pointer. From time to time
7730 * you want to pass an integer instead of a pointer. You could allocate
7731 * an integer, with something like:
7733 * int *ip = g_new (int, 1);
7736 * But this is inconvenient, and it's annoying to have to free the
7737 * memory at some later time.
7739 * Pointers are always at least 32 bits in size (on all platforms GLib
7740 * intends to support). Thus you can store at least 32-bit integer values
7741 * in a pointer value. Naively, you might try this, but it's incorrect:
7748 * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
7749 * The problem is that on some systems you need to do this:
7753 * p = (void*) (long) 42;
7754 * i = (int) (long) p;
7756 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
7757 * to do the right thing on the every platform.
7759 * <warning><para>You may not store pointers in integers. This is not
7760 * portable in any way, shape or form. These macros <emphasis>only</emphasis>
7761 * allow storing integers in pointers, and only preserve 32 bits of the
7762 * integer; values outside the range of a 32-bit integer will be mangled.
7769 * @title: Basic Types
7770 * @short_description: standard GLib types, defined for ease-of-use and portability
7772 * GLib defines a number of commonly used types, which can be divided
7774 * - New types which are not part of standard C (but are defined in
7775 * various C standard library header files) - #gboolean, #gsize,
7776 * #gssize, #goffset, #gintptr, #guintptr.
7777 * - Integer types which are guaranteed to be the same size across
7778 * all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
7779 * #guint32, #gint64, #guint64.
7780 * - Types which are easier to use than their standard C counterparts -
7781 * #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
7782 * - Types which correspond exactly to standard C types, but are
7783 * included for completeness - #gchar, #gint, #gshort, #glong,
7784 * #gfloat, #gdouble.
7786 * GLib also defines macros for the limits of some of the standard
7787 * integer and floating point types, as well as macros for suitable
7788 * printf() formats for these types.
7794 * @Title: Unicode Manipulation
7795 * @Short_description: functions operating on Unicode characters and UTF-8 strings
7796 * @See_also: g_locale_to_utf8(), g_locale_from_utf8()
7798 * This section describes a number of functions for dealing with
7799 * Unicode characters and strings. There are analogues of the
7800 * traditional <filename>ctype.h</filename> character classification
7801 * and case conversion functions, UTF-8 analogues of some string utility
7802 * functions, functions to perform normalization, case conversion and
7803 * collation on UTF-8 strings and finally functions to convert between
7804 * the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
7806 * The implementations of the Unicode functions in GLib are based
7807 * on the Unicode Character Data tables, which are available from
7808 * <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
7809 * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
7810 * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
7811 * GLib 2.30 supports Unicode 6.0.
7817 * @Title: Version Information
7818 * @Short_description: variables and functions to check the GLib version
7820 * GLib provides version information, primarily useful in configure
7821 * checks for builds that have a configure script. Applications will
7822 * not typically use the features described here.
7824 * The GLib headers annotate deprecated APIs in a way that produces
7825 * compiler warnings if these deprecated APIs are used. The warnings
7826 * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
7827 * before including the glib.h header.
7829 * GLib also provides support for building applications against
7830 * defined subsets of deprecated or new GLib APIs. Define the macro
7831 * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
7832 * you want to receive warnings about deprecated APIs. Define the
7833 * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
7834 * GLib whose API you want to use.
7840 * @Title: Message Output and Debugging Functions
7841 * @Short_description: functions to output messages and help debug applications
7843 * These functions provide support for outputting messages.
7845 * The <function>g_return</function> family of macros (g_return_if_fail(),
7846 * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached())
7847 * should only be used for programming errors, a typical use case is
7848 * checking for invalid parameters at the beginning of a public function.
7849 * They should not be used if you just mean "if (error) return", they
7850 * should only be used if you mean "if (bug in program) return".
7851 * The program behavior is generally considered undefined after one
7852 * of these checks fails. They are not intended for normal control
7853 * flow, only to give a perhaps-helpful warning before giving up.
7859 * @title: Windows Compatibility Functions
7860 * @short_description: UNIX emulation on Windows
7862 * These functions provide some level of UNIX emulation on the
7863 * Windows platform. If your application really needs the POSIX
7864 * APIs, we suggest you try the Cygwin project.
7871 * Defines the %TRUE value for the #gboolean type.
7877 * @String: the string to be translated
7879 * Marks a string for translation, gets replaced with the translated string
7887 * _glib_get_locale_dir:
7889 * Return the path to the share\locale or lib\locale subfolder of the
7890 * GLib installation folder. The path is in the system codepage. We
7891 * have to use system codepage as bindtextdomain() doesn't have a
7898 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
7899 * @mode: as in access()
7901 * A wrapper for the POSIX access() function. This function is used to
7902 * test a pathname for one or several of read, write or execute
7903 * permissions, or just existence.
7905 * On Windows, the file protection mechanism is not at all POSIX-like,
7906 * and the underlying function in the C library only checks the
7907 * FAT-style READONLY attribute, and does not look at the ACL of a
7908 * file at all. This function is this in practise almost useless on
7909 * Windows. Software that needs to handle file permissions on Windows
7910 * more exactly should use the Win32 API.
7912 * See your C library manual for more details about access().
7914 * Returns: zero if the pathname refers to an existing file system object that has all the tested permissions, or -1 otherwise or on error.
7920 * g_array_append_val:
7922 * @v: the value to append to the #GArray.
7924 * Adds the value on to the end of the array. The array will grow in
7925 * size automatically if necessary.
7927 * <note><para>g_array_append_val() is a macro which uses a reference
7928 * to the value parameter @v. This means that you cannot use it with
7929 * literal values such as "27". You must use variables.</para></note>
7931 * Returns: the #GArray.
7936 * g_array_append_vals:
7937 * @array: a #GArray.
7938 * @data: a pointer to the elements to append to the end of the array.
7939 * @len: the number of elements to append.
7941 * Adds @len elements onto the end of the array.
7943 * Returns: the #GArray.
7949 * @array: a #GArray.
7950 * @free_segment: if %TRUE the actual element data is freed as well.
7952 * Frees the memory allocated for the #GArray. If @free_segment is
7953 * %TRUE it frees the memory block holding the elements as well and
7954 * also each element if @array has a @element_free_func set. Pass
7955 * %FALSE if you want to free the #GArray wrapper but preserve the
7956 * underlying array for use elsewhere. If the reference count of @array
7957 * is greater than one, the #GArray wrapper is preserved but the size
7958 * of @array will be set to zero.
7960 * <note><para>If array elements contain dynamically-allocated memory,
7961 * they should be freed separately.</para></note>
7963 * Returns: the element data if @free_segment is %FALSE, otherwise %NULL. The element data should be freed using g_free().
7968 * g_array_get_element_size:
7969 * @array: A #GArray.
7971 * Gets the size of the elements in @array.
7973 * Returns: Size of each element, in bytes.
7981 * @t: the type of the elements.
7982 * @i: the index of the element to return.
7984 * Returns the element of a #GArray at the given index. The return
7985 * value is cast to the given type.
7988 * <title>Getting a pointer to an element in a #GArray</title>
7990 * EDayViewEvent *event;
7991 * /<!-- -->* This gets a pointer to the 4th element
7992 * in the array of EDayViewEvent structs. *<!-- -->/
7993 * event = &g_array_index (events, EDayViewEvent, 3);
7997 * Returns: the element of the #GArray at the index given by @i.
8002 * g_array_insert_val:
8004 * @i: the index to place the element at.
8005 * @v: the value to insert into the array.
8007 * Inserts an element into an array at the given index.
8009 * <note><para>g_array_insert_val() is a macro which uses a reference
8010 * to the value parameter @v. This means that you cannot use it with
8011 * literal values such as "27". You must use variables.</para></note>
8013 * Returns: the #GArray.
8018 * g_array_insert_vals:
8019 * @array: a #GArray.
8020 * @index_: the index to place the elements at.
8021 * @data: a pointer to the elements to insert.
8022 * @len: the number of elements to insert.
8024 * Inserts @len elements into a #GArray at the given index.
8026 * Returns: the #GArray.
8032 * @zero_terminated: %TRUE if the array should have an extra element at the end which is set to 0.
8033 * @clear_: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
8034 * @element_size: the size of each element in bytes.
8036 * Creates a new #GArray with a reference count of 1.
8038 * Returns: the new #GArray.
8043 * g_array_prepend_val:
8045 * @v: the value to prepend to the #GArray.
8047 * Adds the value on to the start of the array. The array will grow in
8048 * size automatically if necessary.
8050 * This operation is slower than g_array_append_val() since the
8051 * existing elements in the array have to be moved to make space for
8054 * <note><para>g_array_prepend_val() is a macro which uses a reference
8055 * to the value parameter @v. This means that you cannot use it with
8056 * literal values such as "27". You must use variables.</para></note>
8058 * Returns: the #GArray.
8063 * g_array_prepend_vals:
8064 * @array: a #GArray.
8065 * @data: a pointer to the elements to prepend to the start of the array.
8066 * @len: the number of elements to prepend.
8068 * Adds @len elements onto the start of the array.
8070 * This operation is slower than g_array_append_vals() since the
8071 * existing elements in the array have to be moved to make space for
8074 * Returns: the #GArray.
8080 * @array: A #GArray.
8082 * Atomically increments the reference count of @array by one. This
8083 * function is MT-safe and may be called from any thread.
8085 * Returns: The passed in #GArray.
8091 * g_array_remove_index:
8092 * @array: a #GArray.
8093 * @index_: the index of the element to remove.
8095 * Removes the element at the given index from a #GArray. The following
8096 * elements are moved down one place.
8098 * Returns: the #GArray.
8103 * g_array_remove_index_fast:
8104 * @array: a @GArray.
8105 * @index_: the index of the element to remove.
8107 * Removes the element at the given index from a #GArray. The last
8108 * element in the array is used to fill in the space, so this function
8109 * does not preserve the order of the #GArray. But it is faster than
8110 * g_array_remove_index().
8112 * Returns: the #GArray.
8117 * g_array_remove_range:
8118 * @array: a @GArray.
8119 * @index_: the index of the first element to remove.
8120 * @length: the number of elements to remove.
8122 * Removes the given number of elements starting at the given index
8123 * from a #GArray. The following elements are moved to close the gap.
8125 * Returns: the #GArray.
8131 * g_array_set_clear_func:
8133 * @clear_func: a function to clear an element of @array
8135 * Sets a function to clear an element of @array.
8137 * The @clear_func will be called when an element in the array
8138 * data segment is removed and when the array is freed and data
8139 * segment is deallocated as well.
8141 * Note that in contrast with other uses of #GDestroyNotify
8142 * functions, @clear_func is expected to clear the contents of
8143 * the array element it is given, but not free the element itself.
8151 * @array: a #GArray.
8152 * @length: the new size of the #GArray.
8154 * Sets the size of the array, expanding it if necessary. If the array
8155 * was created with @clear_ set to %TRUE, the new elements are set to 0.
8157 * Returns: the #GArray.
8162 * g_array_sized_new:
8163 * @zero_terminated: %TRUE if the array should have an extra element at the end with all bits cleared.
8164 * @clear_: %TRUE if all bits in the array should be cleared to 0 on allocation.
8165 * @element_size: size of each element in the array.
8166 * @reserved_size: number of elements preallocated.
8168 * Creates a new #GArray with @reserved_size elements preallocated and
8169 * a reference count of 1. This avoids frequent reallocation, if you
8170 * are going to add many elements to the array. Note however that the
8171 * size of the array is still 0.
8173 * Returns: the new #GArray.
8179 * @array: a #GArray.
8180 * @compare_func: comparison function.
8182 * Sorts a #GArray using @compare_func which should be a qsort()-style
8183 * comparison function (returns less than zero for first arg is less
8184 * than second arg, zero for equal, greater zero if first arg is
8185 * greater than second arg).
8187 * This is guaranteed to be a stable sort since version 2.32.
8192 * g_array_sort_with_data:
8193 * @array: a #GArray.
8194 * @compare_func: comparison function.
8195 * @user_data: data to pass to @compare_func.
8197 * Like g_array_sort(), but the comparison function receives an extra
8198 * user data argument.
8200 * This is guaranteed to be a stable sort since version 2.32.
8202 * There used to be a comment here about making the sort stable by
8203 * using the addresses of the elements in the comparison function.
8204 * This did not actually work, so any such code should be removed.
8210 * @array: A #GArray.
8212 * Atomically decrements the reference count of @array by one. If the
8213 * reference count drops to 0, all memory allocated by the array is
8214 * released. This function is MT-safe and may be called from any
8222 * g_ascii_digit_value:
8223 * @c: an ASCII character.
8225 * Determines the numeric value of a character as a decimal
8226 * digit. Differs from g_unichar_digit_value() because it takes
8227 * a char, so there's no worry about sign extension if characters
8230 * Returns: If @c is a decimal digit (according to g_ascii_isdigit()), its numeric value. Otherwise, -1.
8236 * @buffer: A buffer to place the resulting string in
8237 * @buf_len: The length of the buffer.
8238 * @d: The #gdouble to convert
8240 * Converts a #gdouble to a string, using the '.' as
8243 * This functions generates enough precision that converting
8244 * the string back using g_ascii_strtod() gives the same machine-number
8245 * (on machines with IEEE compatible 64bit doubles). It is
8246 * guaranteed that the size of the resulting string will never
8247 * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
8249 * Returns: The pointer to the buffer with the converted string.
8255 * @buffer: A buffer to place the resulting string in
8256 * @buf_len: The length of the buffer.
8257 * @format: The printf()-style format to use for the code to use for converting.
8258 * @d: The #gdouble to convert
8260 * Converts a #gdouble to a string, using the '.' as
8261 * decimal point. To format the number you pass in
8262 * a printf()-style format string. Allowed conversion
8263 * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
8265 * If you just want to want to serialize the value into a
8266 * string, use g_ascii_dtostr().
8268 * Returns: The pointer to the buffer with the converted string.
8276 * Determines whether a character is alphanumeric.
8278 * Unlike the standard C library isalnum() function, this only
8279 * recognizes standard ASCII letters and ignores the locale,
8280 * returning %FALSE for all non-ASCII characters. Also, unlike
8281 * the standard library function, this takes a <type>char</type>,
8282 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8283 * cast to #guchar before passing a possibly non-ASCII character in.
8285 * Returns: %TRUE if @c is an ASCII alphanumeric character
8293 * Determines whether a character is alphabetic (i.e. a letter).
8295 * Unlike the standard C library isalpha() function, this only
8296 * recognizes standard ASCII letters and ignores the locale,
8297 * returning %FALSE for all non-ASCII characters. Also, unlike
8298 * the standard library function, this takes a <type>char</type>,
8299 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8300 * cast to #guchar before passing a possibly non-ASCII character in.
8302 * Returns: %TRUE if @c is an ASCII alphabetic character
8310 * Determines whether a character is a control character.
8312 * Unlike the standard C library iscntrl() function, this only
8313 * recognizes standard ASCII control characters and ignores the
8314 * locale, returning %FALSE for all non-ASCII characters. Also,
8315 * unlike the standard library function, this takes a <type>char</type>,
8316 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8317 * cast to #guchar before passing a possibly non-ASCII character in.
8319 * Returns: %TRUE if @c is an ASCII control character.
8327 * Determines whether a character is digit (0-9).
8329 * Unlike the standard C library isdigit() function, this takes
8330 * a <type>char</type>, not an <type>int</type>, so don't call it
8331 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a possibly
8332 * non-ASCII character in.
8334 * Returns: %TRUE if @c is an ASCII digit.
8342 * Determines whether a character is a printing character and not a space.
8344 * Unlike the standard C library isgraph() function, this only
8345 * recognizes standard ASCII characters and ignores the locale,
8346 * returning %FALSE for all non-ASCII characters. Also, unlike
8347 * the standard library function, this takes a <type>char</type>,
8348 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8349 * to cast to #guchar before passing a possibly non-ASCII character in.
8351 * Returns: %TRUE if @c is an ASCII printing character other than space.
8359 * Determines whether a character is an ASCII lower case letter.
8361 * Unlike the standard C library islower() function, this only
8362 * recognizes standard ASCII letters and ignores the locale,
8363 * returning %FALSE for all non-ASCII characters. Also, unlike
8364 * the standard library function, this takes a <type>char</type>,
8365 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8366 * to worry about casting to #guchar before passing a possibly
8367 * non-ASCII character in.
8369 * Returns: %TRUE if @c is an ASCII lower case letter
8377 * Determines whether a character is a printing character.
8379 * Unlike the standard C library isprint() function, this only
8380 * recognizes standard ASCII characters and ignores the locale,
8381 * returning %FALSE for all non-ASCII characters. Also, unlike
8382 * the standard library function, this takes a <type>char</type>,
8383 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8384 * to cast to #guchar before passing a possibly non-ASCII character in.
8386 * Returns: %TRUE if @c is an ASCII printing character.
8394 * Determines whether a character is a punctuation character.
8396 * Unlike the standard C library ispunct() function, this only
8397 * recognizes standard ASCII letters and ignores the locale,
8398 * returning %FALSE for all non-ASCII characters. Also, unlike
8399 * the standard library function, this takes a <type>char</type>,
8400 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8401 * cast to #guchar before passing a possibly non-ASCII character in.
8403 * Returns: %TRUE if @c is an ASCII punctuation character.
8411 * Determines whether a character is a white-space character.
8413 * Unlike the standard C library isspace() function, this only
8414 * recognizes standard ASCII white-space and ignores the locale,
8415 * returning %FALSE for all non-ASCII characters. Also, unlike
8416 * the standard library function, this takes a <type>char</type>,
8417 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8418 * cast to #guchar before passing a possibly non-ASCII character in.
8420 * Returns: %TRUE if @c is an ASCII white-space character
8428 * Determines whether a character is an ASCII upper case letter.
8430 * Unlike the standard C library isupper() function, this only
8431 * recognizes standard ASCII letters and ignores the locale,
8432 * returning %FALSE for all non-ASCII characters. Also, unlike
8433 * the standard library function, this takes a <type>char</type>,
8434 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8435 * worry about casting to #guchar before passing a possibly non-ASCII
8438 * Returns: %TRUE if @c is an ASCII upper case letter
8446 * Determines whether a character is a hexadecimal-digit character.
8448 * Unlike the standard C library isxdigit() function, this takes
8449 * a <type>char</type>, not an <type>int</type>, so don't call it
8450 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a
8451 * possibly non-ASCII character in.
8453 * Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
8458 * g_ascii_strcasecmp:
8459 * @s1: string to compare with @s2.
8460 * @s2: string to compare with @s1.
8462 * Compare two strings, ignoring the case of ASCII characters.
8464 * Unlike the BSD strcasecmp() function, this only recognizes standard
8465 * ASCII letters and ignores the locale, treating all non-ASCII
8466 * bytes as if they are not letters.
8468 * This function should be used only on strings that are known to be
8469 * in encodings where the bytes corresponding to ASCII letters always
8470 * represent themselves. This includes UTF-8 and the ISO-8859-*
8471 * charsets, but not for instance double-byte encodings like the
8472 * Windows Codepage 932, where the trailing bytes of double-byte
8473 * characters include all ASCII letters. If you compare two CP932
8474 * strings using this function, you will get false matches.
8476 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
8483 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8485 * Converts all upper case ASCII letters to lower case ASCII letters.
8487 * Returns: a newly-allocated string, with all the upper case characters in @str converted to lower case, with semantics that exactly match g_ascii_tolower(). (Note that this is unlike the old g_strdown(), which modified the string in place.)
8492 * g_ascii_strncasecmp:
8493 * @s1: string to compare with @s2.
8494 * @s2: string to compare with @s1.
8495 * @n: number of characters to compare.
8497 * Compare @s1 and @s2, ignoring the case of ASCII characters and any
8498 * characters after the first @n in each string.
8500 * Unlike the BSD strcasecmp() function, this only recognizes standard
8501 * ASCII letters and ignores the locale, treating all non-ASCII
8502 * characters as if they are not letters.
8504 * The same warning as in g_ascii_strcasecmp() applies: Use this
8505 * function only on strings known to be in encodings where bytes
8506 * corresponding to ASCII letters always represent themselves.
8508 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
8514 * @nptr: the string to convert to a numeric value.
8515 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8517 * Converts a string to a #gdouble value.
8519 * This function behaves like the standard strtod() function
8520 * does in the C locale. It does this without actually changing
8521 * the current locale, since that would not be thread-safe.
8522 * A limitation of the implementation is that this function
8523 * will still accept localized versions of infinities and NANs.
8525 * This function is typically used when reading configuration
8526 * files or other non-user input that should be locale independent.
8527 * To handle input from the user you should normally use the
8528 * locale-sensitive system strtod() function.
8530 * To convert from a #gdouble to a string in a locale-insensitive
8531 * way, use g_ascii_dtostr().
8533 * If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
8534 * is returned (according to the sign of the value), and <literal>ERANGE</literal> is
8535 * stored in <literal>errno</literal>. If the correct value would cause underflow,
8536 * zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8538 * This function resets <literal>errno</literal> before calling strtod() so that
8539 * you can reliably detect overflow and underflow.
8541 * Returns: the #gdouble value.
8547 * @nptr: the string to convert to a numeric value.
8548 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8549 * @base: to be used for the conversion, 2..36 or 0
8551 * Converts a string to a #gint64 value.
8552 * This function behaves like the standard strtoll() function
8553 * does in the C locale. It does this without actually
8554 * changing the current locale, since that would not be
8557 * This function is typically used when reading configuration
8558 * files or other non-user input that should be locale independent.
8559 * To handle input from the user you should normally use the
8560 * locale-sensitive system strtoll() function.
8562 * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
8563 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8564 * If the base is outside the valid range, zero is returned, and
8565 * <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
8566 * string conversion fails, zero is returned, and @endptr returns @nptr
8567 * (if @endptr is non-%NULL).
8569 * Returns: the #gint64 value or zero on error.
8576 * @nptr: the string to convert to a numeric value.
8577 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8578 * @base: to be used for the conversion, 2..36 or 0
8580 * Converts a string to a #guint64 value.
8581 * This function behaves like the standard strtoull() function
8582 * does in the C locale. It does this without actually
8583 * changing the current locale, since that would not be
8586 * This function is typically used when reading configuration
8587 * files or other non-user input that should be locale independent.
8588 * To handle input from the user you should normally use the
8589 * locale-sensitive system strtoull() function.
8591 * If the correct value would cause overflow, %G_MAXUINT64
8592 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8593 * If the base is outside the valid range, zero is returned, and
8594 * <literal>EINVAL</literal> is stored in <literal>errno</literal>.
8595 * If the string conversion fails, zero is returned, and @endptr returns
8596 * @nptr (if @endptr is non-%NULL).
8598 * Returns: the #guint64 value or zero on error.
8606 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8608 * Converts all lower case ASCII letters to upper case ASCII letters.
8610 * Returns: a newly allocated string, with all the lower case characters in @str converted to upper case, with semantics that exactly match g_ascii_toupper(). (Note that this is unlike the old g_strup(), which modified the string in place.)
8616 * @c: any character.
8618 * Convert a character to ASCII lower case.
8620 * Unlike the standard C library tolower() function, this only
8621 * recognizes standard ASCII letters and ignores the locale, returning
8622 * all non-ASCII characters unchanged, even if they are lower case
8623 * letters in a particular character set. Also unlike the standard
8624 * library function, this takes and returns a char, not an int, so
8625 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8626 * before passing a possibly non-ASCII character in.
8628 * Returns: the result of converting @c to lower case. If @c is not an ASCII upper case letter, @c is returned unchanged.
8634 * @c: any character.
8636 * Convert a character to ASCII upper case.
8638 * Unlike the standard C library toupper() function, this only
8639 * recognizes standard ASCII letters and ignores the locale, returning
8640 * all non-ASCII characters unchanged, even if they are upper case
8641 * letters in a particular character set. Also unlike the standard
8642 * library function, this takes and returns a char, not an int, so
8643 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8644 * before passing a possibly non-ASCII character in.
8646 * Returns: the result of converting @c to upper case. If @c is not an ASCII lower case letter, @c is returned unchanged.
8651 * g_ascii_xdigit_value:
8652 * @c: an ASCII character.
8654 * Determines the numeric value of a character as a hexidecimal
8655 * digit. Differs from g_unichar_xdigit_value() because it takes
8656 * a char, so there's no worry about sign extension if characters
8659 * Returns: If @c is a hex digit (according to g_ascii_isxdigit()), its numeric value. Otherwise, -1.
8665 * @expr: the expression to check
8667 * Debugging macro to terminate the application if the assertion
8668 * fails. If the assertion fails (i.e. the expression is not true),
8669 * an error message is logged and the application is terminated.
8671 * The macro can be turned off in final releases of code by defining
8672 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8677 * g_assert_cmpfloat:
8678 * @n1: an floating point number
8679 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8680 * @n2: another floating point number
8682 * Debugging macro to terminate the application with a warning
8683 * message if a floating point number comparison fails.
8685 * The effect of <literal>g_assert_cmpfloat (n1, op, n2)</literal> is
8686 * the same as <literal>g_assert (n1 op n2)</literal>. The advantage
8687 * of this macro is that it can produce a message that includes the
8688 * actual values of @n1 and @n2.
8696 * @n1: an unsigned integer
8697 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8698 * @n2: another unsigned integer
8700 * Debugging macro to terminate the application with a warning
8701 * message if an unsigned integer comparison fails.
8703 * This is a variant of g_assert_cmpuint() that displays the numbers
8704 * in hexadecimal notation in the message.
8713 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8714 * @n2: another integer
8716 * Debugging macro to terminate the application with a warning
8717 * message if an integer comparison fails.
8719 * The effect of <literal>g_assert_cmpint (n1, op, n2)</literal> is
8720 * the same as <literal>g_assert (n1 op n2)</literal>. The advantage
8721 * of this macro is that it can produce a message that includes the
8722 * actual values of @n1 and @n2.
8730 * @s1: a string (may be %NULL)
8731 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8732 * @s2: another string (may be %NULL)
8734 * Debugging macro to terminate the application with a warning
8735 * message if a string comparison fails. The strings are compared
8736 * using g_strcmp0().
8738 * The effect of <literal>g_assert_cmpstr (s1, op, s2)</literal> is
8739 * the same as <literal>g_assert (g_strcmp0 (s1, s2) op 0)</literal>.
8740 * The advantage of this macro is that it can produce a message that
8741 * includes the actual values of @s1 and @s2.
8744 * g_assert_cmpstr (mystring, ==, "fubar");
8753 * @n1: an unsigned integer
8754 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8755 * @n2: another unsigned integer
8757 * Debugging macro to terminate the application with a warning
8758 * message if an unsigned integer comparison fails.
8760 * The effect of <literal>g_assert_cmpuint (n1, op, n2)</literal> is
8761 * the same as <literal>g_assert (n1 op n2)</literal>. The advantage
8762 * of this macro is that it can produce a message that includes the
8763 * actual values of @n1 and @n2.
8771 * @err: a #GError, possibly %NULL
8772 * @dom: the expected error domain (a #GQuark)
8773 * @c: the expected error code
8775 * Debugging macro to terminate the application with a warning
8776 * message if a method has not returned the correct #GError.
8778 * The effect of <literal>g_assert_error (err, dom, c)</literal> is
8779 * the same as <literal>g_assert (err != NULL && err->domain
8780 * == dom && err->code == c)</literal>. The advantage of this
8781 * macro is that it can produce a message that includes the incorrect
8782 * error message and code.
8784 * This can only be used to test for a specific error. If you want to
8785 * test that @err is set, but don't care what it's set to, just use
8786 * <literal>g_assert (err != NULL)</literal>
8793 * g_assert_no_error:
8794 * @err: a #GError, possibly %NULL
8796 * Debugging macro to terminate the application with a warning
8797 * message if a method has returned a #GError.
8799 * The effect of <literal>g_assert_no_error (err)</literal> is
8800 * the same as <literal>g_assert (err == NULL)</literal>. The advantage
8801 * of this macro is that it can produce a message that includes
8802 * the error message and code.
8809 * g_assert_not_reached:
8811 * Debugging macro to terminate the application if it is ever
8812 * reached. If it is reached, an error message is logged and the
8813 * application is terminated.
8815 * The macro can be turned off in final releases of code by defining
8816 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8821 * g_async_queue_length:
8822 * @queue: a #GAsyncQueue.
8824 * Returns the length of the queue.
8826 * Actually this function returns the number of data items in
8827 * the queue minus the number of waiting threads, so a negative
8828 * value means waiting threads, and a positive value means available
8829 * entries in the @queue. A return value of 0 could mean n entries
8830 * in the queue and n threads waiting. This can happen due to locking
8831 * of the queue or due to scheduling.
8833 * Returns: the length of the @queue
8838 * g_async_queue_length_unlocked:
8839 * @queue: a #GAsyncQueue
8841 * Returns the length of the queue.
8843 * Actually this function returns the number of data items in
8844 * the queue minus the number of waiting threads, so a negative
8845 * value means waiting threads, and a positive value means available
8846 * entries in the @queue. A return value of 0 could mean n entries
8847 * in the queue and n threads waiting. This can happen due to locking
8848 * of the queue or due to scheduling.
8850 * This function must be called while holding the @queue's lock.
8852 * Returns: the length of the @queue.
8857 * g_async_queue_lock:
8858 * @queue: a #GAsyncQueue
8860 * Acquires the @queue's lock. If another thread is already
8861 * holding the lock, this call will block until the lock
8862 * becomes available.
8864 * Call g_async_queue_unlock() to drop the lock again.
8866 * While holding the lock, you can only call the
8867 * <function>g_async_queue_*_unlocked()</function> functions
8868 * on @queue. Otherwise, deadlock may occur.
8873 * g_async_queue_new:
8875 * Creates a new asynchronous queue.
8877 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8882 * g_async_queue_new_full:
8883 * @item_free_func: function to free queue elements
8885 * Creates a new asynchronous queue and sets up a destroy notify
8886 * function that is used to free any remaining queue items when
8887 * the queue is destroyed after the final unref.
8889 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8895 * g_async_queue_pop:
8896 * @queue: a #GAsyncQueue
8898 * Pops data from the @queue. If @queue is empty, this function
8899 * blocks until data becomes available.
8901 * Returns: data from the queue
8906 * g_async_queue_pop_unlocked:
8907 * @queue: a #GAsyncQueue
8909 * Pops data from the @queue. If @queue is empty, this function
8910 * blocks until data becomes available.
8912 * This function must be called while holding the @queue's lock.
8914 * Returns: data from the queue.
8919 * g_async_queue_push:
8920 * @queue: a #GAsyncQueue
8921 * @data: @data to push into the @queue
8923 * Pushes the @data into the @queue. @data must not be %NULL.
8928 * g_async_queue_push_sorted:
8929 * @queue: a #GAsyncQueue
8930 * @data: the @data to push into the @queue
8931 * @func: the #GCompareDataFunc is used to sort @queue
8932 * @user_data: user data passed to @func.
8934 * Inserts @data into @queue using @func to determine the new
8937 * This function requires that the @queue is sorted before pushing on
8938 * new elements, see g_async_queue_sort().
8940 * This function will lock @queue before it sorts the queue and unlock
8941 * it when it is finished.
8943 * For an example of @func see g_async_queue_sort().
8950 * g_async_queue_push_sorted_unlocked:
8951 * @queue: a #GAsyncQueue
8952 * @data: the @data to push into the @queue
8953 * @func: the #GCompareDataFunc is used to sort @queue
8954 * @user_data: user data passed to @func.
8956 * Inserts @data into @queue using @func to determine the new
8959 * The sort function @func is passed two elements of the @queue.
8960 * It should return 0 if they are equal, a negative value if the
8961 * first element should be higher in the @queue or a positive value
8962 * if the first element should be lower in the @queue than the second
8965 * This function requires that the @queue is sorted before pushing on
8966 * new elements, see g_async_queue_sort().
8968 * This function must be called while holding the @queue's lock.
8970 * For an example of @func see g_async_queue_sort().
8977 * g_async_queue_push_unlocked:
8978 * @queue: a #GAsyncQueue
8979 * @data: @data to push into the @queue
8981 * Pushes the @data into the @queue. @data must not be %NULL.
8983 * This function must be called while holding the @queue's lock.
8988 * g_async_queue_ref:
8989 * @queue: a #GAsyncQueue
8991 * Increases the reference count of the asynchronous @queue by 1.
8992 * You do not need to hold the lock to call this function.
8994 * Returns: the @queue that was passed in (since 2.6)
8999 * g_async_queue_ref_unlocked:
9000 * @queue: a #GAsyncQueue
9002 * Increases the reference count of the asynchronous @queue by 1.
9004 * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_ref() can be used regardless of the @queue's lock.
9009 * g_async_queue_sort:
9010 * @queue: a #GAsyncQueue
9011 * @func: the #GCompareDataFunc is used to sort @queue
9012 * @user_data: user data passed to @func
9014 * Sorts @queue using @func.
9016 * The sort function @func is passed two elements of the @queue.
9017 * It should return 0 if they are equal, a negative value if the
9018 * first element should be higher in the @queue or a positive value
9019 * if the first element should be lower in the @queue than the second
9022 * This function will lock @queue before it sorts the queue and unlock
9023 * it when it is finished.
9025 * If you were sorting a list of priority numbers to make sure the
9026 * lowest priority would be at the top of the queue, you could use:
9031 * id1 = GPOINTER_TO_INT (element1);
9032 * id2 = GPOINTER_TO_INT (element2);
9034 * return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
9042 * g_async_queue_sort_unlocked:
9043 * @queue: a #GAsyncQueue
9044 * @func: the #GCompareDataFunc is used to sort @queue
9045 * @user_data: user data passed to @func
9047 * Sorts @queue using @func.
9049 * The sort function @func is passed two elements of the @queue.
9050 * It should return 0 if they are equal, a negative value if the
9051 * first element should be higher in the @queue or a positive value
9052 * if the first element should be lower in the @queue than the second
9055 * This function must be called while holding the @queue's lock.
9062 * g_async_queue_timed_pop:
9063 * @queue: a #GAsyncQueue
9064 * @end_time: a #GTimeVal, determining the final time
9066 * Pops data from the @queue. If the queue is empty, blocks until
9067 * @end_time or until data becomes available.
9069 * If no data is received before @end_time, %NULL is returned.
9071 * To easily calculate @end_time, a combination of g_get_current_time()
9072 * and g_time_val_add() can be used.
9074 * Returns: data from the queue or %NULL, when no data is received before @end_time.
9075 * Deprecated: use g_async_queue_timeout_pop().
9080 * g_async_queue_timed_pop_unlocked:
9081 * @queue: a #GAsyncQueue
9082 * @end_time: a #GTimeVal, determining the final time
9084 * Pops data from the @queue. If the queue is empty, blocks until
9085 * @end_time or until data becomes available.
9087 * If no data is received before @end_time, %NULL is returned.
9089 * To easily calculate @end_time, a combination of g_get_current_time()
9090 * and g_time_val_add() can be used.
9092 * This function must be called while holding the @queue's lock.
9094 * Returns: data from the queue or %NULL, when no data is received before @end_time.
9095 * Deprecated: use g_async_queue_timeout_pop_unlocked().
9100 * g_async_queue_timeout_pop:
9101 * @queue: a #GAsyncQueue
9102 * @timeout: the number of microseconds to wait
9104 * Pops data from the @queue. If the queue is empty, blocks for
9105 * @timeout microseconds, or until data becomes available.
9107 * If no data is received before the timeout, %NULL is returned.
9109 * Returns: data from the queue or %NULL, when no data is received before the timeout.
9114 * g_async_queue_timeout_pop_unlocked:
9115 * @queue: a #GAsyncQueue
9116 * @timeout: the number of microseconds to wait
9118 * Pops data from the @queue. If the queue is empty, blocks for
9119 * @timeout microseconds, or until data becomes available.
9121 * If no data is received before the timeout, %NULL is returned.
9123 * This function must be called while holding the @queue's lock.
9125 * Returns: data from the queue or %NULL, when no data is received before the timeout.
9130 * g_async_queue_try_pop:
9131 * @queue: a #GAsyncQueue
9133 * Tries to pop data from the @queue. If no data is available,
9134 * %NULL is returned.
9136 * Returns: data from the queue or %NULL, when no data is available immediately.
9141 * g_async_queue_try_pop_unlocked:
9142 * @queue: a #GAsyncQueue
9144 * Tries to pop data from the @queue. If no data is available,
9145 * %NULL is returned.
9147 * This function must be called while holding the @queue's lock.
9149 * Returns: data from the queue or %NULL, when no data is available immediately.
9154 * g_async_queue_unlock:
9155 * @queue: a #GAsyncQueue
9157 * Releases the queue's lock.
9159 * Calling this function when you have not acquired
9160 * the with g_async_queue_lock() leads to undefined
9166 * g_async_queue_unref:
9167 * @queue: a #GAsyncQueue.
9169 * Decreases the reference count of the asynchronous @queue by 1.
9171 * If the reference count went to 0, the @queue will be destroyed
9172 * and the memory allocated will be freed. So you are not allowed
9173 * to use the @queue afterwards, as it might have disappeared.
9174 * You do not need to hold the lock to call this function.
9179 * g_async_queue_unref_and_unlock:
9180 * @queue: a #GAsyncQueue
9182 * Decreases the reference count of the asynchronous @queue by 1
9183 * and releases the lock. This function must be called while holding
9184 * the @queue's lock. If the reference count went to 0, the @queue
9185 * will be destroyed and the memory allocated will be freed.
9187 * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_unref() can be used regardless of the @queue's lock.
9193 * @func: (scope async): the function to call on normal program termination.
9195 * Specifies a function to be called at normal program termination.
9197 * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
9198 * macro that maps to a call to the atexit() function in the C
9199 * library. This means that in case the code that calls g_atexit(),
9200 * i.e. atexit(), is in a DLL, the function will be called when the
9201 * DLL is detached from the program. This typically makes more sense
9202 * than that the function is called when the GLib DLL is detached,
9203 * which happened earlier when g_atexit() was a function in the GLib
9206 * The behaviour of atexit() in the context of dynamically loaded
9207 * modules is not formally specified and varies wildly.
9209 * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
9210 * loaded module which is unloaded before the program terminates might
9211 * well cause a crash at program exit.
9213 * Some POSIX systems implement atexit() like Windows, and have each
9214 * dynamically loaded module maintain an own atexit chain that is
9215 * called when the module is unloaded.
9217 * On other POSIX systems, before a dynamically loaded module is
9218 * unloaded, the registered atexit functions (if any) residing in that
9219 * module are called, regardless where the code that registered them
9220 * resided. This is presumably the most robust approach.
9222 * As can be seen from the above, for portability it's best to avoid
9223 * calling g_atexit() (or atexit()) except in the main executable of a
9226 * Deprecated: 2.32: It is best to avoid g_atexit().
9232 * @atomic: a pointer to a #gint or #guint
9233 * @val: the value to add
9235 * Atomically adds @val to the value of @atomic.
9237 * Think of this operation as an atomic version of
9238 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9240 * This call acts as a full compiler and hardware memory barrier.
9242 * Before version 2.30, this function did not return a value
9243 * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
9245 * Returns: the value of @atomic before the add, signed
9252 * @atomic: a pointer to a #gint or #guint
9253 * @val: the value to 'and'
9255 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9256 * storing the result back in @atomic.
9258 * This call acts as a full compiler and hardware memory barrier.
9260 * Think of this operation as an atomic version of
9261 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9263 * Returns: the value of @atomic before the operation, unsigned
9269 * g_atomic_int_compare_and_exchange:
9270 * @atomic: a pointer to a #gint or #guint
9271 * @oldval: the value to compare with
9272 * @newval: the value to conditionally replace with
9274 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9275 * If @atomic was not equal to @oldval then no change occurs.
9277 * This compare and exchange is done atomically.
9279 * Think of this operation as an atomic version of
9280 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9282 * This call acts as a full compiler and hardware memory barrier.
9284 * Returns: %TRUE if the exchange took place
9290 * g_atomic_int_dec_and_test:
9291 * @atomic: a pointer to a #gint or #guint
9293 * Decrements the value of @atomic by 1.
9295 * Think of this operation as an atomic version of
9296 * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
9298 * This call acts as a full compiler and hardware memory barrier.
9300 * Returns: %TRUE if the resultant value is zero
9306 * g_atomic_int_exchange_and_add:
9307 * @atomic: a pointer to a #gint
9308 * @val: the value to add
9310 * This function existed before g_atomic_int_add() returned the prior
9311 * value of the integer (which it now does). It is retained only for
9312 * compatibility reasons. Don't use this function in new code.
9314 * Returns: the value of @atomic before the add, signed
9316 * Deprecated: 2.30: Use g_atomic_int_add() instead.
9322 * @atomic: a pointer to a #gint or #guint
9324 * Gets the current value of @atomic.
9326 * This call acts as a full compiler and hardware
9327 * memory barrier (before the get).
9329 * Returns: the value of the integer
9336 * @atomic: a pointer to a #gint or #guint
9338 * Increments the value of @atomic by 1.
9340 * Think of this operation as an atomic version of
9341 * <literal>{ *@atomic += 1; }</literal>
9343 * This call acts as a full compiler and hardware memory barrier.
9351 * @atomic: a pointer to a #gint or #guint
9352 * @val: the value to 'or'
9354 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9355 * storing the result back in @atomic.
9357 * Think of this operation as an atomic version of
9358 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9360 * This call acts as a full compiler and hardware memory barrier.
9362 * Returns: the value of @atomic before the operation, unsigned
9369 * @atomic: a pointer to a #gint or #guint
9370 * @newval: a new value to store
9372 * Sets the value of @atomic to @newval.
9374 * This call acts as a full compiler and hardware
9375 * memory barrier (after the set).
9383 * @atomic: a pointer to a #gint or #guint
9384 * @val: the value to 'xor'
9386 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9387 * storing the result back in @atomic.
9389 * Think of this operation as an atomic version of
9390 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9392 * This call acts as a full compiler and hardware memory barrier.
9394 * Returns: the value of @atomic before the operation, unsigned
9400 * g_atomic_pointer_add:
9401 * @atomic: a pointer to a #gpointer-sized value
9402 * @val: the value to add
9404 * Atomically adds @val to the value of @atomic.
9406 * Think of this operation as an atomic version of
9407 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9409 * This call acts as a full compiler and hardware memory barrier.
9411 * Returns: the value of @atomic before the add, signed
9417 * g_atomic_pointer_and:
9418 * @atomic: a pointer to a #gpointer-sized value
9419 * @val: the value to 'and'
9421 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9422 * storing the result back in @atomic.
9424 * Think of this operation as an atomic version of
9425 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9427 * This call acts as a full compiler and hardware memory barrier.
9429 * Returns: the value of @atomic before the operation, unsigned
9435 * g_atomic_pointer_compare_and_exchange:
9436 * @atomic: a pointer to a #gpointer-sized value
9437 * @oldval: the value to compare with
9438 * @newval: the value to conditionally replace with
9440 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9441 * If @atomic was not equal to @oldval then no change occurs.
9443 * This compare and exchange is done atomically.
9445 * Think of this operation as an atomic version of
9446 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9448 * This call acts as a full compiler and hardware memory barrier.
9450 * Returns: %TRUE if the exchange took place
9456 * g_atomic_pointer_get:
9457 * @atomic: a pointer to a #gpointer-sized value
9459 * Gets the current value of @atomic.
9461 * This call acts as a full compiler and hardware
9462 * memory barrier (before the get).
9464 * Returns: the value of the pointer
9470 * g_atomic_pointer_or:
9471 * @atomic: a pointer to a #gpointer-sized value
9472 * @val: the value to 'or'
9474 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9475 * storing the result back in @atomic.
9477 * Think of this operation as an atomic version of
9478 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9480 * This call acts as a full compiler and hardware memory barrier.
9482 * Returns: the value of @atomic before the operation, unsigned
9488 * g_atomic_pointer_set:
9489 * @atomic: a pointer to a #gpointer-sized value
9490 * @newval: a new value to store
9492 * Sets the value of @atomic to @newval.
9494 * This call acts as a full compiler and hardware
9495 * memory barrier (after the set).
9502 * g_atomic_pointer_xor:
9503 * @atomic: a pointer to a #gpointer-sized value
9504 * @val: the value to 'xor'
9506 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9507 * storing the result back in @atomic.
9509 * Think of this operation as an atomic version of
9510 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9512 * This call acts as a full compiler and hardware memory barrier.
9514 * Returns: the value of @atomic before the operation, unsigned
9521 * @text: zero-terminated string with base64 text to decode
9522 * @out_len: (out): The length of the decoded data is written here
9524 * Decode a sequence of Base-64 encoded text into binary data
9526 * Returns: (transfer full) (array length=out_len) (element-type guint8): newly allocated buffer containing the binary data that @text represents. The returned buffer must be freed with g_free().
9532 * g_base64_decode_inplace:
9533 * @text: (inout) (array length=out_len) (element-type guint8): zero-terminated string with base64 text to decode
9534 * @out_len: (inout): The length of the decoded data is written here
9536 * Decode a sequence of Base-64 encoded text into binary data
9537 * by overwriting the input data.
9539 * Returns: (transfer none): The binary data that @text responds. This pointer is the same as the input @text.
9545 * g_base64_decode_step:
9546 * @in: (array length=len) (element-type guint8): binary input data
9547 * @len: max length of @in data to decode
9548 * @out: (out) (array) (element-type guint8): output buffer
9549 * @state: (inout): Saved state between steps, initialize to 0
9550 * @save: (inout): Saved state between steps, initialize to 0
9552 * Incrementally decode a sequence of binary data from its Base-64 stringified
9553 * representation. By calling this function multiple times you can convert
9554 * data in chunks to avoid having to have the full encoded data in memory.
9556 * The output buffer must be large enough to fit all the data that will
9557 * be written to it. Since base64 encodes 3 bytes in 4 chars you need
9558 * at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
9561 * Returns: The number of bytes of output that was written
9568 * @data: (array length=len) (element-type guint8): the binary data to encode
9569 * @len: the length of @data
9571 * Encode a sequence of binary data into its Base-64 stringified
9574 * Returns: (transfer full): a newly allocated, zero-terminated Base-64 encoded string representing @data. The returned string must be freed with g_free().
9580 * g_base64_encode_close:
9581 * @break_lines: whether to break long lines
9582 * @out: (out) (array) (element-type guint8): pointer to destination buffer
9583 * @state: (inout): Saved state from g_base64_encode_step()
9584 * @save: (inout): Saved state from g_base64_encode_step()
9586 * Flush the status from a sequence of calls to g_base64_encode_step().
9588 * The output buffer must be large enough to fit all the data that will
9589 * be written to it. It will need up to 4 bytes, or up to 5 bytes if
9590 * line-breaking is enabled.
9592 * Returns: The number of bytes of output that was written
9598 * g_base64_encode_step:
9599 * @in: (array length=len) (element-type guint8): the binary data to encode
9600 * @len: the length of @in
9601 * @break_lines: whether to break long lines
9602 * @out: (out) (array) (element-type guint8): pointer to destination buffer
9603 * @state: (inout): Saved state between steps, initialize to 0
9604 * @save: (inout): Saved state between steps, initialize to 0
9606 * Incrementally encode a sequence of binary data into its Base-64 stringified
9607 * representation. By calling this function multiple times you can convert
9608 * data in chunks to avoid having to have the full encoded data in memory.
9610 * When all of the data has been converted you must call
9611 * g_base64_encode_close() to flush the saved state.
9613 * The output buffer must be large enough to fit all the data that will
9614 * be written to it. Due to the way base64 encodes you will need
9615 * at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
9616 * non-zero state). If you enable line-breaking you will need at least:
9617 * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
9619 * @break_lines is typically used when putting base64-encoded data in emails.
9620 * It breaks the lines at 72 columns instead of putting all of the text on
9621 * the same line. This avoids problems with long lines in the email system.
9622 * Note however that it breaks the lines with <literal>LF</literal>
9623 * characters, not <literal>CR LF</literal> sequences, so the result cannot
9624 * be passed directly to SMTP or certain other protocols.
9626 * Returns: The number of bytes of output that was written
9633 * @file_name: the name of the file
9635 * Gets the name of the file without any leading directory
9636 * components. It returns a pointer into the given file name
9639 * Returns: the name of the file without any leading directory components
9640 * Deprecated: 2.2: Use g_path_get_basename() instead, but notice that g_path_get_basename() allocates new memory for the returned string, unlike this function which returns a pointer into the argument.
9646 * @address: a pointer to an integer
9647 * @lock_bit: a bit value between 0 and 31
9649 * Sets the indicated @lock_bit in @address. If the bit is already
9650 * set, this call will block until g_bit_unlock() unsets the
9651 * corresponding bit.
9653 * Attempting to lock on two different bits within the same integer is
9654 * not supported and will very probably cause deadlocks.
9656 * The value of the bit that is set is (1u << @bit). If @bit is not
9657 * between 0 and 31 then the result is undefined.
9659 * This function accesses @address atomically. All other accesses to
9660 * @address must be atomic in order for this function to work
9669 * @mask: a #gulong containing flags
9670 * @nth_bit: the index of the bit to start the search from
9672 * Find the position of the first bit set in @mask, searching
9673 * from (but not including) @nth_bit upwards. Bits are numbered
9674 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9675 * usually). To start searching from the 0th bit, set @nth_bit to -1.
9677 * Returns: the index of the first bit set which is higher than @nth_bit
9683 * @mask: a #gulong containing flags
9684 * @nth_bit: the index of the bit to start the search from
9686 * Find the position of the first bit set in @mask, searching
9687 * from (but not including) @nth_bit downwards. Bits are numbered
9688 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9689 * usually). To start searching from the last bit, set @nth_bit to
9690 * -1 or GLIB_SIZEOF_LONG * 8.
9692 * Returns: the index of the first bit set which is lower than @nth_bit
9700 * Gets the number of bits used to hold @number,
9701 * e.g. if @number is 4, 3 bits are needed.
9703 * Returns: the number of bits used to hold @number
9709 * @address: a pointer to an integer
9710 * @lock_bit: a bit value between 0 and 31
9712 * Sets the indicated @lock_bit in @address, returning %TRUE if
9713 * successful. If the bit is already set, returns %FALSE immediately.
9715 * Attempting to lock on two different bits within the same integer is
9718 * The value of the bit that is set is (1u << @bit). If @bit is not
9719 * between 0 and 31 then the result is undefined.
9721 * This function accesses @address atomically. All other accesses to
9722 * @address must be atomic in order for this function to work
9725 * Returns: %TRUE if the lock was acquired
9732 * @address: a pointer to an integer
9733 * @lock_bit: a bit value between 0 and 31
9735 * Clears the indicated @lock_bit in @address. If another thread is
9736 * currently blocked in g_bit_lock() on this same bit then it will be
9739 * This function accesses @address atomically. All other accesses to
9740 * @address must be atomic in order for this function to work
9748 * g_bookmark_file_add_application:
9749 * @bookmark: a #GBookmarkFile
9751 * @name: (allow-none): the name of the application registering the bookmark or %NULL
9752 * @exec: (allow-none): command line to be used to launch the bookmark or %NULL
9754 * Adds the application with @name and @exec to the list of
9755 * applications that have registered a bookmark for @uri into
9758 * Every bookmark inside a #GBookmarkFile must have at least an
9759 * application registered. Each application must provide a name, a
9760 * command line useful for launching the bookmark, the number of times
9761 * the bookmark has been registered by the application and the last
9762 * time the application registered this bookmark.
9764 * If @name is %NULL, the name of the application will be the
9765 * same returned by g_get_application_name(); if @exec is %NULL, the
9766 * command line will be a composition of the program name as
9767 * returned by g_get_prgname() and the "\%u" modifier, which will be
9768 * expanded to the bookmark's URI.
9770 * This function will automatically take care of updating the
9771 * registrations count and timestamping in case an application
9772 * with the same @name had already registered a bookmark for
9773 * @uri inside @bookmark.
9775 * If no bookmark for @uri is found, one is created.
9782 * g_bookmark_file_add_group:
9783 * @bookmark: a #GBookmarkFile
9785 * @group: the group name to be added
9787 * Adds @group to the list of groups to which the bookmark for @uri
9790 * If no bookmark for @uri is found then it is created.
9797 * g_bookmark_file_free:
9798 * @bookmark: a #GBookmarkFile
9800 * Frees a #GBookmarkFile.
9807 * g_bookmark_file_get_added:
9808 * @bookmark: a #GBookmarkFile
9810 * @error: return location for a #GError, or %NULL
9812 * Gets the time the bookmark for @uri was added to @bookmark
9814 * In the event the URI cannot be found, -1 is returned and
9815 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9817 * Returns: a timestamp
9823 * g_bookmark_file_get_app_info:
9824 * @bookmark: a #GBookmarkFile
9826 * @name: an application's name
9827 * @exec: (allow-none): location for the command line of the application, or %NULL
9828 * @count: (allow-none): return location for the registration count, or %NULL
9829 * @stamp: (allow-none): return location for the last registration time, or %NULL
9830 * @error: return location for a #GError, or %NULL
9832 * Gets the registration informations of @app_name for the bookmark for
9833 * @uri. See g_bookmark_file_set_app_info() for more informations about
9834 * the returned data.
9836 * The string returned in @app_exec must be freed.
9838 * In the event the URI cannot be found, %FALSE is returned and
9839 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
9840 * event that no application with name @app_name has registered a bookmark
9841 * for @uri, %FALSE is returned and error is set to
9842 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
9843 * the command line fails, an error of the #G_SHELL_ERROR domain is
9844 * set and %FALSE is returned.
9846 * Returns: %TRUE on success.
9852 * g_bookmark_file_get_applications:
9853 * @bookmark: a #GBookmarkFile
9855 * @length: (allow-none): return location of the length of the returned list, or %NULL
9856 * @error: return location for a #GError, or %NULL
9858 * Retrieves the names of the applications that have registered the
9859 * bookmark for @uri.
9861 * In the event the URI cannot be found, %NULL is returned and
9862 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9864 * Returns: a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
9870 * g_bookmark_file_get_description:
9871 * @bookmark: a #GBookmarkFile
9873 * @error: return location for a #GError, or %NULL
9875 * Retrieves the description of the bookmark for @uri.
9877 * In the event the URI cannot be found, %NULL is returned and
9878 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9880 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
9886 * g_bookmark_file_get_groups:
9887 * @bookmark: a #GBookmarkFile
9889 * @length: (allow-none): return location for the length of the returned string, or %NULL
9890 * @error: return location for a #GError, or %NULL
9892 * Retrieves the list of group names of the bookmark for @uri.
9894 * In the event the URI cannot be found, %NULL is returned and
9895 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9897 * The returned array is %NULL terminated, so @length may optionally
9900 * Returns: a newly allocated %NULL-terminated array of group names. Use g_strfreev() to free it.
9906 * g_bookmark_file_get_icon:
9907 * @bookmark: a #GBookmarkFile
9909 * @href: (allow-none): return location for the icon's location or %NULL
9910 * @mime_type: (allow-none): return location for the icon's MIME type or %NULL
9911 * @error: return location for a #GError or %NULL
9913 * Gets the icon of the bookmark for @uri.
9915 * In the event the URI cannot be found, %FALSE is returned and
9916 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9918 * Returns: %TRUE if the icon for the bookmark for the URI was found. You should free the returned strings.
9924 * g_bookmark_file_get_is_private:
9925 * @bookmark: a #GBookmarkFile
9927 * @error: return location for a #GError, or %NULL
9929 * Gets whether the private flag of the bookmark for @uri is set.
9931 * In the event the URI cannot be found, %FALSE is returned and
9932 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
9933 * event that the private flag cannot be found, %FALSE is returned and
9934 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
9936 * Returns: %TRUE if the private flag is set, %FALSE otherwise.
9942 * g_bookmark_file_get_mime_type:
9943 * @bookmark: a #GBookmarkFile
9945 * @error: return location for a #GError, or %NULL
9947 * Retrieves the MIME type of the resource pointed by @uri.
9949 * In the event the URI cannot be found, %NULL is returned and
9950 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
9951 * event that the MIME type cannot be found, %NULL is returned and
9952 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
9954 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
9960 * g_bookmark_file_get_modified:
9961 * @bookmark: a #GBookmarkFile
9963 * @error: return location for a #GError, or %NULL
9965 * Gets the time when the bookmark for @uri was last modified.
9967 * In the event the URI cannot be found, -1 is returned and
9968 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9970 * Returns: a timestamp
9976 * g_bookmark_file_get_size:
9977 * @bookmark: a #GBookmarkFile
9979 * Gets the number of bookmarks inside @bookmark.
9981 * Returns: the number of bookmarks
9987 * g_bookmark_file_get_title:
9988 * @bookmark: a #GBookmarkFile
9989 * @uri: (allow-none): a valid URI or %NULL
9990 * @error: return location for a #GError, or %NULL
9992 * Returns the title of the bookmark for @uri.
9994 * If @uri is %NULL, the title of @bookmark is returned.
9996 * In the event the URI cannot be found, %NULL is returned and
9997 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9999 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
10005 * g_bookmark_file_get_uris:
10006 * @bookmark: a #GBookmarkFile
10007 * @length: (allow-none): return location for the number of returned URIs, or %NULL
10009 * Returns all URIs of the bookmarks in the bookmark file @bookmark.
10010 * The array of returned URIs will be %NULL-terminated, so @length may
10011 * optionally be %NULL.
10013 * Returns: a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
10019 * g_bookmark_file_get_visited:
10020 * @bookmark: a #GBookmarkFile
10021 * @uri: a valid URI
10022 * @error: return location for a #GError, or %NULL
10024 * Gets the time the bookmark for @uri was last visited.
10026 * In the event the URI cannot be found, -1 is returned and
10027 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10029 * Returns: a timestamp.
10035 * g_bookmark_file_has_application:
10036 * @bookmark: a #GBookmarkFile
10037 * @uri: a valid URI
10038 * @name: the name of the application
10039 * @error: return location for a #GError or %NULL
10041 * Checks whether the bookmark for @uri inside @bookmark has been
10042 * registered by application @name.
10044 * In the event the URI cannot be found, %FALSE is returned and
10045 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10047 * Returns: %TRUE if the application @name was found
10053 * g_bookmark_file_has_group:
10054 * @bookmark: a #GBookmarkFile
10055 * @uri: a valid URI
10056 * @group: the group name to be searched
10057 * @error: return location for a #GError, or %NULL
10059 * Checks whether @group appears in the list of groups to which
10060 * the bookmark for @uri belongs to.
10062 * In the event the URI cannot be found, %FALSE is returned and
10063 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10065 * Returns: %TRUE if @group was found.
10071 * g_bookmark_file_has_item:
10072 * @bookmark: a #GBookmarkFile
10073 * @uri: a valid URI
10075 * Looks whether the desktop bookmark has an item with its URI set to @uri.
10077 * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise
10083 * g_bookmark_file_load_from_data:
10084 * @bookmark: an empty #GBookmarkFile struct
10085 * @data: desktop bookmarks loaded in memory
10086 * @length: the length of @data in bytes
10087 * @error: return location for a #GError, or %NULL
10089 * Loads a bookmark file from memory into an empty #GBookmarkFile
10090 * structure. If the object cannot be created then @error is set to a
10091 * #GBookmarkFileError.
10093 * Returns: %TRUE if a desktop bookmark could be loaded.
10099 * g_bookmark_file_load_from_data_dirs:
10100 * @bookmark: a #GBookmarkFile
10101 * @file: a relative path to a filename to open and parse
10102 * @full_path: (allow-none): return location for a string containing the full path of the file, or %NULL
10103 * @error: return location for a #GError, or %NULL
10105 * This function looks for a desktop bookmark file named @file in the
10106 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
10107 * loads the file into @bookmark and returns the file's full path in
10108 * @full_path. If the file could not be loaded then an %error is
10109 * set to either a #GFileError or #GBookmarkFileError.
10111 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
10117 * g_bookmark_file_load_from_file:
10118 * @bookmark: an empty #GBookmarkFile struct
10119 * @filename: the path of a filename to load, in the GLib file name encoding
10120 * @error: return location for a #GError, or %NULL
10122 * Loads a desktop bookmark file into an empty #GBookmarkFile structure.
10123 * If the file could not be loaded then @error is set to either a #GFileError
10124 * or #GBookmarkFileError.
10126 * Returns: %TRUE if a desktop bookmark file could be loaded
10132 * g_bookmark_file_move_item:
10133 * @bookmark: a #GBookmarkFile
10134 * @old_uri: a valid URI
10135 * @new_uri: (allow-none): a valid URI, or %NULL
10136 * @error: return location for a #GError or %NULL
10138 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any
10139 * existing bookmark for @new_uri will be overwritten. If @new_uri is
10140 * %NULL, then the bookmark is removed.
10142 * In the event the URI cannot be found, %FALSE is returned and
10143 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10145 * Returns: %TRUE if the URI was successfully changed
10151 * g_bookmark_file_new:
10153 * Creates a new empty #GBookmarkFile object.
10155 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
10156 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
10159 * Returns: an empty #GBookmarkFile
10165 * g_bookmark_file_remove_application:
10166 * @bookmark: a #GBookmarkFile
10167 * @uri: a valid URI
10168 * @name: the name of the application
10169 * @error: return location for a #GError or %NULL
10171 * Removes application registered with @name from the list of applications
10172 * that have registered a bookmark for @uri inside @bookmark.
10174 * In the event the URI cannot be found, %FALSE is returned and
10175 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10176 * In the event that no application with name @app_name has registered
10177 * a bookmark for @uri, %FALSE is returned and error is set to
10178 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
10180 * Returns: %TRUE if the application was successfully removed.
10186 * g_bookmark_file_remove_group:
10187 * @bookmark: a #GBookmarkFile
10188 * @uri: a valid URI
10189 * @group: the group name to be removed
10190 * @error: return location for a #GError, or %NULL
10192 * Removes @group from the list of groups to which the bookmark
10193 * for @uri belongs to.
10195 * In the event the URI cannot be found, %FALSE is returned and
10196 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10197 * In the event no group was defined, %FALSE is returned and
10198 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10200 * Returns: %TRUE if @group was successfully removed.
10206 * g_bookmark_file_remove_item:
10207 * @bookmark: a #GBookmarkFile
10208 * @uri: a valid URI
10209 * @error: return location for a #GError, or %NULL
10211 * Removes the bookmark for @uri from the bookmark file @bookmark.
10213 * Returns: %TRUE if the bookmark was removed successfully.
10219 * g_bookmark_file_set_added:
10220 * @bookmark: a #GBookmarkFile
10221 * @uri: a valid URI
10222 * @added: a timestamp or -1 to use the current time
10224 * Sets the time the bookmark for @uri was added into @bookmark.
10226 * If no bookmark for @uri is found then it is created.
10233 * g_bookmark_file_set_app_info:
10234 * @bookmark: a #GBookmarkFile
10235 * @uri: a valid URI
10236 * @name: an application's name
10237 * @exec: an application's command line
10238 * @count: the number of registrations done for this application
10239 * @stamp: the time of the last registration for this application
10240 * @error: return location for a #GError or %NULL
10242 * Sets the meta-data of application @name inside the list of
10243 * applications that have registered a bookmark for @uri inside
10246 * You should rarely use this function; use g_bookmark_file_add_application()
10247 * and g_bookmark_file_remove_application() instead.
10249 * @name can be any UTF-8 encoded string used to identify an
10251 * @exec can have one of these two modifiers: "\%f", which will
10252 * be expanded as the local file name retrieved from the bookmark's
10253 * URI; "\%u", which will be expanded as the bookmark's URI.
10254 * The expansion is done automatically when retrieving the stored
10255 * command line using the g_bookmark_file_get_app_info() function.
10256 * @count is the number of times the application has registered the
10257 * bookmark; if is < 0, the current registration count will be increased
10258 * by one, if is 0, the application with @name will be removed from
10259 * the list of registered applications.
10260 * @stamp is the Unix time of the last registration; if it is -1, the
10261 * current time will be used.
10263 * If you try to remove an application by setting its registration count to
10264 * zero, and no bookmark for @uri is found, %FALSE is returned and
10265 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
10266 * in the event that no application @name has registered a bookmark
10267 * for @uri, %FALSE is returned and error is set to
10268 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
10269 * for @uri is found, one is created.
10271 * Returns: %TRUE if the application's meta-data was successfully changed.
10277 * g_bookmark_file_set_description:
10278 * @bookmark: a #GBookmarkFile
10279 * @uri: (allow-none): a valid URI or %NULL
10280 * @description: a string
10282 * Sets @description as the description of the bookmark for @uri.
10284 * If @uri is %NULL, the description of @bookmark is set.
10286 * If a bookmark for @uri cannot be found then it is created.
10293 * g_bookmark_file_set_groups:
10294 * @bookmark: a #GBookmarkFile
10295 * @uri: an item's URI
10296 * @groups: (allow-none): an array of group names, or %NULL to remove all groups
10297 * @length: number of group name values in @groups
10299 * Sets a list of group names for the item with URI @uri. Each previously
10300 * set group name list is removed.
10302 * If @uri cannot be found then an item for it is created.
10309 * g_bookmark_file_set_icon:
10310 * @bookmark: a #GBookmarkFile
10311 * @uri: a valid URI
10312 * @href: (allow-none): the URI of the icon for the bookmark, or %NULL
10313 * @mime_type: the MIME type of the icon for the bookmark
10315 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
10316 * the currently set icon. @href can either be a full URL for the icon
10317 * file or the icon name following the Icon Naming specification.
10319 * If no bookmark for @uri is found one is created.
10326 * g_bookmark_file_set_is_private:
10327 * @bookmark: a #GBookmarkFile
10328 * @uri: a valid URI
10329 * @is_private: %TRUE if the bookmark should be marked as private
10331 * Sets the private flag of the bookmark for @uri.
10333 * If a bookmark for @uri cannot be found then it is created.
10340 * g_bookmark_file_set_mime_type:
10341 * @bookmark: a #GBookmarkFile
10342 * @uri: a valid URI
10343 * @mime_type: a MIME type
10345 * Sets @mime_type as the MIME type of the bookmark for @uri.
10347 * If a bookmark for @uri cannot be found then it is created.
10354 * g_bookmark_file_set_modified:
10355 * @bookmark: a #GBookmarkFile
10356 * @uri: a valid URI
10357 * @modified: a timestamp or -1 to use the current time
10359 * Sets the last time the bookmark for @uri was last modified.
10361 * If no bookmark for @uri is found then it is created.
10363 * The "modified" time should only be set when the bookmark's meta-data
10364 * was actually changed. Every function of #GBookmarkFile that
10365 * modifies a bookmark also changes the modification time, except for
10366 * g_bookmark_file_set_visited().
10373 * g_bookmark_file_set_title:
10374 * @bookmark: a #GBookmarkFile
10375 * @uri: (allow-none): a valid URI or %NULL
10376 * @title: a UTF-8 encoded string
10378 * Sets @title as the title of the bookmark for @uri inside the
10379 * bookmark file @bookmark.
10381 * If @uri is %NULL, the title of @bookmark is set.
10383 * If a bookmark for @uri cannot be found then it is created.
10390 * g_bookmark_file_set_visited:
10391 * @bookmark: a #GBookmarkFile
10392 * @uri: a valid URI
10393 * @visited: a timestamp or -1 to use the current time
10395 * Sets the time the bookmark for @uri was last visited.
10397 * If no bookmark for @uri is found then it is created.
10399 * The "visited" time should only be set if the bookmark was launched,
10400 * either using the command line retrieved by g_bookmark_file_get_app_info()
10401 * or by the default application for the bookmark's MIME type, retrieved
10402 * using g_bookmark_file_get_mime_type(). Changing the "visited" time
10403 * does not affect the "modified" time.
10410 * g_bookmark_file_to_data:
10411 * @bookmark: a #GBookmarkFile
10412 * @length: (allow-none): return location for the length of the returned string, or %NULL
10413 * @error: return location for a #GError, or %NULL
10415 * This function outputs @bookmark as a string.
10417 * Returns: a newly allocated string holding the contents of the #GBookmarkFile
10423 * g_bookmark_file_to_file:
10424 * @bookmark: a #GBookmarkFile
10425 * @filename: path of the output file
10426 * @error: return location for a #GError, or %NULL
10428 * This function outputs @bookmark into a file. The write process is
10429 * guaranteed to be atomic by using g_file_set_contents() internally.
10431 * Returns: %TRUE if the file was successfully written.
10437 * g_build_filename:
10438 * @first_element: the first element in the path
10439 * @...: remaining elements in path, terminated by %NULL
10441 * Creates a filename from a series of elements using the correct
10442 * separator for filenames.
10444 * On Unix, this function behaves identically to <literal>g_build_path
10445 * (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
10447 * On Windows, it takes into account that either the backslash
10448 * (<literal>\</literal> or slash (<literal>/</literal>) can be used
10449 * as separator in filenames, but otherwise behaves as on Unix. When
10450 * file pathname separators need to be inserted, the one that last
10451 * previously occurred in the parameters (reading from left to right)
10454 * No attempt is made to force the resulting filename to be an absolute
10455 * path. If the first element is a relative path, the result will
10456 * be a relative path.
10458 * Returns: a newly-allocated string that must be freed with g_free().
10463 * g_build_filenamev:
10464 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10466 * Behaves exactly like g_build_filename(), but takes the path elements
10467 * as a string array, instead of varargs. This function is mainly
10468 * meant for language bindings.
10470 * Returns: a newly-allocated string that must be freed with g_free().
10477 * @separator: a string used to separator the elements of the path.
10478 * @first_element: the first element in the path
10479 * @...: remaining elements in path, terminated by %NULL
10481 * Creates a path from a series of elements using @separator as the
10482 * separator between elements. At the boundary between two elements,
10483 * any trailing occurrences of separator in the first element, or
10484 * leading occurrences of separator in the second element are removed
10485 * and exactly one copy of the separator is inserted.
10487 * Empty elements are ignored.
10489 * The number of leading copies of the separator on the result is
10490 * the same as the number of leading copies of the separator on
10491 * the first non-empty element.
10493 * The number of trailing copies of the separator on the result is
10494 * the same as the number of trailing copies of the separator on
10495 * the last non-empty element. (Determination of the number of
10496 * trailing copies is done without stripping leading copies, so
10497 * if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
10498 * has 1 trailing copy.)
10500 * However, if there is only a single non-empty element, and there
10501 * are no characters in that element not part of the leading or
10502 * trailing separators, then the result is exactly the original value
10505 * Other than for determination of the number of leading and trailing
10506 * copies of the separator, elements consisting only of copies
10507 * of the separator are ignored.
10509 * Returns: a newly-allocated string that must be freed with g_free().
10515 * @separator: a string used to separator the elements of the path.
10516 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10518 * Behaves exactly like g_build_path(), but takes the path elements
10519 * as a string array, instead of varargs. This function is mainly
10520 * meant for language bindings.
10522 * Returns: a newly-allocated string that must be freed with g_free().
10528 * g_byte_array_append:
10529 * @array: a #GByteArray.
10530 * @data: the byte data to be added.
10531 * @len: the number of bytes to add.
10533 * Adds the given bytes to the end of the #GByteArray. The array will
10534 * grow in size automatically if necessary.
10536 * Returns: the #GByteArray.
10541 * g_byte_array_free:
10542 * @array: a #GByteArray.
10543 * @free_segment: if %TRUE the actual byte data is freed as well.
10545 * Frees the memory allocated by the #GByteArray. If @free_segment is
10546 * %TRUE it frees the actual byte data. If the reference count of
10547 * @array is greater than one, the #GByteArray wrapper is preserved but
10548 * the size of @array will be set to zero.
10550 * Returns: the element data if @free_segment is %FALSE, otherwise %NULL. The element data should be freed using g_free().
10555 * g_byte_array_free_to_bytes:
10556 * @array: (transfer full): a #GByteArray
10558 * Transfers the data from the #GByteArray into a new immutable #GBytes.
10560 * The #GByteArray is freed unless the reference count of @array is greater
10561 * than one, the #GByteArray wrapper is preserved but the size of @array
10562 * will be set to zero.
10564 * This is identical to using g_bytes_new_take() and g_byte_array_free()
10568 * Returns: (transfer full): a new immutable #GBytes representing same byte data that was in the array
10573 * g_byte_array_new:
10575 * Creates a new #GByteArray with a reference count of 1.
10577 * Returns: the new #GByteArray.
10582 * g_byte_array_new_take:
10583 * @data: (array length=len): byte data for the array
10584 * @len: length of @data
10586 * Create byte array containing the data. The data will be owned by the array
10587 * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
10590 * Returns: (transfer full): a new #GByteArray
10595 * g_byte_array_prepend:
10596 * @array: a #GByteArray.
10597 * @data: the byte data to be added.
10598 * @len: the number of bytes to add.
10600 * Adds the given data to the start of the #GByteArray. The array will
10601 * grow in size automatically if necessary.
10603 * Returns: the #GByteArray.
10608 * g_byte_array_ref:
10609 * @array: A #GByteArray.
10611 * Atomically increments the reference count of @array by one. This
10612 * function is MT-safe and may be called from any thread.
10614 * Returns: The passed in #GByteArray.
10620 * g_byte_array_remove_index:
10621 * @array: a #GByteArray.
10622 * @index_: the index of the byte to remove.
10624 * Removes the byte at the given index from a #GByteArray. The
10625 * following bytes are moved down one place.
10627 * Returns: the #GByteArray.
10632 * g_byte_array_remove_index_fast:
10633 * @array: a #GByteArray.
10634 * @index_: the index of the byte to remove.
10636 * Removes the byte at the given index from a #GByteArray. The last
10637 * element in the array is used to fill in the space, so this function
10638 * does not preserve the order of the #GByteArray. But it is faster
10639 * than g_byte_array_remove_index().
10641 * Returns: the #GByteArray.
10646 * g_byte_array_remove_range:
10647 * @array: a @GByteArray.
10648 * @index_: the index of the first byte to remove.
10649 * @length: the number of bytes to remove.
10651 * Removes the given number of bytes starting at the given index from a
10652 * #GByteArray. The following elements are moved to close the gap.
10654 * Returns: the #GByteArray.
10660 * g_byte_array_set_size:
10661 * @array: a #GByteArray.
10662 * @length: the new size of the #GByteArray.
10664 * Sets the size of the #GByteArray, expanding it if necessary.
10666 * Returns: the #GByteArray.
10671 * g_byte_array_sized_new:
10672 * @reserved_size: number of bytes preallocated.
10674 * Creates a new #GByteArray with @reserved_size bytes preallocated.
10675 * This avoids frequent reallocation, if you are going to add many
10676 * bytes to the array. Note however that the size of the array is still
10679 * Returns: the new #GByteArray.
10684 * g_byte_array_sort:
10685 * @array: a #GByteArray.
10686 * @compare_func: comparison function.
10688 * Sorts a byte array, using @compare_func which should be a
10689 * qsort()-style comparison function (returns less than zero for first
10690 * arg is less than second arg, zero for equal, greater than zero if
10691 * first arg is greater than second arg).
10693 * If two array elements compare equal, their order in the sorted array
10694 * is undefined. If you want equal elements to keep their order (i.e.
10695 * you want a stable sort) you can write a comparison function that,
10696 * if two elements would otherwise compare equal, compares them by
10702 * g_byte_array_sort_with_data:
10703 * @array: a #GByteArray.
10704 * @compare_func: comparison function.
10705 * @user_data: data to pass to @compare_func.
10707 * Like g_byte_array_sort(), but the comparison function takes an extra
10708 * user data argument.
10713 * g_byte_array_unref:
10714 * @array: A #GByteArray.
10716 * Atomically decrements the reference count of @array by one. If the
10717 * reference count drops to 0, all memory allocated by the array is
10718 * released. This function is MT-safe and may be called from any
10727 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10728 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10730 * Compares the two #GBytes values.
10732 * This function can be used to sort GBytes instances in lexographical order.
10734 * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is greater, and zero if bytes2 is equal to bytes1
10741 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10742 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10744 * Compares the two #GBytes values being pointed to and returns
10745 * %TRUE if they are equal.
10747 * This function can be passed to g_hash_table_new() as the @key_equal_func
10748 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10750 * Returns: %TRUE if the two keys match.
10756 * g_bytes_get_data:
10757 * @bytes: a #GBytes
10758 * @size: (out) (allow-none): location to return size of byte data
10760 * Get the byte data in the #GBytes. This data should not be modified.
10762 * This function will always return the same pointer for a given #GBytes.
10764 * Returns: (array length=size) (type guint8): a pointer to the byte data
10770 * g_bytes_get_size:
10771 * @bytes: a #GBytes
10773 * Get the size of the byte data in the #GBytes.
10775 * This function will always return the same value for a given #GBytes.
10777 * Returns: the size
10784 * @bytes: (type GLib.Bytes): a pointer to a #GBytes key
10786 * Creates an integer hash code for the byte data in the #GBytes.
10788 * This function can be passed to g_hash_table_new() as the @key_equal_func
10789 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10791 * Returns: a hash value corresponding to the key.
10798 * @data: (array length=size): the data to be used for the bytes
10799 * @size: the size of @data
10801 * Creates a new #GBytes from @data.
10805 * Returns: (transfer full): a new #GBytes
10811 * g_bytes_new_from_bytes:
10812 * @bytes: a #GBytes
10813 * @offset: offset which subsection starts at
10814 * @length: length of subsection
10816 * Creates a #GBytes which is a subsection of another #GBytes. The @offset +
10817 * @length may not be longer than the size of @bytes.
10819 * A reference to @bytes will be held by the newly created #GBytes until
10820 * the byte data is no longer needed.
10822 * Returns: (transfer full): a new #GBytes
10828 * g_bytes_new_static:
10829 * @data: (array length=size): the data to be used for the bytes
10830 * @size: the size of @data
10832 * Creates a new #GBytes from static data.
10834 * @data must be static (ie: never modified or freed).
10836 * Returns: (transfer full): a new #GBytes
10842 * g_bytes_new_take:
10843 * @data: (transfer full) (array length=size): the data to be used for the bytes
10844 * @size: the size of @data
10846 * Creates a new #GBytes from @data.
10848 * After this call, @data belongs to the bytes and may no longer be
10849 * modified by the caller. g_free() will be called on @data when the
10850 * bytes is no longer in use. Because of this @data must have been created by
10851 * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
10852 * functions that wrap these calls (such as g_new(), g_strdup(), etc).
10854 * For creating #GBytes with memory from other allocators, see
10855 * g_bytes_new_with_free_func().
10857 * Returns: (transfer full): a new #GBytes
10863 * g_bytes_new_with_free_func:
10864 * @data: (array length=size): the data to be used for the bytes
10865 * @size: the size of @data
10866 * @free_func: the function to call to release the data
10867 * @user_data: data to pass to @free_func
10869 * Creates a #GBytes from @data.
10871 * When the last reference is dropped, @free_func will be called with the
10872 * @user_data argument.
10874 * @data must not be modified after this call is made until @free_func has
10875 * been called to indicate that the bytes is no longer in use.
10877 * Returns: (transfer full): a new #GBytes
10884 * @bytes: a #GBytes
10886 * Increase the reference count on @bytes.
10888 * Returns: the #GBytes
10895 * @bytes: (allow-none): a #GBytes
10897 * Releases a reference on @bytes. This may result in the bytes being
10905 * g_bytes_unref_to_array:
10906 * @bytes: (transfer full): a #GBytes
10908 * Unreferences the bytes, and returns a new mutable #GByteArray containing
10909 * the same byte data.
10911 * As an optimization, the byte data is transferred to the array without copying
10912 * if this was the last reference to bytes and bytes was created with
10913 * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
10914 * other cases the data is copied.
10916 * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
10922 * g_bytes_unref_to_data:
10923 * @bytes: (transfer full): a #GBytes
10924 * @size: location to place the length of the returned data
10926 * Unreferences the bytes, and returns a pointer the same byte data
10929 * As an optimization, the byte data is returned without copying if this was
10930 * the last reference to bytes and bytes was created with g_bytes_new(),
10931 * g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
10934 * Returns: (transfer full): a pointer to the same byte data, which should be freed with g_free()
10941 * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
10943 * A wrapper for the POSIX chdir() function. The function changes the
10944 * current directory of the process to @path.
10946 * See your C library manual for more details about chdir().
10948 * Returns: 0 on success, -1 if an error occurred.
10955 * @checksum: the #GChecksum to copy
10957 * Copies a #GChecksum. If @checksum has been closed, by calling
10958 * g_checksum_get_string() or g_checksum_get_digest(), the copied
10959 * checksum will be closed as well.
10961 * Returns: the copy of the passed #GChecksum. Use g_checksum_free() when finished using it.
10968 * @checksum: a #GChecksum
10970 * Frees the memory allocated for @checksum.
10977 * g_checksum_get_digest:
10978 * @checksum: a #GChecksum
10979 * @buffer: output buffer
10980 * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
10982 * Gets the digest from @checksum as a raw binary vector and places it
10983 * into @buffer. The size of the digest depends on the type of checksum.
10985 * Once this function has been called, the #GChecksum is closed and can
10986 * no longer be updated with g_checksum_update().
10993 * g_checksum_get_string:
10994 * @checksum: a #GChecksum
10996 * Gets the digest as an hexadecimal string.
10998 * Once this function has been called the #GChecksum can no longer be
10999 * updated with g_checksum_update().
11001 * The hexadecimal characters will be lower case.
11003 * Returns: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed.
11010 * @checksum_type: the desired type of checksum
11012 * Creates a new #GChecksum, using the checksum algorithm @checksum_type.
11013 * If the @checksum_type is not known, %NULL is returned.
11014 * A #GChecksum can be used to compute the checksum, or digest, of an
11015 * arbitrary binary blob, using different hashing algorithms.
11017 * A #GChecksum works by feeding a binary blob through g_checksum_update()
11018 * until there is data to be checked; the digest can then be extracted
11019 * using g_checksum_get_string(), which will return the checksum as a
11020 * hexadecimal string; or g_checksum_get_digest(), which will return a
11021 * vector of raw bytes. Once either g_checksum_get_string() or
11022 * g_checksum_get_digest() have been called on a #GChecksum, the checksum
11023 * will be closed and it won't be possible to call g_checksum_update()
11026 * Returns: the newly created #GChecksum, or %NULL. Use g_checksum_free() to free the memory allocated by it.
11032 * g_checksum_reset:
11033 * @checksum: the #GChecksum to reset
11035 * Resets the state of the @checksum back to its initial state.
11042 * g_checksum_type_get_length:
11043 * @checksum_type: a #GChecksumType
11045 * Gets the length in bytes of digests of type @checksum_type
11047 * Returns: the checksum length, or -1 if @checksum_type is not supported.
11053 * g_checksum_update:
11054 * @checksum: a #GChecksum
11055 * @data: buffer used to compute the checksum
11056 * @length: size of the buffer, or -1 if it is a null-terminated string.
11058 * Feeds @data into an existing #GChecksum. The checksum must still be
11059 * open, that is g_checksum_get_string() or g_checksum_get_digest() must
11060 * not have been called on @checksum.
11067 * g_child_watch_add:
11068 * @pid: process id to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11069 * @function: function to call
11070 * @data: data to pass to @function
11072 * Sets a function to be called when the child indicated by @pid
11073 * exits, at a default priority, #G_PRIORITY_DEFAULT.
11075 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11076 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11077 * the spawn function for the child watching to work.
11079 * Note that on platforms where #GPid must be explicitly closed
11080 * (see g_spawn_close_pid()) @pid must not be closed while the
11081 * source is still active. Typically, you will want to call
11082 * g_spawn_close_pid() in the callback function for the source.
11084 * GLib supports only a single callback per process id.
11086 * This internally creates a main loop source using
11087 * g_child_watch_source_new() and attaches it to the main loop context
11088 * using g_source_attach(). You can do these steps manually if you
11089 * need greater control.
11091 * Returns: the ID (greater than 0) of the event source.
11097 * g_child_watch_add_full:
11098 * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
11099 * @pid: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11100 * @function: function to call
11101 * @data: data to pass to @function
11102 * @notify: (allow-none): function to call when the idle is removed, or %NULL
11104 * Sets a function to be called when the child indicated by @pid
11105 * exits, at the priority @priority.
11107 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11108 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11109 * the spawn function for the child watching to work.
11111 * In many programs, you will want to call g_spawn_check_exit_status()
11112 * in the callback to determine whether or not the child exited
11115 * Also, note that on platforms where #GPid must be explicitly closed
11116 * (see g_spawn_close_pid()) @pid must not be closed while the source
11117 * is still active. Typically, you should invoke g_spawn_close_pid()
11118 * in the callback function for the source.
11120 * GLib supports only a single callback per process id.
11122 * This internally creates a main loop source using
11123 * g_child_watch_source_new() and attaches it to the main loop context
11124 * using g_source_attach(). You can do these steps manually if you
11125 * need greater control.
11127 * Returns: the ID (greater than 0) of the event source.
11128 * Rename to: g_child_watch_add
11134 * g_child_watch_source_new:
11135 * @pid: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11137 * Creates a new child_watch source.
11139 * The source will not initially be associated with any #GMainContext
11140 * and must be added to one with g_source_attach() before it will be
11143 * Note that child watch sources can only be used in conjunction with
11144 * <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
11147 * Note that on platforms where #GPid must be explicitly closed
11148 * (see g_spawn_close_pid()) @pid must not be closed while the
11149 * source is still active. Typically, you will want to call
11150 * g_spawn_close_pid() in the callback function for the source.
11152 * Note further that using g_child_watch_source_new() is not
11153 * compatible with calling <literal>waitpid(-1)</literal> in
11154 * the application. Calling waitpid() for individual pids will
11157 * Returns: the newly-created child watch source
11164 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11165 * @mode: as in chmod()
11167 * A wrapper for the POSIX chmod() function. The chmod() function is
11168 * used to set the permissions of a file system object.
11170 * On Windows the file protection mechanism is not at all POSIX-like,
11171 * and the underlying chmod() function in the C library just sets or
11172 * clears the FAT-style READONLY attribute. It does not touch any
11173 * ACL. Software that needs to manage file permissions on Windows
11174 * exactly should use the Win32 API.
11176 * See your C library manual for more details about chmod().
11178 * Returns: zero if the operation succeeded, -1 on error.
11185 * @err: a #GError return location
11187 * If @err is %NULL, does nothing. If @err is non-%NULL,
11188 * calls g_error_free() on *@err and sets *@err to %NULL.
11193 * g_clear_pointer: (skip)
11194 * @pp: a pointer to a variable, struct member etc. holding a pointer
11195 * @destroy: a function to which a gpointer can be passed, to destroy *@pp
11197 * Clears a reference to a variable.
11199 * @pp must not be %NULL.
11201 * If the reference is %NULL then this function does nothing.
11202 * Otherwise, the variable is destroyed using @destroy and the
11203 * pointer is set to %NULL.
11205 * This function is threadsafe and modifies the pointer atomically,
11206 * using memory barriers where needed.
11208 * A macro is also included that allows this function to be used without
11216 * g_compute_checksum_for_bytes:
11217 * @checksum_type: a #GChecksumType
11218 * @data: binary blob to compute the digest of
11220 * Computes the checksum for a binary @data. This is a
11221 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11222 * and g_checksum_free().
11224 * The hexadecimal string returned will be in lower case.
11226 * Returns: the digest of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11232 * g_compute_checksum_for_data:
11233 * @checksum_type: a #GChecksumType
11234 * @data: binary blob to compute the digest of
11235 * @length: length of @data
11237 * Computes the checksum for a binary @data of @length. This is a
11238 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11239 * and g_checksum_free().
11241 * The hexadecimal string returned will be in lower case.
11243 * Returns: the digest of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11249 * g_compute_checksum_for_string:
11250 * @checksum_type: a #GChecksumType
11251 * @str: the string to compute the checksum of
11252 * @length: the length of the string, or -1 if the string is null-terminated.
11254 * Computes the checksum of a string.
11256 * The hexadecimal string returned will be in lower case.
11258 * Returns: the checksum as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11264 * g_compute_hmac_for_data:
11265 * @digest_type: a #GChecksumType to use for the HMAC
11266 * @key: (array length=key_len): the key to use in the HMAC
11267 * @key_len: the length of the key
11268 * @data: binary blob to compute the HMAC of
11269 * @length: length of @data
11271 * Computes the HMAC for a binary @data of @length. This is a
11272 * convenience wrapper for g_hmac_new(), g_hmac_get_string()
11273 * and g_hmac_unref().
11275 * The hexadecimal string returned will be in lower case.
11277 * Returns: the HMAC of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11283 * g_compute_hmac_for_string:
11284 * @digest_type: a #GChecksumType to use for the HMAC
11285 * @key: (array length=key_len): the key to use in the HMAC
11286 * @key_len: the length of the key
11287 * @str: the string to compute the HMAC for
11288 * @length: the length of the string, or -1 if the string is nul-terminated
11290 * Computes the HMAC for a string.
11292 * The hexadecimal string returned will be in lower case.
11294 * Returns: the HMAC as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11300 * g_cond_broadcast:
11303 * If threads are waiting for @cond, all of them are unblocked.
11304 * If no threads are waiting for @cond, this function has no effect.
11305 * It is good practice to lock the same mutex as the waiting threads
11306 * while calling this function, though not required.
11312 * @cond: an initialised #GCond
11314 * Frees the resources allocated to a #GCond with g_cond_init().
11316 * This function should not be used with a #GCond that has been
11317 * statically allocated.
11319 * Calling g_cond_clear() for a #GCond on which threads are
11320 * blocking leads to undefined behaviour.
11328 * @cond: an uninitialized #GCond
11330 * Initialises a #GCond so that it can be used.
11332 * This function is useful to initialise a #GCond that has been
11333 * allocated as part of a larger structure. It is not necessary to
11334 * initialise a #GCond that has been statically allocated.
11336 * To undo the effect of g_cond_init() when a #GCond is no longer
11337 * needed, use g_cond_clear().
11339 * Calling g_cond_init() on an already-initialised #GCond leads
11340 * to undefined behaviour.
11350 * If threads are waiting for @cond, at least one of them is unblocked.
11351 * If no threads are waiting for @cond, this function has no effect.
11352 * It is good practice to hold the same lock as the waiting thread
11353 * while calling this function, though not required.
11360 * @mutex: a #GMutex that is currently locked
11362 * Atomically releases @mutex and waits until @cond is signalled.
11364 * When using condition variables, it is possible that a spurious wakeup
11365 * may occur (ie: g_cond_wait() returns even though g_cond_signal() was
11366 * not called). It's also possible that a stolen wakeup may occur.
11367 * This is when g_cond_signal() is called, but another thread acquires
11368 * @mutex before this thread and modifies the state of the program in
11369 * such a way that when g_cond_wait() is able to return, the expected
11370 * condition is no longer met.
11372 * For this reason, g_cond_wait() must always be used in a loop. See
11373 * the documentation for #GCond for a complete example.
11378 * g_cond_wait_until:
11380 * @mutex: a #GMutex that is currently locked
11381 * @end_time: the monotonic time to wait until
11383 * Waits until either @cond is signalled or @end_time has passed.
11385 * As with g_cond_wait() it is possible that a spurious or stolen wakeup
11386 * could occur. For that reason, waiting on a condition variable should
11387 * always be in a loop, based on an explicitly-checked predicate.
11389 * %TRUE is returned if the condition variable was signalled (or in the
11390 * case of a spurious wakeup). %FALSE is returned if @end_time has
11393 * The following code shows how to correctly perform a timed wait on a
11394 * condition variable (extended the example presented in the
11395 * documentation for #GCond):
11399 * pop_data_timed (void)
11404 * g_mutex_lock (&data_mutex);
11406 * end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
11407 * while (!current_data)
11408 * if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
11410 * // timeout has passed.
11411 * g_mutex_unlock (&data_mutex);
11415 * // there is data for us
11416 * data = current_data;
11417 * current_data = NULL;
11419 * g_mutex_unlock (&data_mutex);
11425 * Notice that the end time is calculated once, before entering the
11426 * loop and reused. This is the motivation behind the use of absolute
11427 * time on this API -- if a relative time of 5 seconds were passed
11428 * directly to the call and a spurious wakeup occurred, the program would
11429 * have to start over waiting again (which would lead to a total wait
11430 * time of more than 5 seconds).
11432 * Returns: %TRUE on a signal, %FALSE on a timeout
11439 * @str: the string to convert
11440 * @len: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe"> <para> Note that some encodings may allow nul bytes to occur inside strings. In that case, using -1 for the @len parameter is unsafe. </para> </footnote>.
11441 * @to_codeset: name of character set into which to convert @str
11442 * @from_codeset: character set of @str.
11443 * @bytes_read: (out): location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
11444 * @bytes_written: (out): the number of bytes stored in the output buffer (not including the terminating nul).
11445 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11447 * Converts a string from one character set to another.
11449 * Note that you should use g_iconv() for streaming
11450 * conversions<footnoteref linkend="streaming-state"/>.
11452 * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11457 * g_convert_with_fallback:
11458 * @str: the string to convert
11459 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11460 * @to_codeset: name of character set into which to convert @str
11461 * @from_codeset: character set of @str.
11462 * @fallback: UTF-8 string to use in place of character not present in the target encoding. (The string must be representable in the target encoding). If %NULL, characters not in the target encoding will be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.
11463 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input.
11464 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11465 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11467 * Converts a string from one character set to another, possibly
11468 * including fallback sequences for characters not representable
11469 * in the output. Note that it is not guaranteed that the specification
11470 * for the fallback sequences in @fallback will be honored. Some
11471 * systems may do an approximate conversion from @from_codeset
11472 * to @to_codeset in their iconv() functions,
11473 * in which case GLib will simply return that approximate conversion.
11475 * Note that you should use g_iconv() for streaming
11476 * conversions<footnoteref linkend="streaming-state"/>.
11478 * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11483 * g_convert_with_iconv:
11484 * @str: the string to convert
11485 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11486 * @converter: conversion descriptor from g_iconv_open()
11487 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
11488 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11489 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11491 * Converts a string from one character set to another.
11493 * Note that you should use g_iconv() for streaming
11494 * conversions<footnote id="streaming-state">
11496 * Despite the fact that @byes_read can return information about partial
11497 * characters, the <literal>g_convert_...</literal> functions
11498 * are not generally suitable for streaming. If the underlying converter
11499 * being used maintains internal state, then this won't be preserved
11500 * across successive calls to g_convert(), g_convert_with_iconv() or
11501 * g_convert_with_fallback(). (An example of this is the GNU C converter
11502 * for CP1255 which does not emit a base character until it knows that
11503 * the next character is not a mark that could combine with the base
11508 * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11514 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11515 * @mode: as in creat()
11517 * A wrapper for the POSIX creat() function. The creat() function is
11518 * used to convert a pathname into a file descriptor, creating a file
11521 * On POSIX systems file descriptors are implemented by the operating
11522 * system. On Windows, it's the C library that implements creat() and
11523 * file descriptors. The actual Windows API for opening files is
11524 * different, see MSDN documentation for CreateFile(). The Win32 API
11525 * uses file handles, which are more randomish integers, not small
11526 * integers like file descriptors.
11528 * Because file descriptors are specific to the C library on Windows,
11529 * the file descriptor returned by this function makes sense only to
11530 * functions in the same C library. Thus if the GLib-using code uses a
11531 * different C library than GLib does, the file descriptor returned by
11532 * this function cannot be passed to C library functions like write()
11535 * See your C library manual for more details about creat().
11537 * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from creat().
11544 * @...: format string, followed by parameters to insert into the format string (as with printf())
11546 * Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
11547 * It's more or less application-defined what constitutes
11548 * a critical vs. a regular warning. You could call
11549 * g_log_set_always_fatal() to make critical warnings exit
11550 * the program, then use g_critical() for fatal errors, for
11553 * You can also make critical warnings fatal at runtime by
11554 * setting the <envar>G_DEBUG</envar> environment variable (see
11555 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
11560 * g_datalist_clear:
11561 * @datalist: a datalist.
11563 * Frees all the data elements of the datalist.
11564 * The data elements' destroy functions are called
11565 * if they have been set.
11570 * g_datalist_foreach:
11571 * @datalist: a datalist.
11572 * @func: the function to call for each data element.
11573 * @user_data: user data to pass to the function.
11575 * Calls the given function for each data element of the datalist. The
11576 * function is called with each data element's #GQuark id and data,
11577 * together with the given @user_data parameter. Note that this
11578 * function is NOT thread-safe. So unless @datalist can be protected
11579 * from any modifications during invocation of this function, it should
11585 * g_datalist_get_data:
11586 * @datalist: a datalist.
11587 * @key: the string identifying a data element.
11589 * Gets a data element, using its string identifier. This is slower than
11590 * g_datalist_id_get_data() because it compares strings.
11592 * Returns: the data element, or %NULL if it is not found.
11597 * g_datalist_get_flags:
11598 * @datalist: pointer to the location that holds a list
11600 * Gets flags values packed in together with the datalist.
11601 * See g_datalist_set_flags().
11603 * Returns: the flags of the datalist
11609 * g_datalist_id_dup_data:
11610 * @datalist: location of a datalist
11611 * @key_id: the #GQuark identifying a data element
11612 * @dup_func: (allow-none): function to duplicate the old value
11613 * @user_data: (allow-none): passed as user_data to @dup_func
11615 * This is a variant of g_datalist_id_get_data() which
11616 * returns a 'duplicate' of the value. @dup_func defines the
11617 * meaning of 'duplicate' in this context, it could e.g.
11618 * take a reference on a ref-counted object.
11620 * If the @key_id is not set in the datalist then @dup_func
11621 * will be called with a %NULL argument.
11623 * Note that @dup_func is called while the datalist is locked, so it
11624 * is not allowed to read or modify the datalist.
11626 * This function can be useful to avoid races when multiple
11627 * threads are using the same datalist and the same key.
11629 * Returns: the result of calling @dup_func on the value associated with @key_id in @datalist, or %NULL if not set. If @dup_func is %NULL, the value is returned unmodified.
11635 * g_datalist_id_get_data:
11636 * @datalist: a datalist.
11637 * @key_id: the #GQuark identifying a data element.
11639 * Retrieves the data element corresponding to @key_id.
11641 * Returns: the data element, or %NULL if it is not found.
11646 * g_datalist_id_remove_data:
11648 * @q: the #GQuark identifying the data element.
11650 * Removes an element, using its #GQuark identifier.
11655 * g_datalist_id_remove_no_notify:
11656 * @datalist: a datalist.
11657 * @key_id: the #GQuark identifying a data element.
11659 * Removes an element, without calling its destroy notification
11662 * Returns: the data previously stored at @key_id, or %NULL if none.
11667 * g_datalist_id_replace_data:
11668 * @datalist: location of a datalist
11669 * @key_id: the #GQuark identifying a data element
11670 * @oldval: (allow-none): the old value to compare against
11671 * @newval: (allow-none): the new value to replace it with
11672 * @destroy: (allow-none): destroy notify for the new value
11673 * @old_destroy: (allow-none): destroy notify for the existing value
11675 * Compares the member that is associated with @key_id in
11676 * @datalist to @oldval, and if they are the same, replace
11677 * @oldval with @newval.
11679 * This is like a typical atomic compare-and-exchange
11680 * operation, for a member of @datalist.
11682 * If the previous value was replaced then ownership of the
11683 * old value (@oldval) is passed to the caller, including
11684 * the registred destroy notify for it (passed out in @old_destroy).
11685 * Its up to the caller to free this as he wishes, which may
11686 * or may not include using @old_destroy as sometimes replacement
11687 * should not destroy the object in the normal way.
11689 * Return: %TRUE if the existing value for @key_id was replaced
11690 * by @newval, %FALSE otherwise.
11697 * g_datalist_id_set_data:
11699 * @q: the #GQuark to identify the data element.
11700 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @q.
11702 * Sets the data corresponding to the given #GQuark id. Any previous
11703 * data with the same key is removed, and its destroy function is
11709 * g_datalist_id_set_data_full:
11710 * @datalist: a datalist.
11711 * @key_id: the #GQuark to identify the data element.
11712 * @data: (allow-none): the data element or %NULL to remove any previous element corresponding to @key_id.
11713 * @destroy_func: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it. If @data is %NULL, then @destroy_func must also be %NULL.
11715 * Sets the data corresponding to the given #GQuark id, and the
11716 * function to be called when the element is removed from the datalist.
11717 * Any previous data with the same key is removed, and its destroy
11718 * function is called.
11724 * @datalist: a pointer to a pointer to a datalist.
11726 * Resets the datalist to %NULL. It does not free any memory or call
11727 * any destroy functions.
11732 * g_datalist_remove_data:
11734 * @k: the string identifying the data element.
11736 * Removes an element using its string identifier. The data element's
11737 * destroy function is called if it has been set.
11742 * g_datalist_remove_no_notify:
11744 * @k: the string identifying the data element.
11746 * Removes an element, without calling its destroy notifier.
11751 * g_datalist_set_data:
11753 * @k: the string to identify the data element.
11754 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11756 * Sets the data element corresponding to the given string identifier.
11761 * g_datalist_set_data_full:
11763 * @k: the string to identify the data element.
11764 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11765 * @f: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it. If @d is %NULL, then @f must also be %NULL.
11767 * Sets the data element corresponding to the given string identifier,
11768 * and the function to be called when the data element is removed.
11773 * g_datalist_set_flags:
11774 * @datalist: pointer to the location that holds a list
11775 * @flags: the flags to turn on. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3; giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
11777 * Turns on flag values for a data list. This function is used
11778 * to keep a small number of boolean flags in an object with
11779 * a data list without using any additional space. It is
11780 * not generally useful except in circumstances where space
11781 * is very tight. (It is used in the base #GObject type, for
11789 * g_datalist_unset_flags:
11790 * @datalist: pointer to the location that holds a list
11791 * @flags: the flags to turn off. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3: giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
11793 * Turns off flag values for a data list. See g_datalist_unset_flags()
11800 * g_dataset_destroy:
11801 * @dataset_location: the location identifying the dataset.
11803 * Destroys the dataset, freeing all memory allocated, and calling any
11804 * destroy functions set for data elements.
11809 * g_dataset_foreach:
11810 * @dataset_location: the location identifying the dataset.
11811 * @func: the function to call for each data element.
11812 * @user_data: user data to pass to the function.
11814 * Calls the given function for each data element which is associated
11815 * with the given location. Note that this function is NOT thread-safe.
11816 * So unless @datalist can be protected from any modifications during
11817 * invocation of this function, it should not be called.
11822 * g_dataset_get_data:
11823 * @l: the location identifying the dataset.
11824 * @k: the string identifying the data element.
11826 * Gets the data element corresponding to a string.
11828 * Returns: the data element corresponding to the string, or %NULL if it is not found.
11833 * g_dataset_id_get_data:
11834 * @dataset_location: the location identifying the dataset.
11835 * @key_id: the #GQuark id to identify the data element.
11837 * Gets the data element corresponding to a #GQuark.
11839 * Returns: the data element corresponding to the #GQuark, or %NULL if it is not found.
11844 * g_dataset_id_remove_data:
11845 * @l: the location identifying the dataset.
11846 * @k: the #GQuark id identifying the data element.
11848 * Removes a data element from a dataset. The data element's destroy
11849 * function is called if it has been set.
11854 * g_dataset_id_remove_no_notify:
11855 * @dataset_location: the location identifying the dataset.
11856 * @key_id: the #GQuark ID identifying the data element.
11858 * Removes an element, without calling its destroy notification
11861 * Returns: the data previously stored at @key_id, or %NULL if none.
11866 * g_dataset_id_set_data:
11867 * @l: the location identifying the dataset.
11868 * @k: the #GQuark id to identify the data element.
11869 * @d: the data element.
11871 * Sets the data element associated with the given #GQuark id. Any
11872 * previous data with the same key is removed, and its destroy function
11878 * g_dataset_id_set_data_full:
11879 * @dataset_location: the location identifying the dataset.
11880 * @key_id: the #GQuark id to identify the data element.
11881 * @data: the data element.
11882 * @destroy_func: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it.
11884 * Sets the data element associated with the given #GQuark id, and also
11885 * the function to call when the data element is destroyed. Any
11886 * previous data with the same key is removed, and its destroy function
11892 * g_dataset_remove_data:
11893 * @l: the location identifying the dataset.
11894 * @k: the string identifying the data element.
11896 * Removes a data element corresponding to a string. Its destroy
11897 * function is called if it has been set.
11902 * g_dataset_remove_no_notify:
11903 * @l: the location identifying the dataset.
11904 * @k: the string identifying the data element.
11906 * Removes an element, without calling its destroy notifier.
11911 * g_dataset_set_data:
11912 * @l: the location identifying the dataset.
11913 * @k: the string to identify the data element.
11914 * @d: the data element.
11916 * Sets the data corresponding to the given string identifier.
11921 * g_dataset_set_data_full:
11922 * @l: the location identifying the dataset.
11923 * @k: the string to identify the data element.
11924 * @d: the data element.
11925 * @f: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it.
11927 * Sets the data corresponding to the given string identifier, and the
11928 * function to call when the data element is destroyed.
11934 * @date: a #GDate to increment
11935 * @n_days: number of days to move the date forward
11937 * Increments a date some number of days.
11938 * To move forward by weeks, add weeks*7 days.
11939 * The date must be valid.
11944 * g_date_add_months:
11945 * @date: a #GDate to increment
11946 * @n_months: number of months to move forward
11948 * Increments a date by some number of months.
11949 * If the day of the month is greater than 28,
11950 * this routine may change the day of the month
11951 * (because the destination month may not have
11952 * the current day in it). The date must be valid.
11957 * g_date_add_years:
11958 * @date: a #GDate to increment
11959 * @n_years: number of years to move forward
11961 * Increments a date by some number of years.
11962 * If the date is February 29, and the destination
11963 * year is not a leap year, the date will be changed
11964 * to February 28. The date must be valid.
11970 * @date: a #GDate to clamp
11971 * @min_date: minimum accepted value for @date
11972 * @max_date: maximum accepted value for @date
11974 * If @date is prior to @min_date, sets @date equal to @min_date.
11975 * If @date falls after @max_date, sets @date equal to @max_date.
11976 * Otherwise, @date is unchanged.
11977 * Either of @min_date and @max_date may be %NULL.
11978 * All non-%NULL dates must be valid.
11984 * @date: pointer to one or more dates to clear
11985 * @n_dates: number of dates to clear
11987 * Initializes one or more #GDate structs to a sane but invalid
11988 * state. The cleared dates will not represent an existing date, but will
11989 * not contain garbage. Useful to init a date declared on the stack.
11990 * Validity can be tested with g_date_valid().
11996 * @lhs: first date to compare
11997 * @rhs: second date to compare
11999 * qsort()-style comparison function for dates.
12000 * Both dates must be valid.
12002 * Returns: 0 for equal, less than zero if @lhs is less than @rhs, greater than zero if @lhs is greater than @rhs
12007 * g_date_days_between:
12008 * @date1: the first date
12009 * @date2: the second date
12011 * Computes the number of days between two dates.
12012 * If @date2 is prior to @date1, the returned value is negative.
12013 * Both dates must be valid.
12015 * Returns: the number of days between @date1 and @date2
12021 * @date: a #GDate to free
12023 * Frees a #GDate returned from g_date_new().
12029 * @date: a #GDate to extract the day of the month from
12031 * Returns the day of the month. The date must be valid.
12033 * Returns: day of the month
12038 * g_date_get_day_of_year:
12039 * @date: a #GDate to extract day of year from
12041 * Returns the day of the year, where Jan 1 is the first day of the
12042 * year. The date must be valid.
12044 * Returns: day of the year
12049 * g_date_get_days_in_month:
12053 * Returns the number of days in a month, taking leap
12054 * years into account.
12056 * Returns: number of days in @month during the @year
12061 * g_date_get_iso8601_week_of_year:
12062 * @date: a valid #GDate
12064 * Returns the week of the year, where weeks are interpreted according
12067 * Returns: ISO 8601 week number of the year.
12073 * g_date_get_julian:
12074 * @date: a #GDate to extract the Julian day from
12076 * Returns the Julian day or "serial number" of the #GDate. The
12077 * Julian day is simply the number of days since January 1, Year 1; i.e.,
12078 * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
12079 * etc. The date must be valid.
12081 * Returns: Julian day
12086 * g_date_get_monday_week_of_year:
12089 * Returns the week of the year, where weeks are understood to start on
12090 * Monday. If the date is before the first Monday of the year, return
12091 * 0. The date must be valid.
12093 * Returns: week of the year
12098 * g_date_get_monday_weeks_in_year:
12101 * Returns the number of weeks in the year, where weeks
12102 * are taken to start on Monday. Will be 52 or 53. The
12103 * date must be valid. (Years always have 52 7-day periods,
12104 * plus 1 or 2 extra days depending on whether it's a leap
12105 * year. This function is basically telling you how many
12106 * Mondays are in the year, i.e. there are 53 Mondays if
12107 * one of the extra days happens to be a Monday.)
12109 * Returns: number of Mondays in the year
12114 * g_date_get_month:
12115 * @date: a #GDate to get the month from
12117 * Returns the month of the year. The date must be valid.
12119 * Returns: month of the year as a #GDateMonth
12124 * g_date_get_sunday_week_of_year:
12127 * Returns the week of the year during which this date falls, if weeks
12128 * are understood to being on Sunday. The date must be valid. Can return
12129 * 0 if the day is before the first Sunday of the year.
12131 * Returns: week number
12136 * g_date_get_sunday_weeks_in_year:
12137 * @year: year to count weeks in
12139 * Returns the number of weeks in the year, where weeks
12140 * are taken to start on Sunday. Will be 52 or 53. The
12141 * date must be valid. (Years always have 52 7-day periods,
12142 * plus 1 or 2 extra days depending on whether it's a leap
12143 * year. This function is basically telling you how many
12144 * Sundays are in the year, i.e. there are 53 Sundays if
12145 * one of the extra days happens to be a Sunday.)
12147 * Returns: the number of weeks in @year
12152 * g_date_get_weekday:
12155 * Returns the day of the week for a #GDate. The date must be valid.
12157 * Returns: day of the week as a #GDateWeekday.
12165 * Returns the year of a #GDate. The date must be valid.
12167 * Returns: year in which the date falls
12172 * g_date_is_first_of_month:
12173 * @date: a #GDate to check
12175 * Returns %TRUE if the date is on the first of a month.
12176 * The date must be valid.
12178 * Returns: %TRUE if the date is the first of the month
12183 * g_date_is_last_of_month:
12184 * @date: a #GDate to check
12186 * Returns %TRUE if the date is the last day of the month.
12187 * The date must be valid.
12189 * Returns: %TRUE if the date is the last day of the month
12194 * g_date_is_leap_year:
12195 * @year: year to check
12197 * Returns %TRUE if the year is a leap year.
12198 * <footnote><para>For the purposes of this function,
12199 * leap year is every year divisible by 4 unless that year
12200 * is divisible by 100. If it is divisible by 100 it would
12201 * be a leap year only if that year is also divisible
12202 * by 400.</para></footnote>
12204 * Returns: %TRUE if the year is a leap year
12211 * Allocates a #GDate and initializes
12212 * it to a sane state. The new date will
12213 * be cleared (as if you'd called g_date_clear()) but invalid (it won't
12214 * represent an existing day). Free the return value with g_date_free().
12216 * Returns: a newly-allocated #GDate
12222 * @day: day of the month
12223 * @month: month of the year
12226 * Like g_date_new(), but also sets the value of the date. Assuming the
12227 * day-month-year triplet you pass in represents an existing day, the
12228 * returned date will be valid.
12230 * Returns: a newly-allocated #GDate initialized with @day, @month, and @year
12235 * g_date_new_julian:
12236 * @julian_day: days since January 1, Year 1
12238 * Like g_date_new(), but also sets the value of the date. Assuming the
12239 * Julian day number you pass in is valid (greater than 0, less than an
12240 * unreasonably large number), the returned date will be valid.
12242 * Returns: a newly-allocated #GDate initialized with @julian_day
12248 * @date1: the first date
12249 * @date2: the second date
12251 * Checks if @date1 is less than or equal to @date2,
12252 * and swap the values if this is not the case.
12261 * Sets the day of the month for a #GDate. If the resulting
12262 * day-month-year triplet is invalid, the date will be invalid.
12273 * Sets the value of a #GDate from a day, month, and year.
12274 * The day-month-year triplet must be valid; if you aren't
12275 * sure it is, call g_date_valid_dmy() to check before you
12281 * g_date_set_julian:
12283 * @julian_date: Julian day number (days since January 1, Year 1)
12285 * Sets the value of a #GDate from a Julian day number.
12290 * g_date_set_month:
12292 * @month: month to set
12294 * Sets the month of the year for a #GDate. If the resulting
12295 * day-month-year triplet is invalid, the date will be invalid.
12300 * g_date_set_parse:
12301 * @date: a #GDate to fill in
12302 * @str: string to parse
12304 * Parses a user-inputted string @str, and try to figure out what date it
12305 * represents, taking the <link linkend="setlocale">current locale</link>
12306 * into account. If the string is successfully parsed, the date will be
12307 * valid after the call. Otherwise, it will be invalid. You should check
12308 * using g_date_valid() to see whether the parsing succeeded.
12310 * This function is not appropriate for file formats and the like; it
12311 * isn't very precise, and its exact behavior varies with the locale.
12312 * It's intended to be a heuristic routine that guesses what the user
12313 * means by a given string (and it does work pretty well in that
12321 * @time_: #GTime value to set.
12323 * Sets the value of a date from a #GTime value.
12324 * The time to date conversion is done using the user's current timezone.
12326 * Deprecated: 2.10: Use g_date_set_time_t() instead.
12331 * g_date_set_time_t:
12333 * @timet: <type>time_t</type> value to set
12335 * Sets the value of a date to the date corresponding to a time
12336 * specified as a time_t. The time to date conversion is done using
12337 * the user's current timezone.
12339 * To set the value of a date to the current day, you could write:
12341 * g_date_set_time_t (date, time (NULL));
12349 * g_date_set_time_val:
12351 * @timeval: #GTimeVal value to set
12353 * Sets the value of a date from a #GTimeVal value. Note that the
12354 * @tv_usec member is ignored, because #GDate can't make use of the
12355 * additional precision.
12357 * The time to date conversion is done using the user's current timezone.
12366 * @year: year to set
12368 * Sets the year for a #GDate. If the resulting day-month-year
12369 * triplet is invalid, the date will be invalid.
12375 * @s: destination buffer
12376 * @slen: buffer size
12377 * @format: format string
12378 * @date: valid #GDate
12380 * Generates a printed representation of the date, in a
12381 * <link linkend="setlocale">locale</link>-specific way.
12382 * Works just like the platform's C library strftime() function,
12383 * but only accepts date-related formats; time-related formats
12384 * give undefined results. Date must be valid. Unlike strftime()
12385 * (which uses the locale encoding), works on a UTF-8 format
12386 * string and stores a UTF-8 result.
12388 * This function does not provide any conversion specifiers in
12389 * addition to those implemented by the platform's C library.
12390 * For example, don't expect that using g_date_strftime() would
12391 * make the \%F provided by the C99 strftime() work on Windows
12392 * where the C library only complies to C89.
12394 * Returns: number of characters written to the buffer, or 0 the buffer was too small
12399 * g_date_subtract_days:
12400 * @date: a #GDate to decrement
12401 * @n_days: number of days to move
12403 * Moves a date some number of days into the past.
12404 * To move by weeks, just move by weeks*7 days.
12405 * The date must be valid.
12410 * g_date_subtract_months:
12411 * @date: a #GDate to decrement
12412 * @n_months: number of months to move
12414 * Moves a date some number of months into the past.
12415 * If the current day of the month doesn't exist in
12416 * the destination month, the day of the month
12417 * may change. The date must be valid.
12422 * g_date_subtract_years:
12423 * @date: a #GDate to decrement
12424 * @n_years: number of years to move
12426 * Moves a date some number of years into the past.
12427 * If the current day doesn't exist in the destination
12428 * year (i.e. it's February 29 and you move to a non-leap-year)
12429 * then the day is changed to February 29. The date
12436 * @datetime: a #GDateTime
12437 * @timespan: a #GTimeSpan
12439 * Creates a copy of @datetime and adds the specified timespan to the copy.
12441 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12447 * g_date_time_add_days:
12448 * @datetime: a #GDateTime
12449 * @days: the number of days
12451 * Creates a copy of @datetime and adds the specified number of days to the
12454 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12460 * g_date_time_add_full:
12461 * @datetime: a #GDateTime
12462 * @years: the number of years to add
12463 * @months: the number of months to add
12464 * @days: the number of days to add
12465 * @hours: the number of hours to add
12466 * @minutes: the number of minutes to add
12467 * @seconds: the number of seconds to add
12469 * Creates a new #GDateTime adding the specified values to the current date and
12470 * time in @datetime.
12472 * Returns: the newly created #GDateTime that should be freed with g_date_time_unref().
12478 * g_date_time_add_hours:
12479 * @datetime: a #GDateTime
12480 * @hours: the number of hours to add
12482 * Creates a copy of @datetime and adds the specified number of hours
12484 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12490 * g_date_time_add_minutes:
12491 * @datetime: a #GDateTime
12492 * @minutes: the number of minutes to add
12494 * Creates a copy of @datetime adding the specified number of minutes.
12496 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12502 * g_date_time_add_months:
12503 * @datetime: a #GDateTime
12504 * @months: the number of months
12506 * Creates a copy of @datetime and adds the specified number of months to the
12509 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12515 * g_date_time_add_seconds:
12516 * @datetime: a #GDateTime
12517 * @seconds: the number of seconds to add
12519 * Creates a copy of @datetime and adds the specified number of seconds.
12521 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12527 * g_date_time_add_weeks:
12528 * @datetime: a #GDateTime
12529 * @weeks: the number of weeks
12531 * Creates a copy of @datetime and adds the specified number of weeks to the
12534 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12540 * g_date_time_add_years:
12541 * @datetime: a #GDateTime
12542 * @years: the number of years
12544 * Creates a copy of @datetime and adds the specified number of years to the
12547 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12553 * g_date_time_compare:
12554 * @dt1: first #GDateTime to compare
12555 * @dt2: second #GDateTime to compare
12557 * A comparison function for #GDateTimes that is suitable
12558 * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
12560 * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater than @dt2.
12566 * g_date_time_difference:
12567 * @end: a #GDateTime
12568 * @begin: a #GDateTime
12570 * Calculates the difference in time between @end and @begin. The
12571 * #GTimeSpan that is returned is effectively @end - @begin (ie:
12572 * positive if the first simparameter is larger).
12574 * Returns: the difference between the two #GDateTime, as a time span expressed in microseconds.
12580 * g_date_time_equal:
12581 * @dt1: a #GDateTime
12582 * @dt2: a #GDateTime
12584 * Checks to see if @dt1 and @dt2 are equal.
12586 * Equal here means that they represent the same moment after converting
12587 * them to the same time zone.
12589 * Returns: %TRUE if @dt1 and @dt2 are equal
12595 * g_date_time_format:
12596 * @datetime: A #GDateTime
12597 * @format: a valid UTF-8 string, containing the format for the #GDateTime
12599 * Creates a newly allocated string representing the requested @format.
12601 * The format strings understood by this function are a subset of the
12602 * strftime() format language as specified by C99. The \%D, \%U and \%W
12603 * conversions are not supported, nor is the 'E' modifier. The GNU
12604 * extensions \%k, \%l, \%s and \%P are supported, however, as are the
12605 * '0', '_' and '-' modifiers.
12607 * In contrast to strftime(), this function always produces a UTF-8
12608 * string, regardless of the current locale. Note that the rendering of
12609 * many formats is locale-dependent and may not match the strftime()
12612 * The following format specifiers are supported:
12615 * <varlistentry><term>
12616 * <literal>\%a</literal>:
12617 * </term><listitem><simpara>
12618 * the abbreviated weekday name according to the current locale
12619 * </simpara></listitem></varlistentry>
12620 * <varlistentry><term>
12621 * <literal>\%A</literal>:
12622 * </term><listitem><simpara>
12623 * the full weekday name according to the current locale
12624 * </simpara></listitem></varlistentry>
12625 * <varlistentry><term>
12626 * <literal>\%b</literal>:
12627 * </term><listitem><simpara>
12628 * the abbreviated month name according to the current locale
12629 * </simpara></listitem></varlistentry>
12630 * <varlistentry><term>
12631 * <literal>\%B</literal>:
12632 * </term><listitem><simpara>
12633 * the full month name according to the current locale
12634 * </simpara></listitem></varlistentry>
12635 * <varlistentry><term>
12636 * <literal>\%c</literal>:
12637 * </term><listitem><simpara>
12638 * the preferred date and time representation for the current locale
12639 * </simpara></listitem></varlistentry>
12640 * <varlistentry><term>
12641 * <literal>\%C</literal>:
12642 * </term><listitem><simpara>
12643 * The century number (year/100) as a 2-digit integer (00-99)
12644 * </simpara></listitem></varlistentry>
12645 * <varlistentry><term>
12646 * <literal>\%d</literal>:
12647 * </term><listitem><simpara>
12648 * the day of the month as a decimal number (range 01 to 31)
12649 * </simpara></listitem></varlistentry>
12650 * <varlistentry><term>
12651 * <literal>\%e</literal>:
12652 * </term><listitem><simpara>
12653 * the day of the month as a decimal number (range 1 to 31)
12654 * </simpara></listitem></varlistentry>
12655 * <varlistentry><term>
12656 * <literal>\%F</literal>:
12657 * </term><listitem><simpara>
12658 * equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
12660 * </simpara></listitem></varlistentry>
12661 * <varlistentry><term>
12662 * <literal>\%g</literal>:
12663 * </term><listitem><simpara>
12664 * the last two digits of the ISO 8601 week-based year as a decimal
12665 * number (00-99). This works well with \%V and \%u.
12666 * </simpara></listitem></varlistentry>
12667 * <varlistentry><term>
12668 * <literal>\%G</literal>:
12669 * </term><listitem><simpara>
12670 * the ISO 8601 week-based year as a decimal number. This works well
12671 * with \%V and \%u.
12672 * </simpara></listitem></varlistentry>
12673 * <varlistentry><term>
12674 * <literal>\%h</literal>:
12675 * </term><listitem><simpara>
12676 * equivalent to <literal>\%b</literal>
12677 * </simpara></listitem></varlistentry>
12678 * <varlistentry><term>
12679 * <literal>\%H</literal>:
12680 * </term><listitem><simpara>
12681 * the hour as a decimal number using a 24-hour clock (range 00 to
12683 * </simpara></listitem></varlistentry>
12684 * <varlistentry><term>
12685 * <literal>\%I</literal>:
12686 * </term><listitem><simpara>
12687 * the hour as a decimal number using a 12-hour clock (range 01 to
12689 * </simpara></listitem></varlistentry>
12690 * <varlistentry><term>
12691 * <literal>\%j</literal>:
12692 * </term><listitem><simpara>
12693 * the day of the year as a decimal number (range 001 to 366)
12694 * </simpara></listitem></varlistentry>
12695 * <varlistentry><term>
12696 * <literal>\%k</literal>:
12697 * </term><listitem><simpara>
12698 * the hour (24-hour clock) as a decimal number (range 0 to 23);
12699 * single digits are preceded by a blank
12700 * </simpara></listitem></varlistentry>
12701 * <varlistentry><term>
12702 * <literal>\%l</literal>:
12703 * </term><listitem><simpara>
12704 * the hour (12-hour clock) as a decimal number (range 1 to 12);
12705 * single digits are preceded by a blank
12706 * </simpara></listitem></varlistentry>
12707 * <varlistentry><term>
12708 * <literal>\%m</literal>:
12709 * </term><listitem><simpara>
12710 * the month as a decimal number (range 01 to 12)
12711 * </simpara></listitem></varlistentry>
12712 * <varlistentry><term>
12713 * <literal>\%M</literal>:
12714 * </term><listitem><simpara>
12715 * the minute as a decimal number (range 00 to 59)
12716 * </simpara></listitem></varlistentry>
12717 * <varlistentry><term>
12718 * <literal>\%p</literal>:
12719 * </term><listitem><simpara>
12720 * either "AM" or "PM" according to the given time value, or the
12721 * corresponding strings for the current locale. Noon is treated as
12722 * "PM" and midnight as "AM".
12723 * </simpara></listitem></varlistentry>
12724 * <varlistentry><term>
12725 * <literal>\%P</literal>:
12726 * </term><listitem><simpara>
12727 * like \%p but lowercase: "am" or "pm" or a corresponding string for
12728 * the current locale
12729 * </simpara></listitem></varlistentry>
12730 * <varlistentry><term>
12731 * <literal>\%r</literal>:
12732 * </term><listitem><simpara>
12733 * the time in a.m. or p.m. notation
12734 * </simpara></listitem></varlistentry>
12735 * <varlistentry><term>
12736 * <literal>\%R</literal>:
12737 * </term><listitem><simpara>
12738 * the time in 24-hour notation (<literal>\%H:\%M</literal>)
12739 * </simpara></listitem></varlistentry>
12740 * <varlistentry><term>
12741 * <literal>\%s</literal>:
12742 * </term><listitem><simpara>
12743 * the number of seconds since the Epoch, that is, since 1970-01-01
12745 * </simpara></listitem></varlistentry>
12746 * <varlistentry><term>
12747 * <literal>\%S</literal>:
12748 * </term><listitem><simpara>
12749 * the second as a decimal number (range 00 to 60)
12750 * </simpara></listitem></varlistentry>
12751 * <varlistentry><term>
12752 * <literal>\%t</literal>:
12753 * </term><listitem><simpara>
12755 * </simpara></listitem></varlistentry>
12756 * <varlistentry><term>
12757 * <literal>\%T</literal>:
12758 * </term><listitem><simpara>
12759 * the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
12760 * </simpara></listitem></varlistentry>
12761 * <varlistentry><term>
12762 * <literal>\%u</literal>:
12763 * </term><listitem><simpara>
12764 * the ISO 8601 standard day of the week as a decimal, range 1 to 7,
12765 * Monday being 1. This works well with \%G and \%V.
12766 * </simpara></listitem></varlistentry>
12767 * <varlistentry><term>
12768 * <literal>\%V</literal>:
12769 * </term><listitem><simpara>
12770 * the ISO 8601 standard week number of the current year as a decimal
12771 * number, range 01 to 53, where week 1 is the first week that has at
12772 * least 4 days in the new year. See g_date_time_get_week_of_year().
12773 * This works well with \%G and \%u.
12774 * </simpara></listitem></varlistentry>
12775 * <varlistentry><term>
12776 * <literal>\%w</literal>:
12777 * </term><listitem><simpara>
12778 * the day of the week as a decimal, range 0 to 6, Sunday being 0.
12779 * This is not the ISO 8601 standard format -- use \%u instead.
12780 * </simpara></listitem></varlistentry>
12781 * <varlistentry><term>
12782 * <literal>\%x</literal>:
12783 * </term><listitem><simpara>
12784 * the preferred date representation for the current locale without
12786 * </simpara></listitem></varlistentry>
12787 * <varlistentry><term>
12788 * <literal>\%X</literal>:
12789 * </term><listitem><simpara>
12790 * the preferred time representation for the current locale without
12792 * </simpara></listitem></varlistentry>
12793 * <varlistentry><term>
12794 * <literal>\%y</literal>:
12795 * </term><listitem><simpara>
12796 * the year as a decimal number without the century
12797 * </simpara></listitem></varlistentry>
12798 * <varlistentry><term>
12799 * <literal>\%Y</literal>:
12800 * </term><listitem><simpara>
12801 * the year as a decimal number including the century
12802 * </simpara></listitem></varlistentry>
12803 * <varlistentry><term>
12804 * <literal>\%z</literal>:
12805 * </term><listitem><simpara>
12806 * the time-zone as hour offset from UTC
12807 * </simpara></listitem></varlistentry>
12808 * <varlistentry><term>
12809 * <literal>\%Z</literal>:
12810 * </term><listitem><simpara>
12811 * the time zone or name or abbreviation
12812 * </simpara></listitem></varlistentry>
12813 * <varlistentry><term>
12814 * <literal>\%\%</literal>:
12815 * </term><listitem><simpara>
12816 * a literal <literal>\%</literal> character
12817 * </simpara></listitem></varlistentry>
12820 * Some conversion specifications can be modified by preceding the
12821 * conversion specifier by one or more modifier characters. The
12822 * following modifiers are supported for many of the numeric
12828 * Use alternative numeric symbols, if the current locale
12835 * Pad a numeric result with spaces.
12836 * This overrides the default padding for the specifier.
12842 * Do not pad a numeric result.
12843 * This overrides the default padding for the specifier.
12849 * Pad a numeric result with zeros.
12850 * This overrides the default padding for the specifier.
12855 * Returns: a newly allocated string formatted to the requested format or %NULL in the case that there was an error. The string should be freed with g_free().
12861 * g_date_time_get_day_of_month:
12862 * @datetime: a #GDateTime
12864 * Retrieves the day of the month represented by @datetime in the gregorian
12867 * Returns: the day of the month
12873 * g_date_time_get_day_of_week:
12874 * @datetime: a #GDateTime
12876 * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
12877 * Monday, 2 is Tuesday... 7 is Sunday).
12879 * Returns: the day of the week
12885 * g_date_time_get_day_of_year:
12886 * @datetime: a #GDateTime
12888 * Retrieves the day of the year represented by @datetime in the Gregorian
12891 * Returns: the day of the year
12897 * g_date_time_get_hour:
12898 * @datetime: a #GDateTime
12900 * Retrieves the hour of the day represented by @datetime
12902 * Returns: the hour of the day
12908 * g_date_time_get_microsecond:
12909 * @datetime: a #GDateTime
12911 * Retrieves the microsecond of the date represented by @datetime
12913 * Returns: the microsecond of the second
12919 * g_date_time_get_minute:
12920 * @datetime: a #GDateTime
12922 * Retrieves the minute of the hour represented by @datetime
12924 * Returns: the minute of the hour
12930 * g_date_time_get_month:
12931 * @datetime: a #GDateTime
12933 * Retrieves the month of the year represented by @datetime in the Gregorian
12936 * Returns: the month represented by @datetime
12942 * g_date_time_get_second:
12943 * @datetime: a #GDateTime
12945 * Retrieves the second of the minute represented by @datetime
12947 * Returns: the second represented by @datetime
12953 * g_date_time_get_seconds:
12954 * @datetime: a #GDateTime
12956 * Retrieves the number of seconds since the start of the last minute,
12957 * including the fractional part.
12959 * Returns: the number of seconds
12965 * g_date_time_get_timezone_abbreviation:
12966 * @datetime: a #GDateTime
12968 * Determines the time zone abbreviation to be used at the time and in
12969 * the time zone of @datetime.
12971 * For example, in Toronto this is currently "EST" during the winter
12972 * months and "EDT" during the summer months when daylight savings
12973 * time is in effect.
12975 * Returns: (transfer none): the time zone abbreviation. The returned string is owned by the #GDateTime and it should not be modified or freed
12981 * g_date_time_get_utc_offset:
12982 * @datetime: a #GDateTime
12984 * Determines the offset to UTC in effect at the time and in the time
12985 * zone of @datetime.
12987 * The offset is the number of microseconds that you add to UTC time to
12988 * arrive at local time for the time zone (ie: negative numbers for time
12989 * zones west of GMT, positive numbers for east).
12991 * If @datetime represents UTC time, then the offset is always zero.
12993 * Returns: the number of microseconds that should be added to UTC to get the local time
12999 * g_date_time_get_week_numbering_year:
13000 * @datetime: a #GDateTime
13002 * Returns the ISO 8601 week-numbering year in which the week containing
13005 * This function, taken together with g_date_time_get_week_of_year() and
13006 * g_date_time_get_day_of_week() can be used to determine the full ISO
13007 * week date on which @datetime falls.
13009 * This is usually equal to the normal Gregorian year (as returned by
13010 * g_date_time_get_year()), except as detailed below:
13012 * For Thursday, the week-numbering year is always equal to the usual
13013 * calendar year. For other days, the number is such that every day
13014 * within a complete week (Monday to Sunday) is contained within the
13015 * same week-numbering year.
13017 * For Monday, Tuesday and Wednesday occurring near the end of the year,
13018 * this may mean that the week-numbering year is one greater than the
13019 * calendar year (so that these days have the same week-numbering year
13020 * as the Thursday occurring early in the next year).
13022 * For Friday, Saturaday and Sunday occurring near the start of the year,
13023 * this may mean that the week-numbering year is one less than the
13024 * calendar year (so that these days have the same week-numbering year
13025 * as the Thursday occurring late in the previous year).
13027 * An equivalent description is that the week-numbering year is equal to
13028 * the calendar year containing the majority of the days in the current
13029 * week (Monday to Sunday).
13031 * Note that January 1 0001 in the proleptic Gregorian calendar is a
13032 * Monday, so this function never returns 0.
13034 * Returns: the ISO 8601 week-numbering year for @datetime
13040 * g_date_time_get_week_of_year:
13041 * @datetime: a #GDateTime
13043 * Returns the ISO 8601 week number for the week containing @datetime.
13044 * The ISO 8601 week number is the same for every day of the week (from
13045 * Moday through Sunday). That can produce some unusual results
13046 * (described below).
13048 * The first week of the year is week 1. This is the week that contains
13049 * the first Thursday of the year. Equivalently, this is the first week
13050 * that has more than 4 of its days falling within the calendar year.
13052 * The value 0 is never returned by this function. Days contained
13053 * within a year but occurring before the first ISO 8601 week of that
13054 * year are considered as being contained in the last week of the
13055 * previous year. Similarly, the final days of a calendar year may be
13056 * considered as being part of the first ISO 8601 week of the next year
13057 * if 4 or more days of that week are contained within the new year.
13059 * Returns: the ISO 8601 week number for @datetime.
13065 * g_date_time_get_year:
13066 * @datetime: A #GDateTime
13068 * Retrieves the year represented by @datetime in the Gregorian calendar.
13070 * Returns: the year represented by @datetime
13076 * g_date_time_get_ymd:
13077 * @datetime: a #GDateTime.
13078 * @year: (out) (allow-none): the return location for the gregorian year, or %NULL.
13079 * @month: (out) (allow-none): the return location for the month of the year, or %NULL.
13080 * @day: (out) (allow-none): the return location for the day of the month, or %NULL.
13082 * Retrieves the Gregorian day, month, and year of a given #GDateTime.
13089 * g_date_time_hash:
13090 * @datetime: a #GDateTime
13092 * Hashes @datetime into a #guint, suitable for use within #GHashTable.
13094 * Returns: a #guint containing the hash
13100 * g_date_time_is_daylight_savings:
13101 * @datetime: a #GDateTime
13103 * Determines if daylight savings time is in effect at the time and in
13104 * the time zone of @datetime.
13106 * Returns: %TRUE if daylight savings time is in effect
13113 * @tz: a #GTimeZone
13114 * @year: the year component of the date
13115 * @month: the month component of the date
13116 * @day: the day component of the date
13117 * @hour: the hour component of the date
13118 * @minute: the minute component of the date
13119 * @seconds: the number of seconds past the minute
13121 * Creates a new #GDateTime corresponding to the given date and time in
13122 * the time zone @tz.
13124 * The @year must be between 1 and 9999, @month between 1 and 12 and @day
13125 * between 1 and 28, 29, 30 or 31 depending on the month and the year.
13127 * @hour must be between 0 and 23 and @minute must be between 0 and 59.
13129 * @seconds must be at least 0.0 and must be strictly less than 60.0.
13130 * It will be rounded down to the nearest microsecond.
13132 * If the given time is not representable in the given time zone (for
13133 * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
13134 * time) then the time will be rounded up to the nearest existing time
13135 * (in this case, 03:00). If this matters to you then you should verify
13136 * the return value for containing the same as the numbers you gave.
13138 * In the case that the given time is ambiguous in the given time zone
13139 * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
13140 * savings time) then the time falling within standard (ie:
13141 * non-daylight) time is taken.
13143 * It not considered a programmer error for the values to this function
13144 * to be out of range, but in the case that they are, the function will
13147 * You should release the return value by calling g_date_time_unref()
13148 * when you are done with it.
13150 * Returns: a new #GDateTime, or %NULL
13156 * g_date_time_new_from_timeval_local:
13159 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
13162 * The time contained in a #GTimeVal is always stored in the form of
13163 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
13164 * local time offset.
13166 * This call can fail (returning %NULL) if @tv represents a time outside
13167 * of the supported range of #GDateTime.
13169 * You should release the return value by calling g_date_time_unref()
13170 * when you are done with it.
13172 * Returns: a new #GDateTime, or %NULL
13178 * g_date_time_new_from_timeval_utc:
13181 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
13183 * The time contained in a #GTimeVal is always stored in the form of
13184 * seconds elapsed since 1970-01-01 00:00:00 UTC.
13186 * This call can fail (returning %NULL) if @tv represents a time outside
13187 * of the supported range of #GDateTime.
13189 * You should release the return value by calling g_date_time_unref()
13190 * when you are done with it.
13192 * Returns: a new #GDateTime, or %NULL
13198 * g_date_time_new_from_unix_local:
13199 * @t: the Unix time
13201 * Creates a #GDateTime corresponding to the given Unix time @t in the
13204 * Unix time is the number of seconds that have elapsed since 1970-01-01
13205 * 00:00:00 UTC, regardless of the local time offset.
13207 * This call can fail (returning %NULL) if @t represents a time outside
13208 * of the supported range of #GDateTime.
13210 * You should release the return value by calling g_date_time_unref()
13211 * when you are done with it.
13213 * Returns: a new #GDateTime, or %NULL
13219 * g_date_time_new_from_unix_utc:
13220 * @t: the Unix time
13222 * Creates a #GDateTime corresponding to the given Unix time @t in UTC.
13224 * Unix time is the number of seconds that have elapsed since 1970-01-01
13227 * This call can fail (returning %NULL) if @t represents a time outside
13228 * of the supported range of #GDateTime.
13230 * You should release the return value by calling g_date_time_unref()
13231 * when you are done with it.
13233 * Returns: a new #GDateTime, or %NULL
13239 * g_date_time_new_local:
13240 * @year: the year component of the date
13241 * @month: the month component of the date
13242 * @day: the day component of the date
13243 * @hour: the hour component of the date
13244 * @minute: the minute component of the date
13245 * @seconds: the number of seconds past the minute
13247 * Creates a new #GDateTime corresponding to the given date and time in
13248 * the local time zone.
13250 * This call is equivalent to calling g_date_time_new() with the time
13251 * zone returned by g_time_zone_new_local().
13253 * Returns: a #GDateTime, or %NULL
13259 * g_date_time_new_now:
13260 * @tz: a #GTimeZone
13262 * Creates a #GDateTime corresponding to this exact instant in the given
13263 * time zone @tz. The time is as accurate as the system allows, to a
13264 * maximum accuracy of 1 microsecond.
13266 * This function will always succeed unless the system clock is set to
13267 * truly insane values (or unless GLib is still being used after the
13270 * You should release the return value by calling g_date_time_unref()
13271 * when you are done with it.
13273 * Returns: a new #GDateTime, or %NULL
13279 * g_date_time_new_now_local:
13281 * Creates a #GDateTime corresponding to this exact instant in the local
13284 * This is equivalent to calling g_date_time_new_now() with the time
13285 * zone returned by g_time_zone_new_local().
13287 * Returns: a new #GDateTime, or %NULL
13293 * g_date_time_new_now_utc:
13295 * Creates a #GDateTime corresponding to this exact instant in UTC.
13297 * This is equivalent to calling g_date_time_new_now() with the time
13298 * zone returned by g_time_zone_new_utc().
13300 * Returns: a new #GDateTime, or %NULL
13306 * g_date_time_new_utc:
13307 * @year: the year component of the date
13308 * @month: the month component of the date
13309 * @day: the day component of the date
13310 * @hour: the hour component of the date
13311 * @minute: the minute component of the date
13312 * @seconds: the number of seconds past the minute
13314 * Creates a new #GDateTime corresponding to the given date and time in
13317 * This call is equivalent to calling g_date_time_new() with the time
13318 * zone returned by g_time_zone_new_utc().
13320 * Returns: a #GDateTime, or %NULL
13327 * @datetime: a #GDateTime
13329 * Atomically increments the reference count of @datetime by one.
13331 * Returns: the #GDateTime with the reference count increased
13337 * g_date_time_to_local:
13338 * @datetime: a #GDateTime
13340 * Creates a new #GDateTime corresponding to the same instant in time as
13341 * @datetime, but in the local time zone.
13343 * This call is equivalent to calling g_date_time_to_timezone() with the
13344 * time zone returned by g_time_zone_new_local().
13346 * Returns: the newly created #GDateTime
13352 * g_date_time_to_timeval:
13353 * @datetime: a #GDateTime
13354 * @tv: a #GTimeVal to modify
13356 * Stores the instant in time that @datetime represents into @tv.
13358 * The time contained in a #GTimeVal is always stored in the form of
13359 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
13360 * zone associated with @datetime.
13362 * On systems where 'long' is 32bit (ie: all 32bit systems and all
13363 * Windows systems), a #GTimeVal is incapable of storing the entire
13364 * range of values that #GDateTime is capable of expressing. On those
13365 * systems, this function returns %FALSE to indicate that the time is
13368 * On systems where 'long' is 64bit, this function never fails.
13370 * Returns: %TRUE if successful, else %FALSE
13376 * g_date_time_to_timezone:
13377 * @datetime: a #GDateTime
13378 * @tz: the new #GTimeZone
13380 * Create a new #GDateTime corresponding to the same instant in time as
13381 * @datetime, but in the time zone @tz.
13383 * This call can fail in the case that the time goes out of bounds. For
13384 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
13385 * Greenwich will fail (due to the year 0 being out of range).
13387 * You should release the return value by calling g_date_time_unref()
13388 * when you are done with it.
13390 * Returns: a new #GDateTime, or %NULL
13396 * g_date_time_to_unix:
13397 * @datetime: a #GDateTime
13399 * Gives the Unix time corresponding to @datetime, rounding down to the
13402 * Unix time is the number of seconds that have elapsed since 1970-01-01
13403 * 00:00:00 UTC, regardless of the time zone associated with @datetime.
13405 * Returns: the Unix time corresponding to @datetime
13411 * g_date_time_to_utc:
13412 * @datetime: a #GDateTime
13414 * Creates a new #GDateTime corresponding to the same instant in time as
13415 * @datetime, but in UTC.
13417 * This call is equivalent to calling g_date_time_to_timezone() with the
13418 * time zone returned by g_time_zone_new_utc().
13420 * Returns: the newly created #GDateTime
13426 * g_date_time_unref:
13427 * @datetime: a #GDateTime
13429 * Atomically decrements the reference count of @datetime by one.
13431 * When the reference count reaches zero, the resources allocated by
13432 * @datetime are freed
13439 * g_date_to_struct_tm:
13440 * @date: a #GDate to set the <structname>struct tm</structname> from
13441 * @tm: <structname>struct tm</structname> to fill
13443 * Fills in the date-related bits of a <structname>struct tm</structname>
13444 * using the @date value. Initializes the non-date parts with something
13445 * sane but meaningless.
13451 * @date: a #GDate to check
13453 * Returns %TRUE if the #GDate represents an existing day. The date must not
13454 * contain garbage; it should have been initialized with g_date_clear()
13455 * if it wasn't allocated by one of the g_date_new() variants.
13457 * Returns: Whether the date is valid
13462 * g_date_valid_day:
13463 * @day: day to check
13465 * Returns %TRUE if the day of the month is valid (a day is valid if it's
13466 * between 1 and 31 inclusive).
13468 * Returns: %TRUE if the day is valid
13473 * g_date_valid_dmy:
13478 * Returns %TRUE if the day-month-year triplet forms a valid, existing day
13479 * in the range of days #GDate understands (Year 1 or later, no more than
13480 * a few thousand years in the future).
13482 * Returns: %TRUE if the date is a valid one
13487 * g_date_valid_julian:
13488 * @julian_date: Julian day to check
13490 * Returns %TRUE if the Julian day is valid. Anything greater than zero
13491 * is basically a valid Julian, though there is a 32-bit limit.
13493 * Returns: %TRUE if the Julian day is valid
13498 * g_date_valid_month:
13501 * Returns %TRUE if the month value is valid. The 12 #GDateMonth
13502 * enumeration values are the only valid months.
13504 * Returns: %TRUE if the month is valid
13509 * g_date_valid_weekday:
13510 * @weekday: weekday
13512 * Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
13513 * values are the only valid weekdays.
13515 * Returns: %TRUE if the weekday is valid
13520 * g_date_valid_year:
13523 * Returns %TRUE if the year is valid. Any year greater than 0 is valid,
13524 * though there is a 16-bit limit to what #GDate will understand.
13526 * Returns: %TRUE if the year is valid
13532 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13533 * @msgid: message to translate
13534 * @category: a locale category
13536 * This is a variant of g_dgettext() that allows specifying a locale
13537 * category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
13538 * more information about how this functions differs from calling
13539 * dcgettext() directly.
13541 * Returns: the translated string for the given locale category
13548 * @...: format string, followed by parameters to insert into the format string (as with printf())
13550 * A convenience function/macro to log a debug message.
13558 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13559 * @msgid: message to translate
13561 * This function is a wrapper of dgettext() which does not translate
13562 * the message if the default domain as set with textdomain() has no
13563 * translations for the current locale.
13565 * The advantage of using this function over dgettext() proper is that
13566 * libraries using this function (like GTK+) will not use translations
13567 * if the application using the library does not have translations for
13568 * the current locale. This results in a consistent English-only
13569 * interface instead of one having partial translations. For this
13570 * feature to work, the call to textdomain() and setlocale() should
13571 * precede any g_dgettext() invocations. For GTK+, it means calling
13572 * textdomain() before gtk_init or its variants.
13574 * This function disables translations if and only if upon its first
13575 * call all the following conditions hold:
13577 * <listitem>@domain is not %NULL</listitem>
13578 * <listitem>textdomain() has been called to set a default text domain</listitem>
13579 * <listitem>there is no translations available for the default text domain
13580 * and the current locale</listitem>
13581 * <listitem>current locale is not "C" or any English locales (those
13582 * starting with "en_")</listitem>
13585 * Note that this behavior may not be desired for example if an application
13586 * has its untranslated messages in a language other than English. In those
13587 * cases the application should call textdomain() after initializing GTK+.
13589 * Applications should normally not use this function directly,
13590 * but use the _() macro for translations.
13592 * Returns: The translated string
13599 * @dir: a #GDir* created by g_dir_open()
13601 * Closes the directory and deallocates all related resources.
13607 * @tmpl: (type filename) (allow-none): Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
13608 * @error: return location for a #GError
13610 * Creates a subdirectory in the preferred directory for temporary
13611 * files (as returned by g_get_tmp_dir()).
13613 * @tmpl should be a string in the GLib file name encoding containing
13614 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
13615 * However, unlike these functions, the template should only be a
13616 * basename, no directory components are allowed. If template is
13617 * %NULL, a default template is used.
13619 * Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
13620 * modified, and might thus be a read-only literal string.
13622 * Returns: (type filename): The actual name used. This string should be freed with g_free() when not needed any longer and is is in the GLib file name encoding. In case of errors, %NULL is returned and @error will be set.
13629 * @path: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
13630 * @flags: Currently must be set to 0. Reserved for future use.
13631 * @error: return location for a #GError, or %NULL. If non-%NULL, an error will be set if and only if g_dir_open() fails.
13633 * Opens a directory for reading. The names of the files in the
13634 * directory can then be retrieved using g_dir_read_name(). Note
13635 * that the ordering is not defined.
13637 * Returns: a newly allocated #GDir on success, %NULL on failure. If non-%NULL, you must free the result with g_dir_close() when you are finished with it.
13643 * @dir: a #GDir* created by g_dir_open()
13645 * Retrieves the name of another entry in the directory, or %NULL.
13646 * The order of entries returned from this function is not defined,
13647 * and may vary by file system or other operating-system dependent
13650 * %NULL may also be returned in case of errors. On Unix, you can
13651 * check <literal>errno</literal> to find out if %NULL was returned
13652 * because of an error.
13654 * On Unix, the '.' and '..' entries are omitted, and the returned
13655 * name is in the on-disk encoding.
13657 * On Windows, as is true of all GLib functions which operate on
13658 * filenames, the returned name is in UTF-8.
13660 * Returns: The entry's name or %NULL if there are no more entries. The return value is owned by GLib and must not be modified or freed.
13666 * @dir: a #GDir* created by g_dir_open()
13668 * Resets the given directory. The next call to g_dir_read_name()
13669 * will return the first entry again.
13675 * @v1: (allow-none): a key
13676 * @v2: (allow-none): a key to compare with @v1
13678 * Compares two #gpointer arguments and returns %TRUE if they are equal.
13679 * It can be passed to g_hash_table_new() as the @key_equal_func
13680 * parameter, when using opaque pointers compared by pointer value as keys
13681 * in a #GHashTable.
13683 * This equality function is also appropriate for keys that are integers stored
13684 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13686 * Returns: %TRUE if the two keys match.
13692 * @v: (allow-none): a #gpointer key
13694 * Converts a gpointer to a hash value.
13695 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13696 * when using opaque pointers compared by pointer value as keys in a
13699 * This hash function is also appropriate for keys that are integers stored
13700 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13702 * Returns: a hash value corresponding to the key.
13708 * @file_name: the name of the file
13710 * Gets the directory components of a file name.
13712 * If the file name has no directory components "." is returned.
13713 * The returned string should be freed when no longer needed.
13715 * Returns: the directory components of the file
13716 * Deprecated: use g_path_get_dirname() instead
13722 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13723 * @msgid: message to translate
13724 * @msgid_plural: plural form of the message
13725 * @n: the quantity for which translation is needed
13727 * This function is a wrapper of dngettext() which does not translate
13728 * the message if the default domain as set with textdomain() has no
13729 * translations for the current locale.
13731 * See g_dgettext() for details of how this differs from dngettext()
13734 * Returns: The translated string
13741 * @v1: a pointer to a #gdouble key
13742 * @v2: a pointer to a #gdouble key to compare with @v1
13744 * Compares the two #gdouble values being pointed to and returns
13745 * %TRUE if they are equal.
13746 * It can be passed to g_hash_table_new() as the @key_equal_func
13747 * parameter, when using non-%NULL pointers to doubles as keys in a
13750 * Returns: %TRUE if the two keys match.
13757 * @v: a pointer to a #gdouble key
13759 * Converts a pointer to a #gdouble to a hash value.
13760 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13761 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13762 * when using non-%NULL pointers to doubles as keys in a #GHashTable.
13764 * Returns: a hash value corresponding to the key.
13771 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13772 * @msgctxtid: a combined message context and message id, separated by a \004 character
13773 * @msgidoffset: the offset of the message id in @msgctxid
13775 * This function is a variant of g_dgettext() which supports
13776 * a disambiguating message context. GNU gettext uses the
13777 * '\004' character to separate the message context and
13778 * message id in @msgctxtid.
13779 * If 0 is passed as @msgidoffset, this function will fall back to
13780 * trying to use the deprecated convention of using "|" as a separation
13783 * This uses g_dgettext() internally. See that functions for differences
13784 * with dgettext() proper.
13786 * Applications should normally not use this function directly,
13787 * but use the C_() macro for translations with context.
13789 * Returns: The translated string
13796 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13797 * @context: the message context
13798 * @msgid: the message
13800 * This function is a variant of g_dgettext() which supports
13801 * a disambiguating message context. GNU gettext uses the
13802 * '\004' character to separate the message context and
13803 * message id in @msgctxtid.
13805 * This uses g_dgettext() internally. See that functions for differences
13806 * with dgettext() proper.
13808 * This function differs from C_() in that it is not a macro and
13809 * thus you may use non-string-literals as context and msgid arguments.
13811 * Returns: The translated string
13817 * g_environ_getenv:
13818 * @envp: (allow-none) (array zero-terminated=1) (transfer none): an environment list (eg, as returned from g_get_environ()), or %NULL for an empty environment list
13819 * @variable: the environment variable to get, in the GLib file name encoding
13821 * Returns the value of the environment variable @variable in the
13822 * provided list @envp.
13824 * The name and value are in the GLib file name encoding.
13825 * On UNIX, this means the actual bytes which might or might not
13826 * be in some consistent character set and encoding. On Windows,
13827 * it is in UTF-8. On Windows, in case the environment variable's
13828 * value contains references to other environment variables, they
13831 * Returns: the value of the environment variable, or %NULL if the environment variable is not set in @envp. The returned string is owned by @envp, and will be freed if @variable is set or unset again.
13837 * g_environ_setenv:
13838 * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list
13839 * @variable: the environment variable to set, must not contain '='
13840 * @value: the value for to set the variable to
13841 * @overwrite: whether to change the variable if it already exists
13843 * Sets the environment variable @variable in the provided list
13846 * Both the variable's name and value should be in the GLib
13847 * file name encoding. On UNIX, this means that they can be
13848 * arbitrary byte strings. On Windows, they should be in UTF-8.
13850 * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13856 * g_environ_unsetenv:
13857 * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list
13858 * @variable: the environment variable to remove, must not contain '='
13860 * Removes the environment variable @variable from the provided
13861 * environment @envp.
13863 * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13870 * @...: format string, followed by parameters to insert into the format string (as with printf())
13872 * A convenience function/macro to log an error message.
13874 * Error messages are always fatal, resulting in a call to
13875 * abort() to terminate the application. This function will
13876 * result in a core dump; don't use it for errors you expect.
13877 * Using this function indicates a bug in your program, i.e.
13878 * an assertion failure.
13884 * @error: a #GError
13886 * Makes a copy of @error.
13888 * Returns: a new #GError
13894 * @error: a #GError
13896 * Frees a #GError and associated resources.
13902 * @error: (allow-none): a #GError or %NULL
13903 * @domain: an error domain
13904 * @code: an error code
13906 * Returns %TRUE if @error matches @domain and @code, %FALSE
13907 * otherwise. In particular, when @error is %NULL, %FALSE will
13910 * Returns: whether @error has @domain and @code
13916 * @domain: error domain
13917 * @code: error code
13918 * @format: printf()-style format for error message
13919 * @...: parameters for message format
13921 * Creates a new #GError with the given @domain and @code,
13922 * and a message formatted with @format.
13924 * Returns: a new #GError
13929 * g_error_new_literal:
13930 * @domain: error domain
13931 * @code: error code
13932 * @message: error message
13934 * Creates a new #GError; unlike g_error_new(), @message is
13935 * not a printf()-style format string. Use this function if
13936 * @message contains text you don't have control over,
13937 * that could include printf() escape sequences.
13939 * Returns: a new #GError
13944 * g_error_new_valist:
13945 * @domain: error domain
13946 * @code: error code
13947 * @format: printf()-style format for error message
13948 * @args: #va_list of parameters for the message format
13950 * Creates a new #GError with the given @domain and @code,
13951 * and a message formatted with @format.
13953 * Returns: a new #GError
13959 * g_file_error_from_errno:
13960 * @err_no: an "errno" value
13962 * Gets a #GFileError constant based on the passed-in @err_no.
13963 * For example, if you pass in <literal>EEXIST</literal> this function returns
13964 * #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
13965 * assume that all #GFileError values will exist.
13967 * Normally a #GFileError value goes into a #GError returned
13968 * from a function that manipulates files. So you would use
13969 * g_file_error_from_errno() when constructing a #GError.
13971 * Returns: #GFileError corresponding to the given @errno
13976 * g_file_get_contents:
13977 * @filename: (type filename): name of a file to read contents from, in the GLib file name encoding
13978 * @contents: (out) (array length=length) (element-type guint8): location to store an allocated string, use g_free() to free the returned string
13979 * @length: (allow-none): location to store length in bytes of the contents, or %NULL
13980 * @error: return location for a #GError, or %NULL
13982 * Reads an entire file into allocated memory, with good error
13985 * If the call was successful, it returns %TRUE and sets @contents to the file
13986 * contents and @length to the length of the file contents in bytes. The string
13987 * stored in @contents will be nul-terminated, so for text files you can pass
13988 * %NULL for the @length argument. If the call was not successful, it returns
13989 * %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
13990 * codes are those in the #GFileError enumeration. In the error case,
13991 * @contents is set to %NULL and @length is set to zero.
13993 * Returns: %TRUE on success, %FALSE if an error occurred
13999 * @tmpl: (type filename) (allow-none): Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
14000 * @name_used: (out) (type filename): location to store actual name used, or %NULL
14001 * @error: return location for a #GError
14003 * Opens a file for writing in the preferred directory for temporary
14004 * files (as returned by g_get_tmp_dir()).
14006 * @tmpl should be a string in the GLib file name encoding containing
14007 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14008 * However, unlike these functions, the template should only be a
14009 * basename, no directory components are allowed. If template is
14010 * %NULL, a default template is used.
14012 * Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
14013 * modified, and might thus be a read-only literal string.
14015 * Upon success, and if @name_used is non-%NULL, the actual name used
14016 * is returned in @name_used. This string should be freed with g_free()
14017 * when not needed any longer. The returned name is in the GLib file
14020 * Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and @error will be set.
14025 * g_file_read_link:
14026 * @filename: the symbolic link
14027 * @error: return location for a #GError
14029 * Reads the contents of the symbolic link @filename like the POSIX
14030 * readlink() function. The returned string is in the encoding used
14031 * for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
14033 * Returns: A newly-allocated string with the contents of the symbolic link, or %NULL if an error occurred.
14039 * g_file_set_contents:
14040 * @filename: (type filename): name of a file to write @contents to, in the GLib file name encoding
14041 * @contents: (array length=length) (element-type guint8): string to write to the file
14042 * @length: length of @contents, or -1 if @contents is a nul-terminated string
14043 * @error: return location for a #GError, or %NULL
14045 * Writes all of @contents to a file named @filename, with good error checking.
14046 * If a file called @filename already exists it will be overwritten.
14048 * This write is atomic in the sense that it is first written to a temporary
14049 * file which is then renamed to the final name. Notes:
14052 * On Unix, if @filename already exists hard links to @filename will break.
14053 * Also since the file is recreated, existing permissions, access control
14054 * lists, metadata etc. may be lost. If @filename is a symbolic link,
14055 * the link itself will be replaced, not the linked file.
14058 * On Windows renaming a file will not remove an existing file with the
14059 * new name, so on Windows there is a race condition between the existing
14060 * file being removed and the temporary file being renamed.
14063 * On Windows there is no way to remove a file that is open to some
14064 * process, or mapped into memory. Thus, this function will fail if
14065 * @filename already exists and is open.
14069 * If the call was successful, it returns %TRUE. If the call was not successful,
14070 * it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
14071 * Possible error codes are those in the #GFileError enumeration.
14073 * Note that the name for the temporary file is constructed by appending up
14074 * to 7 characters to @filename.
14076 * Returns: %TRUE on success, %FALSE if an error occurred
14083 * @filename: a filename to test in the GLib file name encoding
14084 * @test: bitfield of #GFileTest flags
14086 * Returns %TRUE if any of the tests in the bitfield @test are
14087 * %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
14088 * G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
14089 * the check whether it's a directory doesn't matter since the existence
14090 * test is %TRUE. With the current set of available tests, there's no point
14091 * passing in more than one test at a time.
14093 * Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
14094 * so for a symbolic link to a regular file g_file_test() will return
14095 * %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
14097 * Note, that for a dangling symbolic link g_file_test() will return
14098 * %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
14100 * You should never use g_file_test() to test whether it is safe
14101 * to perform an operation, because there is always the possibility
14102 * of the condition changing before you actually perform the operation.
14103 * For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
14104 * to know whether it is safe to write to a file without being
14105 * tricked into writing into a different location. It doesn't work!
14107 * /* DON'T DO THIS */
14108 * if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
14110 * fd = g_open (filename, O_WRONLY);
14111 * /* write to fd */
14115 * Another thing to note is that %G_FILE_TEST_EXISTS and
14116 * %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
14117 * system call. This usually doesn't matter, but if your program
14118 * is setuid or setgid it means that these tests will give you
14119 * the answer for the real user ID and group ID, rather than the
14120 * effective user ID and group ID.
14122 * On Windows, there are no symlinks, so testing for
14123 * %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
14124 * %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
14125 * its name indicates that it is executable, checking for well-known
14126 * extensions and those listed in the <envar>PATHEXT</envar> environment variable.
14128 * Returns: whether a test was %TRUE
14133 * g_filename_display_basename:
14134 * @filename: an absolute pathname in the GLib file name encoding
14136 * Returns the display basename for the particular filename, guaranteed
14137 * to be valid UTF-8. The display name might not be identical to the filename,
14138 * for instance there might be problems converting it to UTF-8, and some files
14139 * can be translated in the display.
14141 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14142 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14143 * You can search the result for the UTF-8 encoding of this character (which is
14144 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14147 * You must pass the whole absolute pathname to this functions so that
14148 * translation of well known locations can be done.
14150 * This function is preferred over g_filename_display_name() if you know the
14151 * whole path, as it allows translation.
14153 * Returns: a newly allocated string containing a rendition of the basename of the filename in valid UTF-8
14159 * g_filename_display_name:
14160 * @filename: a pathname hopefully in the GLib file name encoding
14162 * Converts a filename into a valid UTF-8 string. The conversion is
14163 * not necessarily reversible, so you should keep the original around
14164 * and use the return value of this function only for display purposes.
14165 * Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
14166 * even if the filename actually isn't in the GLib file name encoding.
14168 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14169 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14170 * You can search the result for the UTF-8 encoding of this character (which is
14171 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14174 * If you know the whole pathname of the file you should use
14175 * g_filename_display_basename(), since that allows location-based
14176 * translation of filenames.
14178 * Returns: a newly allocated string containing a rendition of the filename in valid UTF-8
14184 * g_filename_from_uri:
14185 * @uri: a uri describing a filename (escaped, encoded in ASCII).
14186 * @hostname: (allow-none): Location to store hostname for the URI, or %NULL. If there is no hostname in the URI, %NULL will be stored in this location.
14187 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14189 * Converts an escaped ASCII-encoded URI to a local filename in the
14190 * encoding used for filenames.
14192 * Returns: a newly-allocated string holding the resulting filename, or %NULL on an error.
14197 * g_filename_from_utf8:
14198 * @utf8string: a UTF-8 encoded string.
14199 * @len: the length of the string, or -1 if the string is nul-terminated.
14200 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
14201 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
14202 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14204 * Converts a string from UTF-8 to the encoding GLib uses for
14205 * filenames. Note that on Windows GLib uses UTF-8 for filenames;
14206 * on other platforms, this function indirectly depends on the
14207 * <link linkend="setlocale">current locale</link>.
14209 * Returns: The converted string, or %NULL on an error.
14214 * g_filename_to_uri:
14215 * @filename: an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows
14216 * @hostname: (allow-none): A UTF-8 encoded hostname, or %NULL for none.
14217 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14219 * Converts an absolute filename to an escaped ASCII-encoded URI, with the path
14220 * component following Section 3.3. of RFC 2396.
14222 * Returns: a newly-allocated string holding the resulting URI, or %NULL on an error.
14227 * g_filename_to_utf8:
14228 * @opsysstring: a string in the encoding for filenames
14229 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
14230 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
14231 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
14232 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14234 * Converts a string which is in the encoding used by GLib for
14235 * filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
14236 * for filenames; on other platforms, this function indirectly depends on
14237 * the <link linkend="setlocale">current locale</link>.
14239 * Returns: The converted string, or %NULL on an error.
14244 * g_find_program_in_path:
14245 * @program: a program name in the GLib file name encoding
14247 * Locates the first executable named @program in the user's path, in the
14248 * same way that execvp() would locate it. Returns an allocated string
14249 * with the absolute path name, or %NULL if the program is not found in
14250 * the path. If @program is already an absolute path, returns a copy of
14251 * @program if @program exists and is executable, and %NULL otherwise.
14253 * On Windows, if @program does not have a file type suffix, tries
14254 * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
14255 * the <envar>PATHEXT</envar> environment variable.
14257 * On Windows, it looks for the file in the same way as CreateProcess()
14258 * would. This means first in the directory where the executing
14259 * program was loaded from, then in the current directory, then in the
14260 * Windows 32-bit system directory, then in the Windows directory, and
14261 * finally in the directories in the <envar>PATH</envar> environment
14262 * variable. If the program is found, the return value contains the
14263 * full name including the type suffix.
14265 * Returns: a newly-allocated string with the absolute path, or %NULL
14271 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14272 * @mode: a string describing the mode in which the file should be opened
14274 * A wrapper for the stdio fopen() function. The fopen() function
14275 * opens a file and associates a new stream with it.
14277 * Because file descriptors are specific to the C library on Windows,
14278 * and a file descriptor is partof the <type>FILE</type> struct, the
14279 * <type>FILE</type> pointer returned by this function makes sense
14280 * only to functions in the same C library. Thus if the GLib-using
14281 * code uses a different C library than GLib does, the
14282 * <type>FILE</type> pointer returned by this function cannot be
14283 * passed to C library functions like fprintf() or fread().
14285 * See your C library manual for more details about fopen().
14287 * Returns: A <type>FILE</type> pointer if the file was successfully opened, or %NULL if an error occurred
14294 * @size: a size in bytes
14296 * Formats a size (for example the size of a file) into a human readable
14297 * string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
14298 * and are displayed rounded to the nearest tenth. E.g. the file size
14299 * 3292528 bytes will be converted into the string "3.2 MB".
14301 * The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
14303 * This string should be freed with g_free() when not needed any longer.
14305 * See g_format_size_full() for more options about how the size might be
14308 * Returns: a newly-allocated formatted string containing a human readable file size
14314 * g_format_size_for_display:
14315 * @size: a size in bytes
14317 * Formats a size (for example the size of a file) into a human
14318 * readable string. Sizes are rounded to the nearest size prefix
14319 * (KB, MB, GB) and are displayed rounded to the nearest tenth.
14320 * E.g. the file size 3292528 bytes will be converted into the
14323 * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
14325 * This string should be freed with g_free() when not needed any longer.
14327 * Returns: a newly-allocated formatted string containing a human readable file size
14329 * Deprecated: 2.30: This function is broken due to its use of SI suffixes to denote IEC units. Use g_format_size() instead.
14334 * g_format_size_full:
14335 * @size: a size in bytes
14336 * @flags: #GFormatSizeFlags to modify the output
14340 * This function is similar to g_format_size() but allows for flags
14341 * that modify the output. See #GFormatSizeFlags.
14343 * Returns: a newly-allocated formatted string containing a human readable file size
14350 * @file: the stream to write to.
14351 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
14352 * @...: the arguments to insert in the output.
14354 * An implementation of the standard fprintf() function which supports
14355 * positional parameters, as specified in the Single Unix Specification.
14357 * Returns: the number of bytes printed.
14364 * @mem: the memory to free
14366 * Frees the memory pointed to by @mem.
14367 * If @mem is %NULL it simply returns.
14373 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14374 * @mode: a string describing the mode in which the file should be opened
14375 * @stream: (allow-none): an existing stream which will be reused, or %NULL
14377 * A wrapper for the POSIX freopen() function. The freopen() function
14378 * opens a file and associates it with an existing stream.
14380 * See your C library manual for more details about freopen().
14382 * Returns: A <literal>FILE</literal> pointer if the file was successfully opened, or %NULL if an error occurred.
14388 * g_get_application_name:
14390 * Gets a human-readable name for the application, as set by
14391 * g_set_application_name(). This name should be localized if
14392 * possible, and is intended for display to the user. Contrast with
14393 * g_get_prgname(), which gets a non-localized name. If
14394 * g_set_application_name() has not been called, returns the result of
14395 * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
14398 * Returns: human-readable application name. may return %NULL
14405 * @charset: return location for character set name
14407 * Obtains the character set for the <link linkend="setlocale">current
14408 * locale</link>; you might use this character set as an argument to
14409 * g_convert(), to convert from the current locale's encoding to some
14410 * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
14411 * are nice shortcuts, though.)
14413 * On Windows the character set returned by this function is the
14414 * so-called system default ANSI code-page. That is the character set
14415 * used by the "narrow" versions of C library and Win32 functions that
14416 * handle file names. It might be different from the character set
14417 * used by the C library's current locale.
14419 * The return value is %TRUE if the locale's encoding is UTF-8, in that
14420 * case you can perhaps avoid calling g_convert().
14422 * The string returned in @charset is not allocated, and should not be
14425 * Returns: %TRUE if the returned charset is UTF-8
14432 * Gets the character set for the current locale.
14434 * Returns: a newly allocated string containing the name of the character set. This string must be freed with g_free().
14439 * g_get_current_dir:
14441 * Gets the current directory.
14443 * The returned string should be freed when no longer needed.
14444 * The encoding of the returned string is system defined.
14445 * On Windows, it is always UTF-8.
14447 * Returns: the current directory
14452 * g_get_current_time:
14453 * @result: #GTimeVal structure in which to store current time.
14455 * Equivalent to the UNIX gettimeofday() function, but portable.
14457 * You may find g_get_real_time() to be more convenient.
14464 * Gets the list of environment variables for the current process.
14466 * The list is %NULL terminated and each item in the list is of the
14467 * form 'NAME=VALUE'.
14469 * This is equivalent to direct access to the 'environ' global variable,
14472 * The return value is freshly allocated and it should be freed with
14473 * g_strfreev() when it is no longer needed.
14475 * Returns: (array zero-terminated=1) (transfer full): the list of environment variables
14481 * g_get_filename_charsets:
14482 * @charsets: return location for the %NULL-terminated list of encoding names
14484 * Determines the preferred character sets used for filenames.
14485 * The first character set from the @charsets is the filename encoding, the
14486 * subsequent character sets are used when trying to generate a displayable
14487 * representation of a filename, see g_filename_display_name().
14489 * On Unix, the character sets are determined by consulting the
14490 * environment variables <envar>G_FILENAME_ENCODING</envar> and
14491 * <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
14492 * used in the GLib API is always UTF-8 and said environment variables
14495 * <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
14496 * of character set names. The special token "@locale" is taken to
14497 * mean the character set for the <link linkend="setlocale">current
14498 * locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
14499 * <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
14500 * locale is taken as the filename encoding. If neither environment variable
14501 * is set, UTF-8 is taken as the filename encoding, but the character
14502 * set of the current locale is also put in the list of encodings.
14504 * The returned @charsets belong to GLib and must not be freed.
14506 * Note that on Unix, regardless of the locale character set or
14507 * <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
14508 * on a system might be in any random encoding or just gibberish.
14510 * Returns: %TRUE if the filename encoding is UTF-8.
14518 * Gets the current user's home directory as defined in the
14519 * password database.
14521 * Note that in contrast to traditional UNIX tools, this function
14522 * prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
14523 * environment variable.
14525 * One of the reasons for this decision is that applications in many
14526 * cases need special handling to deal with the case where
14527 * <envar>HOME</envar> is
14529 * <member>Not owned by the user</member>
14530 * <member>Not writeable</member>
14531 * <member>Not even readable</member>
14533 * Since applications are in general <emphasis>not</emphasis> written
14534 * to deal with these situations it was considered better to make
14535 * g_get_home_dir() not pay attention to <envar>HOME</envar> and to
14536 * return the real home directory for the user. If applications
14537 * want to pay attention to <envar>HOME</envar>, they can do:
14539 * const char *homedir = g_getenv ("HOME");
14541 * homedir = g_get_home_dir (<!-- -->);
14544 * Returns: the current user's home directory
14551 * Return a name for the machine.
14553 * The returned name is not necessarily a fully-qualified domain name,
14554 * or even present in DNS or some other name service at all. It need
14555 * not even be unique on your local network or site, but usually it
14556 * is. Callers should not rely on the return value having any specific
14557 * properties like uniqueness for security purposes. Even if the name
14558 * of the machine is changed while an application is running, the
14559 * return value from this function does not change. The returned
14560 * string is owned by GLib and should not be modified or freed. If no
14561 * name can be determined, a default fixed string "localhost" is
14564 * Returns: the host name of the machine.
14570 * g_get_language_names:
14572 * Computes a list of applicable locale names, which can be used to
14573 * e.g. construct locale-dependent filenames or search paths. The returned
14574 * list is sorted from most desirable to least desirable and always contains
14575 * the default locale "C".
14577 * For example, if LANGUAGE=de:en_US, then the returned list is
14578 * "de", "en_US", "en", "C".
14580 * This function consults the environment variables <envar>LANGUAGE</envar>,
14581 * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
14582 * to find the list of locales specified by the user.
14584 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14590 * g_get_locale_variants:
14591 * @locale: a locale identifier
14593 * Returns a list of derived variants of @locale, which can be used to
14594 * e.g. construct locale-dependent filenames or search paths. The returned
14595 * list is sorted from most desirable to least desirable.
14596 * This function handles territory, charset and extra locale modifiers.
14598 * For example, if @locale is "fr_BE", then the returned list
14599 * is "fr_BE", "fr".
14601 * If you need the list of variants for the <emphasis>current locale</emphasis>,
14602 * use g_get_language_names().
14604 * Returns: (transfer full) (array zero-terminated=1) (element-type utf8): a newly allocated array of newly allocated strings with the locale variants. Free with g_strfreev().
14610 * g_get_monotonic_time:
14612 * Queries the system monotonic time, if available.
14614 * On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
14615 * is a very shallow wrapper for that. Otherwise, we make a best effort
14616 * that probably involves returning the wall clock time (with at least
14617 * microsecond accuracy, subject to the limitations of the OS kernel).
14619 * It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
14620 * not count time spent while the machine is suspended.
14622 * On Windows, "limitations of the OS kernel" is a rather substantial
14623 * statement. Depending on the configuration of the system, the wall
14624 * clock time is updated as infrequently as 64 times a second (which
14625 * is approximately every 16ms). Also, on XP (but not on Vista or later)
14626 * the monotonic clock is locally monotonic, but may differ in exact
14627 * value between processes due to timer wrap handling.
14629 * Returns: the monotonic time, in microseconds
14637 * Gets the name of the program. This name should <emphasis>not</emphasis>
14638 * be localized, contrast with g_get_application_name().
14639 * (If you are using GDK or GTK+ the program name is set in gdk_init(),
14640 * which is called by gtk_init(). The program name is found by taking
14641 * the last component of <literal>argv[0]</literal>.)
14643 * Returns: the name of the program. The returned string belongs to GLib and must not be modified or freed.
14650 * Gets the real name of the user. This usually comes from the user's entry
14651 * in the <filename>passwd</filename> file. The encoding of the returned
14652 * string is system-defined. (On Windows, it is, however, always UTF-8.)
14653 * If the real user name cannot be determined, the string "Unknown" is
14656 * Returns: the user's real name.
14663 * Queries the system wall-clock time.
14665 * This call is functionally equivalent to g_get_current_time() except
14666 * that the return value is often more convenient than dealing with a
14669 * You should only use this call if you are actually interested in the real
14670 * wall-clock time. g_get_monotonic_time() is probably more useful for
14671 * measuring intervals.
14673 * Returns: the number of microseconds since January 1, 1970 UTC.
14679 * g_get_system_config_dirs:
14681 * Returns an ordered list of base directories in which to access
14682 * system-wide configuration information.
14684 * On UNIX platforms this is determined using the mechanisms described in
14685 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14686 * XDG Base Directory Specification</ulink>.
14687 * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
14689 * On Windows is the directory that contains application data for all users.
14690 * A typical path is C:\Documents and Settings\All Users\Application Data.
14691 * This folder is used for application data that is not user specific.
14692 * For example, an application can store a spell-check dictionary, a database
14693 * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
14694 * This information will not roam and is available to anyone using the computer.
14696 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14702 * g_get_system_data_dirs:
14704 * Returns an ordered list of base directories in which to access
14705 * system-wide application data.
14707 * On UNIX platforms this is determined using the mechanisms described in
14708 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14709 * XDG Base Directory Specification</ulink>
14710 * In this case the list of directories retrieved will be XDG_DATA_DIRS.
14712 * On Windows the first elements in the list are the Application Data
14713 * and Documents folders for All Users. (These can be determined only
14714 * on Windows 2000 or later and are not present in the list on other
14715 * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
14716 * CSIDL_COMMON_DOCUMENTS.
14718 * Then follows the "share" subfolder in the installation folder for
14719 * the package containing the DLL that calls this function, if it can
14722 * Finally the list contains the "share" subfolder in the installation
14723 * folder for GLib, and in the installation folder for the package the
14724 * application's .exe file belongs to.
14726 * The installation folders above are determined by looking up the
14727 * folder where the module (DLL or EXE) in question is located. If the
14728 * folder's name is "bin", its parent is used, otherwise the folder
14731 * Note that on Windows the returned list can vary depending on where
14732 * this function is called.
14734 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14742 * Gets the directory to use for temporary files. This is found from
14743 * inspecting the environment variables <envar>TMPDIR</envar>,
14744 * <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
14745 * of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
14746 * The encoding of the returned string is system-defined. On Windows,
14747 * it is always UTF-8. The return value is never %NULL or the empty string.
14749 * Returns: the directory to use for temporary files.
14754 * g_get_user_cache_dir:
14756 * Returns a base directory in which to store non-essential, cached
14757 * data specific to particular user.
14759 * On UNIX platforms this is determined using the mechanisms described in
14760 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14761 * XDG Base Directory Specification</ulink>.
14762 * In this case the directory retrieved will be XDG_CACHE_HOME.
14764 * On Windows is the directory that serves as a common repository for
14765 * temporary Internet files. A typical path is
14766 * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
14767 * See documentation for CSIDL_INTERNET_CACHE.
14769 * Returns: a string owned by GLib that must not be modified or freed.
14775 * g_get_user_config_dir:
14777 * Returns a base directory in which to store user-specific application
14778 * configuration information such as user preferences and settings.
14780 * On UNIX platforms this is determined using the mechanisms described in
14781 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14782 * XDG Base Directory Specification</ulink>.
14783 * In this case the directory retrieved will be XDG_CONFIG_HOME.
14785 * On Windows this is the folder to use for local (as opposed to
14786 * roaming) application data. See documentation for
14787 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14788 * what g_get_user_data_dir() returns.
14790 * Returns: a string owned by GLib that must not be modified or freed.
14796 * g_get_user_data_dir:
14798 * Returns a base directory in which to access application data such
14799 * as icons that is customized for a particular user.
14801 * On UNIX platforms this is determined using the mechanisms described in
14802 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14803 * XDG Base Directory Specification</ulink>.
14804 * In this case the directory retrieved will be XDG_DATA_HOME.
14806 * On Windows this is the folder to use for local (as opposed to
14807 * roaming) application data. See documentation for
14808 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14809 * what g_get_user_config_dir() returns.
14811 * Returns: a string owned by GLib that must not be modified or freed.
14819 * Gets the user name of the current user. The encoding of the returned
14820 * string is system-defined. On UNIX, it might be the preferred file name
14821 * encoding, or something else, and there is no guarantee that it is even
14822 * consistent on a machine. On Windows, it is always UTF-8.
14824 * Returns: the user name of the current user.
14829 * g_get_user_runtime_dir:
14831 * Returns a directory that is unique to the current user on the local
14834 * On UNIX platforms this is determined using the mechanisms described in
14835 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14836 * XDG Base Directory Specification</ulink>. This is the directory
14837 * specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
14838 * In the case that this variable is not set, GLib will issue a warning
14839 * message to stderr and return the value of g_get_user_cache_dir().
14841 * On Windows this is the folder to use for local (as opposed to
14842 * roaming) application data. See documentation for
14843 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14844 * what g_get_user_config_dir() returns.
14846 * Returns: a string owned by GLib that must not be modified or freed.
14852 * g_get_user_special_dir:
14853 * @directory: the logical id of special directory
14855 * Returns the full path of a special directory using its logical id.
14857 * On Unix this is done using the XDG special user directories.
14858 * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
14859 * falls back to <filename>$HOME/Desktop</filename> when XDG special
14860 * user directories have not been set up.
14862 * Depending on the platform, the user might be able to change the path
14863 * of the special directory without requiring the session to restart; GLib
14864 * will not reflect any change once the special directories are loaded.
14866 * Returns: the path to the specified special directory, or %NULL if the logical id was not found. The returned string is owned by GLib and should not be modified or freed.
14873 * @variable: the environment variable to get, in the GLib file name encoding
14875 * Returns the value of an environment variable.
14877 * The name and value are in the GLib file name encoding. On UNIX,
14878 * this means the actual bytes which might or might not be in some
14879 * consistent character set and encoding. On Windows, it is in UTF-8.
14880 * On Windows, in case the environment variable's value contains
14881 * references to other environment variables, they are expanded.
14883 * Returns: the value of the environment variable, or %NULL if the environment variable is not found. The returned string may be overwritten by the next call to g_getenv(), g_setenv() or g_unsetenv().
14888 * g_hash_table_add:
14889 * @hash_table: a #GHashTable
14890 * @key: a key to insert
14892 * This is a convenience function for using a #GHashTable as a set. It
14893 * is equivalent to calling g_hash_table_replace() with @key as both the
14894 * key and the value.
14896 * When a hash table only ever contains keys that have themselves as the
14897 * corresponding value it is able to be stored more efficiently. See
14898 * the discussion in the section description.
14905 * g_hash_table_contains:
14906 * @hash_table: a #GHashTable
14907 * @key: a key to check
14909 * Checks if @key is in @hash_table.
14916 * g_hash_table_destroy:
14917 * @hash_table: a #GHashTable
14919 * Destroys all keys and values in the #GHashTable and decrements its
14920 * reference count by 1. If keys and/or values are dynamically allocated,
14921 * you should either free them first or create the #GHashTable with destroy
14922 * notifiers using g_hash_table_new_full(). In the latter case the destroy
14923 * functions you supplied will be called on all keys and values during the
14924 * destruction phase.
14929 * g_hash_table_find:
14930 * @hash_table: a #GHashTable
14931 * @predicate: function to test the key/value pairs for a certain property
14932 * @user_data: user data to pass to the function
14934 * Calls the given function for key/value pairs in the #GHashTable
14935 * until @predicate returns %TRUE. The function is passed the key
14936 * and value of each pair, and the given @user_data parameter. The
14937 * hash table may not be modified while iterating over it (you can't
14938 * add/remove items).
14940 * Note, that hash tables are really only optimized for forward
14941 * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
14942 * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
14943 * once per every entry in a hash table) should probably be reworked
14944 * to use additional or different data structures for reverse lookups
14945 * (keep in mind that an O(n) find/foreach operation issued for all n
14946 * values in a hash table ends up needing O(n*n) operations).
14948 * Returns: (allow-none): The value of the first key/value pair is returned, for which @predicate evaluates to %TRUE. If no pair with the requested property is found, %NULL is returned.
14954 * g_hash_table_foreach:
14955 * @hash_table: a #GHashTable
14956 * @func: the function to call for each key/value pair
14957 * @user_data: user data to pass to the function
14959 * Calls the given function for each of the key/value pairs in the
14960 * #GHashTable. The function is passed the key and value of each
14961 * pair, and the given @user_data parameter. The hash table may not
14962 * be modified while iterating over it (you can't add/remove
14963 * items). To remove all items matching a predicate, use
14964 * g_hash_table_foreach_remove().
14966 * See g_hash_table_find() for performance caveats for linear
14967 * order searches in contrast to g_hash_table_lookup().
14972 * g_hash_table_foreach_remove:
14973 * @hash_table: a #GHashTable
14974 * @func: the function to call for each key/value pair
14975 * @user_data: user data to pass to the function
14977 * Calls the given function for each key/value pair in the
14978 * #GHashTable. If the function returns %TRUE, then the key/value
14979 * pair is removed from the #GHashTable. If you supplied key or
14980 * value destroy functions when creating the #GHashTable, they are
14981 * used to free the memory allocated for the removed keys and values.
14983 * See #GHashTableIter for an alternative way to loop over the
14984 * key/value pairs in the hash table.
14986 * Returns: the number of key/value pairs removed
14991 * g_hash_table_foreach_steal:
14992 * @hash_table: a #GHashTable
14993 * @func: the function to call for each key/value pair
14994 * @user_data: user data to pass to the function
14996 * Calls the given function for each key/value pair in the
14997 * #GHashTable. If the function returns %TRUE, then the key/value
14998 * pair is removed from the #GHashTable, but no key or value
14999 * destroy functions are called.
15001 * See #GHashTableIter for an alternative way to loop over the
15002 * key/value pairs in the hash table.
15004 * Returns: the number of key/value pairs removed.
15009 * g_hash_table_freeze:
15010 * @hash_table: a #GHashTable
15012 * This function is deprecated and will be removed in the next major
15013 * release of GLib. It does nothing.
15018 * g_hash_table_get_keys:
15019 * @hash_table: a #GHashTable
15021 * Retrieves every key inside @hash_table. The returned data
15022 * is valid until @hash_table is modified.
15024 * Returns: a #GList containing all the keys inside the hash table. The content of the list is owned by the hash table and should not be modified or freed. Use g_list_free() when done using the list.
15030 * g_hash_table_get_values:
15031 * @hash_table: a #GHashTable
15033 * Retrieves every value inside @hash_table. The returned data
15034 * is valid until @hash_table is modified.
15036 * Returns: a #GList containing all the values inside the hash table. The content of the list is owned by the hash table and should not be modified or freed. Use g_list_free() when done using the list.
15042 * g_hash_table_insert:
15043 * @hash_table: a #GHashTable
15044 * @key: a key to insert
15045 * @value: the value to associate with the key
15047 * Inserts a new key and value into a #GHashTable.
15049 * If the key already exists in the #GHashTable its current
15050 * value is replaced with the new value. If you supplied a
15051 * @value_destroy_func when creating the #GHashTable, the old
15052 * value is freed using that function. If you supplied a
15053 * @key_destroy_func when creating the #GHashTable, the passed
15054 * key is freed using that function.
15059 * g_hash_table_iter_get_hash_table:
15060 * @iter: an initialized #GHashTableIter
15062 * Returns the #GHashTable associated with @iter.
15064 * Returns: the #GHashTable associated with @iter.
15070 * g_hash_table_iter_init:
15071 * @iter: an uninitialized #GHashTableIter
15072 * @hash_table: a #GHashTable
15074 * Initializes a key/value pair iterator and associates it with
15075 * @hash_table. Modifying the hash table after calling this function
15076 * invalidates the returned iterator.
15078 * GHashTableIter iter;
15079 * gpointer key, value;
15081 * g_hash_table_iter_init (&iter, hash_table);
15082 * while (g_hash_table_iter_next (&iter, &key, &value))
15084 * /* do something with key and value */
15093 * g_hash_table_iter_next:
15094 * @iter: an initialized #GHashTableIter
15095 * @key: (allow-none): a location to store the key, or %NULL
15096 * @value: (allow-none): a location to store the value, or %NULL
15098 * Advances @iter and retrieves the key and/or value that are now
15099 * pointed to as a result of this advancement. If %FALSE is returned,
15100 * @key and @value are not set, and the iterator becomes invalid.
15102 * Returns: %FALSE if the end of the #GHashTable has been reached.
15108 * g_hash_table_iter_remove:
15109 * @iter: an initialized #GHashTableIter
15111 * Removes the key/value pair currently pointed to by the iterator
15112 * from its associated #GHashTable. Can only be called after
15113 * g_hash_table_iter_next() returned %TRUE, and cannot be called
15114 * more than once for the same key/value pair.
15116 * If the #GHashTable was created using g_hash_table_new_full(),
15117 * the key and value are freed using the supplied destroy functions,
15118 * otherwise you have to make sure that any dynamically allocated
15119 * values are freed yourself.
15126 * g_hash_table_iter_replace:
15127 * @iter: an initialized #GHashTableIter
15128 * @value: the value to replace with
15130 * Replaces the value currently pointed to by the iterator
15131 * from its associated #GHashTable. Can only be called after
15132 * g_hash_table_iter_next() returned %TRUE.
15134 * If you supplied a @value_destroy_func when creating the
15135 * #GHashTable, the old value is freed using that function.
15142 * g_hash_table_iter_steal:
15143 * @iter: an initialized #GHashTableIter
15145 * Removes the key/value pair currently pointed to by the
15146 * iterator from its associated #GHashTable, without calling
15147 * the key and value destroy functions. Can only be called
15148 * after g_hash_table_iter_next() returned %TRUE, and cannot
15149 * be called more than once for the same key/value pair.
15156 * g_hash_table_lookup:
15157 * @hash_table: a #GHashTable
15158 * @key: the key to look up
15160 * Looks up a key in a #GHashTable. Note that this function cannot
15161 * distinguish between a key that is not present and one which is present
15162 * and has the value %NULL. If you need this distinction, use
15163 * g_hash_table_lookup_extended().
15165 * Returns: (allow-none): the associated value, or %NULL if the key is not found
15170 * g_hash_table_lookup_extended:
15171 * @hash_table: a #GHashTable
15172 * @lookup_key: the key to look up
15173 * @orig_key: (allow-none): return location for the original key, or %NULL
15174 * @value: (allow-none): return location for the value associated with the key, or %NULL
15176 * Looks up a key in the #GHashTable, returning the original key and the
15177 * associated value and a #gboolean which is %TRUE if the key was found. This
15178 * is useful if you need to free the memory allocated for the original key,
15179 * for example before calling g_hash_table_remove().
15181 * You can actually pass %NULL for @lookup_key to test
15182 * whether the %NULL key exists, provided the hash and equal functions
15183 * of @hash_table are %NULL-safe.
15185 * Returns: %TRUE if the key was found in the #GHashTable
15190 * g_hash_table_new:
15191 * @hash_func: a function to create a hash value from a key
15192 * @key_equal_func: a function to check two keys for equality
15194 * Creates a new #GHashTable with a reference count of 1.
15196 * Hash values returned by @hash_func are used to determine where keys
15197 * are stored within the #GHashTable data structure. The g_direct_hash(),
15198 * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
15199 * functions are provided for some common types of keys.
15200 * If @hash_func is %NULL, g_direct_hash() is used.
15202 * @key_equal_func is used when looking up keys in the #GHashTable.
15203 * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
15204 * and g_str_equal() functions are provided for the most common types
15205 * of keys. If @key_equal_func is %NULL, keys are compared directly in
15206 * a similar fashion to g_direct_equal(), but without the overhead of
15209 * Returns: a new #GHashTable
15214 * g_hash_table_new_full:
15215 * @hash_func: a function to create a hash value from a key
15216 * @key_equal_func: a function to check two keys for equality
15217 * @key_destroy_func: (allow-none): a function to free the memory allocated for the key used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
15218 * @value_destroy_func: (allow-none): a function to free the memory allocated for the value used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
15220 * Creates a new #GHashTable like g_hash_table_new() with a reference
15221 * count of 1 and allows to specify functions to free the memory
15222 * allocated for the key and value that get called when removing the
15223 * entry from the #GHashTable.
15225 * Returns: a new #GHashTable
15230 * g_hash_table_ref:
15231 * @hash_table: a valid #GHashTable
15233 * Atomically increments the reference count of @hash_table by one.
15234 * This function is MT-safe and may be called from any thread.
15236 * Returns: the passed in #GHashTable
15242 * g_hash_table_remove:
15243 * @hash_table: a #GHashTable
15244 * @key: the key to remove
15246 * Removes a key and its associated value from a #GHashTable.
15248 * If the #GHashTable was created using g_hash_table_new_full(), the
15249 * key and value are freed using the supplied destroy functions, otherwise
15250 * you have to make sure that any dynamically allocated values are freed
15253 * Returns: %TRUE if the key was found and removed from the #GHashTable
15258 * g_hash_table_remove_all:
15259 * @hash_table: a #GHashTable
15261 * Removes all keys and their associated values from a #GHashTable.
15263 * If the #GHashTable was created using g_hash_table_new_full(),
15264 * the keys and values are freed using the supplied destroy functions,
15265 * otherwise you have to make sure that any dynamically allocated
15266 * values are freed yourself.
15273 * g_hash_table_replace:
15274 * @hash_table: a #GHashTable
15275 * @key: a key to insert
15276 * @value: the value to associate with the key
15278 * Inserts a new key and value into a #GHashTable similar to
15279 * g_hash_table_insert(). The difference is that if the key
15280 * already exists in the #GHashTable, it gets replaced by the
15281 * new key. If you supplied a @value_destroy_func when creating
15282 * the #GHashTable, the old value is freed using that function.
15283 * If you supplied a @key_destroy_func when creating the
15284 * #GHashTable, the old key is freed using that function.
15289 * g_hash_table_size:
15290 * @hash_table: a #GHashTable
15292 * Returns the number of elements contained in the #GHashTable.
15294 * Returns: the number of key/value pairs in the #GHashTable.
15299 * g_hash_table_steal:
15300 * @hash_table: a #GHashTable
15301 * @key: the key to remove
15303 * Removes a key and its associated value from a #GHashTable without
15304 * calling the key and value destroy functions.
15306 * Returns: %TRUE if the key was found and removed from the #GHashTable
15311 * g_hash_table_steal_all:
15312 * @hash_table: a #GHashTable
15314 * Removes all keys and their associated values from a #GHashTable
15315 * without calling the key and value destroy functions.
15322 * g_hash_table_thaw:
15323 * @hash_table: a #GHashTable
15325 * This function is deprecated and will be removed in the next major
15326 * release of GLib. It does nothing.
15331 * g_hash_table_unref:
15332 * @hash_table: a valid #GHashTable
15334 * Atomically decrements the reference count of @hash_table by one.
15335 * If the reference count drops to 0, all keys and values will be
15336 * destroyed, and all memory allocated by the hash table is released.
15337 * This function is MT-safe and may be called from any thread.
15345 * @hmac: the #GHmac to copy
15347 * Copies a #GHmac. If @hmac has been closed, by calling
15348 * g_hmac_get_string() or g_hmac_get_digest(), the copied
15349 * HMAC will be closed as well.
15351 * Returns: the copy of the passed #GHmac. Use g_hmac_unref() when finished using it.
15357 * g_hmac_get_digest:
15359 * @buffer: output buffer
15360 * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
15362 * Gets the digest from @checksum as a raw binary array and places it
15363 * into @buffer. The size of the digest depends on the type of checksum.
15365 * Once this function has been called, the #GHmac is closed and can
15366 * no longer be updated with g_checksum_update().
15373 * g_hmac_get_string:
15376 * Gets the HMAC as an hexadecimal string.
15378 * Once this function has been called the #GHmac can no longer be
15379 * updated with g_hmac_update().
15381 * The hexadecimal characters will be lower case.
15383 * Returns: the hexadecimal representation of the HMAC. The returned string is owned by the HMAC and should not be modified or freed.
15390 * @digest_type: the desired type of digest
15391 * @key: (array length=key_len): the key for the HMAC
15392 * @key_len: the length of the keys
15394 * Creates a new #GHmac, using the digest algorithm @digest_type.
15395 * If the @digest_type is not known, %NULL is returned.
15396 * A #GHmac can be used to compute the HMAC of a key and an
15397 * arbitrary binary blob, using different hashing algorithms.
15399 * A #GHmac works by feeding a binary blob through g_hmac_update()
15400 * until the data is complete; the digest can then be extracted
15401 * using g_hmac_get_string(), which will return the checksum as a
15402 * hexadecimal string; or g_hmac_get_digest(), which will return a
15403 * array of raw bytes. Once either g_hmac_get_string() or
15404 * g_hmac_get_digest() have been called on a #GHmac, the HMAC
15405 * will be closed and it won't be possible to call g_hmac_update()
15408 * Returns: the newly created #GHmac, or %NULL. Use g_hmac_unref() to free the memory allocated by it.
15415 * @hmac: a valid #GHmac
15417 * Atomically increments the reference count of @hmac by one.
15419 * This function is MT-safe and may be called from any thread.
15421 * Returns: the passed in #GHmac.
15430 * Atomically decrements the reference count of @hmac by one.
15432 * If the reference count drops to 0, all keys and values will be
15433 * destroyed, and all memory allocated by the hash table is released.
15434 * This function is MT-safe and may be called from any thread.
15435 * Frees the memory allocated for @hmac.
15444 * @data: (array length=length): buffer used to compute the checksum
15445 * @length: size of the buffer, or -1 if it is a nul-terminated string
15447 * Feeds @data into an existing #GHmac.
15449 * The HMAC must still be open, that is g_hmac_get_string() or
15450 * g_hmac_get_digest() must not have been called on @hmac.
15458 * @hook_list: a #GHookList
15460 * Allocates space for a #GHook and initializes it.
15462 * Returns: a new #GHook
15468 * @hook_list: a #GHookList
15469 * @hook: the #GHook to add to the end of @hook_list
15471 * Appends a #GHook onto the end of a #GHookList.
15476 * g_hook_compare_ids:
15477 * @new_hook: a #GHook
15478 * @sibling: a #GHook to compare with @new_hook
15480 * Compares the ids of two #GHook elements, returning a negative value
15481 * if the second id is greater than the first.
15483 * Returns: a value <= 0 if the id of @sibling is >= the id of @new_hook
15489 * @hook_list: a #GHookList
15490 * @hook_id: a hook ID
15492 * Destroys a #GHook, given its ID.
15494 * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed
15499 * g_hook_destroy_link:
15500 * @hook_list: a #GHookList
15501 * @hook: the #GHook to remove
15503 * Removes one #GHook from a #GHookList, marking it
15504 * inactive and calling g_hook_unref() on it.
15510 * @hook_list: a #GHookList
15511 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15512 * @func: the function to call for each #GHook, which should return %TRUE when the #GHook has been found
15513 * @data: the data to pass to @func
15515 * Finds a #GHook in a #GHookList using the given function to
15516 * test for a match.
15518 * Returns: the found #GHook or %NULL if no matching #GHook is found
15523 * g_hook_find_data:
15524 * @hook_list: a #GHookList
15525 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15526 * @data: the data to find
15528 * Finds a #GHook in a #GHookList with the given data.
15530 * Returns: the #GHook with the given @data or %NULL if no matching #GHook is found
15535 * g_hook_find_func:
15536 * @hook_list: a #GHookList
15537 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15538 * @func: the function to find
15540 * Finds a #GHook in a #GHookList with the given function.
15542 * Returns: the #GHook with the given @func or %NULL if no matching #GHook is found
15547 * g_hook_find_func_data:
15548 * @hook_list: a #GHookList
15549 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15550 * @func: the function to find
15551 * @data: the data to find
15553 * Finds a #GHook in a #GHookList with the given function and data.
15555 * Returns: the #GHook with the given @func and @data or %NULL if no matching #GHook is found
15560 * g_hook_first_valid:
15561 * @hook_list: a #GHookList
15562 * @may_be_in_call: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15564 * Returns the first #GHook in a #GHookList which has not been destroyed.
15565 * The reference count for the #GHook is incremented, so you must call
15566 * g_hook_unref() to restore it when no longer needed. (Or call
15567 * g_hook_next_valid() if you are stepping through the #GHookList.)
15569 * Returns: the first valid #GHook, or %NULL if none are valid
15575 * @hook_list: a #GHookList
15576 * @hook: the #GHook to free
15578 * Calls the #GHookList @finalize_hook function if it exists,
15579 * and frees the memory allocated for the #GHook.
15585 * @hook_list: a #GHookList
15586 * @hook_id: a hook id
15588 * Returns the #GHook with the given id, or %NULL if it is not found.
15590 * Returns: the #GHook with the given id, or %NULL if it is not found
15595 * g_hook_insert_before:
15596 * @hook_list: a #GHookList
15597 * @sibling: the #GHook to insert the new #GHook before
15598 * @hook: the #GHook to insert
15600 * Inserts a #GHook into a #GHookList, before a given #GHook.
15605 * g_hook_insert_sorted:
15606 * @hook_list: a #GHookList
15607 * @hook: the #GHook to insert
15608 * @func: the comparison function used to sort the #GHook elements
15610 * Inserts a #GHook into a #GHookList, sorted by the given function.
15615 * g_hook_list_clear:
15616 * @hook_list: a #GHookList
15618 * Removes all the #GHook elements from a #GHookList.
15623 * g_hook_list_init:
15624 * @hook_list: a #GHookList
15625 * @hook_size: the size of each element in the #GHookList, typically <literal>sizeof (GHook)</literal>
15627 * Initializes a #GHookList.
15628 * This must be called before the #GHookList is used.
15633 * g_hook_list_invoke:
15634 * @hook_list: a #GHookList
15635 * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15637 * Calls all of the #GHook functions in a #GHookList.
15642 * g_hook_list_invoke_check:
15643 * @hook_list: a #GHookList
15644 * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15646 * Calls all of the #GHook functions in a #GHookList.
15647 * Any function which returns %FALSE is removed from the #GHookList.
15652 * g_hook_list_marshal:
15653 * @hook_list: a #GHookList
15654 * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15655 * @marshaller: the function to call for each #GHook
15656 * @marshal_data: data to pass to @marshaller
15658 * Calls a function on each valid #GHook.
15663 * g_hook_list_marshal_check:
15664 * @hook_list: a #GHookList
15665 * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15666 * @marshaller: the function to call for each #GHook
15667 * @marshal_data: data to pass to @marshaller
15669 * Calls a function on each valid #GHook and destroys it if the
15670 * function returns %FALSE.
15675 * g_hook_next_valid:
15676 * @hook_list: a #GHookList
15677 * @hook: the current #GHook
15678 * @may_be_in_call: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15680 * Returns the next #GHook in a #GHookList which has not been destroyed.
15681 * The reference count for the #GHook is incremented, so you must call
15682 * g_hook_unref() to restore it when no longer needed. (Or continue to call
15683 * g_hook_next_valid() until %NULL is returned.)
15685 * Returns: the next valid #GHook, or %NULL if none are valid
15691 * @hook_list: a #GHookList
15692 * @hook: the #GHook to add to the start of @hook_list
15694 * Prepends a #GHook on the start of a #GHookList.
15700 * @hook_list: a #GHookList
15701 * @hook: the #GHook to increment the reference count of
15703 * Increments the reference count for a #GHook.
15705 * Returns: the @hook that was passed in (since 2.6)
15711 * @hook_list: a #GHookList
15712 * @hook: the #GHook to unref
15714 * Decrements the reference count of a #GHook.
15715 * If the reference count falls to 0, the #GHook is removed
15716 * from the #GHookList and g_hook_free() is called to free it.
15721 * g_hostname_is_ascii_encoded:
15722 * @hostname: a hostname
15724 * Tests if @hostname contains segments with an ASCII-compatible
15725 * encoding of an Internationalized Domain Name. If this returns
15726 * %TRUE, you should decode the hostname with g_hostname_to_unicode()
15727 * before displaying it to the user.
15729 * Note that a hostname might contain a mix of encoded and unencoded
15730 * segments, and so it is possible for g_hostname_is_non_ascii() and
15731 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15733 * Returns: %TRUE if @hostname contains any ASCII-encoded segments.
15739 * g_hostname_is_ip_address:
15740 * @hostname: a hostname (or IP address in string form)
15742 * Tests if @hostname is the string form of an IPv4 or IPv6 address.
15743 * (Eg, "192.168.0.1".)
15745 * Returns: %TRUE if @hostname is an IP address
15751 * g_hostname_is_non_ascii:
15752 * @hostname: a hostname
15754 * Tests if @hostname contains Unicode characters. If this returns
15755 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
15756 * before using it in non-IDN-aware contexts.
15758 * Note that a hostname might contain a mix of encoded and unencoded
15759 * segments, and so it is possible for g_hostname_is_non_ascii() and
15760 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15762 * Returns: %TRUE if @hostname contains any non-ASCII characters
15768 * g_hostname_to_ascii:
15769 * @hostname: a valid UTF-8 or ASCII hostname
15771 * Converts @hostname to its canonical ASCII form; an ASCII-only
15772 * string containing no uppercase letters and not ending with a
15775 * Returns: an ASCII hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15781 * g_hostname_to_unicode:
15782 * @hostname: a valid UTF-8 or ASCII hostname
15784 * Converts @hostname to its canonical presentation form; a UTF-8
15785 * string in Unicode normalization form C, containing no uppercase
15786 * letters, no forbidden characters, and no ASCII-encoded segments,
15787 * and not ending with a trailing dot.
15789 * Of course if @hostname is not an internationalized hostname, then
15790 * the canonical presentation form will be entirely ASCII.
15792 * Returns: a UTF-8 hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15799 * @val: a 32-bit integer value in host byte order
15801 * Converts a 32-bit integer value from host to network byte order.
15803 * Returns: @val converted to network byte order
15809 * @val: a 16-bit integer value in host byte order
15811 * Converts a 16-bit integer value from host to network byte order.
15813 * Returns: @val converted to network byte order
15819 * @converter: conversion descriptor from g_iconv_open()
15820 * @inbuf: bytes to convert
15821 * @inbytes_left: inout parameter, bytes remaining to convert in @inbuf
15822 * @outbuf: converted output bytes
15823 * @outbytes_left: inout parameter, bytes available to fill in @outbuf
15825 * Same as the standard UNIX routine iconv(), but
15826 * may be implemented via libiconv on UNIX flavors that lack
15827 * a native implementation.
15829 * GLib provides g_convert() and g_locale_to_utf8() which are likely
15830 * more convenient than the raw iconv wrappers.
15832 * Returns: count of non-reversible conversions, or -1 on error
15838 * @converter: a conversion descriptor from g_iconv_open()
15840 * Same as the standard UNIX routine iconv_close(), but
15841 * may be implemented via libiconv on UNIX flavors that lack
15842 * a native implementation. Should be called to clean up
15843 * the conversion descriptor from g_iconv_open() when
15844 * you are done converting things.
15846 * GLib provides g_convert() and g_locale_to_utf8() which are likely
15847 * more convenient than the raw iconv wrappers.
15849 * Returns: -1 on error, 0 on success
15855 * @to_codeset: destination codeset
15856 * @from_codeset: source codeset
15858 * Same as the standard UNIX routine iconv_open(), but
15859 * may be implemented via libiconv on UNIX flavors that lack
15860 * a native implementation.
15862 * GLib provides g_convert() and g_locale_to_utf8() which are likely
15863 * more convenient than the raw iconv wrappers.
15865 * Returns: a "conversion descriptor", or (GIConv)-1 if opening the converter failed.
15871 * @function: function to call
15872 * @data: data to pass to @function.
15874 * Adds a function to be called whenever there are no higher priority
15875 * events pending to the default main loop. The function is given the
15876 * default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
15877 * returns %FALSE it is automatically removed from the list of event
15878 * sources and will not be called again.
15880 * This internally creates a main loop source using g_idle_source_new()
15881 * and attaches it to the main loop context using g_source_attach().
15882 * You can do these steps manually if you need greater control.
15884 * Returns: the ID (greater than 0) of the event source.
15890 * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
15891 * @function: function to call
15892 * @data: data to pass to @function
15893 * @notify: (allow-none): function to call when the idle is removed, or %NULL
15895 * Adds a function to be called whenever there are no higher priority
15896 * events pending. If the function returns %FALSE it is automatically
15897 * removed from the list of event sources and will not be called again.
15899 * This internally creates a main loop source using g_idle_source_new()
15900 * and attaches it to the main loop context using g_source_attach().
15901 * You can do these steps manually if you need greater control.
15903 * Returns: the ID (greater than 0) of the event source.
15904 * Rename to: g_idle_add
15909 * g_idle_remove_by_data:
15910 * @data: the data for the idle source's callback.
15912 * Removes the idle function with the given data.
15914 * Returns: %TRUE if an idle source was found and removed.
15919 * g_idle_source_new:
15921 * Creates a new idle source.
15923 * The source will not initially be associated with any #GMainContext
15924 * and must be added to one with g_source_attach() before it will be
15925 * executed. Note that the default priority for idle sources is
15926 * %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
15927 * have a default priority of %G_PRIORITY_DEFAULT.
15929 * Returns: the newly-created idle source
15935 * @v1: a pointer to a #gint64 key
15936 * @v2: a pointer to a #gint64 key to compare with @v1
15938 * Compares the two #gint64 values being pointed to and returns
15939 * %TRUE if they are equal.
15940 * It can be passed to g_hash_table_new() as the @key_equal_func
15941 * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
15944 * Returns: %TRUE if the two keys match.
15951 * @v: a pointer to a #gint64 key
15953 * Converts a pointer to a #gint64 to a hash value.
15955 * It can be passed to g_hash_table_new() as the @hash_func parameter,
15956 * when using non-%NULL pointers to 64-bit integer values as keys in a
15959 * Returns: a hash value corresponding to the key.
15966 * @v1: a pointer to a #gint key
15967 * @v2: a pointer to a #gint key to compare with @v1
15969 * Compares the two #gint values being pointed to and returns
15970 * %TRUE if they are equal.
15971 * It can be passed to g_hash_table_new() as the @key_equal_func
15972 * parameter, when using non-%NULL pointers to integers as keys in a
15975 * Note that this function acts on pointers to #gint, not on #gint directly:
15976 * if your hash table's keys are of the form
15977 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
15979 * Returns: %TRUE if the two keys match.
15985 * @v: a pointer to a #gint key
15987 * Converts a pointer to a #gint to a hash value.
15988 * It can be passed to g_hash_table_new() as the @hash_func parameter,
15989 * when using non-%NULL pointers to integer values as keys in a #GHashTable.
15991 * Note that this function acts on pointers to #gint, not on #gint directly:
15992 * if your hash table's keys are of the form
15993 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
15995 * Returns: a hash value corresponding to the key.
16000 * g_intern_static_string:
16001 * @string: (allow-none): a static string
16003 * Returns a canonical representation for @string. Interned strings
16004 * can be compared for equality by comparing the pointers, instead of
16005 * using strcmp(). g_intern_static_string() does not copy the string,
16006 * therefore @string must not be freed or modified.
16008 * Returns: a canonical representation for the string
16015 * @string: (allow-none): a string
16017 * Returns a canonical representation for @string. Interned strings
16018 * can be compared for equality by comparing the pointers, instead of
16021 * Returns: a canonical representation for the string
16028 * @channel: a #GIOChannel
16029 * @condition: the condition to watch for
16030 * @func: the function to call when the condition is satisfied
16031 * @user_data: user data to pass to @func
16033 * Adds the #GIOChannel into the default main loop context
16034 * with the default priority.
16036 * Returns: the event source id
16041 * g_io_add_watch_full:
16042 * @channel: a #GIOChannel
16043 * @priority: the priority of the #GIOChannel source
16044 * @condition: the condition to watch for
16045 * @func: the function to call when the condition is satisfied
16046 * @user_data: user data to pass to @func
16047 * @notify: the function to call when the source is removed
16049 * Adds the #GIOChannel into the default main loop context
16050 * with the given priority.
16052 * This internally creates a main loop source using g_io_create_watch()
16053 * and attaches it to the main loop context with g_source_attach().
16054 * You can do these steps manually if you need greater control.
16056 * Returns: the event source id
16057 * Rename to: g_io_add_watch
16062 * g_io_channel_close:
16063 * @channel: A #GIOChannel
16065 * Close an IO channel. Any pending data to be written will be
16066 * flushed, ignoring errors. The channel will not be freed until the
16067 * last reference is dropped using g_io_channel_unref().
16069 * Deprecated: 2.2: Use g_io_channel_shutdown() instead.
16074 * g_io_channel_error_from_errno:
16075 * @en: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
16077 * Converts an <literal>errno</literal> error number to a #GIOChannelError.
16079 * Returns: a #GIOChannelError error number, e.g. %G_IO_CHANNEL_ERROR_INVAL.
16084 * g_io_channel_error_quark:
16088 * Returns: the quark used as %G_IO_CHANNEL_ERROR
16093 * g_io_channel_flush:
16094 * @channel: a #GIOChannel
16095 * @error: location to store an error of type #GIOChannelError
16097 * Flushes the write buffer for the GIOChannel.
16099 * Returns: the status of the operation: One of #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or #G_IO_STATUS_ERROR.
16104 * g_io_channel_get_buffer_condition:
16105 * @channel: A #GIOChannel
16107 * This function returns a #GIOCondition depending on whether there
16108 * is data to be read/space to write data in the internal buffers in
16109 * the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
16111 * Returns: A #GIOCondition
16116 * g_io_channel_get_buffer_size:
16117 * @channel: a #GIOChannel
16119 * Gets the buffer size.
16121 * Returns: the size of the buffer.
16126 * g_io_channel_get_buffered:
16127 * @channel: a #GIOChannel
16129 * Returns whether @channel is buffered.
16131 * Returns: %TRUE if the @channel is buffered.
16136 * g_io_channel_get_close_on_unref:
16137 * @channel: a #GIOChannel.
16139 * Returns whether the file/socket/whatever associated with @channel
16140 * will be closed when @channel receives its final unref and is
16141 * destroyed. The default value of this is %TRUE for channels created
16142 * by g_io_channel_new_file (), and %FALSE for all other channels.
16144 * Returns: Whether the channel will be closed on the final unref of the GIOChannel data structure.
16149 * g_io_channel_get_encoding:
16150 * @channel: a #GIOChannel
16152 * Gets the encoding for the input/output of the channel.
16153 * The internal encoding is always UTF-8. The encoding %NULL
16154 * makes the channel safe for binary data.
16156 * Returns: A string containing the encoding, this string is owned by GLib and must not be freed.
16161 * g_io_channel_get_flags:
16162 * @channel: a #GIOChannel
16164 * Gets the current flags for a #GIOChannel, including read-only
16165 * flags such as %G_IO_FLAG_IS_READABLE.
16167 * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
16168 * are cached for internal use by the channel when it is created.
16169 * If they should change at some later point (e.g. partial shutdown
16170 * of a socket with the UNIX shutdown() function), the user
16171 * should immediately call g_io_channel_get_flags() to update
16172 * the internal values of these flags.
16174 * Returns: the flags which are set on the channel
16179 * g_io_channel_get_line_term:
16180 * @channel: a #GIOChannel
16181 * @length: a location to return the length of the line terminator
16183 * This returns the string that #GIOChannel uses to determine
16184 * where in the file a line break occurs. A value of %NULL
16185 * indicates autodetection.
16187 * Returns: The line termination string. This value is owned by GLib and must not be freed.
16192 * g_io_channel_init:
16193 * @channel: a #GIOChannel
16195 * Initializes a #GIOChannel struct.
16197 * This is called by each of the above functions when creating a
16198 * #GIOChannel, and so is not often needed by the application
16199 * programmer (unless you are creating a new type of #GIOChannel).
16204 * g_io_channel_new_file:
16205 * @filename: A string containing the name of a file
16206 * @mode: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
16207 * @error: A location to return an error of type %G_FILE_ERROR
16209 * Open a file @filename as a #GIOChannel using mode @mode. This
16210 * channel will be closed when the last reference to it is dropped,
16211 * so there is no need to call g_io_channel_close() (though doing
16212 * so will not cause problems, as long as no attempt is made to
16213 * access the channel after it is closed).
16215 * Returns: A #GIOChannel on success, %NULL on failure.
16220 * g_io_channel_read:
16221 * @channel: a #GIOChannel
16222 * @buf: a buffer to read the data into (which should be at least count bytes long)
16223 * @count: the number of bytes to read from the #GIOChannel
16224 * @bytes_read: returns the number of bytes actually read
16226 * Reads data from a #GIOChannel.
16228 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16229 * Deprecated: 2.2: Use g_io_channel_read_chars() instead.
16234 * g_io_channel_read_chars:
16235 * @channel: a #GIOChannel
16236 * @buf: a buffer to read data into
16237 * @count: the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character.
16238 * @bytes_read: (allow-none): The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-%NULL. This indicates that the next UTF-8 character is too wide for the buffer.
16239 * @error: a location to return an error of type #GConvertError or #GIOChannelError.
16241 * Replacement for g_io_channel_read() with the new API.
16243 * Returns: the status of the operation.
16248 * g_io_channel_read_line:
16249 * @channel: a #GIOChannel
16250 * @str_return: The line read from the #GIOChannel, including the line terminator. This data should be freed with g_free() when no longer needed. This is a nul-terminated string. If a @length of zero is returned, this will be %NULL instead.
16251 * @length: (allow-none): location to store length of the read data, or %NULL
16252 * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
16253 * @error: A location to return an error of type #GConvertError or #GIOChannelError
16255 * Reads a line, including the terminating character(s),
16256 * from a #GIOChannel into a newly-allocated string.
16257 * @str_return will contain allocated memory if the return
16258 * is %G_IO_STATUS_NORMAL.
16260 * Returns: the status of the operation.
16265 * g_io_channel_read_line_string:
16266 * @channel: a #GIOChannel
16267 * @buffer: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
16268 * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
16269 * @error: a location to store an error of type #GConvertError or #GIOChannelError
16271 * Reads a line from a #GIOChannel, using a #GString as a buffer.
16273 * Returns: the status of the operation.
16278 * g_io_channel_read_to_end:
16279 * @channel: a #GIOChannel
16280 * @str_return: Location to store a pointer to a string holding the remaining data in the #GIOChannel. This data should be freed with g_free() when no longer needed. This data is terminated by an extra nul character, but there may be other nuls in the intervening data.
16281 * @length: location to store length of the data
16282 * @error: location to return an error of type #GConvertError or #GIOChannelError
16284 * Reads all the remaining data from the file.
16286 * Returns: %G_IO_STATUS_NORMAL on success. This function never returns %G_IO_STATUS_EOF.
16291 * g_io_channel_read_unichar:
16292 * @channel: a #GIOChannel
16293 * @thechar: a location to return a character
16294 * @error: a location to return an error of type #GConvertError or #GIOChannelError
16296 * Reads a Unicode character from @channel.
16297 * This function cannot be called on a channel with %NULL encoding.
16299 * Returns: a #GIOStatus
16304 * g_io_channel_ref:
16305 * @channel: a #GIOChannel
16307 * Increments the reference count of a #GIOChannel.
16309 * Returns: the @channel that was passed in (since 2.6)
16314 * g_io_channel_seek:
16315 * @channel: a #GIOChannel
16316 * @offset: an offset, in bytes, which is added to the position specified by @type
16317 * @type: the position in the file, which can be %G_SEEK_CUR (the current position), %G_SEEK_SET (the start of the file), or %G_SEEK_END (the end of the file)
16319 * Sets the current position in the #GIOChannel, similar to the standard
16320 * library function fseek().
16322 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16323 * Deprecated: 2.2: Use g_io_channel_seek_position() instead.
16328 * g_io_channel_seek_position:
16329 * @channel: a #GIOChannel
16330 * @offset: The offset in bytes from the position specified by @type
16331 * @type: a #GSeekType. The type %G_SEEK_CUR is only allowed in those cases where a call to g_io_channel_set_encoding () is allowed. See the documentation for g_io_channel_set_encoding () for details.
16332 * @error: A location to return an error of type #GIOChannelError
16334 * Replacement for g_io_channel_seek() with the new API.
16336 * Returns: the status of the operation.
16341 * g_io_channel_set_buffer_size:
16342 * @channel: a #GIOChannel
16343 * @size: the size of the buffer, or 0 to let GLib pick a good size
16345 * Sets the buffer size.
16350 * g_io_channel_set_buffered:
16351 * @channel: a #GIOChannel
16352 * @buffered: whether to set the channel buffered or unbuffered
16354 * The buffering state can only be set if the channel's encoding
16355 * is %NULL. For any other encoding, the channel must be buffered.
16357 * A buffered channel can only be set unbuffered if the channel's
16358 * internal buffers have been flushed. Newly created channels or
16359 * channels which have returned %G_IO_STATUS_EOF
16360 * not require such a flush. For write-only channels, a call to
16361 * g_io_channel_flush () is sufficient. For all other channels,
16362 * the buffers may be flushed by a call to g_io_channel_seek_position ().
16363 * This includes the possibility of seeking with seek type %G_SEEK_CUR
16364 * and an offset of zero. Note that this means that socket-based
16365 * channels cannot be set unbuffered once they have had data
16368 * On unbuffered channels, it is safe to mix read and write
16369 * calls from the new and old APIs, if this is necessary for
16370 * maintaining old code.
16372 * The default state of the channel is buffered.
16377 * g_io_channel_set_close_on_unref:
16378 * @channel: a #GIOChannel
16379 * @do_close: Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is %TRUE for channels created by g_io_channel_new_file (), and %FALSE for all other channels.
16381 * Setting this flag to %TRUE for a channel you have already closed
16382 * can cause problems.
16387 * g_io_channel_set_encoding:
16388 * @channel: a #GIOChannel
16389 * @encoding: (allow-none): the encoding type
16390 * @error: location to store an error of type #GConvertError
16392 * Sets the encoding for the input/output of the channel.
16393 * The internal encoding is always UTF-8. The default encoding
16394 * for the external file is UTF-8.
16396 * The encoding %NULL is safe to use with binary data.
16398 * The encoding can only be set if one of the following conditions
16402 * The channel was just created, and has not been written to or read
16404 * </para></listitem>
16406 * The channel is write-only.
16407 * </para></listitem>
16409 * The channel is a file, and the file pointer was just
16410 * repositioned by a call to g_io_channel_seek_position().
16411 * (This flushes all the internal buffers.)
16412 * </para></listitem>
16414 * The current encoding is %NULL or UTF-8.
16415 * </para></listitem>
16417 * One of the (new API) read functions has just returned %G_IO_STATUS_EOF
16418 * (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
16419 * </para></listitem>
16421 * One of the functions g_io_channel_read_chars() or
16422 * g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
16423 * %G_IO_STATUS_ERROR. This may be useful in the case of
16424 * %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
16425 * Returning one of these statuses from g_io_channel_read_line(),
16426 * g_io_channel_read_line_string(), or g_io_channel_read_to_end()
16427 * does <emphasis>not</emphasis> guarantee that the encoding can
16429 * </para></listitem>
16431 * Channels which do not meet one of the above conditions cannot call
16432 * g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
16433 * they are "seekable", cannot call g_io_channel_write_chars() after
16434 * calling one of the API "read" functions.
16436 * Returns: %G_IO_STATUS_NORMAL if the encoding was successfully set.
16441 * g_io_channel_set_flags:
16442 * @channel: a #GIOChannel
16443 * @flags: the flags to set on the IO channel
16444 * @error: A location to return an error of type #GIOChannelError
16446 * Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
16448 * Returns: the status of the operation.
16453 * g_io_channel_set_line_term:
16454 * @channel: a #GIOChannel
16455 * @line_term: (allow-none): The line termination string. Use %NULL for autodetect. Autodetection breaks on "\n", "\r\n", "\r", "\0", and the Unicode paragraph separator. Autodetection should not be used for anything other than file-based channels.
16456 * @length: The length of the termination string. If -1 is passed, the string is assumed to be nul-terminated. This option allows termination strings with embedded nuls.
16458 * This sets the string that #GIOChannel uses to determine
16459 * where in the file a line break occurs.
16464 * g_io_channel_shutdown:
16465 * @channel: a #GIOChannel
16466 * @flush: if %TRUE, flush pending
16467 * @err: location to store a #GIOChannelError
16469 * Close an IO channel. Any pending data to be written will be
16470 * flushed if @flush is %TRUE. The channel will not be freed until the
16471 * last reference is dropped using g_io_channel_unref().
16473 * Returns: the status of the operation.
16478 * g_io_channel_unix_get_fd:
16479 * @channel: a #GIOChannel, created with g_io_channel_unix_new().
16481 * Returns the file descriptor of the #GIOChannel.
16483 * On Windows this function returns the file descriptor or socket of
16486 * Returns: the file descriptor of the #GIOChannel.
16491 * g_io_channel_unix_new:
16492 * @fd: a file descriptor.
16494 * Creates a new #GIOChannel given a file descriptor. On UNIX systems
16495 * this works for plain files, pipes, and sockets.
16497 * The returned #GIOChannel has a reference count of 1.
16499 * The default encoding for #GIOChannel is UTF-8. If your application
16500 * is reading output from a command using via pipe, you may need to set
16501 * the encoding to the encoding of the current locale (see
16502 * g_get_charset()) with the g_io_channel_set_encoding() function.
16504 * If you want to read raw binary data without interpretation, then
16505 * call the g_io_channel_set_encoding() function with %NULL for the
16506 * encoding argument.
16508 * This function is available in GLib on Windows, too, but you should
16509 * avoid using it on Windows. The domain of file descriptors and
16510 * sockets overlap. There is no way for GLib to know which one you mean
16511 * in case the argument you pass to this function happens to be both a
16512 * valid file descriptor and socket. If that happens a warning is
16513 * issued, and GLib assumes that it is the file descriptor you mean.
16515 * Returns: a new #GIOChannel.
16520 * g_io_channel_unref:
16521 * @channel: a #GIOChannel
16523 * Decrements the reference count of a #GIOChannel.
16528 * g_io_channel_win32_new_fd:
16529 * @fd: a C library file descriptor.
16531 * Creates a new #GIOChannel given a file descriptor on Windows. This
16532 * works for file descriptors from the C runtime.
16534 * This function works for file descriptors as returned by the open(),
16535 * creat(), pipe() and fileno() calls in the Microsoft C runtime. In
16536 * order to meaningfully use this function your code should use the
16537 * same C runtime as GLib uses, which is msvcrt.dll. Note that in
16538 * current Microsoft compilers it is near impossible to convince it to
16539 * build code that would use msvcrt.dll. The last Microsoft compiler
16540 * version that supported using msvcrt.dll as the C runtime was version
16541 * 6. The GNU compiler and toolchain for Windows, also known as Mingw,
16542 * fully supports msvcrt.dll.
16544 * If you have created a #GIOChannel for a file descriptor and started
16545 * watching (polling) it, you shouldn't call read() on the file
16546 * descriptor. This is because adding polling for a file descriptor is
16547 * implemented in GLib on Windows by starting a thread that sits
16548 * blocked in a read() from the file descriptor most of the time. All
16549 * reads from the file descriptor should be done by this internal GLib
16550 * thread. Your code should call only g_io_channel_read().
16552 * This function is available only in GLib on Windows.
16554 * Returns: a new #GIOChannel.
16559 * g_io_channel_win32_new_messages:
16560 * @hwnd: a window handle.
16562 * Creates a new #GIOChannel given a window handle on Windows.
16564 * This function creates a #GIOChannel that can be used to poll for
16565 * Windows messages for the window in question.
16567 * Returns: a new #GIOChannel.
16572 * g_io_channel_win32_new_socket:
16573 * @socket: a Winsock socket
16575 * Creates a new #GIOChannel given a socket on Windows.
16577 * This function works for sockets created by Winsock. It's available
16578 * only in GLib on Windows.
16580 * Polling a #GSource created to watch a channel for a socket puts the
16581 * socket in non-blocking mode. This is a side-effect of the
16582 * implementation and unavoidable.
16584 * Returns: a new #GIOChannel
16589 * g_io_channel_write:
16590 * @channel: a #GIOChannel
16591 * @buf: the buffer containing the data to write
16592 * @count: the number of bytes to write
16593 * @bytes_written: the number of bytes actually written
16595 * Writes data to a #GIOChannel.
16597 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16598 * Deprecated: 2.2: Use g_io_channel_write_chars() instead.
16603 * g_io_channel_write_chars:
16604 * @channel: a #GIOChannel
16605 * @buf: a buffer to write data from
16606 * @count: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
16607 * @bytes_written: The number of bytes written. This can be nonzero even if the return value is not %G_IO_STATUS_NORMAL. If the return value is %G_IO_STATUS_NORMAL and the channel is blocking, this will always be equal to @count if @count >= 0.
16608 * @error: a location to return an error of type #GConvertError or #GIOChannelError
16610 * Replacement for g_io_channel_write() with the new API.
16612 * On seekable channels with encodings other than %NULL or UTF-8, generic
16613 * mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
16614 * may only be made on a channel from which data has been read in the
16615 * cases described in the documentation for g_io_channel_set_encoding ().
16617 * Returns: the status of the operation.
16622 * g_io_channel_write_unichar:
16623 * @channel: a #GIOChannel
16624 * @thechar: a character
16625 * @error: location to return an error of type #GConvertError or #GIOChannelError
16627 * Writes a Unicode character to @channel.
16628 * This function cannot be called on a channel with %NULL encoding.
16630 * Returns: a #GIOStatus
16635 * g_io_create_watch:
16636 * @channel: a #GIOChannel to watch
16637 * @condition: conditions to watch for
16639 * Creates a #GSource that's dispatched when @condition is met for the
16640 * given @channel. For example, if condition is #G_IO_IN, the source will
16641 * be dispatched when there's data available for reading.
16643 * g_io_add_watch() is a simpler interface to this same functionality, for
16644 * the case where you want to add the source to the default main loop context
16645 * at the default priority.
16647 * On Windows, polling a #GSource created to watch a channel for a socket
16648 * puts the socket in non-blocking mode. This is a side-effect of the
16649 * implementation and unavoidable.
16651 * Returns: a new #GSource
16656 * g_key_file_free: (skip)
16657 * @key_file: a #GKeyFile
16659 * Clears all keys and groups from @key_file, and decreases the
16660 * reference count by 1. If the reference count reaches zero,
16661 * frees the key file and all its allocated memory.
16668 * g_key_file_get_boolean:
16669 * @key_file: a #GKeyFile
16670 * @group_name: a group name
16672 * @error: return location for a #GError
16674 * Returns the value associated with @key under @group_name as a
16677 * If @key cannot be found then %FALSE is returned and @error is set
16678 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
16679 * associated with @key cannot be interpreted as a boolean then %FALSE
16680 * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16682 * Returns: the value associated with the key as a boolean, or %FALSE if the key was not found or could not be parsed.
16688 * g_key_file_get_boolean_list:
16689 * @key_file: a #GKeyFile
16690 * @group_name: a group name
16692 * @length: (out): the number of booleans returned
16693 * @error: return location for a #GError
16695 * Returns the values associated with @key under @group_name as
16698 * If @key cannot be found then %NULL is returned and @error is set to
16699 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16700 * with @key cannot be interpreted as booleans then %NULL is returned
16701 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16703 * Returns: (array length=length) (element-type gboolean) (transfer container): the values associated with the key as a list of booleans, or %NULL if the key was not found or could not be parsed. The returned list of booleans should be freed with g_free() when no longer needed.
16709 * g_key_file_get_comment:
16710 * @key_file: a #GKeyFile
16711 * @group_name: (allow-none): a group name, or %NULL
16713 * @error: return location for a #GError
16715 * Retrieves a comment above @key from @group_name.
16716 * If @key is %NULL then @comment will be read from above
16717 * @group_name. If both @key and @group_name are %NULL, then
16718 * @comment will be read from above the first group in the file.
16720 * Returns: a comment that should be freed with g_free()
16726 * g_key_file_get_double:
16727 * @key_file: a #GKeyFile
16728 * @group_name: a group name
16730 * @error: return location for a #GError
16732 * Returns the value associated with @key under @group_name as a
16733 * double. If @group_name is %NULL, the start_group is used.
16735 * If @key cannot be found then 0.0 is returned and @error is set to
16736 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16737 * with @key cannot be interpreted as a double then 0.0 is returned
16738 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16740 * Returns: the value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.
16746 * g_key_file_get_double_list:
16747 * @key_file: a #GKeyFile
16748 * @group_name: a group name
16750 * @length: (out): the number of doubles returned
16751 * @error: return location for a #GError
16753 * Returns the values associated with @key under @group_name as
16756 * If @key cannot be found then %NULL is returned and @error is set to
16757 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16758 * with @key cannot be interpreted as doubles then %NULL is returned
16759 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16761 * Returns: (array length=length) (element-type gdouble) (transfer container): the values associated with the key as a list of doubles, or %NULL if the key was not found or could not be parsed. The returned list of doubles should be freed with g_free() when no longer needed.
16767 * g_key_file_get_groups:
16768 * @key_file: a #GKeyFile
16769 * @length: (out) (allow-none): return location for the number of returned groups, or %NULL
16771 * Returns all groups in the key file loaded with @key_file.
16772 * The array of returned groups will be %NULL-terminated, so
16773 * @length may optionally be %NULL.
16775 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16781 * g_key_file_get_int64:
16782 * @key_file: a non-%NULL #GKeyFile
16783 * @group_name: a non-%NULL group name
16784 * @key: a non-%NULL key
16785 * @error: return location for a #GError
16787 * Returns the value associated with @key under @group_name as a signed
16788 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
16789 * 64-bit results without truncation.
16791 * Returns: the value associated with the key as a signed 64-bit integer, or 0 if the key was not found or could not be parsed.
16797 * g_key_file_get_integer:
16798 * @key_file: a #GKeyFile
16799 * @group_name: a group name
16801 * @error: return location for a #GError
16803 * Returns the value associated with @key under @group_name as an
16806 * If @key cannot be found then 0 is returned and @error is set to
16807 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16808 * with @key cannot be interpreted as an integer then 0 is returned
16809 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16811 * Returns: the value associated with the key as an integer, or 0 if the key was not found or could not be parsed.
16817 * g_key_file_get_integer_list:
16818 * @key_file: a #GKeyFile
16819 * @group_name: a group name
16821 * @length: (out): the number of integers returned
16822 * @error: return location for a #GError
16824 * Returns the values associated with @key under @group_name as
16827 * If @key cannot be found then %NULL is returned and @error is set to
16828 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16829 * with @key cannot be interpreted as integers then %NULL is returned
16830 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16832 * Returns: (array length=length) (element-type gint) (transfer container): the values associated with the key as a list of integers, or %NULL if the key was not found or could not be parsed. The returned list of integers should be freed with g_free() when no longer needed.
16838 * g_key_file_get_keys:
16839 * @key_file: a #GKeyFile
16840 * @group_name: a group name
16841 * @length: (out) (allow-none): return location for the number of keys returned, or %NULL
16842 * @error: return location for a #GError, or %NULL
16844 * Returns all keys for the group name @group_name. The array of
16845 * returned keys will be %NULL-terminated, so @length may
16846 * optionally be %NULL. In the event that the @group_name cannot
16847 * be found, %NULL is returned and @error is set to
16848 * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16850 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16856 * g_key_file_get_locale_string:
16857 * @key_file: a #GKeyFile
16858 * @group_name: a group name
16860 * @locale: (allow-none): a locale identifier or %NULL
16861 * @error: return location for a #GError, or %NULL
16863 * Returns the value associated with @key under @group_name
16864 * translated in the given @locale if available. If @locale is
16865 * %NULL then the current locale is assumed.
16867 * If @key cannot be found then %NULL is returned and @error is set
16868 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
16869 * with @key cannot be interpreted or no suitable translation can
16870 * be found then the untranslated value is returned.
16872 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
16878 * g_key_file_get_locale_string_list:
16879 * @key_file: a #GKeyFile
16880 * @group_name: a group name
16882 * @locale: (allow-none): a locale identifier or %NULL
16883 * @length: (out) (allow-none): return location for the number of returned strings or %NULL
16884 * @error: return location for a #GError or %NULL
16886 * Returns the values associated with @key under @group_name
16887 * translated in the given @locale if available. If @locale is
16888 * %NULL then the current locale is assumed.
16890 * If @key cannot be found then %NULL is returned and @error is set
16891 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
16892 * with @key cannot be interpreted or no suitable translations
16893 * can be found then the untranslated values are returned. The
16894 * returned array is %NULL-terminated, so @length may optionally
16897 * Returns: (array length=length zero-terminated=1) (element-type utf8) (transfer full): a newly allocated %NULL-terminated string array or %NULL if the key isn't found. The string array should be freed with g_strfreev().
16903 * g_key_file_get_start_group:
16904 * @key_file: a #GKeyFile
16906 * Returns the name of the start group of the file.
16908 * Returns: The start group of the key file.
16914 * g_key_file_get_string:
16915 * @key_file: a #GKeyFile
16916 * @group_name: a group name
16918 * @error: return location for a #GError, or %NULL
16920 * Returns the string value associated with @key under @group_name.
16921 * Unlike g_key_file_get_value(), this function handles escape sequences
16924 * In the event the key cannot be found, %NULL is returned and
16925 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
16926 * event that the @group_name cannot be found, %NULL is returned
16927 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16929 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
16935 * g_key_file_get_string_list:
16936 * @key_file: a #GKeyFile
16937 * @group_name: a group name
16939 * @length: (out) (allow-none): return location for the number of returned strings, or %NULL
16940 * @error: return location for a #GError, or %NULL
16942 * Returns the values associated with @key under @group_name.
16944 * In the event the key cannot be found, %NULL is returned and
16945 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
16946 * event that the @group_name cannot be found, %NULL is returned
16947 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16949 * Returns: (array length=length zero-terminated=1) (element-type utf8) (transfer full): a %NULL-terminated string array or %NULL if the specified key cannot be found. The array should be freed with g_strfreev().
16955 * g_key_file_get_uint64:
16956 * @key_file: a non-%NULL #GKeyFile
16957 * @group_name: a non-%NULL group name
16958 * @key: a non-%NULL key
16959 * @error: return location for a #GError
16961 * Returns the value associated with @key under @group_name as an unsigned
16962 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
16963 * large positive results without truncation.
16965 * Returns: the value associated with the key as an unsigned 64-bit integer, or 0 if the key was not found or could not be parsed.
16971 * g_key_file_get_value:
16972 * @key_file: a #GKeyFile
16973 * @group_name: a group name
16975 * @error: return location for a #GError, or %NULL
16977 * Returns the raw value associated with @key under @group_name.
16978 * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
16980 * In the event the key cannot be found, %NULL is returned and
16981 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
16982 * event that the @group_name cannot be found, %NULL is returned
16983 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16985 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
16991 * g_key_file_has_group:
16992 * @key_file: a #GKeyFile
16993 * @group_name: a group name
16995 * Looks whether the key file has the group @group_name.
16997 * Returns: %TRUE if @group_name is a part of @key_file, %FALSE otherwise.
17003 * g_key_file_has_key: (skip)
17004 * @key_file: a #GKeyFile
17005 * @group_name: a group name
17007 * @error: return location for a #GError
17009 * Looks whether the key file has the key @key in the group
17012 * <note>This function does not follow the rules for #GError strictly;
17013 * the return value both carries meaning and signals an error. To use
17014 * this function, you must pass a #GError pointer in @error, and check
17015 * whether it is not %NULL to see if an error occurred.</note>
17017 * Language bindings should use g_key_file_get_value() to test whether
17018 * or not a key exists.
17020 * Returns: %TRUE if @key is a part of @group_name, %FALSE otherwise.
17026 * g_key_file_load_from_data:
17027 * @key_file: an empty #GKeyFile struct
17028 * @data: key file loaded in memory
17029 * @length: the length of @data in bytes (or -1 if data is nul-terminated)
17030 * @flags: flags from #GKeyFileFlags
17031 * @error: return location for a #GError, or %NULL
17033 * Loads a key file from memory into an empty #GKeyFile structure.
17034 * If the object cannot be created then %error is set to a #GKeyFileError.
17036 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17042 * g_key_file_load_from_data_dirs:
17043 * @key_file: an empty #GKeyFile struct
17044 * @file: (type filename): a relative path to a filename to open and parse
17045 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17046 * @flags: flags from #GKeyFileFlags
17047 * @error: return location for a #GError, or %NULL
17049 * This function looks for a key file named @file in the paths
17050 * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
17051 * loads the file into @key_file and returns the file's full path in
17052 * @full_path. If the file could not be loaded then an %error is
17053 * set to either a #GFileError or #GKeyFileError.
17055 * Returns: %TRUE if a key file could be loaded, %FALSE othewise
17061 * g_key_file_load_from_dirs:
17062 * @key_file: an empty #GKeyFile struct
17063 * @file: (type filename): a relative path to a filename to open and parse
17064 * @search_dirs: (array zero-terminated=1) (element-type filename): %NULL-terminated array of directories to search
17065 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17066 * @flags: flags from #GKeyFileFlags
17067 * @error: return location for a #GError, or %NULL
17069 * This function looks for a key file named @file in the paths
17070 * specified in @search_dirs, loads the file into @key_file and
17071 * returns the file's full path in @full_path. If the file could not
17072 * be loaded then an %error is set to either a #GFileError or
17075 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17081 * g_key_file_load_from_file:
17082 * @key_file: an empty #GKeyFile struct
17083 * @file: (type filename): the path of a filename to load, in the GLib filename encoding
17084 * @flags: flags from #GKeyFileFlags
17085 * @error: return location for a #GError, or %NULL
17087 * Loads a key file into an empty #GKeyFile structure.
17088 * If the file could not be loaded then @error is set to
17089 * either a #GFileError or #GKeyFileError.
17091 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17099 * Creates a new empty #GKeyFile object. Use
17100 * g_key_file_load_from_file(), g_key_file_load_from_data(),
17101 * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
17102 * read an existing key file.
17104 * Returns: (transfer full): an empty #GKeyFile.
17110 * g_key_file_ref: (skip)
17111 * @key_file: a #GKeyFile
17113 * Increases the reference count of @key_file.
17115 * Returns: the same @key_file.
17121 * g_key_file_remove_comment:
17122 * @key_file: a #GKeyFile
17123 * @group_name: (allow-none): a group name, or %NULL
17124 * @key: (allow-none): a key
17125 * @error: return location for a #GError
17127 * Removes a comment above @key from @group_name.
17128 * If @key is %NULL then @comment will be removed above @group_name.
17129 * If both @key and @group_name are %NULL, then @comment will
17130 * be removed above the first group in the file.
17132 * Returns: %TRUE if the comment was removed, %FALSE otherwise
17138 * g_key_file_remove_group:
17139 * @key_file: a #GKeyFile
17140 * @group_name: a group name
17141 * @error: return location for a #GError or %NULL
17143 * Removes the specified group, @group_name,
17144 * from the key file.
17146 * Returns: %TRUE if the group was removed, %FALSE otherwise
17152 * g_key_file_remove_key:
17153 * @key_file: a #GKeyFile
17154 * @group_name: a group name
17155 * @key: a key name to remove
17156 * @error: return location for a #GError or %NULL
17158 * Removes @key in @group_name from the key file.
17160 * Returns: %TRUE if the key was removed, %FALSE otherwise
17166 * g_key_file_set_boolean:
17167 * @key_file: a #GKeyFile
17168 * @group_name: a group name
17170 * @value: %TRUE or %FALSE
17172 * Associates a new boolean value with @key under @group_name.
17173 * If @key cannot be found then it is created.
17180 * g_key_file_set_boolean_list:
17181 * @key_file: a #GKeyFile
17182 * @group_name: a group name
17184 * @list: (array length=length): an array of boolean values
17185 * @length: length of @list
17187 * Associates a list of boolean values with @key under @group_name.
17188 * If @key cannot be found then it is created.
17189 * If @group_name is %NULL, the start_group is used.
17196 * g_key_file_set_comment:
17197 * @key_file: a #GKeyFile
17198 * @group_name: (allow-none): a group name, or %NULL
17199 * @key: (allow-none): a key
17200 * @comment: a comment
17201 * @error: return location for a #GError
17203 * Places a comment above @key from @group_name.
17204 * If @key is %NULL then @comment will be written above @group_name.
17205 * If both @key and @group_name are %NULL, then @comment will be
17206 * written above the first group in the file.
17208 * Returns: %TRUE if the comment was written, %FALSE otherwise
17214 * g_key_file_set_double:
17215 * @key_file: a #GKeyFile
17216 * @group_name: a group name
17218 * @value: an double value
17220 * Associates a new double value with @key under @group_name.
17221 * If @key cannot be found then it is created.
17228 * g_key_file_set_double_list:
17229 * @key_file: a #GKeyFile
17230 * @group_name: a group name
17232 * @list: (array length=length): an array of double values
17233 * @length: number of double values in @list
17235 * Associates a list of double values with @key under
17236 * @group_name. If @key cannot be found then it is created.
17243 * g_key_file_set_int64:
17244 * @key_file: a #GKeyFile
17245 * @group_name: a group name
17247 * @value: an integer value
17249 * Associates a new integer value with @key under @group_name.
17250 * If @key cannot be found then it is created.
17257 * g_key_file_set_integer:
17258 * @key_file: a #GKeyFile
17259 * @group_name: a group name
17261 * @value: an integer value
17263 * Associates a new integer value with @key under @group_name.
17264 * If @key cannot be found then it is created.
17271 * g_key_file_set_integer_list:
17272 * @key_file: a #GKeyFile
17273 * @group_name: a group name
17275 * @list: (array length=length): an array of integer values
17276 * @length: number of integer values in @list
17278 * Associates a list of integer values with @key under @group_name.
17279 * If @key cannot be found then it is created.
17286 * g_key_file_set_list_separator:
17287 * @key_file: a #GKeyFile
17288 * @separator: the separator
17290 * Sets the character which is used to separate
17291 * values in lists. Typically ';' or ',' are used
17292 * as separators. The default list separator is ';'.
17299 * g_key_file_set_locale_string:
17300 * @key_file: a #GKeyFile
17301 * @group_name: a group name
17303 * @locale: a locale identifier
17304 * @string: a string
17306 * Associates a string value for @key and @locale under @group_name.
17307 * If the translation for @key cannot be found then it is created.
17314 * g_key_file_set_locale_string_list:
17315 * @key_file: a #GKeyFile
17316 * @group_name: a group name
17318 * @locale: a locale identifier
17319 * @list: (array length=length zero-terminated=1): a %NULL-terminated array of locale string values
17320 * @length: the length of @list
17322 * Associates a list of string values for @key and @locale under
17323 * @group_name. If the translation for @key cannot be found then
17331 * g_key_file_set_string:
17332 * @key_file: a #GKeyFile
17333 * @group_name: a group name
17335 * @string: a string
17337 * Associates a new string value with @key under @group_name.
17338 * If @key cannot be found then it is created.
17339 * If @group_name cannot be found then it is created.
17340 * Unlike g_key_file_set_value(), this function handles characters
17341 * that need escaping, such as newlines.
17348 * g_key_file_set_string_list:
17349 * @key_file: a #GKeyFile
17350 * @group_name: a group name
17352 * @list: (array length=length zero-terminated=1) (element-type utf8): an array of string values
17353 * @length: number of string values in @list
17355 * Associates a list of string values for @key under @group_name.
17356 * If @key cannot be found then it is created.
17357 * If @group_name cannot be found then it is created.
17364 * g_key_file_set_uint64:
17365 * @key_file: a #GKeyFile
17366 * @group_name: a group name
17368 * @value: an integer value
17370 * Associates a new integer value with @key under @group_name.
17371 * If @key cannot be found then it is created.
17378 * g_key_file_set_value:
17379 * @key_file: a #GKeyFile
17380 * @group_name: a group name
17384 * Associates a new value with @key under @group_name.
17386 * If @key cannot be found then it is created. If @group_name cannot
17387 * be found then it is created. To set an UTF-8 string which may contain
17388 * characters that need escaping (such as newlines or spaces), use
17389 * g_key_file_set_string().
17396 * g_key_file_to_data:
17397 * @key_file: a #GKeyFile
17398 * @length: (out) (allow-none): return location for the length of the returned string, or %NULL
17399 * @error: return location for a #GError, or %NULL
17401 * This function outputs @key_file as a string.
17403 * Note that this function never reports an error,
17404 * so it is safe to pass %NULL as @error.
17406 * Returns: a newly allocated string holding the contents of the #GKeyFile
17412 * g_key_file_unref:
17413 * @key_file: a #GKeyFile
17415 * Decreases the reference count of @key_file by 1. If the reference count
17416 * reaches zero, frees the key file and all its allocated memory.
17425 * Allocates space for one #GList element. It is called by
17426 * g_list_append(), g_list_prepend(), g_list_insert() and
17427 * g_list_insert_sorted() and so is rarely used on its own.
17429 * Returns: a pointer to the newly-allocated #GList element.
17435 * @list: a pointer to a #GList
17436 * @data: the data for the new element
17438 * Adds a new element on to the end of the list.
17441 * The return value is the new start of the list, which
17442 * may have changed, so make sure you store the new value.
17446 * Note that g_list_append() has to traverse the entire list
17447 * to find the end, which is inefficient when adding multiple
17448 * elements. A common idiom to avoid the inefficiency is to prepend
17449 * the elements and reverse the list when all elements have been added.
17453 * /* Notice that these are initialized to the empty list. */
17454 * GList *list = NULL, *number_list = NULL;
17456 * /* This is a list of strings. */
17457 * list = g_list_append (list, "first");
17458 * list = g_list_append (list, "second");
17460 * /* This is a list of integers. */
17461 * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
17462 * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
17465 * Returns: the new start of the #GList
17472 * @list2: the #GList to add to the end of the first #GList
17474 * Adds the second #GList onto the end of the first #GList.
17475 * Note that the elements of the second #GList are not copied.
17476 * They are used directly.
17478 * Returns: the start of the new #GList
17489 * Note that this is a "shallow" copy. If the list elements
17490 * consist of pointers to data, the pointers are copied but
17491 * the actual data is not. See g_list_copy_deep() if you need
17492 * to copy the data as well.
17495 * Returns: a copy of @list
17500 * g_list_copy_deep:
17502 * @func: a copy function used to copy every element in the list
17503 * @user_data: user data passed to the copy function @func, or #NULL
17505 * Makes a full (deep) copy of a #GList.
17507 * In contrast with g_list_copy(), this function uses @func to make a copy of
17508 * each list element, in addition to copying the list container itself.
17510 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
17511 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
17514 * For instance, if @list holds a list of GObjects, you can do:
17516 * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
17519 * And, to entirely free the new list, you could do:
17521 * g_list_free_full (another_list, g_object_unref);
17524 * Returns: a full copy of @list, use #g_list_free_full to free it
17530 * g_list_delete_link:
17532 * @link_: node to delete from @list
17534 * Removes the node link_ from the list and frees it.
17535 * Compare this to g_list_remove_link() which removes the node
17536 * without freeing it.
17538 * Returns: the new head of @list
17545 * @data: the element data to find
17547 * Finds the element in a #GList which
17548 * contains the given data.
17550 * Returns: the found #GList element, or %NULL if it is not found
17555 * g_list_find_custom:
17557 * @data: user data passed to the function
17558 * @func: the function to call for each element. It should return 0 when the desired element is found
17560 * Finds an element in a #GList, using a supplied function to
17561 * find the desired element. It iterates over the list, calling
17562 * the given function which should return 0 when the desired
17563 * element is found. The function takes two #gconstpointer arguments,
17564 * the #GList element's data as the first argument and the
17567 * Returns: the found #GList element, or %NULL if it is not found
17575 * Gets the first element in a #GList.
17577 * Returns: the first element in the #GList, or %NULL if the #GList has no elements
17584 * @func: the function to call with each element's data
17585 * @user_data: user data to pass to the function
17587 * Calls a function for each element of a #GList.
17595 * Frees all of the memory used by a #GList.
17596 * The freed elements are returned to the slice allocator.
17599 * If list elements contain dynamically-allocated memory,
17600 * you should either use g_list_free_full() or free them manually
17609 * Another name for g_list_free_1().
17615 * @list: a #GList element
17617 * Frees one #GList element.
17618 * It is usually used after g_list_remove_link().
17623 * g_list_free_full:
17624 * @list: a pointer to a #GList
17625 * @free_func: the function to be called to free each element's data
17627 * Convenience method, which frees all the memory used by a #GList, and
17628 * calls the specified destroy function on every element's data.
17637 * @data: the data to find
17639 * Gets the position of the element containing
17640 * the given data (starting from 0).
17642 * Returns: the index of the element containing the data, or -1 if the data is not found
17648 * @list: a pointer to a #GList
17649 * @data: the data for the new element
17650 * @position: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
17652 * Inserts a new element into the list at the given position.
17654 * Returns: the new start of the #GList
17659 * g_list_insert_before:
17660 * @list: a pointer to a #GList
17661 * @sibling: the list element before which the new element is inserted or %NULL to insert at the end of the list
17662 * @data: the data for the new element
17664 * Inserts a new element into the list before the given position.
17666 * Returns: the new start of the #GList
17671 * g_list_insert_sorted:
17672 * @list: a pointer to a #GList
17673 * @data: the data for the new element
17674 * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
17676 * Inserts a new element into the list, using the given comparison
17677 * function to determine its position.
17679 * Returns: the new start of the #GList
17684 * g_list_insert_sorted_with_data:
17685 * @list: a pointer to a #GList
17686 * @data: the data for the new element
17687 * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
17688 * @user_data: user data to pass to comparison function.
17690 * Inserts a new element into the list, using the given comparison
17691 * function to determine its position.
17693 * Returns: the new start of the #GList
17702 * Gets the last element in a #GList.
17704 * Returns: the last element in the #GList, or %NULL if the #GList has no elements
17712 * Gets the number of elements in a #GList.
17715 * This function iterates over the whole list to
17716 * count its elements.
17719 * Returns: the number of elements in the #GList
17725 * @list: an element in a #GList.
17727 * A convenience macro to get the next element in a #GList.
17729 * Returns: the next element, or %NULL if there are no more elements.
17736 * @n: the position of the element, counting from 0
17738 * Gets the element at the given position in a #GList.
17740 * Returns: the element, or %NULL if the position is off the end of the #GList
17747 * @n: the position of the element
17749 * Gets the data of the element at the given position.
17751 * Returns: the element's data, or %NULL if the position is off the end of the #GList
17758 * @n: the position of the element, counting from 0
17760 * Gets the element @n places before @list.
17762 * Returns: the element, or %NULL if the position is off the end of the #GList
17769 * @llink: an element in the #GList
17771 * Gets the position of the given element
17772 * in the #GList (starting from 0).
17774 * Returns: the position of the element in the #GList, or -1 if the element is not found
17780 * @list: a pointer to a #GList
17781 * @data: the data for the new element
17783 * Adds a new element on to the start of the list.
17786 * The return value is the new start of the list, which
17787 * may have changed, so make sure you store the new value.
17791 * /* Notice that it is initialized to the empty list. */
17792 * GList *list = NULL;
17793 * list = g_list_prepend (list, "last");
17794 * list = g_list_prepend (list, "first");
17797 * Returns: the new start of the #GList
17803 * @list: an element in a #GList.
17805 * A convenience macro to get the previous element in a #GList.
17807 * Returns: the previous element, or %NULL if there are no previous elements.
17814 * @data: the data of the element to remove
17816 * Removes an element from a #GList.
17817 * If two elements contain the same data, only the first is removed.
17818 * If none of the elements contain the data, the #GList is unchanged.
17820 * Returns: the new start of the #GList
17825 * g_list_remove_all:
17827 * @data: data to remove
17829 * Removes all list nodes with data equal to @data.
17830 * Returns the new head of the list. Contrast with
17831 * g_list_remove() which removes only the first node
17832 * matching the given data.
17834 * Returns: new head of @list
17839 * g_list_remove_link:
17841 * @llink: an element in the #GList
17843 * Removes an element from a #GList, without freeing the element.
17844 * The removed element's prev and next links are set to %NULL, so
17845 * that it becomes a self-contained list with one element.
17847 * Returns: the new start of the #GList, without the element
17855 * Reverses a #GList.
17856 * It simply switches the next and prev pointers of each element.
17858 * Returns: the start of the reversed #GList
17865 * @compare_func: the comparison function used to sort the #GList. This function is passed the data from 2 elements of the #GList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
17867 * Sorts a #GList using the given comparison function. The algorithm
17868 * used is a stable sort.
17870 * Returns: the start of the sorted #GList
17875 * g_list_sort_with_data:
17877 * @compare_func: comparison function
17878 * @user_data: user data to pass to comparison function
17880 * Like g_list_sort(), but the comparison function accepts
17881 * a user data argument.
17883 * Returns: the new head of @list
17890 * Gets the names of all variables set in the environment.
17892 * Programs that want to be portable to Windows should typically use
17893 * this function and g_getenv() instead of using the environ array
17894 * from the C library directly. On Windows, the strings in the environ
17895 * array are in system codepage encoding, while in most of the typical
17896 * use cases for environment variables in GLib-using programs you want
17897 * the UTF-8 encoding that this function and g_getenv() provide.
17899 * Returns: (array zero-terminated=1) (transfer full): a %NULL-terminated list of strings which must be freed with g_strfreev().
17905 * g_locale_from_utf8:
17906 * @utf8string: a UTF-8 encoded string
17907 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17908 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
17909 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
17910 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
17912 * Converts a string from UTF-8 to the encoding used for strings by
17913 * the C runtime (usually the same as that used by the operating
17914 * system) in the <link linkend="setlocale">current locale</link>. On
17915 * Windows this means the system codepage.
17917 * Returns: The converted string, or %NULL on an error.
17922 * g_locale_to_utf8:
17923 * @opsysstring: a string in the encoding of the current locale. On Windows this means the system codepage.
17924 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17925 * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
17926 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
17927 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
17929 * Converts a string which is in the encoding used for strings by
17930 * the C runtime (usually the same as that used by the operating
17931 * system) in the <link linkend="setlocale">current locale</link> into a
17934 * Returns: The converted string, or %NULL on an error.
17940 * @log_domain: the log domain, usually #G_LOG_DOMAIN
17941 * @log_level: the log level, either from #GLogLevelFlags or a user-defined level
17942 * @format: the message format. See the printf() documentation
17943 * @...: the parameters to insert into the format string
17945 * Logs an error or debugging message.
17947 * If the log level has been set as fatal, the abort()
17948 * function is called to terminate the program.
17953 * g_log_default_handler:
17954 * @log_domain: the log domain of the message
17955 * @log_level: the level of the message
17956 * @message: the message
17957 * @unused_data: data passed from g_log() which is unused
17959 * The default log handler set up by GLib; g_log_set_default_handler()
17960 * allows to install an alternate default log handler.
17961 * This is used if no log handler has been set for the particular log
17962 * domain and log level combination. It outputs the message to stderr
17963 * or stdout and if the log level is fatal it calls abort().
17965 * The behavior of this log handler can be influenced by a number of
17966 * environment variables:
17969 * <term><envar>G_MESSAGES_PREFIXED</envar></term>
17971 * A :-separated list of log levels for which messages should
17972 * be prefixed by the program name and PID of the aplication.
17976 * <term><envar>G_MESSAGES_DEBUG</envar></term>
17978 * A space-separated list of log domains for which debug and
17979 * informational messages are printed. By default these
17980 * messages are not printed.
17985 * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
17986 * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
17992 * g_log_remove_handler:
17993 * @log_domain: the log domain
17994 * @handler_id: the id of the handler, which was returned in g_log_set_handler()
17996 * Removes the log handler.
18001 * g_log_set_always_fatal:
18002 * @fatal_mask: the mask containing bits set for each level of error which is to be fatal
18004 * Sets the message levels which are always fatal, in any log domain.
18005 * When a message with any of these levels is logged the program terminates.
18006 * You can only set the levels defined by GLib to be fatal.
18007 * %G_LOG_LEVEL_ERROR is always fatal.
18009 * You can also make some message levels fatal at runtime by setting
18010 * the <envar>G_DEBUG</envar> environment variable (see
18011 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
18013 * Returns: the old fatal mask
18018 * g_log_set_default_handler:
18019 * @log_func: the log handler function
18020 * @user_data: data passed to the log handler
18022 * Installs a default log handler which is used if no
18023 * log handler has been set for the particular log domain
18024 * and log level combination. By default, GLib uses
18025 * g_log_default_handler() as default log handler.
18027 * Returns: the previous default log handler
18033 * g_log_set_fatal_mask:
18034 * @log_domain: the log domain
18035 * @fatal_mask: the new fatal mask
18037 * Sets the log levels which are fatal in the given domain.
18038 * %G_LOG_LEVEL_ERROR is always fatal.
18040 * Returns: the old fatal mask for the log domain
18045 * g_log_set_handler:
18046 * @log_domain: (allow-none): the log domain, or %NULL for the default "" application domain
18047 * @log_levels: the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION bit flags.
18048 * @log_func: the log handler function
18049 * @user_data: data passed to the log handler
18051 * Sets the log handler for a domain and a set of log levels.
18052 * To handle fatal and recursive messages the @log_levels parameter
18053 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
18056 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
18057 * you want to set a handler for this log level you must combine it with
18058 * #G_LOG_FLAG_FATAL.
18061 * <title>Adding a log handler for all warning messages in the default
18062 * (application) domain</title>
18064 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
18065 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18066 * </programlisting>
18070 * <title>Adding a log handler for all critical messages from GTK+</title>
18072 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
18073 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18074 * </programlisting>
18078 * <title>Adding a log handler for <emphasis>all</emphasis> messages from
18081 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
18082 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18083 * </programlisting>
18086 * Returns: the id of the new handler
18092 * @log_domain: the log domain
18093 * @log_level: the log level
18094 * @format: the message format. See the printf() documentation
18095 * @args: the parameters to insert into the format string
18097 * Logs an error or debugging message.
18099 * If the log level has been set as fatal, the abort()
18100 * function is called to terminate the program.
18106 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
18107 * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
18109 * A wrapper for the POSIX lstat() function. The lstat() function is
18110 * like stat() except that in the case of symbolic links, it returns
18111 * information about the symbolic link itself and not the file that it
18112 * refers to. If the system does not support symbolic links g_lstat()
18113 * is identical to g_stat().
18115 * See your C library manual for more details about lstat().
18117 * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
18123 * g_main_context_acquire:
18124 * @context: a #GMainContext
18126 * Tries to become the owner of the specified context.
18127 * If some other thread is the owner of the context,
18128 * returns %FALSE immediately. Ownership is properly
18129 * recursive: the owner can require ownership again
18130 * and will release ownership when g_main_context_release()
18131 * is called as many times as g_main_context_acquire().
18133 * You must be the owner of a context before you
18134 * can call g_main_context_prepare(), g_main_context_query(),
18135 * g_main_context_check(), g_main_context_dispatch().
18137 * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18142 * g_main_context_add_poll:
18143 * @context: (allow-none): a #GMainContext (or %NULL for the default context)
18144 * @fd: a #GPollFD structure holding information about a file descriptor to watch.
18145 * @priority: the priority for this file descriptor which should be the same as the priority used for g_source_attach() to ensure that the file descriptor is polled whenever the results may be needed.
18147 * Adds a file descriptor to the set of file descriptors polled for
18148 * this context. This will very seldom be used directly. Instead
18149 * a typical event source will use g_source_add_poll() instead.
18154 * g_main_context_check:
18155 * @context: a #GMainContext
18156 * @max_priority: the maximum numerical priority of sources to check
18157 * @fds: (array length=n_fds): array of #GPollFD's that was passed to the last call to g_main_context_query()
18158 * @n_fds: return value of g_main_context_query()
18160 * Passes the results of polling back to the main loop.
18162 * Returns: %TRUE if some sources are ready to be dispatched.
18167 * g_main_context_default:
18169 * Returns the global default main context. This is the main context
18170 * used for main loop functions when a main loop is not explicitly
18171 * specified, and corresponds to the "main" main loop. See also
18172 * g_main_context_get_thread_default().
18174 * Returns: (transfer none): the global default main context.
18179 * g_main_context_dispatch:
18180 * @context: a #GMainContext
18182 * Dispatches all pending sources.
18187 * g_main_context_find_source_by_funcs_user_data:
18188 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
18189 * @funcs: the @source_funcs passed to g_source_new().
18190 * @user_data: the user data from the callback.
18192 * Finds a source with the given source functions and user data. If
18193 * multiple sources exist with the same source function and user data,
18194 * the first one found will be returned.
18196 * Returns: (transfer none): the source, if one was found, otherwise %NULL
18201 * g_main_context_find_source_by_id:
18202 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18203 * @source_id: the source ID, as returned by g_source_get_id().
18205 * Finds a #GSource given a pair of context and ID.
18207 * Returns: (transfer none): the #GSource if found, otherwise, %NULL
18212 * g_main_context_find_source_by_user_data:
18213 * @context: a #GMainContext
18214 * @user_data: the user_data for the callback.
18216 * Finds a source with the given user data for the callback. If
18217 * multiple sources exist with the same user data, the first
18218 * one found will be returned.
18220 * Returns: (transfer none): the source, if one was found, otherwise %NULL
18225 * g_main_context_get_poll_func:
18226 * @context: a #GMainContext
18228 * Gets the poll function set by g_main_context_set_poll_func().
18230 * Returns: the poll function
18235 * g_main_context_get_thread_default:
18237 * Gets the thread-default #GMainContext for this thread. Asynchronous
18238 * operations that want to be able to be run in contexts other than
18239 * the default one should call this method or
18240 * g_main_context_ref_thread_default() to get a #GMainContext to add
18241 * their #GSource<!-- -->s to. (Note that even in single-threaded
18242 * programs applications may sometimes want to temporarily push a
18243 * non-default context, so it is not safe to assume that this will
18244 * always return %NULL if you are running in the default thread.)
18246 * If you need to hold a reference on the context, use
18247 * g_main_context_ref_thread_default() instead.
18249 * Returns: (transfer none): the thread-default #GMainContext, or %NULL if the thread-default context is the global default context.
18255 * g_main_context_invoke:
18256 * @context: (allow-none): a #GMainContext, or %NULL
18257 * @function: function to call
18258 * @data: data to pass to @function
18260 * Invokes a function in such a way that @context is owned during the
18261 * invocation of @function.
18263 * If @context is %NULL then the global default main context — as
18264 * returned by g_main_context_default() — is used.
18266 * If @context is owned by the current thread, @function is called
18267 * directly. Otherwise, if @context is the thread-default main context
18268 * of the current thread and g_main_context_acquire() succeeds, then
18269 * @function is called and g_main_context_release() is called
18272 * In any other case, an idle source is created to call @function and
18273 * that source is attached to @context (presumably to be run in another
18274 * thread). The idle source is attached with #G_PRIORITY_DEFAULT
18275 * priority. If you want a different priority, use
18276 * g_main_context_invoke_full().
18278 * Note that, as with normal idle functions, @function should probably
18279 * return %FALSE. If it returns %TRUE, it will be continuously run in a
18280 * loop (and may prevent this call from returning).
18287 * g_main_context_invoke_full:
18288 * @context: (allow-none): a #GMainContext, or %NULL
18289 * @priority: the priority at which to run @function
18290 * @function: function to call
18291 * @data: data to pass to @function
18292 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
18294 * Invokes a function in such a way that @context is owned during the
18295 * invocation of @function.
18297 * This function is the same as g_main_context_invoke() except that it
18298 * lets you specify the priority incase @function ends up being
18299 * scheduled as an idle and also lets you give a #GDestroyNotify for @data.
18301 * @notify should not assume that it is called from any particular
18302 * thread or with any particular context acquired.
18309 * g_main_context_is_owner:
18310 * @context: a #GMainContext
18312 * Determines whether this thread holds the (recursive)
18313 * ownership of this #GMainContext. This is useful to
18314 * know before waiting on another thread that may be
18315 * blocking to get ownership of @context.
18317 * Returns: %TRUE if current thread is owner of @context.
18323 * g_main_context_iteration:
18324 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18325 * @may_block: whether the call may block.
18327 * Runs a single iteration for the given main loop. This involves
18328 * checking to see if any event sources are ready to be processed,
18329 * then if no events sources are ready and @may_block is %TRUE, waiting
18330 * for a source to become ready, then dispatching the highest priority
18331 * events sources that are ready. Otherwise, if @may_block is %FALSE
18332 * sources are not waited to become ready, only those highest priority
18333 * events sources will be dispatched (if any), that are ready at this
18334 * given moment without further waiting.
18336 * Note that even when @may_block is %TRUE, it is still possible for
18337 * g_main_context_iteration() to return %FALSE, since the wait may
18338 * be interrupted for other reasons than an event source becoming ready.
18340 * Returns: %TRUE if events were dispatched.
18345 * g_main_context_new:
18347 * Creates a new #GMainContext structure.
18349 * Returns: the new #GMainContext
18354 * g_main_context_pending:
18355 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18357 * Checks if any sources have pending events for the given context.
18359 * Returns: %TRUE if events are pending.
18364 * g_main_context_pop_thread_default:
18365 * @context: (allow-none): a #GMainContext object, or %NULL
18367 * Pops @context off the thread-default context stack (verifying that
18368 * it was on the top of the stack).
18375 * g_main_context_prepare:
18376 * @context: a #GMainContext
18377 * @priority: location to store priority of highest priority source already ready.
18379 * Prepares to poll sources within a main loop. The resulting information
18380 * for polling is determined by calling g_main_context_query ().
18382 * Returns: %TRUE if some source is ready to be dispatched prior to polling.
18387 * g_main_context_push_thread_default:
18388 * @context: (allow-none): a #GMainContext, or %NULL for the global default context
18390 * Acquires @context and sets it as the thread-default context for the
18391 * current thread. This will cause certain asynchronous operations
18392 * (such as most <link linkend="gio">gio</link>-based I/O) which are
18393 * started in this thread to run under @context and deliver their
18394 * results to its main loop, rather than running under the global
18395 * default context in the main thread. Note that calling this function
18396 * changes the context returned by
18397 * g_main_context_get_thread_default(), <emphasis>not</emphasis> the
18398 * one returned by g_main_context_default(), so it does not affect the
18399 * context used by functions like g_idle_add().
18401 * Normally you would call this function shortly after creating a new
18402 * thread, passing it a #GMainContext which will be run by a
18403 * #GMainLoop in that thread, to set a new default context for all
18404 * async operations in that thread. (In this case, you don't need to
18405 * ever call g_main_context_pop_thread_default().) In some cases
18406 * however, you may want to schedule a single operation in a
18407 * non-default context, or temporarily use a non-default context in
18408 * the main thread. In that case, you can wrap the call to the
18409 * asynchronous operation inside a
18410 * g_main_context_push_thread_default() /
18411 * g_main_context_pop_thread_default() pair, but it is up to you to
18412 * ensure that no other asynchronous operations accidentally get
18413 * started while the non-default context is active.
18415 * Beware that libraries that predate this function may not correctly
18416 * handle being used from a thread with a thread-default context. Eg,
18417 * see g_file_supports_thread_contexts().
18424 * g_main_context_query:
18425 * @context: a #GMainContext
18426 * @max_priority: maximum priority source to check
18427 * @timeout_: (out): location to store timeout to be used in polling
18428 * @fds: (out caller-allocates) (array length=n_fds): location to store #GPollFD records that need to be polled.
18429 * @n_fds: length of @fds.
18431 * Determines information necessary to poll this main loop.
18433 * Returns: the number of records actually stored in @fds, or, if more than @n_fds records need to be stored, the number of records that need to be stored.
18438 * g_main_context_ref:
18439 * @context: a #GMainContext
18441 * Increases the reference count on a #GMainContext object by one.
18443 * Returns: the @context that was passed in (since 2.6)
18448 * g_main_context_ref_thread_default:
18450 * Gets the thread-default #GMainContext for this thread, as with
18451 * g_main_context_get_thread_default(), but also adds a reference to
18452 * it with g_main_context_ref(). In addition, unlike
18453 * g_main_context_get_thread_default(), if the thread-default context
18454 * is the global default context, this will return that #GMainContext
18455 * (with a ref added to it) rather than returning %NULL.
18457 * Returns: (transfer full): the thread-default #GMainContext. Unref with g_main_context_unref() when you are done with it.
18463 * g_main_context_release:
18464 * @context: a #GMainContext
18466 * Releases ownership of a context previously acquired by this thread
18467 * with g_main_context_acquire(). If the context was acquired multiple
18468 * times, the ownership will be released only when g_main_context_release()
18469 * is called as many times as it was acquired.
18474 * g_main_context_remove_poll:
18475 * @context: a #GMainContext
18476 * @fd: a #GPollFD descriptor previously added with g_main_context_add_poll()
18478 * Removes file descriptor from the set of file descriptors to be
18479 * polled for a particular context.
18484 * g_main_context_set_poll_func:
18485 * @context: a #GMainContext
18486 * @func: the function to call to poll all file descriptors
18488 * Sets the function to use to handle polling of file descriptors. It
18489 * will be used instead of the poll() system call
18490 * (or GLib's replacement function, which is used where
18491 * poll() isn't available).
18493 * This function could possibly be used to integrate the GLib event
18494 * loop with an external event loop.
18499 * g_main_context_unref:
18500 * @context: a #GMainContext
18502 * Decreases the reference count on a #GMainContext object by one. If
18503 * the result is zero, free the context and free all associated memory.
18508 * g_main_context_wait:
18509 * @context: a #GMainContext
18510 * @cond: a condition variable
18511 * @mutex: a mutex, currently held
18513 * Tries to become the owner of the specified context,
18514 * as with g_main_context_acquire(). But if another thread
18515 * is the owner, atomically drop @mutex and wait on @cond until
18516 * that owner releases ownership or until @cond is signaled, then
18517 * try again (once) to become the owner.
18519 * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18524 * g_main_context_wakeup:
18525 * @context: a #GMainContext
18527 * If @context is currently waiting in a poll(), interrupt
18528 * the poll(), and continue the iteration process.
18533 * g_main_current_source:
18535 * Returns the currently firing source for this thread.
18537 * Returns: (transfer none): The currently firing source or %NULL.
18545 * Returns the depth of the stack of calls to
18546 * g_main_context_dispatch() on any #GMainContext in the current thread.
18547 * That is, when called from the toplevel, it gives 0. When
18548 * called from within a callback from g_main_context_iteration()
18549 * (or g_main_loop_run(), etc.) it returns 1. When called from within
18550 * a callback to a recursive call to g_main_context_iteration(),
18551 * it returns 2. And so forth.
18553 * This function is useful in a situation like the following:
18554 * Imagine an extremely simple "garbage collected" system.
18557 * static GList *free_list;
18560 * allocate_memory (gsize size)
18562 * gpointer result = g_malloc (size);
18563 * free_list = g_list_prepend (free_list, result);
18568 * free_allocated_memory (void)
18571 * for (l = free_list; l; l = l->next);
18572 * g_free (l->data);
18573 * g_list_free (free_list);
18574 * free_list = NULL;
18581 * g_main_context_iteration (NULL, TRUE);
18582 * free_allocated_memory();
18586 * This works from an application, however, if you want to do the same
18587 * thing from a library, it gets more difficult, since you no longer
18588 * control the main loop. You might think you can simply use an idle
18589 * function to make the call to free_allocated_memory(), but that
18590 * doesn't work, since the idle function could be called from a
18591 * recursive callback. This can be fixed by using g_main_depth()
18595 * allocate_memory (gsize size)
18597 * FreeListBlock *block = g_new (FreeListBlock, 1);
18598 * block->mem = g_malloc (size);
18599 * block->depth = g_main_depth ();
18600 * free_list = g_list_prepend (free_list, block);
18601 * return block->mem;
18605 * free_allocated_memory (void)
18609 * int depth = g_main_depth ();
18610 * for (l = free_list; l; );
18612 * GList *next = l->next;
18613 * FreeListBlock *block = l->data;
18614 * if (block->depth > depth)
18616 * g_free (block->mem);
18618 * free_list = g_list_delete_link (free_list, l);
18626 * There is a temptation to use g_main_depth() to solve
18627 * problems with reentrancy. For instance, while waiting for data
18628 * to be received from the network in response to a menu item,
18629 * the menu item might be selected again. It might seem that
18630 * one could make the menu item's callback return immediately
18631 * and do nothing if g_main_depth() returns a value greater than 1.
18632 * However, this should be avoided since the user then sees selecting
18633 * the menu item do nothing. Furthermore, you'll find yourself adding
18634 * these checks all over your code, since there are doubtless many,
18635 * many things that the user could do. Instead, you can use the
18636 * following techniques:
18641 * Use gtk_widget_set_sensitive() or modal dialogs to prevent
18642 * the user from interacting with elements while the main
18643 * loop is recursing.
18648 * Avoid main loop recursion in situations where you can't handle
18649 * arbitrary callbacks. Instead, structure your code so that you
18650 * simply return to the main loop and then get called again when
18651 * there is more work to do.
18656 * Returns: The main loop recursion level in the current thread
18661 * g_main_loop_get_context:
18662 * @loop: a #GMainLoop.
18664 * Returns the #GMainContext of @loop.
18666 * Returns: (transfer none): the #GMainContext of @loop
18671 * g_main_loop_is_running:
18672 * @loop: a #GMainLoop.
18674 * Checks to see if the main loop is currently being run via g_main_loop_run().
18676 * Returns: %TRUE if the mainloop is currently being run.
18682 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
18683 * @is_running: set to %TRUE to indicate that the loop is running. This is not very important since calling g_main_loop_run() will set this to %TRUE anyway.
18685 * Creates a new #GMainLoop structure.
18687 * Returns: a new #GMainLoop.
18692 * g_main_loop_quit:
18693 * @loop: a #GMainLoop
18695 * Stops a #GMainLoop from running. Any calls to g_main_loop_run()
18696 * for the loop will return.
18698 * Note that sources that have already been dispatched when
18699 * g_main_loop_quit() is called will still be executed.
18705 * @loop: a #GMainLoop
18707 * Increases the reference count on a #GMainLoop object by one.
18715 * @loop: a #GMainLoop
18717 * Runs a main loop until g_main_loop_quit() is called on the loop.
18718 * If this is called for the thread of the loop's #GMainContext,
18719 * it will process events from the loop, otherwise it will
18725 * g_main_loop_unref:
18726 * @loop: a #GMainLoop
18728 * Decreases the reference count on a #GMainLoop object by one. If
18729 * the result is zero, free the loop and free all associated memory.
18735 * @n_bytes: the number of bytes to allocate
18737 * Allocates @n_bytes bytes of memory.
18738 * If @n_bytes is 0 it returns %NULL.
18740 * Returns: a pointer to the allocated memory
18746 * @n_bytes: the number of bytes to allocate
18748 * Allocates @n_bytes bytes of memory, initialized to 0's.
18749 * If @n_bytes is 0 it returns %NULL.
18751 * Returns: a pointer to the allocated memory
18757 * @n_blocks: the number of blocks to allocate
18758 * @n_block_bytes: the size of each block in bytes
18760 * This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
18761 * but care is taken to detect possible overflow during multiplication.
18764 * Returns: a pointer to the allocated memory
18770 * @n_blocks: the number of blocks to allocate
18771 * @n_block_bytes: the size of each block in bytes
18773 * This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
18774 * but care is taken to detect possible overflow during multiplication.
18777 * Returns: a pointer to the allocated memory
18782 * g_mapped_file_free:
18783 * @file: a #GMappedFile
18785 * This call existed before #GMappedFile had refcounting and is currently
18786 * exactly the same as g_mapped_file_unref().
18789 * Deprecated: 2.22: Use g_mapped_file_unref() instead.
18794 * g_mapped_file_get_bytes:
18795 * @file: a #GMappedFile
18797 * Creates a new #GBytes which references the data mapped from @file.
18798 * The mapped contents of the file must not be modified after creating this
18799 * bytes object, because a #GBytes should be immutable.
18801 * Returns: (transfer full): A newly allocated #GBytes referencing data from @file
18807 * g_mapped_file_get_contents:
18808 * @file: a #GMappedFile
18810 * Returns the contents of a #GMappedFile.
18812 * Note that the contents may not be zero-terminated,
18813 * even if the #GMappedFile is backed by a text file.
18815 * If the file is empty then %NULL is returned.
18817 * Returns: the contents of @file, or %NULL.
18823 * g_mapped_file_get_length:
18824 * @file: a #GMappedFile
18826 * Returns the length of the contents of a #GMappedFile.
18828 * Returns: the length of the contents of @file.
18834 * g_mapped_file_new:
18835 * @filename: The path of the file to load, in the GLib filename encoding
18836 * @writable: whether the mapping should be writable
18837 * @error: return location for a #GError, or %NULL
18839 * Maps a file into memory. On UNIX, this is using the mmap() function.
18841 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
18842 * it is an error to modify the mapped buffer. Modifications to the buffer
18843 * are not visible to other processes mapping the same file, and are not
18844 * written back to the file.
18846 * Note that modifications of the underlying file might affect the contents
18847 * of the #GMappedFile. Therefore, mapping should only be used if the file
18848 * will not be modified, or if all modifications of the file are done
18849 * atomically (e.g. using g_file_set_contents()).
18851 * If @filename is the name of an empty, regular file, the function
18852 * will successfully return an empty #GMappedFile. In other cases of
18853 * size 0 (e.g. device files such as /dev/null), @error will be set
18854 * to the #GFileError value #G_FILE_ERROR_INVAL.
18856 * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
18862 * g_mapped_file_new_from_fd:
18863 * @fd: The file descriptor of the file to load
18864 * @writable: whether the mapping should be writable
18865 * @error: return location for a #GError, or %NULL
18867 * Maps a file into memory. On UNIX, this is using the mmap() function.
18869 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
18870 * it is an error to modify the mapped buffer. Modifications to the buffer
18871 * are not visible to other processes mapping the same file, and are not
18872 * written back to the file.
18874 * Note that modifications of the underlying file might affect the contents
18875 * of the #GMappedFile. Therefore, mapping should only be used if the file
18876 * will not be modified, or if all modifications of the file are done
18877 * atomically (e.g. using g_file_set_contents()).
18879 * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
18885 * g_mapped_file_ref:
18886 * @file: a #GMappedFile
18888 * Increments the reference count of @file by one. It is safe to call
18889 * this function from any thread.
18891 * Returns: the passed in #GMappedFile.
18897 * g_mapped_file_unref:
18898 * @file: a #GMappedFile
18900 * Decrements the reference count of @file by one. If the reference count
18901 * drops to 0, unmaps the buffer of @file and frees it.
18903 * It is safe to call this function from any thread.
18910 * g_markup_collect_attributes:
18911 * @element_name: the current tag name
18912 * @attribute_names: the attribute names
18913 * @attribute_values: the attribute values
18914 * @error: a pointer to a #GError or %NULL
18915 * @first_type: the #GMarkupCollectType of the first attribute
18916 * @first_attr: the name of the first attribute
18917 * @...: a pointer to the storage location of the first attribute (or %NULL), followed by more types names and pointers, ending with %G_MARKUP_COLLECT_INVALID
18919 * Collects the attributes of the element from the data passed to the
18920 * #GMarkupParser start_element function, dealing with common error
18921 * conditions and supporting boolean values.
18923 * This utility function is not required to write a parser but can save
18926 * The @element_name, @attribute_names, @attribute_values and @error
18927 * parameters passed to the start_element callback should be passed
18928 * unmodified to this function.
18930 * Following these arguments is a list of "supported" attributes to collect.
18931 * It is an error to specify multiple attributes with the same name. If any
18932 * attribute not in the list appears in the @attribute_names array then an
18933 * unknown attribute error will result.
18935 * The #GMarkupCollectType field allows specifying the type of collection
18936 * to perform and if a given attribute must appear or is optional.
18938 * The attribute name is simply the name of the attribute to collect.
18940 * The pointer should be of the appropriate type (see the descriptions
18941 * under #GMarkupCollectType) and may be %NULL in case a particular
18942 * attribute is to be allowed but ignored.
18944 * This function deals with issuing errors for missing attributes
18945 * (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
18946 * (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
18947 * attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
18948 * as parse errors for boolean-valued attributes (again of type
18949 * %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
18950 * will be returned and @error will be set as appropriate.
18952 * Returns: %TRUE if successful
18958 * g_markup_escape_text:
18959 * @text: some valid UTF-8 text
18960 * @length: length of @text in bytes, or -1 if the text is nul-terminated
18962 * Escapes text so that the markup parser will parse it verbatim.
18963 * Less than, greater than, ampersand, etc. are replaced with the
18964 * corresponding entities. This function would typically be used
18965 * when writing out a file to be parsed with the markup parser.
18967 * Note that this function doesn't protect whitespace and line endings
18968 * from being processed according to the XML rules for normalization
18969 * of line endings and attribute values.
18971 * Note also that this function will produce character references in
18972 * the range of &#x1; ... &#x1f; for all control sequences
18973 * except for tabstop, newline and carriage return. The character
18974 * references in this range are not valid XML 1.0, but they are
18975 * valid XML 1.1 and will be accepted by the GMarkup parser.
18977 * Returns: a newly allocated string with the escaped text
18982 * g_markup_parse_context_end_parse:
18983 * @context: a #GMarkupParseContext
18984 * @error: return location for a #GError
18986 * Signals to the #GMarkupParseContext that all data has been
18987 * fed into the parse context with g_markup_parse_context_parse().
18989 * This function reports an error if the document isn't complete,
18990 * for example if elements are still open.
18992 * Returns: %TRUE on success, %FALSE if an error was set
18997 * g_markup_parse_context_free:
18998 * @context: a #GMarkupParseContext
19000 * Frees a #GMarkupParseContext.
19002 * This function can't be called from inside one of the
19003 * #GMarkupParser functions or while a subparser is pushed.
19008 * g_markup_parse_context_get_element:
19009 * @context: a #GMarkupParseContext
19011 * Retrieves the name of the currently open element.
19013 * If called from the start_element or end_element handlers this will
19014 * give the element_name as passed to those functions. For the parent
19015 * elements, see g_markup_parse_context_get_element_stack().
19017 * Returns: the name of the currently open element, or %NULL
19023 * g_markup_parse_context_get_element_stack:
19024 * @context: a #GMarkupParseContext
19026 * Retrieves the element stack from the internal state of the parser.
19028 * The returned #GSList is a list of strings where the first item is
19029 * the currently open tag (as would be returned by
19030 * g_markup_parse_context_get_element()) and the next item is its
19031 * immediate parent.
19033 * This function is intended to be used in the start_element and
19034 * end_element handlers where g_markup_parse_context_get_element()
19035 * would merely return the name of the element that is being
19038 * Returns: the element stack, which must not be modified
19044 * g_markup_parse_context_get_position:
19045 * @context: a #GMarkupParseContext
19046 * @line_number: (allow-none): return location for a line number, or %NULL
19047 * @char_number: (allow-none): return location for a char-on-line number, or %NULL
19049 * Retrieves the current line number and the number of the character on
19050 * that line. Intended for use in error messages; there are no strict
19051 * semantics for what constitutes the "current" line number other than
19052 * "the best number we could come up with for error messages."
19057 * g_markup_parse_context_get_user_data:
19058 * @context: a #GMarkupParseContext
19060 * Returns the user_data associated with @context.
19062 * This will either be the user_data that was provided to
19063 * g_markup_parse_context_new() or to the most recent call
19064 * of g_markup_parse_context_push().
19066 * Returns: the provided user_data. The returned data belongs to the markup context and will be freed when g_markup_parse_context_free() is called.
19072 * g_markup_parse_context_new:
19073 * @parser: a #GMarkupParser
19074 * @flags: one or more #GMarkupParseFlags
19075 * @user_data: user data to pass to #GMarkupParser functions
19076 * @user_data_dnotify: user data destroy notifier called when the parse context is freed
19078 * Creates a new parse context. A parse context is used to parse
19079 * marked-up documents. You can feed any number of documents into
19080 * a context, as long as no errors occur; once an error occurs,
19081 * the parse context can't continue to parse text (you have to
19082 * free it and create a new parse context).
19084 * Returns: a new #GMarkupParseContext
19089 * g_markup_parse_context_parse:
19090 * @context: a #GMarkupParseContext
19091 * @text: chunk of text to parse
19092 * @text_len: length of @text in bytes
19093 * @error: return location for a #GError
19095 * Feed some data to the #GMarkupParseContext.
19097 * The data need not be valid UTF-8; an error will be signaled if
19098 * it's invalid. The data need not be an entire document; you can
19099 * feed a document into the parser incrementally, via multiple calls
19100 * to this function. Typically, as you receive data from a network
19101 * connection or file, you feed each received chunk of data into this
19102 * function, aborting the process if an error occurs. Once an error
19103 * is reported, no further data may be fed to the #GMarkupParseContext;
19104 * all errors are fatal.
19106 * Returns: %FALSE if an error occurred, %TRUE on success
19111 * g_markup_parse_context_pop:
19112 * @context: a #GMarkupParseContext
19114 * Completes the process of a temporary sub-parser redirection.
19116 * This function exists to collect the user_data allocated by a
19117 * matching call to g_markup_parse_context_push(). It must be called
19118 * in the end_element handler corresponding to the start_element
19119 * handler during which g_markup_parse_context_push() was called.
19120 * You must not call this function from the error callback -- the
19121 * @user_data is provided directly to the callback in that case.
19123 * This function is not intended to be directly called by users
19124 * interested in invoking subparsers. Instead, it is intended to
19125 * be used by the subparsers themselves to implement a higher-level
19128 * Returns: the user data passed to g_markup_parse_context_push()
19134 * g_markup_parse_context_push:
19135 * @context: a #GMarkupParseContext
19136 * @parser: a #GMarkupParser
19137 * @user_data: user data to pass to #GMarkupParser functions
19139 * Temporarily redirects markup data to a sub-parser.
19141 * This function may only be called from the start_element handler of
19142 * a #GMarkupParser. It must be matched with a corresponding call to
19143 * g_markup_parse_context_pop() in the matching end_element handler
19144 * (except in the case that the parser aborts due to an error).
19146 * All tags, text and other data between the matching tags is
19147 * redirected to the subparser given by @parser. @user_data is used
19148 * as the user_data for that parser. @user_data is also passed to the
19149 * error callback in the event that an error occurs. This includes
19150 * errors that occur in subparsers of the subparser.
19152 * The end tag matching the start tag for which this call was made is
19153 * handled by the previous parser (which is given its own user_data)
19154 * which is why g_markup_parse_context_pop() is provided to allow "one
19155 * last access" to the @user_data provided to this function. In the
19156 * case of error, the @user_data provided here is passed directly to
19157 * the error callback of the subparser and g_markup_parse_context_pop()
19158 * should not be called. In either case, if @user_data was allocated
19159 * then it ought to be freed from both of these locations.
19161 * This function is not intended to be directly called by users
19162 * interested in invoking subparsers. Instead, it is intended to be
19163 * used by the subparsers themselves to implement a higher-level
19166 * As an example, see the following implementation of a simple
19167 * parser that counts the number of tags encountered.
19176 * counter_start_element (GMarkupParseContext *context,
19177 * const gchar *element_name,
19178 * const gchar **attribute_names,
19179 * const gchar **attribute_values,
19180 * gpointer user_data,
19183 * CounterData *data = user_data;
19185 * data->tag_count++;
19189 * counter_error (GMarkupParseContext *context,
19191 * gpointer user_data)
19193 * CounterData *data = user_data;
19195 * g_slice_free (CounterData, data);
19198 * static GMarkupParser counter_subparser =
19200 * counter_start_element,
19208 * In order to allow this parser to be easily used as a subparser, the
19209 * following interface is provided:
19213 * start_counting (GMarkupParseContext *context)
19215 * CounterData *data = g_slice_new (CounterData);
19217 * data->tag_count = 0;
19218 * g_markup_parse_context_push (context, &counter_subparser, data);
19222 * end_counting (GMarkupParseContext *context)
19224 * CounterData *data = g_markup_parse_context_pop (context);
19227 * result = data->tag_count;
19228 * g_slice_free (CounterData, data);
19234 * The subparser would then be used as follows:
19237 * static void start_element (context, element_name, ...)
19239 * if (strcmp (element_name, "count-these") == 0)
19240 * start_counting (context);
19242 * /* else, handle other tags... */
19245 * static void end_element (context, element_name, ...)
19247 * if (strcmp (element_name, "count-these") == 0)
19248 * g_print ("Counted %d tags\n", end_counting (context));
19250 * /* else, handle other tags... */
19259 * g_markup_printf_escaped:
19260 * @format: printf() style format string
19261 * @...: the arguments to insert in the format string
19263 * Formats arguments according to @format, escaping
19264 * all string and character arguments in the fashion
19265 * of g_markup_escape_text(). This is useful when you
19266 * want to insert literal strings into XML-style markup
19267 * output, without having to worry that the strings
19268 * might themselves contain markup.
19271 * const char *store = "Fortnum & Mason";
19272 * const char *item = "Tea";
19275 * output = g_markup_printf_escaped ("<purchase>"
19276 * "<store>%s</store>"
19277 * "<item>%s</item>"
19278 * "</purchase>",
19282 * Returns: newly allocated result from formatting operation. Free with g_free().
19288 * g_markup_vprintf_escaped:
19289 * @format: printf() style format string
19290 * @args: variable argument list, similar to vprintf()
19292 * Formats the data in @args according to @format, escaping
19293 * all string and character arguments in the fashion
19294 * of g_markup_escape_text(). See g_markup_printf_escaped().
19296 * Returns: newly allocated result from formatting operation. Free with g_free().
19302 * g_match_info_expand_references:
19303 * @match_info: (allow-none): a #GMatchInfo or %NULL
19304 * @string_to_expand: the string to expand
19305 * @error: location to store the error occurring, or %NULL to ignore errors
19307 * Returns a new string containing the text in @string_to_expand with
19308 * references and escape sequences expanded. References refer to the last
19309 * match done with @string against @regex and have the same syntax used by
19310 * g_regex_replace().
19312 * The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
19313 * passed to g_regex_new().
19315 * The backreferences are extracted from the string passed to the match
19316 * function, so you cannot call this function after freeing the string.
19318 * @match_info may be %NULL in which case @string_to_expand must not
19319 * contain references. For instance "foo\n" does not refer to an actual
19320 * pattern and '\n' merely will be replaced with \n character,
19321 * while to expand "\0" (whole match) one needs the result of a match.
19322 * Use g_regex_check_replacement() to find out whether @string_to_expand
19323 * contains references.
19325 * Returns: (allow-none): the expanded string, or %NULL if an error occurred
19331 * g_match_info_fetch:
19332 * @match_info: #GMatchInfo structure
19333 * @match_num: number of the sub expression
19335 * Retrieves the text matching the @match_num<!-- -->'th capturing
19336 * parentheses. 0 is the full text of the match, 1 is the first paren
19337 * set, 2 the second, and so on.
19339 * If @match_num is a valid sub pattern but it didn't match anything
19340 * (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
19341 * string is returned.
19343 * If the match was obtained using the DFA algorithm, that is using
19344 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19345 * string is not that of a set of parentheses but that of a matched
19346 * substring. Substrings are matched in reverse order of length, so
19347 * 0 is the longest match.
19349 * The string is fetched from the string passed to the match function,
19350 * so you cannot call this function after freeing the string.
19352 * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19358 * g_match_info_fetch_all:
19359 * @match_info: a #GMatchInfo structure
19361 * Bundles up pointers to each of the matching substrings from a match
19362 * and stores them in an array of gchar pointers. The first element in
19363 * the returned array is the match number 0, i.e. the entire matched
19366 * If a sub pattern didn't match anything (e.g. sub pattern 1, matching
19367 * "b" against "(a)?b") then an empty string is inserted.
19369 * If the last match was obtained using the DFA algorithm, that is using
19370 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19371 * strings are not that matched by sets of parentheses but that of the
19372 * matched substring. Substrings are matched in reverse order of length,
19373 * so the first one is the longest match.
19375 * The strings are fetched from the string passed to the match function,
19376 * so you cannot call this function after freeing the string.
19378 * Returns: (transfer full): a %NULL-terminated array of gchar * pointers. It must be freed using g_strfreev(). If the previous match failed %NULL is returned
19384 * g_match_info_fetch_named:
19385 * @match_info: #GMatchInfo structure
19386 * @name: name of the subexpression
19388 * Retrieves the text matching the capturing parentheses named @name.
19390 * If @name is a valid sub pattern name but it didn't match anything
19391 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
19392 * then an empty string is returned.
19394 * The string is fetched from the string passed to the match function,
19395 * so you cannot call this function after freeing the string.
19397 * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19403 * g_match_info_fetch_named_pos:
19404 * @match_info: #GMatchInfo structure
19405 * @name: name of the subexpression
19406 * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19407 * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19409 * Retrieves the position in bytes of the capturing parentheses named @name.
19411 * If @name is a valid sub pattern name but it didn't match anything
19412 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
19413 * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
19415 * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged.
19421 * g_match_info_fetch_pos:
19422 * @match_info: #GMatchInfo structure
19423 * @match_num: number of the sub expression
19424 * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19425 * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19427 * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
19428 * parentheses. 0 is the full text of the match, 1 is the first
19429 * paren set, 2 the second, and so on.
19431 * If @match_num is a valid sub pattern but it didn't match anything
19432 * (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
19433 * and @end_pos are set to -1 and %TRUE is returned.
19435 * If the match was obtained using the DFA algorithm, that is using
19436 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19437 * position is not that of a set of parentheses but that of a matched
19438 * substring. Substrings are matched in reverse order of length, so
19439 * 0 is the longest match.
19441 * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged
19447 * g_match_info_free:
19448 * @match_info: (allow-none): a #GMatchInfo, or %NULL
19450 * If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
19458 * g_match_info_get_match_count:
19459 * @match_info: a #GMatchInfo structure
19461 * Retrieves the number of matched substrings (including substring 0,
19462 * that is the whole matched text), so 1 is returned if the pattern
19463 * has no substrings in it and 0 is returned if the match failed.
19465 * If the last match was obtained using the DFA algorithm, that is
19466 * using g_regex_match_all() or g_regex_match_all_full(), the retrieved
19467 * count is not that of the number of capturing parentheses but that of
19468 * the number of matched substrings.
19470 * Returns: Number of matched substrings, or -1 if an error occurred
19476 * g_match_info_get_regex:
19477 * @match_info: a #GMatchInfo
19479 * Returns #GRegex object used in @match_info. It belongs to Glib
19480 * and must not be freed. Use g_regex_ref() if you need to keep it
19481 * after you free @match_info object.
19483 * Returns: #GRegex object used in @match_info
19489 * g_match_info_get_string:
19490 * @match_info: a #GMatchInfo
19492 * Returns the string searched with @match_info. This is the
19493 * string passed to g_regex_match() or g_regex_replace() so
19494 * you may not free it before calling this function.
19496 * Returns: the string searched with @match_info
19502 * g_match_info_is_partial_match:
19503 * @match_info: a #GMatchInfo structure
19505 * Usually if the string passed to g_regex_match*() matches as far as
19506 * it goes, but is too short to match the entire pattern, %FALSE is
19507 * returned. There are circumstances where it might be helpful to
19508 * distinguish this case from other cases in which there is no match.
19510 * Consider, for example, an application where a human is required to
19511 * type in data for a field with specific formatting requirements. An
19512 * example might be a date in the form ddmmmyy, defined by the pattern
19513 * "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
19514 * If the application sees the user’s keystrokes one by one, and can
19515 * check that what has been typed so far is potentially valid, it is
19516 * able to raise an error as soon as a mistake is made.
19518 * GRegex supports the concept of partial matching by means of the
19519 * #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD flags.
19520 * When they are used, the return code for
19521 * g_regex_match() or g_regex_match_full() is, as usual, %TRUE
19522 * for a complete match, %FALSE otherwise. But, when these functions
19523 * return %FALSE, you can check if the match was partial calling
19524 * g_match_info_is_partial_match().
19526 * The difference between #G_REGEX_MATCH_PARTIAL_SOFT and
19527 * #G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
19528 * with #G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
19529 * possible complete match, while with #G_REGEX_MATCH_PARTIAL_HARD matching
19530 * stops at the partial match.
19531 * When both #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD
19532 * are set, the latter takes precedence.
19533 * See <ulink>man:pcrepartial</ulink> for more information on partial matching.
19535 * Because of the way certain internal optimizations are implemented
19536 * the partial matching algorithm cannot be used with all patterns.
19537 * So repeated single characters such as "a{2,4}" and repeated single
19538 * meta-sequences such as "\d+" are not permitted if the maximum number
19539 * of occurrences is greater than one. Optional items such as "\d?"
19540 * (where the maximum is one) are permitted. Quantifiers with any values
19541 * are permitted after parentheses, so the invalid examples above can be
19542 * coded thus "(a){2,4}" and "(\d)+". If #G_REGEX_MATCH_PARTIAL or
19543 * #G_REGEX_MATCH_PARTIAL_HARD is set
19544 * for a pattern that does not conform to the restrictions, matching
19545 * functions return an error.
19547 * Returns: %TRUE if the match was partial, %FALSE otherwise
19553 * g_match_info_matches:
19554 * @match_info: a #GMatchInfo structure
19556 * Returns whether the previous match operation succeeded.
19558 * Returns: %TRUE if the previous match operation succeeded, %FALSE otherwise
19564 * g_match_info_next:
19565 * @match_info: a #GMatchInfo structure
19566 * @error: location to store the error occurring, or %NULL to ignore errors
19568 * Scans for the next match using the same parameters of the previous
19569 * call to g_regex_match_full() or g_regex_match() that returned
19572 * The match is done on the string passed to the match function, so you
19573 * cannot free it before calling this function.
19575 * Returns: %TRUE is the string matched, %FALSE otherwise
19581 * g_match_info_ref:
19582 * @match_info: a #GMatchInfo
19584 * Increases reference count of @match_info by 1.
19586 * Returns: @match_info
19592 * g_match_info_unref:
19593 * @match_info: a #GMatchInfo
19595 * Decreases reference count of @match_info by 1. When reference count drops
19596 * to zero, it frees all the memory associated with the match_info structure.
19603 * g_mem_gc_friendly:
19605 * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
19606 * includes the key <literal>gc-friendly</literal>.
19611 * g_mem_is_system_malloc:
19613 * Checks whether the allocator used by g_malloc() is the system's
19614 * malloc implementation. If it returns %TRUE memory allocated with
19615 * malloc() can be used interchangeable with memory allocated using g_malloc().
19616 * This function is useful for avoiding an extra copy of allocated memory returned
19617 * by a non-GLib-based API.
19619 * A different allocator can be set using g_mem_set_vtable().
19621 * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
19628 * Outputs a summary of memory usage.
19630 * It outputs the frequency of allocations of different sizes,
19631 * the total number of bytes which have been allocated,
19632 * the total number of bytes which have been freed,
19633 * and the difference between the previous two values, i.e. the number of bytes
19636 * Note that this function will not output anything unless you have
19637 * previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
19642 * g_mem_set_vtable:
19643 * @vtable: table of memory allocation routines.
19645 * Sets the #GMemVTable to use for memory allocation. You can use this to provide
19646 * custom memory allocation routines. <emphasis>This function must be called
19647 * before using any other GLib functions.</emphasis> The @vtable only needs to
19648 * provide malloc(), realloc(), and free() functions; GLib can provide default
19649 * implementations of the others. The malloc() and realloc() implementations
19650 * should return %NULL on failure, GLib will handle error-checking for you.
19651 * @vtable is copied, so need not persist after this function has been called.
19657 * @mem: the memory to copy.
19658 * @byte_size: the number of bytes to copy.
19660 * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
19661 * from @mem. If @mem is %NULL it returns %NULL.
19663 * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem is %NULL.
19669 * @dest: the destination address to copy the bytes to.
19670 * @src: the source address to copy the bytes from.
19671 * @len: the number of bytes to copy.
19673 * Copies a block of memory @len bytes long, from @src to @dest.
19674 * The source and destination areas may overlap.
19676 * In order to use this function, you must include
19677 * <filename>string.h</filename> yourself, because this macro will
19678 * typically simply resolve to memmove() and GLib does not include
19679 * <filename>string.h</filename> for you.
19685 * @...: format string, followed by parameters to insert into the format string (as with printf())
19687 * A convenience function/macro to log a normal message.
19693 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
19694 * @mode: permissions to use for the newly created directory
19696 * A wrapper for the POSIX mkdir() function. The mkdir() function
19697 * attempts to create a directory with the given name and permissions.
19698 * The mode argument is ignored on Windows.
19700 * See your C library manual for more details about mkdir().
19702 * Returns: 0 if the directory was successfully created, -1 if an error occurred
19708 * g_mkdir_with_parents:
19709 * @pathname: a pathname in the GLib file name encoding
19710 * @mode: permissions to use for newly created directories
19712 * Create a directory if it doesn't already exist. Create intermediate
19713 * parent directories as needed, too.
19715 * Returns: 0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set.
19722 * @tmpl: (type filename): template directory name
19724 * Creates a temporary directory. See the mkdtemp() documentation
19725 * on most UNIX-like systems.
19727 * The parameter is a string that should follow the rules for
19728 * mkdtemp() templates, i.e. contain the string "XXXXXX".
19729 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19730 * sequence does not have to occur at the very end of the template
19731 * and you can pass a @mode and additional @flags. The X string will
19732 * be modified to form the name of a directory that didn't exist.
19733 * The string should be in the GLib file name encoding. Most importantly,
19734 * on Windows it should be in UTF-8.
19736 * Returns: A pointer to @tmpl, which has been modified to hold the directory name. In case of errors, %NULL is returned and %errno will be set.
19743 * @tmpl: (type filename): template directory name
19744 * @mode: permissions to create the temporary directory with
19746 * Creates a temporary directory. See the mkdtemp() documentation
19747 * on most UNIX-like systems.
19749 * The parameter is a string that should follow the rules for
19750 * mkdtemp() templates, i.e. contain the string "XXXXXX".
19751 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19752 * sequence does not have to occur at the very end of the template
19753 * and you can pass a @mode. The X string will be modified to form
19754 * the name of a directory that didn't exist. The string should be
19755 * in the GLib file name encoding. Most importantly, on Windows it
19756 * should be in UTF-8.
19758 * Returns: A pointer to @tmpl, which has been modified to hold the directory name. In case of errors, %NULL is returned, and %errno will be set.
19765 * @tmpl: (type filename): template filename
19767 * Opens a temporary file. See the mkstemp() documentation
19768 * on most UNIX-like systems.
19770 * The parameter is a string that should follow the rules for
19771 * mkstemp() templates, i.e. contain the string "XXXXXX".
19772 * g_mkstemp() is slightly more flexible than mkstemp() in that the
19773 * sequence does not have to occur at the very end of the template.
19774 * The X string will be modified to form the name of a file that
19775 * didn't exist. The string should be in the GLib file name encoding.
19776 * Most importantly, on Windows it should be in UTF-8.
19778 * Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and %errno will be set.
19784 * @tmpl: (type filename): template filename
19785 * @flags: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
19786 * @mode: permissions to create the temporary file with
19788 * Opens a temporary file. See the mkstemp() documentation
19789 * on most UNIX-like systems.
19791 * The parameter is a string that should follow the rules for
19792 * mkstemp() templates, i.e. contain the string "XXXXXX".
19793 * g_mkstemp_full() is slightly more flexible than mkstemp()
19794 * in that the sequence does not have to occur at the very end of the
19795 * template and you can pass a @mode and additional @flags. The X
19796 * string will be modified to form the name of a file that didn't exist.
19797 * The string should be in the GLib file name encoding. Most importantly,
19798 * on Windows it should be in UTF-8.
19800 * Returns: A file handle (as from open()) to the file opened for reading and writing. The file handle should be closed with close(). In case of errors, -1 is returned and %errno will be set.
19807 * @mutex: an initialized #GMutex
19809 * Frees the resources allocated to a mutex with g_mutex_init().
19811 * This function should not be used with a #GMutex that has been
19812 * statically allocated.
19814 * Calling g_mutex_clear() on a locked mutex leads to undefined
19823 * @mutex: an uninitialized #GMutex
19825 * Initializes a #GMutex so that it can be used.
19827 * This function is useful to initialize a mutex that has been
19828 * allocated on the stack, or as part of a larger structure.
19829 * It is not necessary to initialize a mutex that has been
19830 * statically allocated.
19840 * b = g_new (Blob, 1);
19841 * g_mutex_init (&b->m);
19844 * To undo the effect of g_mutex_init() when a mutex is no longer
19845 * needed, use g_mutex_clear().
19847 * Calling g_mutex_init() on an already initialized #GMutex leads
19848 * to undefined behaviour.
19856 * @mutex: a #GMutex
19858 * Locks @mutex. If @mutex is already locked by another thread, the
19859 * current thread will block until @mutex is unlocked by the other
19862 * <note>#GMutex is neither guaranteed to be recursive nor to be
19863 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
19864 * already been locked by the same thread results in undefined behaviour
19865 * (including but not limited to deadlocks).</note>
19871 * @mutex: a #GMutex
19873 * Tries to lock @mutex. If @mutex is already locked by another thread,
19874 * it immediately returns %FALSE. Otherwise it locks @mutex and returns
19877 * <note>#GMutex is neither guaranteed to be recursive nor to be
19878 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
19879 * already been locked by the same thread results in undefined behaviour
19880 * (including but not limited to deadlocks or arbitrary return values).
19883 * Returns: %TRUE if @mutex could be locked
19889 * @mutex: a #GMutex
19891 * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
19892 * call for @mutex, it will become unblocked and can lock @mutex itself.
19894 * Calling g_mutex_unlock() on a mutex that is not locked by the
19895 * current thread leads to undefined behaviour.
19900 * g_node_child_index:
19902 * @data: the data to find
19904 * Gets the position of the first child of a #GNode
19905 * which contains the given data.
19907 * Returns: the index of the child of @node which contains @data, or -1 if the data is not found
19912 * g_node_child_position:
19914 * @child: a child of @node
19916 * Gets the position of a #GNode with respect to its siblings.
19917 * @child must be a child of @node. The first child is numbered 0,
19918 * the second 1, and so on.
19920 * Returns: the position of @child with respect to its siblings
19925 * g_node_children_foreach:
19927 * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
19928 * @func: the function to call for each visited node
19929 * @data: user data to pass to the function
19931 * Calls a function for each of the children of a #GNode.
19932 * Note that it doesn't descend beneath the child nodes.
19940 * Recursively copies a #GNode (but does not deep-copy the data inside the
19941 * nodes, see g_node_copy_deep() if you need that).
19943 * Returns: a new #GNode containing the same data pointers
19948 * g_node_copy_deep:
19950 * @copy_func: the function which is called to copy the data inside each node, or %NULL to use the original data.
19951 * @data: data to pass to @copy_func
19953 * Recursively copies a #GNode and its data.
19955 * Returns: a new #GNode containing copies of the data in @node.
19964 * Gets the depth of a #GNode.
19966 * If @node is %NULL the depth is 0. The root node has a depth of 1.
19967 * For the children of the root node the depth is 2. And so on.
19969 * Returns: the depth of the #GNode
19975 * @root: the root of the tree/subtree to destroy
19977 * Removes @root and its children from the tree, freeing any memory
19984 * @root: the root #GNode of the tree to search
19985 * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
19986 * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
19987 * @data: the data to find
19989 * Finds a #GNode in a tree.
19991 * Returns: the found #GNode, or %NULL if the data is not found
19996 * g_node_find_child:
19998 * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
19999 * @data: the data to find
20001 * Finds the first child of a #GNode with the given data.
20003 * Returns: the found child #GNode, or %NULL if the data is not found
20008 * g_node_first_sibling:
20011 * Gets the first sibling of a #GNode.
20012 * This could possibly be the node itself.
20014 * Returns: the first sibling of @node
20022 * Gets the root of a tree.
20024 * Returns: the root of the tree
20030 * @parent: the #GNode to place @node under
20031 * @position: the position to place @node at, with respect to its siblings If position is -1, @node is inserted as the last child of @parent
20032 * @node: the #GNode to insert
20034 * Inserts a #GNode beneath the parent at the given position.
20036 * Returns: the inserted #GNode
20041 * g_node_insert_after:
20042 * @parent: the #GNode to place @node under
20043 * @sibling: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
20044 * @node: the #GNode to insert
20046 * Inserts a #GNode beneath the parent after the given sibling.
20048 * Returns: the inserted #GNode
20053 * g_node_insert_before:
20054 * @parent: the #GNode to place @node under
20055 * @sibling: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
20056 * @node: the #GNode to insert
20058 * Inserts a #GNode beneath the parent before the given sibling.
20060 * Returns: the inserted #GNode
20065 * g_node_is_ancestor:
20067 * @descendant: a #GNode
20069 * Returns %TRUE if @node is an ancestor of @descendant.
20070 * This is true if node is the parent of @descendant,
20071 * or if node is the grandparent of @descendant etc.
20073 * Returns: %TRUE if @node is an ancestor of @descendant
20078 * g_node_last_child:
20079 * @node: a #GNode (must not be %NULL)
20081 * Gets the last child of a #GNode.
20083 * Returns: the last child of @node, or %NULL if @node has no children
20088 * g_node_last_sibling:
20091 * Gets the last sibling of a #GNode.
20092 * This could possibly be the node itself.
20094 * Returns: the last sibling of @node
20099 * g_node_max_height:
20102 * Gets the maximum height of all branches beneath a #GNode.
20103 * This is the maximum distance from the #GNode to all leaf nodes.
20105 * If @root is %NULL, 0 is returned. If @root has no children,
20106 * 1 is returned. If @root has children, 2 is returned. And so on.
20108 * Returns: the maximum height of the tree beneath @root
20113 * g_node_n_children:
20116 * Gets the number of children of a #GNode.
20118 * Returns: the number of children of @node
20125 * @flags: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20127 * Gets the number of nodes in a tree.
20129 * Returns: the number of nodes in the tree
20135 * @data: the data of the new node
20137 * Creates a new #GNode containing the given data.
20138 * Used to create the first node in a tree.
20140 * Returns: a new #GNode
20145 * g_node_nth_child:
20147 * @n: the index of the desired child
20149 * Gets a child of a #GNode, using the given index.
20150 * The first child is at index 0. If the index is
20151 * too big, %NULL is returned.
20153 * Returns: the child of @node at index @n
20159 * @parent: the #GNode to place the new #GNode under
20160 * @node: the #GNode to insert
20162 * Inserts a #GNode as the first child of the given parent.
20164 * Returns: the inserted #GNode
20169 * g_node_reverse_children:
20172 * Reverses the order of the children of a #GNode.
20173 * (It doesn't change the order of the grandchildren.)
20179 * @root: the root #GNode of the tree to traverse
20180 * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
20181 * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20182 * @max_depth: the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on.
20183 * @func: the function to call for each visited #GNode
20184 * @data: user data to pass to the function
20186 * Traverses a tree starting at the given root #GNode.
20187 * It calls the given function for each node visited.
20188 * The traversal can be halted at any point by returning %TRUE from @func.
20194 * @node: the #GNode to unlink, which becomes the root of a new tree
20196 * Unlinks a #GNode from a tree, resulting in two separate trees.
20202 * @val: a 32-bit integer value in network byte order
20204 * Converts a 32-bit integer value from network to host byte order.
20206 * Returns: @val converted to host byte order.
20212 * @val: a 16-bit integer value in network byte order
20214 * Converts a 16-bit integer value from network to host byte order.
20216 * Returns: @val converted to host byte order
20221 * g_nullify_pointer:
20222 * @nullify_location: the memory address of the pointer.
20224 * Set the pointer at the specified location to %NULL.
20229 * g_on_error_query:
20230 * @prg_name: the program name, needed by <command>gdb</command> for the [S]tack trace option. If @prg_name is %NULL, g_get_prgname() is called to get the program name (which will work correctly if gdk_init() or gtk_init() has been called)
20232 * Prompts the user with
20233 * <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
20234 * This function is intended to be used for debugging use only.
20235 * The following example shows how it can be used together with
20236 * the g_log() functions.
20239 * #include <glib.h>
20242 * log_handler (const gchar *log_domain,
20243 * GLogLevelFlags log_level,
20244 * const gchar *message,
20245 * gpointer user_data)
20247 * g_log_default_handler (log_domain, log_level, message, user_data);
20249 * g_on_error_query (MY_PROGRAM_NAME);
20253 * main (int argc, char *argv[])
20255 * g_log_set_handler (MY_LOG_DOMAIN,
20256 * G_LOG_LEVEL_WARNING |
20257 * G_LOG_LEVEL_ERROR |
20258 * G_LOG_LEVEL_CRITICAL,
20261 * /* ... */
20264 * If [E]xit is selected, the application terminates with a call
20265 * to <literal>_exit(0)</literal>.
20267 * If [S]tack trace is selected, g_on_error_stack_trace() is called.
20268 * This invokes <command>gdb</command>, which attaches to the current
20269 * process and shows a stack trace. The prompt is then shown again.
20271 * If [P]roceed is selected, the function returns.
20273 * This function may cause different actions on non-UNIX platforms.
20278 * g_on_error_stack_trace:
20279 * @prg_name: the program name, needed by <command>gdb</command> for the [S]tack trace option.
20281 * Invokes <command>gdb</command>, which attaches to the current
20282 * process and shows a stack trace. Called by g_on_error_query()
20283 * when the [S]tack trace option is selected. You can get the current
20284 * process's "program name" with g_get_prgname(), assuming that you
20285 * have called gtk_init() or gdk_init().
20287 * This function may cause different actions on non-UNIX platforms.
20293 * @once: a #GOnce structure
20294 * @func: the #GThreadFunc function associated to @once. This function is called only once, regardless of the number of times it and its associated #GOnce struct are passed to g_once().
20295 * @arg: data to be passed to @func
20297 * The first call to this routine by a process with a given #GOnce
20298 * struct calls @func with the given argument. Thereafter, subsequent
20299 * calls to g_once() with the same #GOnce struct do not call @func
20300 * again, but return the stored result of the first call. On return
20301 * from g_once(), the status of @once will be %G_ONCE_STATUS_READY.
20303 * For example, a mutex or a thread-specific data key must be created
20304 * exactly once. In a threaded environment, calling g_once() ensures
20305 * that the initialization is serialized across multiple threads.
20307 * Calling g_once() recursively on the same #GOnce struct in
20308 * @func will lead to a deadlock.
20312 * get_debug_flags (void)
20314 * static GOnce my_once = G_ONCE_INIT;
20316 * g_once (&my_once, parse_debug_flags, NULL);
20318 * return my_once.retval;
20327 * g_once_init_enter:
20328 * @location: location of a static initializable variable containing 0
20330 * Function to be called when starting a critical initialization
20331 * section. The argument @location must point to a static
20332 * 0-initialized variable that will be set to a value other than 0 at
20333 * the end of the initialization section. In combination with
20334 * g_once_init_leave() and the unique address @value_location, it can
20335 * be ensured that an initialization section will be executed only once
20336 * during a program's life time, and that concurrent threads are
20337 * blocked until initialization completed. To be used in constructs
20341 * static gsize initialization_value = 0;
20343 * if (g_once_init_enter (&initialization_value))
20345 * gsize setup_value = 42; /** initialization code here **/
20347 * g_once_init_leave (&initialization_value, setup_value);
20350 * /** use initialization_value here **/
20353 * Returns: %TRUE if the initialization section should be entered, %FALSE and blocks otherwise
20359 * g_once_init_leave:
20360 * @location: location of a static initializable variable containing 0
20361 * @result: new non-0 value for *@value_location
20363 * Counterpart to g_once_init_enter(). Expects a location of a static
20364 * 0-initialized initialization variable, and an initialization value
20365 * other than 0. Sets the variable to the initialization value, and
20366 * releases concurrent threads blocking in g_once_init_enter() on this
20367 * initialization variable.
20375 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
20376 * @flags: as in open()
20377 * @mode: as in open()
20379 * A wrapper for the POSIX open() function. The open() function is
20380 * used to convert a pathname into a file descriptor.
20382 * On POSIX systems file descriptors are implemented by the operating
20383 * system. On Windows, it's the C library that implements open() and
20384 * file descriptors. The actual Win32 API for opening files is quite
20385 * different, see MSDN documentation for CreateFile(). The Win32 API
20386 * uses file handles, which are more randomish integers, not small
20387 * integers like file descriptors.
20389 * Because file descriptors are specific to the C library on Windows,
20390 * the file descriptor returned by this function makes sense only to
20391 * functions in the same C library. Thus if the GLib-using code uses a
20392 * different C library than GLib does, the file descriptor returned by
20393 * this function cannot be passed to C library functions like write()
20396 * See your C library manual for more details about open().
20398 * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from open().
20404 * g_option_context_add_group:
20405 * @context: a #GOptionContext
20406 * @group: the group to add
20408 * Adds a #GOptionGroup to the @context, so that parsing with @context
20409 * will recognize the options in the group. Note that the group will
20410 * be freed together with the context when g_option_context_free() is
20411 * called, so you must not free the group yourself after adding it
20419 * g_option_context_add_main_entries:
20420 * @context: a #GOptionContext
20421 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20422 * @translation_domain: (allow-none): a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
20424 * A convenience function which creates a main group if it doesn't
20425 * exist, adds the @entries to it and sets the translation domain.
20432 * g_option_context_free:
20433 * @context: a #GOptionContext
20435 * Frees context and all the groups which have been
20438 * Please note that parsed arguments need to be freed separately (see
20446 * g_option_context_get_description:
20447 * @context: a #GOptionContext
20449 * Returns the description. See g_option_context_set_description().
20451 * Returns: the description
20457 * g_option_context_get_help:
20458 * @context: a #GOptionContext
20459 * @main_help: if %TRUE, only include the main group
20460 * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
20462 * Returns a formatted, translated help text for the given context.
20463 * To obtain the text produced by <option>--help</option>, call
20464 * <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
20465 * To obtain the text produced by <option>--help-all</option>, call
20466 * <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
20467 * To obtain the help text for an option group, call
20468 * <literal>g_option_context_get_help (context, FALSE, group)</literal>.
20470 * Returns: A newly allocated string containing the help text
20476 * g_option_context_get_help_enabled:
20477 * @context: a #GOptionContext
20479 * Returns whether automatic <option>--help</option> generation
20480 * is turned on for @context. See g_option_context_set_help_enabled().
20482 * Returns: %TRUE if automatic help generation is turned on.
20488 * g_option_context_get_ignore_unknown_options:
20489 * @context: a #GOptionContext
20491 * Returns whether unknown options are ignored or not. See
20492 * g_option_context_set_ignore_unknown_options().
20494 * Returns: %TRUE if unknown options are ignored.
20500 * g_option_context_get_main_group:
20501 * @context: a #GOptionContext
20503 * Returns a pointer to the main group of @context.
20505 * Returns: the main group of @context, or %NULL if @context doesn't have a main group. Note that group belongs to @context and should not be modified or freed.
20511 * g_option_context_get_summary:
20512 * @context: a #GOptionContext
20514 * Returns the summary. See g_option_context_set_summary().
20516 * Returns: the summary
20522 * g_option_context_new:
20523 * @parameter_string: a string which is displayed in the first line of <option>--help</option> output, after the usage summary <literal><replaceable>programname</replaceable> [OPTION...]</literal>
20525 * Creates a new option context.
20527 * The @parameter_string can serve multiple purposes. It can be used
20528 * to add descriptions for "rest" arguments, which are not parsed by
20529 * the #GOptionContext, typically something like "FILES" or
20530 * "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
20531 * collecting "rest" arguments, GLib handles this automatically by
20532 * using the @arg_description of the corresponding #GOptionEntry in
20533 * the usage summary.
20535 * Another usage is to give a short summary of the program
20536 * functionality, like " - frob the strings", which will be displayed
20537 * in the same line as the usage. For a longer description of the
20538 * program functionality that should be displayed as a paragraph
20539 * below the usage line, use g_option_context_set_summary().
20541 * Note that the @parameter_string is translated using the
20542 * function set with g_option_context_set_translate_func(), so
20543 * it should normally be passed untranslated.
20545 * Returns: a newly created #GOptionContext, which must be freed with g_option_context_free() after use.
20551 * g_option_context_parse:
20552 * @context: a #GOptionContext
20553 * @argc: (inout) (allow-none): a pointer to the number of command line arguments
20554 * @argv: (inout) (array length=argc) (allow-none): a pointer to the array of command line arguments
20555 * @error: a return location for errors
20557 * Parses the command line arguments, recognizing options
20558 * which have been added to @context. A side-effect of
20559 * calling this function is that g_set_prgname() will be
20562 * If the parsing is successful, any parsed arguments are
20563 * removed from the array and @argc and @argv are updated
20564 * accordingly. A '--' option is stripped from @argv
20565 * unless there are unparsed options before and after it,
20566 * or some of the options after it start with '-'. In case
20567 * of an error, @argc and @argv are left unmodified.
20569 * If automatic <option>--help</option> support is enabled
20570 * (see g_option_context_set_help_enabled()), and the
20571 * @argv array contains one of the recognized help options,
20572 * this function will produce help output to stdout and
20573 * call <literal>exit (0)</literal>.
20575 * Note that function depends on the
20576 * <link linkend="setlocale">current locale</link> for
20577 * automatic character set conversion of string and filename
20580 * Returns: %TRUE if the parsing was successful, %FALSE if an error occurred
20586 * g_option_context_set_description:
20587 * @context: a #GOptionContext
20588 * @description: (allow-none): a string to be shown in <option>--help</option> output after the list of options, or %NULL
20590 * Adds a string to be displayed in <option>--help</option> output
20591 * after the list of options. This text often includes a bug reporting
20594 * Note that the summary is translated (see
20595 * g_option_context_set_translate_func()).
20602 * g_option_context_set_help_enabled:
20603 * @context: a #GOptionContext
20604 * @help_enabled: %TRUE to enable <option>--help</option>, %FALSE to disable it
20606 * Enables or disables automatic generation of <option>--help</option>
20607 * output. By default, g_option_context_parse() recognizes
20608 * <option>--help</option>, <option>-h</option>,
20609 * <option>-?</option>, <option>--help-all</option>
20610 * and <option>--help-</option><replaceable>groupname</replaceable> and creates
20611 * suitable output to stdout.
20618 * g_option_context_set_ignore_unknown_options:
20619 * @context: a #GOptionContext
20620 * @ignore_unknown: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
20622 * Sets whether to ignore unknown options or not. If an argument is
20623 * ignored, it is left in the @argv array after parsing. By default,
20624 * g_option_context_parse() treats unknown options as error.
20626 * This setting does not affect non-option arguments (i.e. arguments
20627 * which don't start with a dash). But note that GOption cannot reliably
20628 * determine whether a non-option belongs to a preceding unknown option.
20635 * g_option_context_set_main_group:
20636 * @context: a #GOptionContext
20637 * @group: the group to set as main group
20639 * Sets a #GOptionGroup as main group of the @context.
20640 * This has the same effect as calling g_option_context_add_group(),
20641 * the only difference is that the options in the main group are
20642 * treated differently when generating <option>--help</option> output.
20649 * g_option_context_set_summary:
20650 * @context: a #GOptionContext
20651 * @summary: (allow-none): a string to be shown in <option>--help</option> output before the list of options, or %NULL
20653 * Adds a string to be displayed in <option>--help</option> output
20654 * before the list of options. This is typically a summary of the
20655 * program functionality.
20657 * Note that the summary is translated (see
20658 * g_option_context_set_translate_func() and
20659 * g_option_context_set_translation_domain()).
20666 * g_option_context_set_translate_func:
20667 * @context: a #GOptionContext
20668 * @func: (allow-none): the #GTranslateFunc, or %NULL
20669 * @data: (allow-none): user data to pass to @func, or %NULL
20670 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20672 * Sets the function which is used to translate the contexts
20673 * user-visible strings, for <option>--help</option> output.
20674 * If @func is %NULL, strings are not translated.
20676 * Note that option groups have their own translation functions,
20677 * this function only affects the @parameter_string (see g_option_context_new()),
20678 * the summary (see g_option_context_set_summary()) and the description
20679 * (see g_option_context_set_description()).
20681 * If you are using gettext(), you only need to set the translation
20682 * domain, see g_option_context_set_translation_domain().
20689 * g_option_context_set_translation_domain:
20690 * @context: a #GOptionContext
20691 * @domain: the domain to use
20693 * A convenience function to use gettext() for translating
20694 * user-visible strings.
20701 * g_option_group_add_entries:
20702 * @group: a #GOptionGroup
20703 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20705 * Adds the options specified in @entries to @group.
20712 * g_option_group_free:
20713 * @group: a #GOptionGroup
20715 * Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
20716 * free groups which have been added to a #GOptionContext.
20723 * g_option_group_new:
20724 * @name: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
20725 * @description: a description for this group to be shown in <option>--help</option>. This string is translated using the translation domain or translation function of the group
20726 * @help_description: a description for the <option>--help-</option>@name option. This string is translated using the translation domain or translation function of the group
20727 * @user_data: (allow-none): user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
20728 * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
20730 * Creates a new #GOptionGroup.
20732 * Returns: a newly created option group. It should be added to a #GOptionContext or freed with g_option_group_free().
20738 * g_option_group_set_error_hook:
20739 * @group: a #GOptionGroup
20740 * @error_func: a function to call when an error occurs
20742 * Associates a function with @group which will be called
20743 * from g_option_context_parse() when an error occurs.
20745 * Note that the user data to be passed to @error_func can be
20746 * specified when constructing the group with g_option_group_new().
20753 * g_option_group_set_parse_hooks:
20754 * @group: a #GOptionGroup
20755 * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
20756 * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
20758 * Associates two functions with @group which will be called
20759 * from g_option_context_parse() before the first option is parsed
20760 * and after the last option has been parsed, respectively.
20762 * Note that the user data to be passed to @pre_parse_func and
20763 * @post_parse_func can be specified when constructing the group
20764 * with g_option_group_new().
20771 * g_option_group_set_translate_func:
20772 * @group: a #GOptionGroup
20773 * @func: (allow-none): the #GTranslateFunc, or %NULL
20774 * @data: (allow-none): user data to pass to @func, or %NULL
20775 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20777 * Sets the function which is used to translate user-visible
20778 * strings, for <option>--help</option> output. Different
20779 * groups can use different #GTranslateFunc<!-- -->s. If @func
20780 * is %NULL, strings are not translated.
20782 * If you are using gettext(), you only need to set the translation
20783 * domain, see g_option_group_set_translation_domain().
20790 * g_option_group_set_translation_domain:
20791 * @group: a #GOptionGroup
20792 * @domain: the domain to use
20794 * A convenience function to use gettext() for translating
20795 * user-visible strings.
20802 * g_parse_debug_string:
20803 * @string: (allow-none): a list of debug options separated by colons, spaces, or commas, or %NULL.
20804 * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate strings with bit flags.
20805 * @nkeys: the number of #GDebugKey<!-- -->s in the array.
20807 * Parses a string containing debugging options
20808 * into a %guint containing bit flags. This is used
20809 * within GDK and GTK+ to parse the debug options passed on the
20810 * command line or through environment variables.
20812 * If @string is equal to <code>"all"</code>, all flags are set. Any flags
20813 * specified along with <code>"all"</code> in @string are inverted; thus,
20814 * <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
20815 * except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
20817 * If @string is equal to <code>"help"</code>, all the available keys in @keys
20818 * are printed out to standard error.
20820 * Returns: the combined set of bit flags.
20825 * g_path_get_basename:
20826 * @file_name: the name of the file
20828 * Gets the last component of the filename.
20830 * If @file_name ends with a directory separator it gets the component
20831 * before the last slash. If @file_name consists only of directory
20832 * separators (and on Windows, possibly a drive letter), a single
20833 * separator is returned. If @file_name is empty, it gets ".".
20835 * Returns: a newly allocated string containing the last component of the filename
20840 * g_path_get_dirname:
20841 * @file_name: the name of the file
20843 * Gets the directory components of a file name.
20845 * If the file name has no directory components "." is returned.
20846 * The returned string should be freed when no longer needed.
20848 * Returns: the directory components of the file
20853 * g_path_is_absolute:
20854 * @file_name: a file name
20856 * Returns %TRUE if the given @file_name is an absolute file name.
20857 * Note that this is a somewhat vague concept on Windows.
20859 * On POSIX systems, an absolute file name is well-defined. It always
20860 * starts from the single root directory. For example "/usr/local".
20862 * On Windows, the concepts of current drive and drive-specific
20863 * current directory introduce vagueness. This function interprets as
20864 * an absolute file name one that either begins with a directory
20865 * separator such as "\Users\tml" or begins with the root on a drive,
20866 * for example "C:\Windows". The first case also includes UNC paths
20867 * such as "\\myserver\docs\foo". In all cases, either slashes or
20868 * backslashes are accepted.
20870 * Note that a file name relative to the current drive root does not
20871 * truly specify a file uniquely over time and across processes, as
20872 * the current drive is a per-process value and can be changed.
20874 * File names relative the current directory on some specific drive,
20875 * such as "D:foo/bar", are not interpreted as absolute by this
20876 * function, but they obviously are not relative to the normal current
20877 * directory as returned by getcwd() or g_get_current_dir()
20878 * either. Such paths should be avoided, or need to be handled using
20879 * Windows-specific code.
20881 * Returns: %TRUE if @file_name is absolute
20886 * g_path_skip_root:
20887 * @file_name: a file name
20889 * Returns a pointer into @file_name after the root component,
20890 * i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
20891 * is not an absolute path it returns %NULL.
20893 * Returns: a pointer into @file_name after the root component
20899 * @pspec: a #GPatternSpec
20900 * @string_length: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
20901 * @string: the UTF-8 encoded string to match
20902 * @string_reversed: (allow-none): the reverse of @string or %NULL
20904 * Matches a string against a compiled pattern. Passing the correct
20905 * length of the string given is mandatory. The reversed string can be
20906 * omitted by passing %NULL, this is more efficient if the reversed
20907 * version of the string to be matched is not at hand, as
20908 * g_pattern_match() will only construct it if the compiled pattern
20909 * requires reverse matches.
20911 * Note that, if the user code will (possibly) match a string against a
20912 * multitude of patterns containing wildcards, chances are high that
20913 * some patterns will require a reversed string. In this case, it's
20914 * more efficient to provide the reversed string to avoid multiple
20915 * constructions thereof in the various calls to g_pattern_match().
20917 * Note also that the reverse of a UTF-8 encoded string can in general
20918 * <emphasis>not</emphasis> be obtained by g_strreverse(). This works
20919 * only if the string doesn't contain any multibyte characters. GLib
20920 * offers the g_utf8_strreverse() function to reverse UTF-8 encoded
20923 * Returns: %TRUE if @string matches @pspec
20928 * g_pattern_match_simple:
20929 * @pattern: the UTF-8 encoded pattern
20930 * @string: the UTF-8 encoded string to match
20932 * Matches a string against a pattern given as a string. If this
20933 * function is to be called in a loop, it's more efficient to compile
20934 * the pattern once with g_pattern_spec_new() and call
20935 * g_pattern_match_string() repeatedly.
20937 * Returns: %TRUE if @string matches @pspec
20942 * g_pattern_match_string:
20943 * @pspec: a #GPatternSpec
20944 * @string: the UTF-8 encoded string to match
20946 * Matches a string against a compiled pattern. If the string is to be
20947 * matched against more than one pattern, consider using
20948 * g_pattern_match() instead while supplying the reversed string.
20950 * Returns: %TRUE if @string matches @pspec
20955 * g_pattern_spec_equal:
20956 * @pspec1: a #GPatternSpec
20957 * @pspec2: another #GPatternSpec
20959 * Compares two compiled pattern specs and returns whether they will
20960 * match the same set of strings.
20962 * Returns: Whether the compiled patterns are equal
20967 * g_pattern_spec_free:
20968 * @pspec: a #GPatternSpec
20970 * Frees the memory allocated for the #GPatternSpec.
20975 * g_pattern_spec_new:
20976 * @pattern: a zero-terminated UTF-8 encoded string
20978 * Compiles a pattern to a #GPatternSpec.
20980 * Returns: a newly-allocated #GPatternSpec
20985 * g_pointer_bit_lock:
20986 * @address: a pointer to a #gpointer-sized value
20987 * @lock_bit: a bit value between 0 and 31
20989 * This is equivalent to g_bit_lock, but working on pointers (or other
20990 * pointer-sized values).
20992 * For portability reasons, you may only lock on the bottom 32 bits of
21000 * g_pointer_bit_trylock:
21001 * @address: a pointer to a #gpointer-sized value
21002 * @lock_bit: a bit value between 0 and 31
21004 * This is equivalent to g_bit_trylock, but working on pointers (or
21005 * other pointer-sized values).
21007 * For portability reasons, you may only lock on the bottom 32 bits of
21010 * Returns: %TRUE if the lock was acquired
21016 * g_pointer_bit_unlock:
21017 * @address: a pointer to a #gpointer-sized value
21018 * @lock_bit: a bit value between 0 and 31
21020 * This is equivalent to g_bit_unlock, but working on pointers (or other
21021 * pointer-sized values).
21023 * For portability reasons, you may only lock on the bottom 32 bits of
21032 * @fds: file descriptors to poll
21033 * @nfds: the number of file descriptors in @fds
21034 * @timeout: amount of time to wait, in milliseconds, or -1 to wait forever
21036 * Polls @fds, as with the poll() system call, but portably. (On
21037 * systems that don't have poll(), it is emulated using select().)
21038 * This is used internally by #GMainContext, but it can be called
21039 * directly if you need to block until a file descriptor is ready, but
21040 * don't want to run the full main loop.
21042 * Each element of @fds is a #GPollFD describing a single file
21043 * descriptor to poll. The %fd field indicates the file descriptor,
21044 * and the %events field indicates the events to poll for. On return,
21045 * the %revents fields will be filled with the events that actually
21048 * On POSIX systems, the file descriptors in @fds can be any sort of
21049 * file descriptor, but the situation is much more complicated on
21050 * Windows. If you need to use g_poll() in code that has to run on
21051 * Windows, the easiest solution is to construct all of your
21052 * #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
21054 * Returns: the number of entries in @fds whose %revents fields were filled in, or 0 if the operation timed out, or -1 on error or if the call was interrupted.
21061 * @err: (allow-none): a return location for a #GError, or %NULL
21062 * @format: printf()-style format string
21063 * @...: arguments to @format
21065 * Formats a string according to @format and
21066 * prefix it to an existing error message. If
21067 * @err is %NULL (ie: no error variable) then do
21070 * If *@err is %NULL (ie: an error variable is
21071 * present but there is no error condition) then
21072 * also do nothing. Whether or not it makes
21073 * sense to take advantage of this feature is up
21082 * @format: the message format. See the printf() documentation
21083 * @...: the parameters to insert into the format string
21085 * Outputs a formatted message via the print handler.
21086 * The default print handler simply outputs the message to stdout.
21088 * g_print() should not be used from within libraries for debugging
21089 * messages, since it may be redirected by applications to special
21090 * purpose message windows or even files. Instead, libraries should
21091 * use g_log(), or the convenience functions g_message(), g_warning()
21098 * @format: the message format. See the printf() documentation
21099 * @...: the parameters to insert into the format string
21101 * Outputs a formatted message via the error message handler.
21102 * The default handler simply outputs the message to stderr.
21104 * g_printerr() should not be used from within libraries.
21105 * Instead g_log() should be used, or the convenience functions
21106 * g_message(), g_warning() and g_error().
21112 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21113 * @...: the arguments to insert in the output.
21115 * An implementation of the standard printf() function which supports
21116 * positional parameters, as specified in the Single Unix Specification.
21118 * Returns: the number of bytes printed.
21124 * g_printf_string_upper_bound:
21125 * @format: the format string. See the printf() documentation
21126 * @args: the parameters to be inserted into the format string
21128 * Calculates the maximum space needed to store the output
21129 * of the sprintf() function.
21131 * Returns: the maximum space needed to store the formatted string
21137 * @key: a #GPrivate
21139 * Returns the current value of the thread local variable @key.
21141 * If the value has not yet been set in this thread, %NULL is returned.
21142 * Values are never copied between threads (when a new thread is
21143 * created, for example).
21145 * Returns: the thread-local value
21150 * g_private_replace:
21151 * @key: a #GPrivate
21152 * @value: the new value
21154 * Sets the thread local variable @key to have the value @value in the
21157 * This function differs from g_private_set() in the following way: if
21158 * the previous value was non-%NULL then the #GDestroyNotify handler for
21159 * @key is run on it.
21167 * @key: a #GPrivate
21168 * @value: the new value
21170 * Sets the thread local variable @key to have the value @value in the
21173 * This function differs from g_private_replace() in the following way:
21174 * the #GDestroyNotify for @key is not called on the old value.
21179 * g_propagate_error:
21180 * @dest: error return location
21181 * @src: error to move into the return location
21183 * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
21184 * The error variable @dest points to must be %NULL.
21189 * g_propagate_prefixed_error:
21190 * @dest: error return location
21191 * @src: error to move into the return location
21192 * @format: printf()-style format string
21193 * @...: arguments to @format
21195 * If @dest is %NULL, free @src; otherwise,
21196 * moves @src into *@dest. *@dest must be %NULL.
21197 * After the move, add a prefix as with
21198 * g_prefix_error().
21206 * @array: a #GPtrArray.
21207 * @data: the pointer to add.
21209 * Adds a pointer to the end of the pointer array. The array will grow
21210 * in size automatically if necessary.
21215 * g_ptr_array_foreach:
21216 * @array: a #GPtrArray
21217 * @func: the function to call for each array element
21218 * @user_data: user data to pass to the function
21220 * Calls a function for each element of a #GPtrArray.
21227 * g_ptr_array_free:
21228 * @array: a #GPtrArray.
21229 * @free_seg: if %TRUE the actual pointer array is freed as well.
21231 * Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
21232 * it frees the memory block holding the elements as well. Pass %FALSE
21233 * if you want to free the #GPtrArray wrapper but preserve the
21234 * underlying array for use elsewhere. If the reference count of @array
21235 * is greater than one, the #GPtrArray wrapper is preserved but the
21236 * size of @array will be set to zero.
21238 * <note><para>If array contents point to dynamically-allocated
21239 * memory, they should be freed separately if @free_seg is %TRUE and no
21240 * #GDestroyNotify function has been set for @array.</para></note>
21242 * Returns: the pointer array if @free_seg is %FALSE, otherwise %NULL. The pointer array should be freed using g_free().
21247 * g_ptr_array_index:
21248 * @array: a #GPtrArray.
21249 * @index_: the index of the pointer to return.
21251 * Returns the pointer at the given index of the pointer array.
21253 * Returns: the pointer at the given index.
21260 * Creates a new #GPtrArray with a reference count of 1.
21262 * Returns: the new #GPtrArray.
21267 * g_ptr_array_new_full:
21268 * @reserved_size: number of pointers preallocated.
21269 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21271 * Creates a new #GPtrArray with @reserved_size pointers preallocated
21272 * and a reference count of 1. This avoids frequent reallocation, if
21273 * you are going to add many pointers to the array. Note however that
21274 * the size of the array is still 0. It also set @element_free_func
21275 * for freeing each element when the array is destroyed either via
21276 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21277 * set to %TRUE or when removing elements.
21279 * Returns: A new #GPtrArray.
21285 * g_ptr_array_new_with_free_func:
21286 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21288 * Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
21289 * for freeing each element when the array is destroyed either via
21290 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21291 * set to %TRUE or when removing elements.
21293 * Returns: A new #GPtrArray.
21300 * @array: a #GPtrArray
21302 * Atomically increments the reference count of @array by one.
21303 * This function is thread-safe and may be called from any thread.
21305 * Returns: The passed in #GPtrArray
21311 * g_ptr_array_remove:
21312 * @array: a #GPtrArray.
21313 * @data: the pointer to remove.
21315 * Removes the first occurrence of the given pointer from the pointer
21316 * array. The following elements are moved down one place. If @array
21317 * has a non-%NULL #GDestroyNotify function it is called for the
21320 * It returns %TRUE if the pointer was removed, or %FALSE if the
21321 * pointer was not found.
21323 * Returns: %TRUE if the pointer is removed. %FALSE if the pointer is not found in the array.
21328 * g_ptr_array_remove_fast:
21329 * @array: a #GPtrArray.
21330 * @data: the pointer to remove.
21332 * Removes the first occurrence of the given pointer from the pointer
21333 * array. The last element in the array is used to fill in the space,
21334 * so this function does not preserve the order of the array. But it is
21335 * faster than g_ptr_array_remove(). If @array has a non-%NULL
21336 * #GDestroyNotify function it is called for the removed element.
21338 * It returns %TRUE if the pointer was removed, or %FALSE if the
21339 * pointer was not found.
21341 * Returns: %TRUE if the pointer was found in the array.
21346 * g_ptr_array_remove_index:
21347 * @array: a #GPtrArray.
21348 * @index_: the index of the pointer to remove.
21350 * Removes the pointer at the given index from the pointer array. The
21351 * following elements are moved down one place. If @array has a
21352 * non-%NULL #GDestroyNotify function it is called for the removed
21355 * Returns: the pointer which was removed.
21360 * g_ptr_array_remove_index_fast:
21361 * @array: a #GPtrArray.
21362 * @index_: the index of the pointer to remove.
21364 * Removes the pointer at the given index from the pointer array. The
21365 * last element in the array is used to fill in the space, so this
21366 * function does not preserve the order of the array. But it is faster
21367 * than g_ptr_array_remove_index(). If @array has a non-%NULL
21368 * #GDestroyNotify function it is called for the removed element.
21370 * Returns: the pointer which was removed.
21375 * g_ptr_array_remove_range:
21376 * @array: a @GPtrArray.
21377 * @index_: the index of the first pointer to remove.
21378 * @length: the number of pointers to remove.
21380 * Removes the given number of pointers starting at the given index
21381 * from a #GPtrArray. The following elements are moved to close the
21382 * gap. If @array has a non-%NULL #GDestroyNotify function it is called
21383 * for the removed elements.
21390 * g_ptr_array_set_free_func:
21391 * @array: A #GPtrArray.
21392 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21394 * Sets a function for freeing each element when @array is destroyed
21395 * either via g_ptr_array_unref(), when g_ptr_array_free() is called
21396 * with @free_segment set to %TRUE or when removing elements.
21403 * g_ptr_array_set_size:
21404 * @array: a #GPtrArray.
21405 * @length: the new length of the pointer array.
21407 * Sets the size of the array. When making the array larger,
21408 * newly-added elements will be set to %NULL. When making it smaller,
21409 * if @array has a non-%NULL #GDestroyNotify function then it will be
21410 * called for the removed elements.
21415 * g_ptr_array_sized_new:
21416 * @reserved_size: number of pointers preallocated.
21418 * Creates a new #GPtrArray with @reserved_size pointers preallocated
21419 * and a reference count of 1. This avoids frequent reallocation, if
21420 * you are going to add many pointers to the array. Note however that
21421 * the size of the array is still 0.
21423 * Returns: the new #GPtrArray.
21428 * g_ptr_array_sort:
21429 * @array: a #GPtrArray.
21430 * @compare_func: comparison function.
21432 * Sorts the array, using @compare_func which should be a qsort()-style
21433 * comparison function (returns less than zero for first arg is less
21434 * than second arg, zero for equal, greater than zero if irst arg is
21435 * greater than second arg).
21437 * <note><para>The comparison function for g_ptr_array_sort() doesn't
21438 * take the pointers from the array as arguments, it takes pointers to
21439 * the pointers in the array.</para></note>
21441 * This is guaranteed to be a stable sort since version 2.32.
21446 * g_ptr_array_sort_with_data:
21447 * @array: a #GPtrArray.
21448 * @compare_func: comparison function.
21449 * @user_data: data to pass to @compare_func.
21451 * Like g_ptr_array_sort(), but the comparison function has an extra
21452 * user data argument.
21454 * <note><para>The comparison function for g_ptr_array_sort_with_data()
21455 * doesn't take the pointers from the array as arguments, it takes
21456 * pointers to the pointers in the array.</para></note>
21458 * This is guaranteed to be a stable sort since version 2.32.
21463 * g_ptr_array_unref:
21464 * @array: A #GPtrArray.
21466 * Atomically decrements the reference count of @array by one. If the
21467 * reference count drops to 0, the effect is the same as calling
21468 * g_ptr_array_free() with @free_segment set to %TRUE. This function
21469 * is MT-safe and may be called from any thread.
21476 * g_qsort_with_data:
21477 * @pbase: start of array to sort
21478 * @total_elems: elements in the array
21479 * @size: size of each element
21480 * @compare_func: function to compare elements
21481 * @user_data: data to pass to @compare_func
21483 * This is just like the standard C qsort() function, but
21484 * the comparison routine accepts a user data argument.
21486 * This is guaranteed to be a stable sort since version 2.32.
21491 * g_quark_from_static_string:
21492 * @string: (allow-none): a string.
21494 * Gets the #GQuark identifying the given (static) string. If the
21495 * string does not currently have an associated #GQuark, a new #GQuark
21496 * is created, linked to the given string.
21498 * Note that this function is identical to g_quark_from_string() except
21499 * that if a new #GQuark is created the string itself is used rather
21500 * than a copy. This saves memory, but can only be used if the string
21501 * will <emphasis>always</emphasis> exist. It can be used with
21502 * statically allocated strings in the main program, but not with
21503 * statically allocated memory in dynamically loaded modules, if you
21504 * expect to ever unload the module again (e.g. do not use this
21505 * function in GTK+ theme engines).
21507 * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21512 * g_quark_from_string:
21513 * @string: (allow-none): a string.
21515 * Gets the #GQuark identifying the given string. If the string does
21516 * not currently have an associated #GQuark, a new #GQuark is created,
21517 * using a copy of the string.
21519 * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21524 * g_quark_to_string:
21525 * @quark: a #GQuark.
21527 * Gets the string associated with the given #GQuark.
21529 * Returns: the string associated with the #GQuark
21534 * g_quark_try_string:
21535 * @string: (allow-none): a string.
21537 * Gets the #GQuark associated with the given string, or 0 if string is
21538 * %NULL or it has no associated #GQuark.
21540 * If you want the GQuark to be created if it doesn't already exist,
21541 * use g_quark_from_string() or g_quark_from_static_string().
21543 * Returns: the #GQuark associated with the string, or 0 if @string is %NULL or there is no #GQuark associated with it.
21549 * @queue: a #GQueue
21551 * Removes all the elements in @queue. If queue elements contain
21552 * dynamically-allocated memory, they should be freed first.
21560 * @queue: a #GQueue
21562 * Copies a @queue. Note that is a shallow copy. If the elements in the
21563 * queue consist of pointers to data, the pointers are copied, but the
21564 * actual data is not.
21566 * Returns: A copy of @queue
21572 * g_queue_delete_link:
21573 * @queue: a #GQueue
21574 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
21576 * Removes @link_ from @queue and frees it.
21578 * @link_ must be part of @queue.
21586 * @queue: a #GQueue
21587 * @data: data to find
21589 * Finds the first link in @queue which contains @data.
21591 * Returns: The first link in @queue which contains @data.
21597 * g_queue_find_custom:
21598 * @queue: a #GQueue
21599 * @data: user data passed to @func
21600 * @func: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
21602 * Finds an element in a #GQueue, using a supplied function to find the
21603 * desired element. It iterates over the queue, calling the given function
21604 * which should return 0 when the desired element is found. The function
21605 * takes two gconstpointer arguments, the #GQueue element's data as the
21606 * first argument and the given user data as the second argument.
21608 * Returns: The found link, or %NULL if it wasn't found
21615 * @queue: a #GQueue
21616 * @func: the function to call for each element's data
21617 * @user_data: user data to pass to @func
21619 * Calls @func for each element in the queue passing @user_data to the
21628 * @queue: a #GQueue.
21630 * Frees the memory allocated for the #GQueue. Only call this function if
21631 * @queue was created with g_queue_new(). If queue elements contain
21632 * dynamically-allocated memory, they should be freed first.
21635 * If queue elements contain dynamically-allocated memory,
21636 * you should either use g_queue_free_full() or free them manually
21643 * g_queue_free_full:
21644 * @queue: a pointer to a #GQueue
21645 * @free_func: the function to be called to free each element's data
21647 * Convenience method, which frees all the memory used by a #GQueue, and
21648 * calls the specified destroy function on every element's data.
21655 * g_queue_get_length:
21656 * @queue: a #GQueue
21658 * Returns the number of items in @queue.
21660 * Returns: The number of items in @queue.
21667 * @queue: a #GQueue
21668 * @data: the data to find.
21670 * Returns the position of the first element in @queue which contains @data.
21672 * Returns: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
21679 * @queue: an uninitialized #GQueue
21681 * A statically-allocated #GQueue must be initialized with this function
21682 * before it can be used. Alternatively you can initialize it with
21683 * #G_QUEUE_INIT. It is not necessary to initialize queues created with
21691 * g_queue_insert_after:
21692 * @queue: a #GQueue
21693 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21694 * @data: the data to insert
21696 * Inserts @data into @queue after @sibling
21698 * @sibling must be part of @queue
21705 * g_queue_insert_before:
21706 * @queue: a #GQueue
21707 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21708 * @data: the data to insert
21710 * Inserts @data into @queue before @sibling.
21712 * @sibling must be part of @queue.
21719 * g_queue_insert_sorted:
21720 * @queue: a #GQueue
21721 * @data: the data to insert
21722 * @func: the #GCompareDataFunc used to compare elements in the queue. It is called with two elements of the @queue and @user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.
21723 * @user_data: user data passed to @func.
21725 * Inserts @data into @queue using @func to determine the new position.
21732 * g_queue_is_empty:
21733 * @queue: a #GQueue.
21735 * Returns %TRUE if the queue is empty.
21737 * Returns: %TRUE if the queue is empty.
21742 * g_queue_link_index:
21743 * @queue: a #GQueue
21744 * @link_: A #GList link
21746 * Returns the position of @link_ in @queue.
21748 * Returns: The position of @link_, or -1 if the link is not part of @queue
21756 * Creates a new #GQueue.
21758 * Returns: a new #GQueue.
21763 * g_queue_peek_head:
21764 * @queue: a #GQueue.
21766 * Returns the first element of the queue.
21768 * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
21773 * g_queue_peek_head_link:
21774 * @queue: a #GQueue
21776 * Returns the first link in @queue
21778 * Returns: the first link in @queue, or %NULL if @queue is empty
21784 * g_queue_peek_nth:
21785 * @queue: a #GQueue
21786 * @n: the position of the element.
21788 * Returns the @n'th element of @queue.
21790 * Returns: The data for the @n'th element of @queue, or %NULL if @n is off the end of @queue.
21796 * g_queue_peek_nth_link:
21797 * @queue: a #GQueue
21798 * @n: the position of the link
21800 * Returns the link at the given position
21802 * Returns: The link at the @n'th position, or %NULL if @n is off the end of the list
21808 * g_queue_peek_tail:
21809 * @queue: a #GQueue.
21811 * Returns the last element of the queue.
21813 * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
21818 * g_queue_peek_tail_link:
21819 * @queue: a #GQueue
21821 * Returns the last link @queue.
21823 * Returns: the last link in @queue, or %NULL if @queue is empty
21829 * g_queue_pop_head:
21830 * @queue: a #GQueue.
21832 * Removes the first element of the queue.
21834 * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
21839 * g_queue_pop_head_link:
21840 * @queue: a #GQueue.
21842 * Removes the first element of the queue.
21844 * Returns: the #GList element at the head of the queue, or %NULL if the queue is empty.
21850 * @queue: a #GQueue
21851 * @n: the position of the element.
21853 * Removes the @n'th element of @queue.
21855 * Returns: the element's data, or %NULL if @n is off the end of @queue.
21861 * g_queue_pop_nth_link:
21862 * @queue: a #GQueue
21863 * @n: the link's position
21865 * Removes and returns the link at the given position.
21867 * Returns: The @n'th link, or %NULL if @n is off the end of @queue.
21873 * g_queue_pop_tail:
21874 * @queue: a #GQueue.
21876 * Removes the last element of the queue.
21878 * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
21883 * g_queue_pop_tail_link:
21884 * @queue: a #GQueue.
21886 * Removes the last element of the queue.
21888 * Returns: the #GList element at the tail of the queue, or %NULL if the queue is empty.
21893 * g_queue_push_head:
21894 * @queue: a #GQueue.
21895 * @data: the data for the new element.
21897 * Adds a new element at the head of the queue.
21902 * g_queue_push_head_link:
21903 * @queue: a #GQueue.
21904 * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
21906 * Adds a new element at the head of the queue.
21911 * g_queue_push_nth:
21912 * @queue: a #GQueue
21913 * @data: the data for the new element
21914 * @n: the position to insert the new element. If @n is negative or larger than the number of elements in the @queue, the element is added to the end of the queue.
21916 * Inserts a new element into @queue at the given position
21923 * g_queue_push_nth_link:
21924 * @queue: a #GQueue
21925 * @n: the position to insert the link. If this is negative or larger than the number of elements in @queue, the link is added to the end of @queue.
21926 * @link_: the link to add to @queue
21928 * Inserts @link into @queue at the given position.
21935 * g_queue_push_tail:
21936 * @queue: a #GQueue.
21937 * @data: the data for the new element.
21939 * Adds a new element at the tail of the queue.
21944 * g_queue_push_tail_link:
21945 * @queue: a #GQueue.
21946 * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
21948 * Adds a new element at the tail of the queue.
21954 * @queue: a #GQueue
21955 * @data: data to remove.
21957 * Removes the first element in @queue that contains @data.
21959 * Returns: %TRUE if @data was found and removed from @queue
21965 * g_queue_remove_all:
21966 * @queue: a #GQueue
21967 * @data: data to remove
21969 * Remove all elements whose data equals @data from @queue.
21971 * Returns: the number of elements removed from @queue
21978 * @queue: a #GQueue
21980 * Reverses the order of the items in @queue.
21988 * @queue: a #GQueue
21989 * @compare_func: the #GCompareDataFunc used to sort @queue. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.
21990 * @user_data: user data passed to @compare_func
21992 * Sorts @queue using @compare_func.
22000 * @queue: a #GQueue
22001 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
22003 * Unlinks @link_ so that it will no longer be part of @queue. The link is
22006 * @link_ must be part of @queue,
22014 * @rand_: a #GRand.
22016 * Returns a random #gboolean from @rand_. This corresponds to a
22017 * unbiased coin toss.
22019 * Returns: a random #gboolean.
22025 * @rand_: a #GRand.
22027 * Copies a #GRand into a new one with the same exact state as before.
22028 * This way you can take a snapshot of the random number generator for
22031 * Returns: the new #GRand.
22038 * @rand_: a #GRand.
22040 * Returns the next random #gdouble from @rand_ equally distributed over
22041 * the range [0..1).
22043 * Returns: A random number.
22048 * g_rand_double_range:
22049 * @rand_: a #GRand.
22050 * @begin: lower closed bound of the interval.
22051 * @end: upper open bound of the interval.
22053 * Returns the next random #gdouble from @rand_ equally distributed over
22054 * the range [@begin..@end).
22056 * Returns: A random number.
22062 * @rand_: a #GRand.
22064 * Frees the memory allocated for the #GRand.
22070 * @rand_: a #GRand.
22072 * Returns the next random #guint32 from @rand_ equally distributed over
22073 * the range [0..2^32-1].
22075 * Returns: A random number.
22080 * g_rand_int_range:
22081 * @rand_: a #GRand.
22082 * @begin: lower closed bound of the interval.
22083 * @end: upper open bound of the interval.
22085 * Returns the next random #gint32 from @rand_ equally distributed over
22086 * the range [@begin..@end-1].
22088 * Returns: A random number.
22095 * Creates a new random number generator initialized with a seed taken
22096 * either from <filename>/dev/urandom</filename> (if existing) or from
22097 * the current time (as a fallback).
22099 * Returns: the new #GRand.
22104 * g_rand_new_with_seed:
22105 * @seed: a value to initialize the random number generator.
22107 * Creates a new random number generator initialized with @seed.
22109 * Returns: the new #GRand.
22114 * g_rand_new_with_seed_array:
22115 * @seed: an array of seeds to initialize the random number generator.
22116 * @seed_length: an array of seeds to initialize the random number generator.
22118 * Creates a new random number generator initialized with @seed.
22120 * Returns: the new #GRand.
22127 * @rand_: a #GRand.
22128 * @seed: a value to reinitialize the random number generator.
22130 * Sets the seed for the random number generator #GRand to @seed.
22135 * g_rand_set_seed_array:
22136 * @rand_: a #GRand.
22137 * @seed: array to initialize with
22138 * @seed_length: length of array
22140 * Initializes the random number generator by an array of
22141 * longs. Array can be of arbitrary size, though only the
22142 * first 624 values are taken. This function is useful
22143 * if you have many low entropy seeds, or if you require more then
22144 * 32bits of actual entropy for your application.
22151 * g_random_boolean:
22153 * Returns a random #gboolean. This corresponds to a unbiased coin toss.
22155 * Returns: a random #gboolean.
22162 * Returns a random #gdouble equally distributed over the range [0..1).
22164 * Returns: A random number.
22169 * g_random_double_range:
22170 * @begin: lower closed bound of the interval.
22171 * @end: upper open bound of the interval.
22173 * Returns a random #gdouble equally distributed over the range [@begin..@end).
22175 * Returns: A random number.
22182 * Return a random #guint32 equally distributed over the range
22185 * Returns: A random number.
22190 * g_random_int_range:
22191 * @begin: lower closed bound of the interval.
22192 * @end: upper open bound of the interval.
22194 * Returns a random #gint32 equally distributed over the range
22195 * [@begin..@end-1].
22197 * Returns: A random number.
22202 * g_random_set_seed:
22203 * @seed: a value to reinitialize the global random number generator.
22205 * Sets the seed for the global random number generator, which is used
22206 * by the <function>g_random_*</function> functions, to @seed.
22212 * @mem: the memory to reallocate
22213 * @n_bytes: new size of the memory in bytes
22215 * Reallocates the memory pointed to by @mem, so that it now has space for
22216 * @n_bytes bytes of memory. It returns the new address of the memory, which may
22217 * have been moved. @mem may be %NULL, in which case it's considered to
22218 * have zero-length. @n_bytes may be 0, in which case %NULL will be returned
22219 * and @mem will be freed unless it is %NULL.
22221 * Returns: the new address of the allocated memory
22227 * @mem: the memory to reallocate
22228 * @n_blocks: the number of blocks to allocate
22229 * @n_block_bytes: the size of each block in bytes
22231 * This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22232 * but care is taken to detect possible overflow during multiplication.
22235 * Returns: the new address of the allocated memory
22240 * g_rec_mutex_clear:
22241 * @rec_mutex: an initialized #GRecMutex
22243 * Frees the resources allocated to a recursive mutex with
22244 * g_rec_mutex_init().
22246 * This function should not be used with a #GRecMutex that has been
22247 * statically allocated.
22249 * Calling g_rec_mutex_clear() on a locked recursive mutex leads
22250 * to undefined behaviour.
22257 * g_rec_mutex_init:
22258 * @rec_mutex: an uninitialized #GRecMutex
22260 * Initializes a #GRecMutex so that it can be used.
22262 * This function is useful to initialize a recursive mutex
22263 * that has been allocated on the stack, or as part of a larger
22266 * It is not necessary to initialise a recursive mutex that has been
22267 * statically allocated.
22277 * b = g_new (Blob, 1);
22278 * g_rec_mutex_init (&b->m);
22281 * Calling g_rec_mutex_init() on an already initialized #GRecMutex
22282 * leads to undefined behaviour.
22284 * To undo the effect of g_rec_mutex_init() when a recursive mutex
22285 * is no longer needed, use g_rec_mutex_clear().
22292 * g_rec_mutex_lock:
22293 * @rec_mutex: a #GRecMutex
22295 * Locks @rec_mutex. If @rec_mutex is already locked by another
22296 * thread, the current thread will block until @rec_mutex is
22297 * unlocked by the other thread. If @rec_mutex is already locked
22298 * by the current thread, the 'lock count' of @rec_mutex is increased.
22299 * The mutex will only become available again when it is unlocked
22300 * as many times as it has been locked.
22307 * g_rec_mutex_trylock:
22308 * @rec_mutex: a #GRecMutex
22310 * Tries to lock @rec_mutex. If @rec_mutex is already locked
22311 * by another thread, it immediately returns %FALSE. Otherwise
22312 * it locks @rec_mutex and returns %TRUE.
22314 * Returns: %TRUE if @rec_mutex could be locked
22320 * g_rec_mutex_unlock:
22321 * @rec_mutex: a #GRecMutex
22323 * Unlocks @rec_mutex. If another thread is blocked in a
22324 * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
22325 * and can lock @rec_mutex itself.
22327 * Calling g_rec_mutex_unlock() on a recursive mutex that is not
22328 * locked by the current thread leads to undefined behaviour.
22335 * g_regex_check_replacement:
22336 * @replacement: the replacement string
22337 * @has_references: (out) (allow-none): location to store information about references in @replacement or %NULL
22338 * @error: location to store error
22340 * Checks whether @replacement is a valid replacement string
22341 * (see g_regex_replace()), i.e. that all escape sequences in
22344 * If @has_references is not %NULL then @replacement is checked
22345 * for pattern references. For instance, replacement text 'foo\n'
22346 * does not contain references and may be evaluated without information
22347 * about actual match, but '\0\1' (whole match followed by first
22348 * subpattern) requires valid #GMatchInfo object.
22350 * Returns: whether @replacement is a valid replacement string
22356 * g_regex_escape_nul:
22357 * @string: the string to escape
22358 * @length: the length of @string
22360 * Escapes the nul characters in @string to "\x00". It can be used
22361 * to compile a regex with embedded nul characters.
22363 * For completeness, @length can be -1 for a nul-terminated string.
22364 * In this case the output string will be of course equal to @string.
22366 * Returns: a newly-allocated escaped string
22372 * g_regex_escape_string:
22373 * @string: (array length=length): the string to escape
22374 * @length: the length of @string, or -1 if @string is nul-terminated
22376 * Escapes the special characters used for regular expressions
22377 * in @string, for instance "a.b*c" becomes "a\.b\*c". This
22378 * function is useful to dynamically generate regular expressions.
22380 * @string can contain nul characters that are replaced with "\0",
22381 * in this case remember to specify the correct length of @string
22384 * Returns: a newly-allocated escaped string
22390 * g_regex_get_capture_count:
22391 * @regex: a #GRegex
22393 * Returns the number of capturing subpatterns in the pattern.
22395 * Returns: the number of capturing subpatterns
22401 * g_regex_get_compile_flags:
22402 * @regex: a #GRegex
22404 * Returns the compile options that @regex was created with.
22406 * Returns: flags from #GRegexCompileFlags
22412 * g_regex_get_has_cr_or_lf:
22413 * @regex: a #GRegex structure
22415 * Checks whether the pattern contains explicit CR or LF references.
22417 * Returns: %TRUE if the pattern contains explicit CR or LF references
22423 * g_regex_get_match_flags:
22424 * @regex: a #GRegex
22426 * Returns the match options that @regex was created with.
22428 * Returns: flags from #GRegexMatchFlags
22434 * g_regex_get_max_backref:
22435 * @regex: a #GRegex
22437 * Returns the number of the highest back reference
22438 * in the pattern, or 0 if the pattern does not contain
22441 * Returns: the number of the highest back reference
22447 * g_regex_get_pattern:
22448 * @regex: a #GRegex structure
22450 * Gets the pattern string associated with @regex, i.e. a copy of
22451 * the string passed to g_regex_new().
22453 * Returns: the pattern of @regex
22459 * g_regex_get_string_number:
22460 * @regex: #GRegex structure
22461 * @name: name of the subexpression
22463 * Retrieves the number of the subexpression named @name.
22465 * Returns: The number of the subexpression or -1 if @name does not exists
22472 * @regex: a #GRegex structure from g_regex_new()
22473 * @string: the string to scan for matches
22474 * @match_options: match options
22475 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22477 * Scans for a match in string for the pattern in @regex.
22478 * The @match_options are combined with the match options specified
22479 * when the @regex structure was created, letting you have more
22480 * flexibility in reusing #GRegex structures.
22482 * A #GMatchInfo structure, used to get information on the match,
22483 * is stored in @match_info if not %NULL. Note that if @match_info
22484 * is not %NULL then it is created even if the function returns %FALSE,
22485 * i.e. you must free it regardless if regular expression actually matched.
22487 * To retrieve all the non-overlapping matches of the pattern in
22488 * string you can use g_match_info_next().
22492 * print_uppercase_words (const gchar *string)
22494 * /* Print all uppercase-only words. */
22496 * GMatchInfo *match_info;
22498 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22499 * g_regex_match (regex, string, 0, &match_info);
22500 * while (g_match_info_matches (match_info))
22502 * gchar *word = g_match_info_fetch (match_info, 0);
22503 * g_print ("Found: %s\n", word);
22505 * g_match_info_next (match_info, NULL);
22507 * g_match_info_free (match_info);
22508 * g_regex_unref (regex);
22512 * @string is not copied and is used in #GMatchInfo internally. If
22513 * you use any #GMatchInfo method (except g_match_info_free()) after
22514 * freeing or modifying @string then the behaviour is undefined.
22516 * Returns: %TRUE is the string matched, %FALSE otherwise
22522 * g_regex_match_all:
22523 * @regex: a #GRegex structure from g_regex_new()
22524 * @string: the string to scan for matches
22525 * @match_options: match options
22526 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22528 * Using the standard algorithm for regular expression matching only
22529 * the longest match in the string is retrieved. This function uses
22530 * a different algorithm so it can retrieve all the possible matches.
22531 * For more documentation see g_regex_match_all_full().
22533 * A #GMatchInfo structure, used to get information on the match, is
22534 * stored in @match_info if not %NULL. Note that if @match_info is
22535 * not %NULL then it is created even if the function returns %FALSE,
22536 * i.e. you must free it regardless if regular expression actually
22539 * @string is not copied and is used in #GMatchInfo internally. If
22540 * you use any #GMatchInfo method (except g_match_info_free()) after
22541 * freeing or modifying @string then the behaviour is undefined.
22543 * Returns: %TRUE is the string matched, %FALSE otherwise
22549 * g_regex_match_all_full:
22550 * @regex: a #GRegex structure from g_regex_new()
22551 * @string: (array length=string_len): the string to scan for matches
22552 * @string_len: the length of @string, or -1 if @string is nul-terminated
22553 * @start_position: starting index of the string to match
22554 * @match_options: match options
22555 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22556 * @error: location to store the error occurring, or %NULL to ignore errors
22558 * Using the standard algorithm for regular expression matching only
22559 * the longest match in the string is retrieved, it is not possible
22560 * to obtain all the available matches. For instance matching
22561 * "<a> <b> <c>" against the pattern "<.*>"
22562 * you get "<a> <b> <c>".
22564 * This function uses a different algorithm (called DFA, i.e. deterministic
22565 * finite automaton), so it can retrieve all the possible matches, all
22566 * starting at the same point in the string. For instance matching
22567 * "<a> <b> <c>" against the pattern "<.*>"
22568 * you would obtain three matches: "<a> <b> <c>",
22569 * "<a> <b>" and "<a>".
22571 * The number of matched strings is retrieved using
22572 * g_match_info_get_match_count(). To obtain the matched strings and
22573 * their position you can use, respectively, g_match_info_fetch() and
22574 * g_match_info_fetch_pos(). Note that the strings are returned in
22575 * reverse order of length; that is, the longest matching string is
22578 * Note that the DFA algorithm is slower than the standard one and it
22579 * is not able to capture substrings, so backreferences do not work.
22581 * Setting @start_position differs from just passing over a shortened
22582 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22583 * that begins with any kind of lookbehind assertion, such as "\b".
22585 * A #GMatchInfo structure, used to get information on the match, is
22586 * stored in @match_info if not %NULL. Note that if @match_info is
22587 * not %NULL then it is created even if the function returns %FALSE,
22588 * i.e. you must free it regardless if regular expression actually
22591 * @string is not copied and is used in #GMatchInfo internally. If
22592 * you use any #GMatchInfo method (except g_match_info_free()) after
22593 * freeing or modifying @string then the behaviour is undefined.
22595 * Returns: %TRUE is the string matched, %FALSE otherwise
22601 * g_regex_match_full:
22602 * @regex: a #GRegex structure from g_regex_new()
22603 * @string: (array length=string_len): the string to scan for matches
22604 * @string_len: the length of @string, or -1 if @string is nul-terminated
22605 * @start_position: starting index of the string to match
22606 * @match_options: match options
22607 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22608 * @error: location to store the error occurring, or %NULL to ignore errors
22610 * Scans for a match in string for the pattern in @regex.
22611 * The @match_options are combined with the match options specified
22612 * when the @regex structure was created, letting you have more
22613 * flexibility in reusing #GRegex structures.
22615 * Setting @start_position differs from just passing over a shortened
22616 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22617 * that begins with any kind of lookbehind assertion, such as "\b".
22619 * A #GMatchInfo structure, used to get information on the match, is
22620 * stored in @match_info if not %NULL. Note that if @match_info is
22621 * not %NULL then it is created even if the function returns %FALSE,
22622 * i.e. you must free it regardless if regular expression actually
22625 * @string is not copied and is used in #GMatchInfo internally. If
22626 * you use any #GMatchInfo method (except g_match_info_free()) after
22627 * freeing or modifying @string then the behaviour is undefined.
22629 * To retrieve all the non-overlapping matches of the pattern in
22630 * string you can use g_match_info_next().
22634 * print_uppercase_words (const gchar *string)
22636 * /* Print all uppercase-only words. */
22638 * GMatchInfo *match_info;
22639 * GError *error = NULL;
22641 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22642 * g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
22643 * while (g_match_info_matches (match_info))
22645 * gchar *word = g_match_info_fetch (match_info, 0);
22646 * g_print ("Found: %s\n", word);
22648 * g_match_info_next (match_info, &error);
22650 * g_match_info_free (match_info);
22651 * g_regex_unref (regex);
22652 * if (error != NULL)
22654 * g_printerr ("Error while matching: %s\n", error->message);
22655 * g_error_free (error);
22660 * Returns: %TRUE is the string matched, %FALSE otherwise
22666 * g_regex_match_simple:
22667 * @pattern: the regular expression
22668 * @string: the string to scan for matches
22669 * @compile_options: compile options for the regular expression, or 0
22670 * @match_options: match options, or 0
22672 * Scans for a match in @string for @pattern.
22674 * This function is equivalent to g_regex_match() but it does not
22675 * require to compile the pattern with g_regex_new(), avoiding some
22676 * lines of code when you need just to do a match without extracting
22677 * substrings, capture counts, and so on.
22679 * If this function is to be called on the same @pattern more than
22680 * once, it's more efficient to compile the pattern once with
22681 * g_regex_new() and then use g_regex_match().
22683 * Returns: %TRUE if the string matched, %FALSE otherwise
22690 * @pattern: the regular expression
22691 * @compile_options: compile options for the regular expression, or 0
22692 * @match_options: match options for the regular expression, or 0
22693 * @error: return location for a #GError
22695 * Compiles the regular expression to an internal form, and does
22696 * the initial setup of the #GRegex structure.
22698 * Returns: a #GRegex structure. Call g_regex_unref() when you are done with it
22705 * @regex: a #GRegex
22707 * Increases reference count of @regex by 1.
22716 * @regex: a #GRegex structure
22717 * @string: (array length=string_len): the string to perform matches against
22718 * @string_len: the length of @string, or -1 if @string is nul-terminated
22719 * @start_position: starting index of the string to match
22720 * @replacement: text to replace each match with
22721 * @match_options: options for the match
22722 * @error: location to store the error occurring, or %NULL to ignore errors
22724 * Replaces all occurrences of the pattern in @regex with the
22725 * replacement text. Backreferences of the form '\number' or
22726 * '\g<number>' in the replacement text are interpolated by the
22727 * number-th captured subexpression of the match, '\g<name>' refers
22728 * to the captured subexpression with the given name. '\0' refers to the
22729 * complete match, but '\0' followed by a number is the octal representation
22730 * of a character. To include a literal '\' in the replacement, write '\\'.
22731 * There are also escapes that changes the case of the following text:
22734 * <varlistentry><term>\l</term>
22736 * <para>Convert to lower case the next character</para>
22739 * <varlistentry><term>\u</term>
22741 * <para>Convert to upper case the next character</para>
22744 * <varlistentry><term>\L</term>
22746 * <para>Convert to lower case till \E</para>
22749 * <varlistentry><term>\U</term>
22751 * <para>Convert to upper case till \E</para>
22754 * <varlistentry><term>\E</term>
22756 * <para>End case modification</para>
22761 * If you do not need to use backreferences use g_regex_replace_literal().
22763 * The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
22764 * passed to g_regex_new(). If you want to use not UTF-8 encoded stings
22765 * you can use g_regex_replace_literal().
22767 * Setting @start_position differs from just passing over a shortened
22768 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
22769 * begins with any kind of lookbehind assertion, such as "\b".
22771 * Returns: a newly allocated string containing the replacements
22777 * g_regex_replace_eval:
22778 * @regex: a #GRegex structure from g_regex_new()
22779 * @string: (array length=string_len): string to perform matches against
22780 * @string_len: the length of @string, or -1 if @string is nul-terminated
22781 * @start_position: starting index of the string to match
22782 * @match_options: options for the match
22783 * @eval: a function to call for each match
22784 * @user_data: user data to pass to the function
22785 * @error: location to store the error occurring, or %NULL to ignore errors
22787 * Replaces occurrences of the pattern in regex with the output of
22788 * @eval for that occurrence.
22790 * Setting @start_position differs from just passing over a shortened
22791 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22792 * that begins with any kind of lookbehind assertion, such as "\b".
22794 * The following example uses g_regex_replace_eval() to replace multiple
22798 * eval_cb (const GMatchInfo *info,
22805 * match = g_match_info_fetch (info, 0);
22806 * r = g_hash_table_lookup ((GHashTable *)data, match);
22807 * g_string_append (res, r);
22813 * /* ... */
22819 * h = g_hash_table_new (g_str_hash, g_str_equal);
22821 * g_hash_table_insert (h, "1", "ONE");
22822 * g_hash_table_insert (h, "2", "TWO");
22823 * g_hash_table_insert (h, "3", "THREE");
22824 * g_hash_table_insert (h, "4", "FOUR");
22826 * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
22827 * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
22828 * g_hash_table_destroy (h);
22830 * /* ... */
22833 * Returns: a newly allocated string containing the replacements
22839 * g_regex_replace_literal:
22840 * @regex: a #GRegex structure
22841 * @string: (array length=string_len): the string to perform matches against
22842 * @string_len: the length of @string, or -1 if @string is nul-terminated
22843 * @start_position: starting index of the string to match
22844 * @replacement: text to replace each match with
22845 * @match_options: options for the match
22846 * @error: location to store the error occurring, or %NULL to ignore errors
22848 * Replaces all occurrences of the pattern in @regex with the
22849 * replacement text. @replacement is replaced literally, to
22850 * include backreferences use g_regex_replace().
22852 * Setting @start_position differs from just passing over a
22853 * shortened string and setting #G_REGEX_MATCH_NOTBOL in the
22854 * case of a pattern that begins with any kind of lookbehind
22855 * assertion, such as "\b".
22857 * Returns: a newly allocated string containing the replacements
22864 * @regex: a #GRegex structure
22865 * @string: the string to split with the pattern
22866 * @match_options: match time option flags
22868 * Breaks the string on the pattern, and returns an array of the tokens.
22869 * If the pattern contains capturing parentheses, then the text for each
22870 * of the substrings will also be returned. If the pattern does not match
22871 * anywhere in the string, then the whole string is returned as the first
22874 * As a special case, the result of splitting the empty string "" is an
22875 * empty vector, not a vector containing a single string. The reason for
22876 * this special case is that being able to represent a empty vector is
22877 * typically more useful than consistent handling of empty elements. If
22878 * you do need to represent empty elements, you'll need to check for the
22879 * empty string before calling this function.
22881 * A pattern that can match empty strings splits @string into separate
22882 * characters wherever it matches the empty string between characters.
22883 * For example splitting "ab c" using as a separator "\s*", you will get
22884 * "a", "b" and "c".
22886 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
22892 * g_regex_split_full:
22893 * @regex: a #GRegex structure
22894 * @string: (array length=string_len): the string to split with the pattern
22895 * @string_len: the length of @string, or -1 if @string is nul-terminated
22896 * @start_position: starting index of the string to match
22897 * @match_options: match time option flags
22898 * @max_tokens: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
22899 * @error: return location for a #GError
22901 * Breaks the string on the pattern, and returns an array of the tokens.
22902 * If the pattern contains capturing parentheses, then the text for each
22903 * of the substrings will also be returned. If the pattern does not match
22904 * anywhere in the string, then the whole string is returned as the first
22907 * As a special case, the result of splitting the empty string "" is an
22908 * empty vector, not a vector containing a single string. The reason for
22909 * this special case is that being able to represent a empty vector is
22910 * typically more useful than consistent handling of empty elements. If
22911 * you do need to represent empty elements, you'll need to check for the
22912 * empty string before calling this function.
22914 * A pattern that can match empty strings splits @string into separate
22915 * characters wherever it matches the empty string between characters.
22916 * For example splitting "ab c" using as a separator "\s*", you will get
22917 * "a", "b" and "c".
22919 * Setting @start_position differs from just passing over a shortened
22920 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22921 * that begins with any kind of lookbehind assertion, such as "\b".
22923 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
22929 * g_regex_split_simple:
22930 * @pattern: the regular expression
22931 * @string: the string to scan for matches
22932 * @compile_options: compile options for the regular expression, or 0
22933 * @match_options: match options, or 0
22935 * Breaks the string on the pattern, and returns an array of
22936 * the tokens. If the pattern contains capturing parentheses,
22937 * then the text for each of the substrings will also be returned.
22938 * If the pattern does not match anywhere in the string, then the
22939 * whole string is returned as the first token.
22941 * This function is equivalent to g_regex_split() but it does
22942 * not require to compile the pattern with g_regex_new(), avoiding
22943 * some lines of code when you need just to do a split without
22944 * extracting substrings, capture counts, and so on.
22946 * If this function is to be called on the same @pattern more than
22947 * once, it's more efficient to compile the pattern once with
22948 * g_regex_new() and then use g_regex_split().
22950 * As a special case, the result of splitting the empty string ""
22951 * is an empty vector, not a vector containing a single string.
22952 * The reason for this special case is that being able to represent
22953 * a empty vector is typically more useful than consistent handling
22954 * of empty elements. If you do need to represent empty elements,
22955 * you'll need to check for the empty string before calling this
22958 * A pattern that can match empty strings splits @string into
22959 * separate characters wherever it matches the empty string between
22960 * characters. For example splitting "ab c" using as a separator
22961 * "\s*", you will get "a", "b" and "c".
22963 * Returns: (transfer full): a %NULL-terminated array of strings. Free it using g_strfreev()
22970 * @regex: a #GRegex
22972 * Decreases reference count of @regex by 1. When reference count drops
22973 * to zero, it frees all the memory associated with the regex structure.
22980 * g_reload_user_special_dirs_cache:
22982 * Resets the cache used for g_get_user_special_dir(), so
22983 * that the latest on-disk version is used. Call this only
22984 * if you just changed the data on disk yourself.
22986 * Due to threadsafety issues this may cause leaking of strings
22987 * that were previously returned from g_get_user_special_dir()
22988 * that can't be freed. We ensure to only leak the data for
22989 * the directories that actually changed value though.
22997 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
22999 * A wrapper for the POSIX remove() function. The remove() function
23000 * deletes a name from the filesystem.
23002 * See your C library manual for more details about how remove() works
23003 * on your system. On Unix, remove() removes also directories, as it
23004 * calls unlink() for files and rmdir() for directories. On Windows,
23005 * although remove() in the C library only works for files, this
23006 * function tries first remove() and then if that fails rmdir(), and
23007 * thus works for both files and directories. Note however, that on
23008 * Windows, it is in general not possible to remove a file that is
23009 * open to some process, or mapped into memory.
23011 * If this function fails on Windows you can't infer too much from the
23012 * errno value. rmdir() is tried regardless of what caused remove() to
23013 * fail. Any errno value set by remove() will be overwritten by that
23016 * Returns: 0 if the file was successfully removed, -1 if an error occurred
23023 * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23024 * @newfilename: a pathname in the GLib file name encoding
23026 * A wrapper for the POSIX rename() function. The rename() function
23027 * renames a file, moving it between directories if required.
23029 * See your C library manual for more details about how rename() works
23030 * on your system. It is not possible in general on Windows to rename
23031 * a file that is open to some process.
23033 * Returns: 0 if the renaming succeeded, -1 if an error occurred
23040 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23042 * A wrapper for the POSIX rmdir() function. The rmdir() function
23043 * deletes a directory from the filesystem.
23045 * See your C library manual for more details about how rmdir() works
23048 * Returns: 0 if the directory was successfully removed, -1 if an error occurred
23055 * @rw_lock: an initialized #GRWLock
23057 * Frees the resources allocated to a lock with g_rw_lock_init().
23059 * This function should not be used with a #GRWLock that has been
23060 * statically allocated.
23062 * Calling g_rw_lock_clear() when any thread holds the lock
23063 * leads to undefined behaviour.
23071 * @rw_lock: an uninitialized #GRWLock
23073 * Initializes a #GRWLock so that it can be used.
23075 * This function is useful to initialize a lock that has been
23076 * allocated on the stack, or as part of a larger structure. It is not
23077 * necessary to initialise a reader-writer lock that has been statically
23088 * b = g_new (Blob, 1);
23089 * g_rw_lock_init (&b->l);
23092 * To undo the effect of g_rw_lock_init() when a lock is no longer
23093 * needed, use g_rw_lock_clear().
23095 * Calling g_rw_lock_init() on an already initialized #GRWLock leads
23096 * to undefined behaviour.
23103 * g_rw_lock_reader_lock:
23104 * @rw_lock: a #GRWLock
23106 * Obtain a read lock on @rw_lock. If another thread currently holds
23107 * the write lock on @rw_lock or blocks waiting for it, the current
23108 * thread will block. Read locks can be taken recursively.
23110 * It is implementation-defined how many threads are allowed to
23111 * hold read locks on the same lock simultaneously.
23118 * g_rw_lock_reader_trylock:
23119 * @rw_lock: a #GRWLock
23121 * Tries to obtain a read lock on @rw_lock and returns %TRUE if
23122 * the read lock was successfully obtained. Otherwise it
23125 * Returns: %TRUE if @rw_lock could be locked
23131 * g_rw_lock_reader_unlock:
23132 * @rw_lock: a #GRWLock
23134 * Release a read lock on @rw_lock.
23136 * Calling g_rw_lock_reader_unlock() on a lock that is not held
23137 * by the current thread leads to undefined behaviour.
23144 * g_rw_lock_writer_lock:
23145 * @rw_lock: a #GRWLock
23147 * Obtain a write lock on @rw_lock. If any thread already holds
23148 * a read or write lock on @rw_lock, the current thread will block
23149 * until all other threads have dropped their locks on @rw_lock.
23156 * g_rw_lock_writer_trylock:
23157 * @rw_lock: a #GRWLock
23159 * Tries to obtain a write lock on @rw_lock. If any other thread holds
23160 * a read or write lock on @rw_lock, it immediately returns %FALSE.
23161 * Otherwise it locks @rw_lock and returns %TRUE.
23163 * Returns: %TRUE if @rw_lock could be locked
23169 * g_rw_lock_writer_unlock:
23170 * @rw_lock: a #GRWLock
23172 * Release a write lock on @rw_lock.
23174 * Calling g_rw_lock_writer_unlock() on a lock that is not held
23175 * by the current thread leads to undefined behaviour.
23182 * g_scanner_add_symbol:
23183 * @scanner: a #GScanner
23184 * @symbol: the symbol to add
23185 * @value: the value of the symbol
23187 * Adds a symbol to the default scope.
23189 * Deprecated: 2.2: Use g_scanner_scope_add_symbol() instead.
23194 * g_scanner_cur_line:
23195 * @scanner: a #GScanner
23197 * Returns the current line in the input stream (counting
23198 * from 1). This is the line of the last token parsed via
23199 * g_scanner_get_next_token().
23201 * Returns: the current line
23206 * g_scanner_cur_position:
23207 * @scanner: a #GScanner
23209 * Returns the current position in the current line (counting
23210 * from 0). This is the position of the last token parsed via
23211 * g_scanner_get_next_token().
23213 * Returns: the current position on the line
23218 * g_scanner_cur_token:
23219 * @scanner: a #GScanner
23221 * Gets the current token type. This is simply the @token
23222 * field in the #GScanner structure.
23224 * Returns: the current token type
23229 * g_scanner_cur_value:
23230 * @scanner: a #GScanner
23232 * Gets the current token value. This is simply the @value
23233 * field in the #GScanner structure.
23235 * Returns: the current token value
23240 * g_scanner_destroy:
23241 * @scanner: a #GScanner
23243 * Frees all memory used by the #GScanner.
23249 * @scanner: a #GScanner
23251 * Returns %TRUE if the scanner has reached the end of
23252 * the file or text buffer.
23254 * Returns: %TRUE if the scanner has reached the end of the file or text buffer
23260 * @scanner: a #GScanner
23261 * @format: the message format. See the printf() documentation
23262 * @...: the parameters to insert into the format string
23264 * Outputs an error message, via the #GScanner message handler.
23269 * g_scanner_foreach_symbol:
23270 * @scanner: a #GScanner
23271 * @func: the function to call with each symbol
23272 * @data: data to pass to the function
23274 * Calls a function for each symbol in the default scope.
23276 * Deprecated: 2.2: Use g_scanner_scope_foreach_symbol() instead.
23281 * g_scanner_freeze_symbol_table:
23282 * @scanner: a #GScanner
23284 * There is no reason to use this macro, since it does nothing.
23286 * Deprecated: 2.2: This macro does nothing.
23291 * g_scanner_get_next_token:
23292 * @scanner: a #GScanner
23294 * Parses the next token just like g_scanner_peek_next_token()
23295 * and also removes it from the input stream. The token data is
23296 * placed in the @token, @value, @line, and @position fields of
23297 * the #GScanner structure.
23299 * Returns: the type of the token
23304 * g_scanner_input_file:
23305 * @scanner: a #GScanner
23306 * @input_fd: a file descriptor
23308 * Prepares to scan a file.
23313 * g_scanner_input_text:
23314 * @scanner: a #GScanner
23315 * @text: the text buffer to scan
23316 * @text_len: the length of the text buffer
23318 * Prepares to scan a text buffer.
23323 * g_scanner_lookup_symbol:
23324 * @scanner: a #GScanner
23325 * @symbol: the symbol to look up
23327 * Looks up a symbol in the current scope and return its value.
23328 * If the symbol is not bound in the current scope, %NULL is
23331 * Returns: the value of @symbol in the current scope, or %NULL if @symbol is not bound in the current scope
23337 * @config_templ: the initial scanner settings
23339 * Creates a new #GScanner.
23341 * The @config_templ structure specifies the initial settings
23342 * of the scanner, which are copied into the #GScanner
23343 * @config field. If you pass %NULL then the default settings
23346 * Returns: the new #GScanner
23351 * g_scanner_peek_next_token:
23352 * @scanner: a #GScanner
23354 * Parses the next token, without removing it from the input stream.
23355 * The token data is placed in the @next_token, @next_value, @next_line,
23356 * and @next_position fields of the #GScanner structure.
23358 * Note that, while the token is not removed from the input stream
23359 * (i.e. the next call to g_scanner_get_next_token() will return the
23360 * same token), it will not be reevaluated. This can lead to surprising
23361 * results when changing scope or the scanner configuration after peeking
23362 * the next token. Getting the next token after switching the scope or
23363 * configuration will return whatever was peeked before, regardless of
23364 * any symbols that may have been added or removed in the new scope.
23366 * Returns: the type of the token
23371 * g_scanner_remove_symbol:
23372 * @scanner: a #GScanner
23373 * @symbol: the symbol to remove
23375 * Removes a symbol from the default scope.
23377 * Deprecated: 2.2: Use g_scanner_scope_remove_symbol() instead.
23382 * g_scanner_scope_add_symbol:
23383 * @scanner: a #GScanner
23384 * @scope_id: the scope id
23385 * @symbol: the symbol to add
23386 * @value: the value of the symbol
23388 * Adds a symbol to the given scope.
23393 * g_scanner_scope_foreach_symbol:
23394 * @scanner: a #GScanner
23395 * @scope_id: the scope id
23396 * @func: the function to call for each symbol/value pair
23397 * @user_data: user data to pass to the function
23399 * Calls the given function for each of the symbol/value pairs
23400 * in the given scope of the #GScanner. The function is passed
23401 * the symbol and value of each pair, and the given @user_data
23407 * g_scanner_scope_lookup_symbol:
23408 * @scanner: a #GScanner
23409 * @scope_id: the scope id
23410 * @symbol: the symbol to look up
23412 * Looks up a symbol in a scope and return its value. If the
23413 * symbol is not bound in the scope, %NULL is returned.
23415 * Returns: the value of @symbol in the given scope, or %NULL if @symbol is not bound in the given scope.
23420 * g_scanner_scope_remove_symbol:
23421 * @scanner: a #GScanner
23422 * @scope_id: the scope id
23423 * @symbol: the symbol to remove
23425 * Removes a symbol from a scope.
23430 * g_scanner_set_scope:
23431 * @scanner: a #GScanner
23432 * @scope_id: the new scope id
23434 * Sets the current scope.
23436 * Returns: the old scope id
23441 * g_scanner_sync_file_offset:
23442 * @scanner: a #GScanner
23444 * Rewinds the filedescriptor to the current buffer position
23445 * and blows the file read ahead buffer. This is useful for
23446 * third party uses of the scanners filedescriptor, which hooks
23447 * onto the current scanning position.
23452 * g_scanner_thaw_symbol_table:
23453 * @scanner: a #GScanner
23455 * There is no reason to use this macro, since it does nothing.
23457 * Deprecated: 2.2: This macro does nothing.
23462 * g_scanner_unexp_token:
23463 * @scanner: a #GScanner
23464 * @expected_token: the expected token
23465 * @identifier_spec: a string describing how the scanner's user refers to identifiers (%NULL defaults to "identifier"). This is used if @expected_token is %G_TOKEN_IDENTIFIER or %G_TOKEN_IDENTIFIER_NULL.
23466 * @symbol_spec: a string describing how the scanner's user refers to symbols (%NULL defaults to "symbol"). This is used if @expected_token is %G_TOKEN_SYMBOL or any token value greater than %G_TOKEN_LAST.
23467 * @symbol_name: the name of the symbol, if the scanner's current token is a symbol.
23468 * @message: a message string to output at the end of the warning/error, or %NULL.
23469 * @is_error: if %TRUE it is output as an error. If %FALSE it is output as a warning.
23471 * Outputs a message through the scanner's msg_handler,
23472 * resulting from an unexpected token in the input stream.
23473 * Note that you should not call g_scanner_peek_next_token()
23474 * followed by g_scanner_unexp_token() without an intermediate
23475 * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
23476 * evaluates the scanner's current token (not the peeked token)
23477 * to construct part of the message.
23483 * @scanner: a #GScanner
23484 * @format: the message format. See the printf() documentation
23485 * @...: the parameters to insert into the format string
23487 * Outputs a warning message, via the #GScanner message handler.
23492 * g_sequence_append:
23493 * @seq: a #GSequence
23494 * @data: the data for the new item
23496 * Adds a new item to the end of @seq.
23498 * Returns: an iterator pointing to the new item
23504 * g_sequence_foreach:
23505 * @seq: a #GSequence
23506 * @func: the function to call for each item in @seq
23507 * @user_data: user data passed to @func
23509 * Calls @func for each item in the sequence passing @user_data
23517 * g_sequence_foreach_range:
23518 * @begin: a #GSequenceIter
23519 * @end: a #GSequenceIter
23521 * @user_data: user data passed to @func
23523 * Calls @func for each item in the range (@begin, @end) passing
23524 * @user_data to the function.
23532 * @seq: a #GSequence
23534 * Frees the memory allocated for @seq. If @seq has a data destroy
23535 * function associated with it, that function is called on all items in
23544 * @iter: a #GSequenceIter
23546 * Returns the data that @iter points to.
23548 * Returns: the data that @iter points to
23554 * g_sequence_get_begin_iter:
23555 * @seq: a #GSequence
23557 * Returns the begin iterator for @seq.
23559 * Returns: the begin iterator for @seq.
23565 * g_sequence_get_end_iter:
23566 * @seq: a #GSequence
23568 * Returns the end iterator for @seg
23570 * Returns: the end iterator for @seq
23576 * g_sequence_get_iter_at_pos:
23577 * @seq: a #GSequence
23578 * @pos: a position in @seq, or -1 for the end.
23580 * Returns the iterator at position @pos. If @pos is negative or larger
23581 * than the number of items in @seq, the end iterator is returned.
23583 * Returns: The #GSequenceIter at position @pos
23589 * g_sequence_get_length:
23590 * @seq: a #GSequence
23592 * Returns the length of @seq
23594 * Returns: the length of @seq
23600 * g_sequence_insert_before:
23601 * @iter: a #GSequenceIter
23602 * @data: the data for the new item
23604 * Inserts a new item just before the item pointed to by @iter.
23606 * Returns: an iterator pointing to the new item
23612 * g_sequence_insert_sorted:
23613 * @seq: a #GSequence
23614 * @data: the data to insert
23615 * @cmp_func: the function used to compare items in the sequence
23616 * @cmp_data: user data passed to @cmp_func.
23618 * Inserts @data into @sequence using @func to determine the new
23619 * position. The sequence must already be sorted according to @cmp_func;
23620 * otherwise the new position of @data is undefined.
23622 * @cmp_func is called with two items of the @seq and @user_data.
23623 * It should return 0 if the items are equal, a negative value
23624 * if the first item comes before the second, and a positive value
23625 * if the second item comes before the first.
23627 * Returns: a #GSequenceIter pointing to the new item.
23633 * g_sequence_insert_sorted_iter:
23634 * @seq: a #GSequence
23635 * @data: data for the new item
23636 * @iter_cmp: the function used to compare iterators in the sequence
23637 * @cmp_data: user data passed to @cmp_func
23639 * Like g_sequence_insert_sorted(), but uses
23640 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
23641 * the compare function.
23643 * @iter_cmp is called with two iterators pointing into @seq.
23644 * It should return 0 if the iterators are equal, a negative
23645 * value if the first iterator comes before the second, and a
23646 * positive value if the second iterator comes before the first.
23648 * It is called with two iterators pointing into @seq. It should
23649 * return 0 if the iterators are equal, a negative value if the
23650 * first iterator comes before the second, and a positive value
23651 * if the second iterator comes before the first.
23653 * Returns: a #GSequenceIter pointing to the new item
23659 * g_sequence_iter_compare:
23660 * @a: a #GSequenceIter
23661 * @b: a #GSequenceIter
23663 * Returns a negative number if @a comes before @b, 0 if they are equal,
23664 * and a positive number if @a comes after @b.
23666 * The @a and @b iterators must point into the same sequence.
23668 * Returns: A negative number if @a comes before @b, 0 if they are equal, and a positive number if @a comes after @b.
23674 * g_sequence_iter_get_position:
23675 * @iter: a #GSequenceIter
23677 * Returns the position of @iter
23679 * Returns: the position of @iter
23685 * g_sequence_iter_get_sequence:
23686 * @iter: a #GSequenceIter
23688 * Returns the #GSequence that @iter points into.
23690 * Returns: the #GSequence that @iter points into.
23696 * g_sequence_iter_is_begin:
23697 * @iter: a #GSequenceIter
23699 * Returns whether @iter is the begin iterator
23701 * Returns: whether @iter is the begin iterator
23707 * g_sequence_iter_is_end:
23708 * @iter: a #GSequenceIter
23710 * Returns whether @iter is the end iterator
23712 * Returns: Whether @iter is the end iterator.
23718 * g_sequence_iter_move:
23719 * @iter: a #GSequenceIter
23720 * @delta: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
23722 * Returns the #GSequenceIter which is @delta positions away from @iter.
23723 * If @iter is closer than -@delta positions to the beginning of the sequence,
23724 * the begin iterator is returned. If @iter is closer than @delta positions
23725 * to the end of the sequence, the end iterator is returned.
23727 * Returns: a #GSequenceIter which is @delta positions away from @iter.
23733 * g_sequence_iter_next:
23734 * @iter: a #GSequenceIter
23736 * Returns an iterator pointing to the next position after @iter. If
23737 * @iter is the end iterator, the end iterator is returned.
23739 * Returns: a #GSequenceIter pointing to the next position after @iter.
23745 * g_sequence_iter_prev:
23746 * @iter: a #GSequenceIter
23748 * Returns an iterator pointing to the previous position before @iter. If
23749 * @iter is the begin iterator, the begin iterator is returned.
23751 * Returns: a #GSequenceIter pointing to the previous position before @iter.
23757 * g_sequence_lookup:
23758 * @seq: a #GSequence
23759 * @data: data to lookup
23760 * @cmp_func: the function used to compare items in the sequence
23761 * @cmp_data: user data passed to @cmp_func.
23763 * Returns an iterator pointing to the position of the first item found
23764 * equal to @data according to @cmp_func and @cmp_data. If more than one
23765 * item is equal, it is not guaranteed that it is the first which is
23766 * returned. In that case, you can use g_sequence_iter_next() and
23767 * g_sequence_iter_prev() to get others.
23769 * @cmp_func is called with two items of the @seq and @user_data.
23770 * It should return 0 if the items are equal, a negative value if
23771 * the first item comes before the second, and a positive value if
23772 * the second item comes before the first.
23775 * This function will fail if the data contained in the sequence is
23776 * unsorted. Use g_sequence_insert_sorted() or
23777 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23778 * you want to add a large amount of data, call g_sequence_sort() after
23779 * doing unsorted insertions.
23782 * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data.
23788 * g_sequence_lookup_iter:
23789 * @seq: a #GSequence
23790 * @data: data to lookup
23791 * @iter_cmp: the function used to compare iterators in the sequence
23792 * @cmp_data: user data passed to @iter_cmp
23794 * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
23795 * instead of a #GCompareDataFunc as the compare function.
23797 * @iter_cmp is called with two iterators pointing into @seq.
23798 * It should return 0 if the iterators are equal, a negative value
23799 * if the first iterator comes before the second, and a positive
23800 * value if the second iterator comes before the first.
23803 * This function will fail if the data contained in the sequence is
23804 * unsorted. Use g_sequence_insert_sorted() or
23805 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23806 * you want to add a large amount of data, call g_sequence_sort() after
23807 * doing unsorted insertions.
23810 * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data.
23817 * @src: a #GSequenceIter pointing to the item to move
23818 * @dest: a #GSequenceIter pointing to the position to which the item is moved.
23820 * Moves the item pointed to by @src to the position indicated by @dest.
23821 * After calling this function @dest will point to the position immediately
23822 * after @src. It is allowed for @src and @dest to point into different
23830 * g_sequence_move_range:
23831 * @dest: a #GSequenceIter
23832 * @begin: a #GSequenceIter
23833 * @end: a #GSequenceIter
23835 * Inserts the (@begin, @end) range at the destination pointed to by ptr.
23836 * The @begin and @end iters must point into the same sequence. It is
23837 * allowed for @dest to point to a different sequence than the one pointed
23838 * into by @begin and @end.
23840 * If @dest is NULL, the range indicated by @begin and @end is
23841 * removed from the sequence. If @dest iter points to a place within
23842 * the (@begin, @end) range, the range does not move.
23850 * @data_destroy: (allow-none): a #GDestroyNotify function, or %NULL
23852 * Creates a new GSequence. The @data_destroy function, if non-%NULL will
23853 * be called on all items when the sequence is destroyed and on items that
23854 * are removed from the sequence.
23856 * Returns: a new #GSequence
23862 * g_sequence_prepend:
23863 * @seq: a #GSequence
23864 * @data: the data for the new item
23866 * Adds a new item to the front of @seq
23868 * Returns: an iterator pointing to the new item
23874 * g_sequence_range_get_midpoint:
23875 * @begin: a #GSequenceIter
23876 * @end: a #GSequenceIter
23878 * Finds an iterator somewhere in the range (@begin, @end). This
23879 * iterator will be close to the middle of the range, but is not
23880 * guaranteed to be <emphasis>exactly</emphasis> in the middle.
23882 * The @begin and @end iterators must both point to the same sequence and
23883 * @begin must come before or be equal to @end in the sequence.
23885 * Returns: A #GSequenceIter pointing somewhere in the (@begin, @end) range.
23891 * g_sequence_remove:
23892 * @iter: a #GSequenceIter
23894 * Removes the item pointed to by @iter. It is an error to pass the
23895 * end iterator to this function.
23897 * If the sequence has a data destroy function associated with it, this
23898 * function is called on the data for the removed item.
23905 * g_sequence_remove_range:
23906 * @begin: a #GSequenceIter
23907 * @end: a #GSequenceIter
23909 * Removes all items in the (@begin, @end) range.
23911 * If the sequence has a data destroy function associated with it, this
23912 * function is called on the data for the removed items.
23919 * g_sequence_search:
23920 * @seq: a #GSequence
23921 * @data: data for the new item
23922 * @cmp_func: the function used to compare items in the sequence
23923 * @cmp_data: user data passed to @cmp_func.
23925 * Returns an iterator pointing to the position where @data would
23926 * be inserted according to @cmp_func and @cmp_data.
23928 * @cmp_func is called with two items of the @seq and @user_data.
23929 * It should return 0 if the items are equal, a negative value if
23930 * the first item comes before the second, and a positive value if
23931 * the second item comes before the first.
23933 * If you are simply searching for an existing element of the sequence,
23934 * consider using g_sequence_lookup().
23937 * This function will fail if the data contained in the sequence is
23938 * unsorted. Use g_sequence_insert_sorted() or
23939 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23940 * you want to add a large amount of data, call g_sequence_sort() after
23941 * doing unsorted insertions.
23944 * Returns: an #GSequenceIter pointing to the position where @data would have been inserted according to @cmp_func and @cmp_data.
23950 * g_sequence_search_iter:
23951 * @seq: a #GSequence
23952 * @data: data for the new item
23953 * @iter_cmp: the function used to compare iterators in the sequence
23954 * @cmp_data: user data passed to @iter_cmp
23956 * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
23957 * instead of a #GCompareDataFunc as the compare function.
23959 * @iter_cmp is called with two iterators pointing into @seq.
23960 * It should return 0 if the iterators are equal, a negative value
23961 * if the first iterator comes before the second, and a positive
23962 * value if the second iterator comes before the first.
23964 * If you are simply searching for an existing element of the sequence,
23965 * consider using g_sequence_lookup_iter().
23968 * This function will fail if the data contained in the sequence is
23969 * unsorted. Use g_sequence_insert_sorted() or
23970 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23971 * you want to add a large amount of data, call g_sequence_sort() after
23972 * doing unsorted insertions.
23975 * Returns: a #GSequenceIter pointing to the position in @seq where @data would have been inserted according to @iter_cmp and @cmp_data.
23982 * @iter: a #GSequenceIter
23983 * @data: new data for the item
23985 * Changes the data for the item pointed to by @iter to be @data. If
23986 * the sequence has a data destroy function associated with it, that
23987 * function is called on the existing data that @iter pointed to.
23995 * @seq: a #GSequence
23996 * @cmp_func: the function used to sort the sequence
23997 * @cmp_data: user data passed to @cmp_func
23999 * Sorts @seq using @cmp_func.
24001 * @cmp_func is passed two items of @seq and should
24002 * return 0 if they are equal, a negative value if the
24003 * first comes before the second, and a positive value
24004 * if the second comes before the first.
24011 * g_sequence_sort_changed:
24012 * @iter: A #GSequenceIter
24013 * @cmp_func: the function used to compare items in the sequence
24014 * @cmp_data: user data passed to @cmp_func.
24016 * Moves the data pointed to a new position as indicated by @cmp_func. This
24017 * function should be called for items in a sequence already sorted according
24018 * to @cmp_func whenever some aspect of an item changes so that @cmp_func
24019 * may return different values for that item.
24021 * @cmp_func is called with two items of the @seq and @user_data.
24022 * It should return 0 if the items are equal, a negative value if
24023 * the first item comes before the second, and a positive value if
24024 * the second item comes before the first.
24031 * g_sequence_sort_changed_iter:
24032 * @iter: a #GSequenceIter
24033 * @iter_cmp: the function used to compare iterators in the sequence
24034 * @cmp_data: user data passed to @cmp_func
24036 * Like g_sequence_sort_changed(), but uses
24037 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
24038 * the compare function.
24040 * @iter_cmp is called with two iterators pointing into @seq. It should
24041 * return 0 if the iterators are equal, a negative value if the first
24042 * iterator comes before the second, and a positive value if the second
24043 * iterator comes before the first.
24050 * g_sequence_sort_iter:
24051 * @seq: a #GSequence
24052 * @cmp_func: the function used to compare iterators in the sequence
24053 * @cmp_data: user data passed to @cmp_func
24055 * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
24056 * of a GCompareDataFunc as the compare function
24058 * @cmp_func is called with two iterators pointing into @seq. It should
24059 * return 0 if the iterators are equal, a negative value if the first
24060 * iterator comes before the second, and a positive value if the second
24061 * iterator comes before the first.
24069 * @a: a #GSequenceIter
24070 * @b: a #GSequenceIter
24072 * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
24073 * to point into difference sequences.
24080 * g_set_application_name:
24081 * @application_name: localized name of the application
24083 * Sets a human-readable name for the application. This name should be
24084 * localized if possible, and is intended for display to the user.
24085 * Contrast with g_set_prgname(), which sets a non-localized name.
24086 * g_set_prgname() will be called automatically by gtk_init(),
24087 * but g_set_application_name() will not.
24089 * Note that for thread safety reasons, this function can only
24092 * The application name will be used in contexts such as error messages,
24093 * or when displaying an application's name in the task list.
24101 * @err: (allow-none): a return location for a #GError, or %NULL
24102 * @domain: error domain
24103 * @code: error code
24104 * @format: printf()-style format
24105 * @...: args for @format
24107 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24108 * must be %NULL. A new #GError is created and assigned to *@err.
24113 * g_set_error_literal:
24114 * @err: (allow-none): a return location for a #GError, or %NULL
24115 * @domain: error domain
24116 * @code: error code
24117 * @message: error message
24119 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24120 * must be %NULL. A new #GError is created and assigned to *@err.
24121 * Unlike g_set_error(), @message is not a printf()-style format string.
24122 * Use this function if @message contains text you don't have control over,
24123 * that could include printf() escape sequences.
24131 * @prgname: the name of the program.
24133 * Sets the name of the program. This name should <emphasis>not</emphasis>
24134 * be localized, contrast with g_set_application_name(). Note that for
24135 * thread-safety reasons this function can only be called once.
24140 * g_set_print_handler:
24141 * @func: the new print handler
24143 * Sets the print handler.
24145 * Any messages passed to g_print() will be output via
24146 * the new handler. The default handler simply outputs
24147 * the message to stdout. By providing your own handler
24148 * you can redirect the output, to a GTK+ widget or a
24149 * log file for example.
24151 * Returns: the old print handler
24156 * g_set_printerr_handler:
24157 * @func: the new error message handler
24159 * Sets the handler for printing error messages.
24161 * Any messages passed to g_printerr() will be output via
24162 * the new handler. The default handler simply outputs the
24163 * message to stderr. By providing your own handler you can
24164 * redirect the output, to a GTK+ widget or a log file for
24167 * Returns: the old error message handler
24173 * @variable: the environment variable to set, must not contain '='.
24174 * @value: the value for to set the variable to.
24175 * @overwrite: whether to change the variable if it already exists.
24177 * Sets an environment variable. Both the variable's name and value
24178 * should be in the GLib file name encoding. On UNIX, this means that
24179 * they can be arbitrary byte strings. On Windows, they should be in
24182 * Note that on some systems, when variables are overwritten, the memory
24183 * used for the previous variables and its value isn't reclaimed.
24186 * Environment variable handling in UNIX is not thread-safe, and your
24187 * program may crash if one thread calls g_setenv() while another
24188 * thread is calling getenv(). (And note that many functions, such as
24189 * gettext(), call getenv() internally.) This function is only safe to
24190 * use at the very start of your program, before creating any other
24191 * threads (or creating objects that create worker threads of their
24194 * If you need to set up the environment for a child process, you can
24195 * use g_get_environ() to get an environment array, modify that with
24196 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
24197 * array directly to execvpe(), g_spawn_async(), or the like.
24198 * </para></warning>
24200 * Returns: %FALSE if the environment variable couldn't be set.
24206 * g_shell_parse_argv:
24207 * @command_line: command line to parse
24208 * @argcp: (out): return location for number of args
24209 * @argvp: (out) (array length=argcp zero-terminated=1): return location for array of args
24210 * @error: return location for error
24212 * Parses a command line into an argument vector, in much the same way
24213 * the shell would, but without many of the expansions the shell would
24214 * perform (variable expansion, globs, operators, filename expansion,
24215 * etc. are not supported). The results are defined to be the same as
24216 * those you would get from a UNIX98 /bin/sh, as long as the input
24217 * contains none of the unsupported shell expansions. If the input
24218 * does contain such expansions, they are passed through
24219 * literally. Possible errors are those from the #G_SHELL_ERROR
24220 * domain. Free the returned vector with g_strfreev().
24222 * Returns: %TRUE on success, %FALSE if error set
24228 * @unquoted_string: a literal string
24230 * Quotes a string so that the shell (/bin/sh) will interpret the
24231 * quoted string to mean @unquoted_string. If you pass a filename to
24232 * the shell, for example, you should first quote it with this
24233 * function. The return value must be freed with g_free(). The
24234 * quoting style used is undefined (single or double quotes may be
24237 * Returns: quoted string
24243 * @quoted_string: shell-quoted string
24244 * @error: error return location or NULL
24246 * Unquotes a string as the shell (/bin/sh) would. Only handles
24247 * quotes; if a string contains file globs, arithmetic operators,
24248 * variables, backticks, redirections, or other special-to-the-shell
24249 * features, the result will be different from the result a real shell
24250 * would produce (the variables, backticks, etc. will be passed
24251 * through literally instead of being expanded). This function is
24252 * guaranteed to succeed if applied to the result of
24253 * g_shell_quote(). If it fails, it returns %NULL and sets the
24254 * error. The @quoted_string need not actually contain quoted or
24255 * escaped text; g_shell_unquote() simply goes through the string and
24256 * unquotes/unescapes anything that the shell would. Both single and
24257 * double quotes are handled, as are escapes including escaped
24258 * newlines. The return value must be freed with g_free(). Possible
24259 * errors are in the #G_SHELL_ERROR domain.
24261 * Shell quoting rules are a bit strange. Single quotes preserve the
24262 * literal string exactly. escape sequences are not allowed; not even
24263 * \' - if you want a ' in the quoted text, you have to do something
24264 * like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
24265 * be escaped with backslash. Otherwise double quotes preserve things
24268 * Returns: an unquoted string
24274 * @block_size: the number of bytes to allocate
24276 * Allocates a block of memory from the slice allocator.
24277 * The block adress handed out can be expected to be aligned
24278 * to at least <literal>1 * sizeof (void*)</literal>,
24279 * though in general slices are 2 * sizeof (void*) bytes aligned,
24280 * if a malloc() fallback implementation is used instead,
24281 * the alignment may be reduced in a libc dependent fashion.
24282 * Note that the underlying slice allocation mechanism can
24283 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24284 * environment variable.
24286 * Returns: a pointer to the allocated memory block
24293 * @block_size: the number of bytes to allocate
24295 * Allocates a block of memory via g_slice_alloc() and initializes
24296 * the returned memory to 0. Note that the underlying slice allocation
24297 * mechanism can be changed with the
24298 * <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24299 * environment variable.
24301 * Returns: a pointer to the allocated block
24308 * @block_size: the number of bytes to allocate
24309 * @mem_block: the memory to copy
24311 * Allocates a block of memory from the slice allocator
24312 * and copies @block_size bytes into it from @mem_block.
24314 * Returns: a pointer to the allocated memory block
24321 * @type: the type to duplicate, typically a structure name
24322 * @mem: the memory to copy into the allocated block
24324 * A convenience macro to duplicate a block of memory using
24325 * the slice allocator.
24327 * It calls g_slice_copy() with <literal>sizeof (@type)</literal>
24328 * and casts the returned pointer to a pointer of the given type,
24329 * avoiding a type cast in the source code.
24330 * Note that the underlying slice allocation mechanism can
24331 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24332 * environment variable.
24334 * Returns: a pointer to the allocated block, cast to a pointer to @type
24341 * @type: the type of the block to free, typically a structure name
24342 * @mem: a pointer to the block to free
24344 * A convenience macro to free a block of memory that has
24345 * been allocated from the slice allocator.
24347 * It calls g_slice_free1() using <literal>sizeof (type)</literal>
24348 * as the block size.
24349 * Note that the exact release behaviour can be changed with the
24350 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24351 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24352 * related debugging options.
24360 * @block_size: the size of the block
24361 * @mem_block: a pointer to the block to free
24363 * Frees a block of memory.
24365 * The memory must have been allocated via g_slice_alloc() or
24366 * g_slice_alloc0() and the @block_size has to match the size
24367 * specified upon allocation. Note that the exact release behaviour
24368 * can be changed with the
24369 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24370 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24371 * related debugging options.
24378 * g_slice_free_chain:
24379 * @type: the type of the @mem_chain blocks
24380 * @mem_chain: a pointer to the first block of the chain
24381 * @next: the field name of the next pointer in @type
24383 * Frees a linked list of memory blocks of structure type @type.
24384 * The memory blocks must be equal-sized, allocated via
24385 * g_slice_alloc() or g_slice_alloc0() and linked together by
24386 * a @next pointer (similar to #GSList). The name of the
24387 * @next field in @type is passed as third argument.
24388 * Note that the exact release behaviour can be changed with the
24389 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24390 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24391 * related debugging options.
24398 * g_slice_free_chain_with_offset:
24399 * @block_size: the size of the blocks
24400 * @mem_chain: a pointer to the first block of the chain
24401 * @next_offset: the offset of the @next field in the blocks
24403 * Frees a linked list of memory blocks of structure type @type.
24405 * The memory blocks must be equal-sized, allocated via
24406 * g_slice_alloc() or g_slice_alloc0() and linked together by a
24407 * @next pointer (similar to #GSList). The offset of the @next
24408 * field in each block is passed as third argument.
24409 * Note that the exact release behaviour can be changed with the
24410 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24411 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24412 * related debugging options.
24420 * @type: the type to allocate, typically a structure name
24422 * A convenience macro to allocate a block of memory from the
24425 * It calls g_slice_alloc() with <literal>sizeof (@type)</literal>
24426 * and casts the returned pointer to a pointer of the given type,
24427 * avoiding a type cast in the source code.
24428 * Note that the underlying slice allocation mechanism can
24429 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24430 * environment variable.
24432 * Returns: a pointer to the allocated block, cast to a pointer to @type
24439 * @type: the type to allocate, typically a structure name
24441 * A convenience macro to allocate a block of memory from the
24442 * slice allocator and set the memory to 0.
24444 * It calls g_slice_alloc0() with <literal>sizeof (@type)</literal>
24445 * and casts the returned pointer to a pointer of the given type,
24446 * avoiding a type cast in the source code.
24447 * Note that the underlying slice allocation mechanism can
24448 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24449 * environment variable.
24458 * Allocates space for one #GSList element. It is called by the
24459 * g_slist_append(), g_slist_prepend(), g_slist_insert() and
24460 * g_slist_insert_sorted() functions and so is rarely used on its own.
24462 * Returns: a pointer to the newly-allocated #GSList element.
24469 * @data: the data for the new element
24471 * Adds a new element on to the end of the list.
24474 * The return value is the new start of the list, which may
24475 * have changed, so make sure you store the new value.
24479 * Note that g_slist_append() has to traverse the entire list
24480 * to find the end, which is inefficient when adding multiple
24481 * elements. A common idiom to avoid the inefficiency is to prepend
24482 * the elements and reverse the list when all elements have been added.
24486 * /* Notice that these are initialized to the empty list. */
24487 * GSList *list = NULL, *number_list = NULL;
24489 * /* This is a list of strings. */
24490 * list = g_slist_append (list, "first");
24491 * list = g_slist_append (list, "second");
24493 * /* This is a list of integers. */
24494 * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
24495 * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
24498 * Returns: the new start of the #GSList
24504 * @list1: a #GSList
24505 * @list2: the #GSList to add to the end of the first #GSList
24507 * Adds the second #GSList onto the end of the first #GSList.
24508 * Note that the elements of the second #GSList are not copied.
24509 * They are used directly.
24511 * Returns: the start of the new #GSList
24519 * Copies a #GSList.
24522 * Note that this is a "shallow" copy. If the list elements
24523 * consist of pointers to data, the pointers are copied but
24524 * the actual data isn't. See g_slist_copy_deep() if you need
24525 * to copy the data as well.
24528 * Returns: a copy of @list
24533 * g_slist_copy_deep:
24535 * @func: a copy function used to copy every element in the list
24536 * @user_data: user data passed to the copy function @func, or #NULL
24538 * Makes a full (deep) copy of a #GSList.
24540 * In contrast with g_slist_copy(), this function uses @func to make a copy of
24541 * each list element, in addition to copying the list container itself.
24543 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
24544 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
24547 * For instance, if @list holds a list of GObjects, you can do:
24549 * another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
24552 * And, to entirely free the new list, you could do:
24554 * g_slist_free_full (another_list, g_object_unref);
24557 * Returns: a full copy of @list, use #g_slist_free_full to free it
24563 * g_slist_delete_link:
24565 * @link_: node to delete
24567 * Removes the node link_ from the list and frees it.
24568 * Compare this to g_slist_remove_link() which removes the node
24569 * without freeing it.
24571 * <note>Removing arbitrary nodes from a singly-linked list
24572 * requires time that is proportional to the length of the list
24573 * (ie. O(n)). If you find yourself using g_slist_delete_link()
24574 * frequently, you should consider a different data structure, such
24575 * as the doubly-linked #GList.</note>
24577 * Returns: the new head of @list
24584 * @data: the element data to find
24586 * Finds the element in a #GSList which
24587 * contains the given data.
24589 * Returns: the found #GSList element, or %NULL if it is not found
24594 * g_slist_find_custom:
24596 * @data: user data passed to the function
24597 * @func: the function to call for each element. It should return 0 when the desired element is found
24599 * Finds an element in a #GSList, using a supplied function to
24600 * find the desired element. It iterates over the list, calling
24601 * the given function which should return 0 when the desired
24602 * element is found. The function takes two #gconstpointer arguments,
24603 * the #GSList element's data as the first argument and the
24606 * Returns: the found #GSList element, or %NULL if it is not found
24613 * @func: the function to call with each element's data
24614 * @user_data: user data to pass to the function
24616 * Calls a function for each element of a #GSList.
24624 * Frees all of the memory used by a #GSList.
24625 * The freed elements are returned to the slice allocator.
24628 * If list elements contain dynamically-allocated memory,
24629 * you should either use g_slist_free_full() or free them manually
24638 * A macro which does the same as g_slist_free_1().
24646 * @list: a #GSList element
24648 * Frees one #GSList element.
24649 * It is usually used after g_slist_remove_link().
24654 * g_slist_free_full:
24655 * @list: a pointer to a #GSList
24656 * @free_func: the function to be called to free each element's data
24658 * Convenience method, which frees all the memory used by a #GSList, and
24659 * calls the specified destroy function on every element's data.
24668 * @data: the data to find
24670 * Gets the position of the element containing
24671 * the given data (starting from 0).
24673 * Returns: the index of the element containing the data, or -1 if the data is not found
24680 * @data: the data for the new element
24681 * @position: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
24683 * Inserts a new element into the list at the given position.
24685 * Returns: the new start of the #GSList
24690 * g_slist_insert_before:
24691 * @slist: a #GSList
24692 * @sibling: node to insert @data before
24693 * @data: data to put in the newly-inserted node
24695 * Inserts a node before @sibling containing @data.
24697 * Returns: the new head of the list.
24702 * g_slist_insert_sorted:
24704 * @data: the data for the new element
24705 * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
24707 * Inserts a new element into the list, using the given
24708 * comparison function to determine its position.
24710 * Returns: the new start of the #GSList
24715 * g_slist_insert_sorted_with_data:
24717 * @data: the data for the new element
24718 * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
24719 * @user_data: data to pass to comparison function
24721 * Inserts a new element into the list, using the given
24722 * comparison function to determine its position.
24724 * Returns: the new start of the #GSList
24733 * Gets the last element in a #GSList.
24736 * This function iterates over the whole list.
24739 * Returns: the last element in the #GSList, or %NULL if the #GSList has no elements
24747 * Gets the number of elements in a #GSList.
24750 * This function iterates over the whole list to
24751 * count its elements.
24754 * Returns: the number of elements in the #GSList
24760 * @slist: an element in a #GSList.
24762 * A convenience macro to get the next element in a #GSList.
24764 * Returns: the next element, or %NULL if there are no more elements.
24771 * @n: the position of the element, counting from 0
24773 * Gets the element at the given position in a #GSList.
24775 * Returns: the element, or %NULL if the position is off the end of the #GSList
24780 * g_slist_nth_data:
24782 * @n: the position of the element
24784 * Gets the data of the element at the given position.
24786 * Returns: the element's data, or %NULL if the position is off the end of the #GSList
24791 * g_slist_position:
24793 * @llink: an element in the #GSList
24795 * Gets the position of the given element
24796 * in the #GSList (starting from 0).
24798 * Returns: the position of the element in the #GSList, or -1 if the element is not found
24805 * @data: the data for the new element
24807 * Adds a new element on to the start of the list.
24810 * The return value is the new start of the list, which
24811 * may have changed, so make sure you store the new value.
24815 * /* Notice that it is initialized to the empty list. */
24816 * GSList *list = NULL;
24817 * list = g_slist_prepend (list, "last");
24818 * list = g_slist_prepend (list, "first");
24821 * Returns: the new start of the #GSList
24828 * @data: the data of the element to remove
24830 * Removes an element from a #GSList.
24831 * If two elements contain the same data, only the first is removed.
24832 * If none of the elements contain the data, the #GSList is unchanged.
24834 * Returns: the new start of the #GSList
24839 * g_slist_remove_all:
24841 * @data: data to remove
24843 * Removes all list nodes with data equal to @data.
24844 * Returns the new head of the list. Contrast with
24845 * g_slist_remove() which removes only the first node
24846 * matching the given data.
24848 * Returns: new head of @list
24853 * g_slist_remove_link:
24855 * @link_: an element in the #GSList
24857 * Removes an element from a #GSList, without
24858 * freeing the element. The removed element's next
24859 * link is set to %NULL, so that it becomes a
24860 * self-contained list with one element.
24862 * <note>Removing arbitrary nodes from a singly-linked list
24863 * requires time that is proportional to the length of the list
24864 * (ie. O(n)). If you find yourself using g_slist_remove_link()
24865 * frequently, you should consider a different data structure, such
24866 * as the doubly-linked #GList.</note>
24868 * Returns: the new start of the #GSList, without the element
24876 * Reverses a #GSList.
24878 * Returns: the start of the reversed #GSList
24885 * @compare_func: the comparison function used to sort the #GSList. This function is passed the data from 2 elements of the #GSList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
24887 * Sorts a #GSList using the given comparison function.
24889 * Returns: the start of the sorted #GSList
24894 * g_slist_sort_with_data:
24896 * @compare_func: comparison function
24897 * @user_data: data to pass to comparison function
24899 * Like g_slist_sort(), but the sort function accepts a user data argument.
24901 * Returns: new head of the list
24907 * @string: the buffer to hold the output.
24908 * @n: the maximum number of bytes to produce (including the terminating nul character).
24909 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24910 * @...: the arguments to insert in the output.
24912 * A safer form of the standard sprintf() function. The output is guaranteed
24913 * to not exceed @n characters (including the terminating nul character), so
24914 * it is easy to ensure that a buffer overflow cannot occur.
24916 * See also g_strdup_printf().
24918 * In versions of GLib prior to 1.2.3, this function may return -1 if the
24919 * output was truncated, and the truncated string may not be nul-terminated.
24920 * In versions prior to 1.3.12, this function returns the length of the output
24923 * The return value of g_snprintf() conforms to the snprintf()
24924 * function as standardized in ISO C99. Note that this is different from
24925 * traditional snprintf(), which returns the length of the output string.
24927 * The format string may contain positional parameters, as specified in
24928 * the Single Unix Specification.
24930 * Returns: the number of bytes which would be produced if the buffer was large enough.
24935 * g_source_add_child_source:
24936 * @source: a #GSource
24937 * @child_source: a second #GSource that @source should "poll"
24939 * Adds @child_source to @source as a "polled" source; when @source is
24940 * added to a #GMainContext, @child_source will be automatically added
24941 * with the same priority, when @child_source is triggered, it will
24942 * cause @source to dispatch (in addition to calling its own
24943 * callback), and when @source is destroyed, it will destroy
24944 * @child_source as well. (@source will also still be dispatched if
24945 * its own prepare/check functions indicate that it is ready.)
24947 * If you don't need @child_source to do anything on its own when it
24948 * triggers, you can call g_source_set_dummy_callback() on it to set a
24949 * callback that does nothing (except return %TRUE if appropriate).
24951 * @source will hold a reference on @child_source while @child_source
24952 * is attached to it.
24959 * g_source_add_poll:
24960 * @source: a #GSource
24961 * @fd: a #GPollFD structure holding information about a file descriptor to watch.
24963 * Adds a file descriptor to the set of file descriptors polled for
24964 * this source. This is usually combined with g_source_new() to add an
24965 * event source. The event source's check function will typically test
24966 * the @revents field in the #GPollFD struct and return %TRUE if events need
24973 * @source: a #GSource
24974 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
24976 * Adds a #GSource to a @context so that it will be executed within
24977 * that context. Remove it by calling g_source_destroy().
24979 * Returns: the ID (greater than 0) for the source within the #GMainContext.
24984 * g_source_destroy:
24985 * @source: a #GSource
24987 * Removes a source from its #GMainContext, if any, and mark it as
24988 * destroyed. The source cannot be subsequently added to another
24994 * g_source_get_can_recurse:
24995 * @source: a #GSource
24997 * Checks whether a source is allowed to be called recursively.
24998 * see g_source_set_can_recurse().
25000 * Returns: whether recursion is allowed.
25005 * g_source_get_context:
25006 * @source: a #GSource
25008 * Gets the #GMainContext with which the source is associated.
25010 * You can call this on a source that has been destroyed, provided
25011 * that the #GMainContext it was attached to still exists (in which
25012 * case it will return that #GMainContext). In particular, you can
25013 * always call this function on the source returned from
25014 * g_main_current_source(). But calling this function on a source
25015 * whose #GMainContext has been destroyed is an error.
25017 * Returns: (transfer none) (allow-none): the #GMainContext with which the source is associated, or %NULL if the context has not yet been added to a source.
25022 * g_source_get_current_time:
25023 * @source: a #GSource
25024 * @timeval: #GTimeVal structure in which to store current time.
25026 * This function ignores @source and is otherwise the same as
25027 * g_get_current_time().
25029 * Deprecated: 2.28: use g_source_get_time() instead
25035 * @source: a #GSource
25037 * Returns the numeric ID for a particular source. The ID of a source
25038 * is a positive integer which is unique within a particular main loop
25039 * context. The reverse
25040 * mapping from ID to source is done by g_main_context_find_source_by_id().
25042 * Returns: the ID (greater than 0) for the source
25047 * g_source_get_name:
25048 * @source: a #GSource
25050 * Gets a name for the source, used in debugging and profiling.
25051 * The name may be #NULL if it has never been set with
25052 * g_source_set_name().
25054 * Returns: the name of the source
25060 * g_source_get_priority:
25061 * @source: a #GSource
25063 * Gets the priority of a source.
25065 * Returns: the priority of the source
25070 * g_source_get_time:
25071 * @source: a #GSource
25073 * Gets the time to be used when checking this source. The advantage of
25074 * calling this function over calling g_get_monotonic_time() directly is
25075 * that when checking multiple sources, GLib can cache a single value
25076 * instead of having to repeatedly get the system monotonic time.
25078 * The time here is the system monotonic time, if available, or some
25079 * other reasonable alternative otherwise. See g_get_monotonic_time().
25081 * Returns: the monotonic time in microseconds
25087 * g_source_is_destroyed:
25088 * @source: a #GSource
25090 * Returns whether @source has been destroyed.
25092 * This is important when you operate upon your objects
25093 * from within idle handlers, but may have freed the object
25094 * before the dispatch of your idle handler.
25098 * idle_callback (gpointer data)
25100 * SomeWidget *self = data;
25102 * GDK_THREADS_ENTER (<!-- -->);
25103 * /<!-- -->* do stuff with self *<!-- -->/
25104 * self->idle_id = 0;
25105 * GDK_THREADS_LEAVE (<!-- -->);
25107 * return G_SOURCE_REMOVE;
25111 * some_widget_do_stuff_later (SomeWidget *self)
25113 * self->idle_id = g_idle_add (idle_callback, self);
25117 * some_widget_finalize (GObject *object)
25119 * SomeWidget *self = SOME_WIDGET (object);
25121 * if (self->idle_id)
25122 * g_source_remove (self->idle_id);
25124 * G_OBJECT_CLASS (parent_class)->finalize (object);
25128 * This will fail in a multi-threaded application if the
25129 * widget is destroyed before the idle handler fires due
25130 * to the use after free in the callback. A solution, to
25131 * this particular problem, is to check to if the source
25132 * has already been destroy within the callback.
25136 * idle_callback (gpointer data)
25138 * SomeWidget *self = data;
25140 * GDK_THREADS_ENTER ();
25141 * if (!g_source_is_destroyed (g_main_current_source ()))
25143 * /<!-- -->* do stuff with self *<!-- -->/
25145 * GDK_THREADS_LEAVE ();
25151 * Returns: %TRUE if the source has been destroyed
25158 * @source_funcs: structure containing functions that implement the sources behavior.
25159 * @struct_size: size of the #GSource structure to create.
25161 * Creates a new #GSource structure. The size is specified to
25162 * allow creating structures derived from #GSource that contain
25163 * additional data. The size passed in must be at least
25164 * <literal>sizeof (GSource)</literal>.
25166 * The source will not initially be associated with any #GMainContext
25167 * and must be added to one with g_source_attach() before it will be
25170 * Returns: the newly-created #GSource.
25176 * @source: a #GSource
25178 * Increases the reference count on a source by one.
25186 * @tag: the ID of the source to remove.
25188 * Removes the source with the given id from the default main context.
25190 * a #GSource is given by g_source_get_id(), or will be returned by the
25191 * functions g_source_attach(), g_idle_add(), g_idle_add_full(),
25192 * g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
25193 * g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
25195 * See also g_source_destroy(). You must use g_source_destroy() for sources
25196 * added to a non-default main context.
25198 * Returns: %TRUE if the source was found and removed.
25203 * g_source_remove_by_funcs_user_data:
25204 * @funcs: The @source_funcs passed to g_source_new()
25205 * @user_data: the user data for the callback
25207 * Removes a source from the default main loop context given the
25208 * source functions and user data. If multiple sources exist with the
25209 * same source functions and user data, only one will be destroyed.
25211 * Returns: %TRUE if a source was found and removed.
25216 * g_source_remove_by_user_data:
25217 * @user_data: the user_data for the callback.
25219 * Removes a source from the default main loop context given the user
25220 * data for the callback. If multiple sources exist with the same user
25221 * data, only one will be destroyed.
25223 * Returns: %TRUE if a source was found and removed.
25228 * g_source_remove_child_source:
25229 * @source: a #GSource
25230 * @child_source: a #GSource previously passed to g_source_add_child_source().
25232 * Detaches @child_source from @source and destroys it.
25239 * g_source_remove_poll:
25240 * @source: a #GSource
25241 * @fd: a #GPollFD structure previously passed to g_source_add_poll().
25243 * Removes a file descriptor from the set of file descriptors polled for
25249 * g_source_set_callback:
25250 * @source: the source
25251 * @func: a callback function
25252 * @data: the data to pass to callback function
25253 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
25255 * Sets the callback function for a source. The callback for a source is
25256 * called from the source's dispatch function.
25258 * The exact type of @func depends on the type of source; ie. you
25259 * should not count on @func being called with @data as its first
25262 * Typically, you won't use this function. Instead use functions specific
25263 * to the type of source you are using.
25268 * g_source_set_callback_indirect:
25269 * @source: the source
25270 * @callback_data: pointer to callback data "object"
25271 * @callback_funcs: functions for reference counting @callback_data and getting the callback and data
25273 * Sets the callback function storing the data as a refcounted callback
25274 * "object". This is used internally. Note that calling
25275 * g_source_set_callback_indirect() assumes
25276 * an initial reference count on @callback_data, and thus
25277 * @callback_funcs->unref will eventually be called once more
25278 * than @callback_funcs->ref.
25283 * g_source_set_can_recurse:
25284 * @source: a #GSource
25285 * @can_recurse: whether recursion is allowed for this source
25287 * Sets whether a source can be called recursively. If @can_recurse is
25288 * %TRUE, then while the source is being dispatched then this source
25289 * will be processed normally. Otherwise, all processing of this
25290 * source is blocked until the dispatch function returns.
25295 * g_source_set_funcs:
25296 * @source: a #GSource
25297 * @funcs: the new #GSourceFuncs
25299 * Sets the source functions (can be used to override
25300 * default implementations) of an unattached source.
25307 * g_source_set_name:
25308 * @source: a #GSource
25309 * @name: debug name for the source
25311 * Sets a name for the source, used in debugging and profiling.
25312 * The name defaults to #NULL.
25314 * The source name should describe in a human-readable way
25315 * what the source does. For example, "X11 event queue"
25316 * or "GTK+ repaint idle handler" or whatever it is.
25318 * It is permitted to call this function multiple times, but is not
25319 * recommended due to the potential performance impact. For example,
25320 * one could change the name in the "check" function of a #GSourceFuncs
25321 * to include details like the event type in the source name.
25328 * g_source_set_name_by_id:
25329 * @tag: a #GSource ID
25330 * @name: debug name for the source
25332 * Sets the name of a source using its ID.
25334 * This is a convenience utility to set source names from the return
25335 * value of g_idle_add(), g_timeout_add(), etc.
25342 * g_source_set_priority:
25343 * @source: a #GSource
25344 * @priority: the new priority.
25346 * Sets the priority of a source. While the main loop is being run, a
25347 * source will be dispatched if it is ready to be dispatched and no
25348 * sources at a higher (numerically smaller) priority are ready to be
25355 * @source: a #GSource
25357 * Decreases the reference count of a source by one. If the
25358 * resulting reference count is zero the source and associated
25359 * memory will be destroyed.
25364 * g_spaced_primes_closest:
25367 * Gets the smallest prime number from a built-in array of primes which
25368 * is larger than @num. This is used within GLib to calculate the optimum
25369 * size of a #GHashTable.
25371 * The built-in array of primes ranges from 11 to 13845163 such that
25372 * each prime is approximately 1.5-2 times the previous prime.
25374 * Returns: the smallest prime number from a built-in array of primes which is larger than @num
25380 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
25381 * @argv: (array zero-terminated=1): child's argument vector
25382 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
25383 * @flags: flags from #GSpawnFlags
25384 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25385 * @user_data: (closure): user data for @child_setup
25386 * @child_pid: (out) (allow-none): return location for child process reference, or %NULL
25387 * @error: return location for error
25389 * See g_spawn_async_with_pipes() for a full description; this function
25390 * simply calls the g_spawn_async_with_pipes() without any pipes.
25392 * You should call g_spawn_close_pid() on the returned child process
25393 * reference when you don't need it any more.
25396 * If you are writing a GTK+ application, and the program you
25397 * are spawning is a graphical application, too, then you may
25398 * want to use gdk_spawn_on_screen() instead to ensure that
25399 * the spawned program opens its windows on the right screen.
25402 * <note><para> Note that the returned @child_pid on Windows is a
25403 * handle to the child process and not its identifier. Process handles
25404 * and process identifiers are different concepts on Windows.
25407 * Returns: %TRUE on success, %FALSE if error is set
25412 * g_spawn_async_with_pipes:
25413 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
25414 * @argv: (array zero-terminated=1): child's argument vector, in the GLib file name encoding
25415 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's, in the GLib file name encoding
25416 * @flags: flags from #GSpawnFlags
25417 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25418 * @user_data: (closure): user data for @child_setup
25419 * @child_pid: (out) (allow-none): return location for child process ID, or %NULL
25420 * @standard_input: (out) (allow-none): return location for file descriptor to write to child's stdin, or %NULL
25421 * @standard_output: (out) (allow-none): return location for file descriptor to read child's stdout, or %NULL
25422 * @standard_error: (out) (allow-none): return location for file descriptor to read child's stderr, or %NULL
25423 * @error: return location for error
25425 * Executes a child program asynchronously (your program will not
25426 * block waiting for the child to exit). The child program is
25427 * specified by the only argument that must be provided, @argv. @argv
25428 * should be a %NULL-terminated array of strings, to be passed as the
25429 * argument vector for the child. The first string in @argv is of
25430 * course the name of the program to execute. By default, the name of
25431 * the program must be a full path. If @flags contains the
25432 * %G_SPAWN_SEARCH_PATH flag, the <envar>PATH</envar> environment variable
25433 * is used to search for the executable. If @flags contains the
25434 * %G_SPAWN_SEARCH_PATH_FROM_ENVP flag, the <envar>PATH</envar> variable from
25435 * @envp is used to search for the executable.
25436 * If both the %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP
25437 * flags are set, the <envar>PATH</envar> variable from @envp takes precedence
25438 * over the environment variable.
25440 * If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
25441 * used, then the program will be run from the current directory (or
25442 * @working_directory, if specified); this might be unexpected or even
25443 * dangerous in some cases when the current directory is world-writable.
25445 * On Windows, note that all the string or string vector arguments to
25446 * this function and the other g_spawn*() functions are in UTF-8, the
25447 * GLib file name encoding. Unicode characters that are not part of
25448 * the system codepage passed in these arguments will be correctly
25449 * available in the spawned program only if it uses wide character API
25450 * to retrieve its command line. For C programs built with Microsoft's
25451 * tools it is enough to make the program have a wmain() instead of
25452 * main(). wmain() has a wide character argument vector as parameter.
25454 * At least currently, mingw doesn't support wmain(), so if you use
25455 * mingw to develop the spawned program, it will have to call the
25456 * undocumented function __wgetmainargs() to get the wide character
25457 * argument vector and environment. See gspawn-win32-helper.c in the
25458 * GLib sources or init.c in the mingw runtime sources for a prototype
25459 * for that function. Alternatively, you can retrieve the Win32 system
25460 * level wide character command line passed to the spawned program
25461 * using the GetCommandLineW() function.
25463 * On Windows the low-level child process creation API
25464 * <function>CreateProcess()</function> doesn't use argument vectors,
25465 * but a command line. The C runtime library's
25466 * <function>spawn*()</function> family of functions (which
25467 * g_spawn_async_with_pipes() eventually calls) paste the argument
25468 * vector elements together into a command line, and the C runtime startup code
25469 * does a corresponding reconstruction of an argument vector from the
25470 * command line, to be passed to main(). Complications arise when you have
25471 * argument vector elements that contain spaces of double quotes. The
25472 * <function>spawn*()</function> functions don't do any quoting or
25473 * escaping, but on the other hand the startup code does do unquoting
25474 * and unescaping in order to enable receiving arguments with embedded
25475 * spaces or double quotes. To work around this asymmetry,
25476 * g_spawn_async_with_pipes() will do quoting and escaping on argument
25477 * vector elements that need it before calling the C runtime
25478 * spawn() function.
25480 * The returned @child_pid on Windows is a handle to the child
25481 * process, not its identifier. Process handles and process
25482 * identifiers are different concepts on Windows.
25484 * @envp is a %NULL-terminated array of strings, where each string
25485 * has the form <literal>KEY=VALUE</literal>. This will become
25486 * the child's environment. If @envp is %NULL, the child inherits its
25487 * parent's environment.
25489 * @flags should be the bitwise OR of any flags you want to affect the
25490 * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
25491 * child will not automatically be reaped; you must use a child watch to
25492 * be notified about the death of the child process. Eventually you must
25493 * call g_spawn_close_pid() on the @child_pid, in order to free
25494 * resources which may be associated with the child process. (On Unix,
25495 * using a child watch is equivalent to calling waitpid() or handling
25496 * the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
25497 * is equivalent to calling CloseHandle() on the process handle returned
25498 * in @child_pid). See g_child_watch_add().
25500 * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
25501 * descriptors will be inherited by the child; otherwise all
25502 * descriptors except stdin/stdout/stderr will be closed before
25503 * calling exec() in the child. %G_SPAWN_SEARCH_PATH
25504 * means that <literal>argv[0]</literal> need not be an absolute path, it
25505 * will be looked for in the <envar>PATH</envar> environment variable.
25506 * %G_SPAWN_SEARCH_PATH_FROM_ENVP means need not be an absolute path, it
25507 * will be looked for in the <envar>PATH</envar> variable from @envp. If
25508 * both %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP are used,
25509 * the value from @envp takes precedence over the environment.
25510 * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
25511 * be discarded, instead of going to the same location as the parent's
25512 * standard output. If you use this flag, @standard_output must be %NULL.
25513 * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
25514 * will be discarded, instead of going to the same location as the parent's
25515 * standard error. If you use this flag, @standard_error must be %NULL.
25516 * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
25517 * standard input (by default, the child's standard input is attached to
25518 * /dev/null). If you use this flag, @standard_input must be %NULL.
25519 * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
25520 * the file to execute, while the remaining elements are the
25521 * actual argument vector to pass to the file. Normally
25522 * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
25523 * passes all of @argv to the child.
25525 * @child_setup and @user_data are a function and user data. On POSIX
25526 * platforms, the function is called in the child after GLib has
25527 * performed all the setup it plans to perform (including creating
25528 * pipes, closing file descriptors, etc.) but before calling
25529 * exec(). That is, @child_setup is called just
25530 * before calling exec() in the child. Obviously
25531 * actions taken in this function will only affect the child, not the
25534 * On Windows, there is no separate fork() and exec()
25535 * functionality. Child processes are created and run with a single
25536 * API call, CreateProcess(). There is no sensible thing @child_setup
25537 * could be used for on Windows so it is ignored and not called.
25539 * If non-%NULL, @child_pid will on Unix be filled with the child's
25540 * process ID. You can use the process ID to send signals to the
25541 * child, or to use g_child_watch_add() (or waitpid()) if you specified the
25542 * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
25543 * filled with a handle to the child process only if you specified the
25544 * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
25545 * process using the Win32 API, for example wait for its termination
25546 * with the <function>WaitFor*()</function> functions, or examine its
25547 * exit code with GetExitCodeProcess(). You should close the handle
25548 * with CloseHandle() or g_spawn_close_pid() when you no longer need it.
25550 * If non-%NULL, the @standard_input, @standard_output, @standard_error
25551 * locations will be filled with file descriptors for writing to the child's
25552 * standard input or reading from its standard output or standard error.
25553 * The caller of g_spawn_async_with_pipes() must close these file descriptors
25554 * when they are no longer in use. If these parameters are %NULL, the corresponding
25555 * pipe won't be created.
25557 * If @standard_input is NULL, the child's standard input is attached to
25558 * /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
25560 * If @standard_error is NULL, the child's standard error goes to the same
25561 * location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
25564 * If @standard_output is NULL, the child's standard output goes to the same
25565 * location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
25568 * @error can be %NULL to ignore errors, or non-%NULL to report errors.
25569 * If an error is set, the function returns %FALSE. Errors
25570 * are reported even if they occur in the child (for example if the
25571 * executable in <literal>argv[0]</literal> is not found). Typically
25572 * the <literal>message</literal> field of returned errors should be displayed
25573 * to users. Possible errors are those from the #G_SPAWN_ERROR domain.
25575 * If an error occurs, @child_pid, @standard_input, @standard_output,
25576 * and @standard_error will not be filled with valid values.
25578 * If @child_pid is not %NULL and an error does not occur then the returned
25579 * process reference must be closed using g_spawn_close_pid().
25582 * If you are writing a GTK+ application, and the program you
25583 * are spawning is a graphical application, too, then you may
25584 * want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
25585 * the spawned program opens its windows on the right screen.
25588 * Returns: %TRUE on success, %FALSE if an error was set
25593 * g_spawn_check_exit_status:
25594 * @exit_status: An exit code as returned from g_spawn_sync()
25595 * @error: a #GError
25597 * Set @error if @exit_status indicates the child exited abnormally
25598 * (e.g. with a nonzero exit code, or via a fatal signal).
25600 * The g_spawn_sync() and g_child_watch_add() family of APIs return an
25601 * exit status for subprocesses encoded in a platform-specific way.
25602 * On Unix, this is guaranteed to be in the same format
25603 * <literal>waitpid(2)</literal> returns, and on Windows it is
25604 * guaranteed to be the result of
25605 * <literal>GetExitCodeProcess()</literal>. Prior to the introduction
25606 * of this function in GLib 2.34, interpreting @exit_status required
25607 * use of platform-specific APIs, which is problematic for software
25608 * using GLib as a cross-platform layer.
25610 * Additionally, many programs simply want to determine whether or not
25611 * the child exited successfully, and either propagate a #GError or
25612 * print a message to standard error. In that common case, this
25613 * function can be used. Note that the error message in @error will
25614 * contain human-readable information about the exit status.
25616 * The <literal>domain</literal> and <literal>code</literal> of @error
25617 * have special semantics in the case where the process has an "exit
25618 * code", as opposed to being killed by a signal. On Unix, this
25619 * happens if <literal>WIFEXITED</literal> would be true of
25620 * @exit_status. On Windows, it is always the case.
25622 * The special semantics are that the actual exit code will be the
25623 * code set in @error, and the domain will be %G_SPAWN_EXIT_ERROR.
25624 * This allows you to differentiate between different exit codes.
25626 * If the process was terminated by some means other than an exit
25627 * status, the domain will be %G_SPAWN_ERROR, and the code will be
25628 * %G_SPAWN_ERROR_FAILED.
25630 * This function just offers convenience; you can of course also check
25631 * the available platform via a macro such as %G_OS_UNIX, and use
25632 * <literal>WIFEXITED()</literal> and <literal>WEXITSTATUS()</literal>
25633 * on @exit_status directly. Do not attempt to scan or parse the
25634 * error message string; it may be translated and/or change in future
25635 * versions of GLib.
25637 * Returns: %TRUE if child exited successfully, %FALSE otherwise (and @error will be set)
25643 * g_spawn_close_pid:
25644 * @pid: The process reference to close
25646 * On some platforms, notably Windows, the #GPid type represents a resource
25647 * which must be closed to prevent resource leaking. g_spawn_close_pid()
25648 * is provided for this purpose. It should be used on all platforms, even
25649 * though it doesn't do anything under UNIX.
25654 * g_spawn_command_line_async:
25655 * @command_line: a command line
25656 * @error: return location for errors
25658 * A simple version of g_spawn_async() that parses a command line with
25659 * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
25660 * command line in the background. Unlike g_spawn_async(), the
25661 * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
25662 * that %G_SPAWN_SEARCH_PATH can have security implications, so
25663 * consider using g_spawn_async() directly if appropriate. Possible
25664 * errors are those from g_shell_parse_argv() and g_spawn_async().
25666 * The same concerns on Windows apply as for g_spawn_command_line_sync().
25668 * Returns: %TRUE on success, %FALSE if error is set.
25673 * g_spawn_command_line_sync:
25674 * @command_line: a command line
25675 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output
25676 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child errors
25677 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid()
25678 * @error: return location for errors
25680 * A simple version of g_spawn_sync() with little-used parameters
25681 * removed, taking a command line instead of an argument vector. See
25682 * g_spawn_sync() for full details. @command_line will be parsed by
25683 * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
25684 * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
25685 * implications, so consider using g_spawn_sync() directly if
25686 * appropriate. Possible errors are those from g_spawn_sync() and those
25687 * from g_shell_parse_argv().
25689 * If @exit_status is non-%NULL, the platform-specific exit status of
25690 * the child is stored there; see the documentation of
25691 * g_spawn_check_exit_status() for how to use and interpret this.
25693 * On Windows, please note the implications of g_shell_parse_argv()
25694 * parsing @command_line. Parsing is done according to Unix shell rules, not
25695 * Windows command interpreter rules.
25696 * Space is a separator, and backslashes are
25697 * special. Thus you cannot simply pass a @command_line containing
25698 * canonical Windows paths, like "c:\\program files\\app\\app.exe", as
25699 * the backslashes will be eaten, and the space will act as a
25700 * separator. You need to enclose such paths with single quotes, like
25701 * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
25703 * Returns: %TRUE on success, %FALSE if an error was set
25709 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
25710 * @argv: (array zero-terminated=1): child's argument vector
25711 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
25712 * @flags: flags from #GSpawnFlags
25713 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25714 * @user_data: (closure): user data for @child_setup
25715 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output, or %NULL
25716 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child error messages, or %NULL
25717 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid(), or %NULL
25718 * @error: return location for error, or %NULL
25720 * Executes a child synchronously (waits for the child to exit before returning).
25721 * All output from the child is stored in @standard_output and @standard_error,
25722 * if those parameters are non-%NULL. Note that you must set the
25723 * %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
25724 * passing %NULL for @standard_output and @standard_error.
25726 * If @exit_status is non-%NULL, the platform-specific exit status of
25727 * the child is stored there; see the doucumentation of
25728 * g_spawn_check_exit_status() for how to use and interpret this.
25729 * Note that it is invalid to pass %G_SPAWN_DO_NOT_REAP_CHILD in
25732 * If an error occurs, no data is returned in @standard_output,
25733 * @standard_error, or @exit_status.
25735 * This function calls g_spawn_async_with_pipes() internally; see that
25736 * function for full details on the other parameters and details on
25737 * how these functions work on Windows.
25739 * Returns: %TRUE on success, %FALSE if an error was set.
25745 * @string: A pointer to a memory buffer to contain the resulting string. It is up to the caller to ensure that the allocated buffer is large enough to hold the formatted result
25746 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
25747 * @...: the arguments to insert in the output.
25749 * An implementation of the standard sprintf() function which supports
25750 * positional parameters, as specified in the Single Unix Specification.
25752 * Note that it is usually better to use g_snprintf(), to avoid the
25753 * risk of buffer overflow.
25755 * See also g_strdup_printf().
25757 * Returns: the number of bytes printed.
25764 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
25765 * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
25767 * A wrapper for the POSIX stat() function. The stat() function
25768 * returns information about a file. On Windows the stat() function in
25769 * the C library checks only the FAT-style READONLY attribute and does
25770 * not look at the ACL at all. Thus on Windows the protection bits in
25771 * the st_mode field are a fabrication of little use.
25773 * On Windows the Microsoft C libraries have several variants of the
25774 * <structname>stat</structname> struct and stat() function with names
25775 * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
25776 * used here is for 32-bit code the one with 32-bit size and time
25777 * fields, specifically called "_stat32".
25779 * In Microsoft's compiler, by default "struct stat" means one with
25780 * 64-bit time fields while in MinGW "struct stat" is the legacy one
25781 * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
25782 * header defines a type GStatBuf which is the appropriate struct type
25783 * depending on the platform and/or compiler being used. On POSIX it
25784 * is just "struct stat", but note that even on POSIX platforms,
25785 * "stat" might be a macro.
25787 * See your C library manual for more details about stat().
25789 * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
25796 * @dest: destination buffer.
25797 * @src: source string.
25799 * Copies a nul-terminated string into the dest buffer, include the
25800 * trailing nul, and return a pointer to the trailing nul byte.
25801 * This is useful for concatenating multiple strings together
25802 * without having to repeatedly scan for the end.
25804 * Returns: a pointer to trailing nul byte.
25811 * @v2: a key to compare with @v1
25813 * Compares two strings for byte-by-byte equality and returns %TRUE
25814 * if they are equal. It can be passed to g_hash_table_new() as the
25815 * @key_equal_func parameter, when using non-%NULL strings as keys in a
25818 * Note that this function is primarily meant as a hash table comparison
25819 * function. For a general-purpose, %NULL-safe string comparison function,
25822 * Returns: %TRUE if the two keys match
25827 * g_str_has_prefix:
25828 * @str: a nul-terminated string
25829 * @prefix: the nul-terminated prefix to look for
25831 * Looks whether the string @str begins with @prefix.
25833 * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
25839 * g_str_has_suffix:
25840 * @str: a nul-terminated string
25841 * @suffix: the nul-terminated suffix to look for
25843 * Looks whether the string @str ends with @suffix.
25845 * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
25854 * Converts a string to a hash value.
25856 * This function implements the widely used "djb" hash apparently posted
25857 * by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
25858 * unsigned hash value starts at 5381 and for each byte 'c' in the
25859 * string, is updated: <literal>hash = hash * 33 + c</literal>. This
25860 * function uses the signed value of each byte.
25862 * It can be passed to g_hash_table_new() as the @hash_func parameter,
25863 * when using non-%NULL strings as keys in a #GHashTable.
25865 * Returns: a hash value corresponding to the key
25871 * @string: a nul-terminated array of bytes
25872 * @valid_chars: bytes permitted in @string
25873 * @substitutor: replacement character for disallowed bytes
25875 * For each character in @string, if the character is not in
25876 * @valid_chars, replaces the character with @substitutor.
25877 * Modifies @string in place, and return @string itself, not
25878 * a copy. The return value is to allow nesting such as
25880 * g_ascii_strup (g_strcanon (str, "abc", '?'))
25890 * @s2: a string to compare with @s1.
25892 * A case-insensitive string comparison, corresponding to the standard
25893 * strcasecmp() function on platforms which support it.
25895 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
25896 * Deprecated: 2.2: See g_strncasecmp() for a discussion of why this function is deprecated and how to replace it.
25902 * @string: a string to remove the trailing whitespace from
25904 * Removes trailing whitespace from a string.
25906 * This function doesn't allocate or reallocate any memory;
25907 * it modifies @string in place. The pointer to @string is
25908 * returned to allow the nesting of functions.
25910 * Also see g_strchug() and g_strstrip().
25912 * Returns: @string.
25918 * @string: a string to remove the leading whitespace from
25920 * Removes leading whitespace from a string, by moving the rest
25921 * of the characters forward.
25923 * This function doesn't allocate or reallocate any memory;
25924 * it modifies @string in place. The pointer to @string is
25925 * returned to allow the nesting of functions.
25927 * Also see g_strchomp() and g_strstrip().
25935 * @str1: (allow-none): a C string or %NULL
25936 * @str2: (allow-none): another C string or %NULL
25938 * Compares @str1 and @str2 like strcmp(). Handles %NULL
25939 * gracefully by sorting it before non-%NULL strings.
25940 * Comparing two %NULL pointers returns 0.
25942 * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
25949 * @source: a string to compress
25951 * Replaces all escaped characters with their one byte equivalent.
25953 * This function does the reverse conversion of g_strescape().
25955 * Returns: a newly-allocated copy of @source with all escaped character compressed
25961 * @string1: the first string to add, which must not be %NULL
25962 * @...: a %NULL-terminated list of strings to append to the string
25964 * Concatenates all of the given strings into one long string.
25965 * The returned string should be freed with g_free() when no longer needed.
25967 * Note that this function is usually not the right function to use to
25968 * assemble a translated message from pieces, since proper translation
25969 * often requires the pieces to be reordered.
25971 * <warning><para>The variable argument list <emphasis>must</emphasis> end
25972 * with %NULL. If you forget the %NULL, g_strconcat() will start appending
25973 * random memory junk to your string.</para></warning>
25975 * Returns: a newly-allocated string containing all the string arguments
25981 * @string: the string to convert
25982 * @delimiters: (allow-none): a string containing the current delimiters, or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
25983 * @new_delimiter: the new delimiter character
25985 * Converts any delimiter characters in @string to @new_delimiter.
25986 * Any characters in @string which are found in @delimiters are
25987 * changed to the @new_delimiter character. Modifies @string in place,
25988 * and returns @string itself, not a copy. The return value is to
25989 * allow nesting such as
25991 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
26000 * @string: the string to convert.
26002 * Converts a string to lower case.
26004 * Returns: the string
26005 * Deprecated: 2.2: This function is totally broken for the reasons discussed in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown() instead.
26011 * @str: the string to duplicate
26013 * Duplicates a string. If @str is %NULL it returns %NULL.
26014 * The returned string should be freed with g_free()
26015 * when no longer needed.
26017 * Returns: a newly-allocated copy of @str
26023 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26024 * @...: the parameters to insert into the format string
26026 * Similar to the standard C sprintf() function but safer, since it
26027 * calculates the maximum space required and allocates memory to hold
26028 * the result. The returned string should be freed with g_free() when no
26031 * Returns: a newly-allocated string holding the result
26036 * g_strdup_vprintf:
26037 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26038 * @args: the list of parameters to insert into the format string
26040 * Similar to the standard C vsprintf() function but safer, since it
26041 * calculates the maximum space required and allocates memory to hold
26042 * the result. The returned string should be freed with g_free() when
26043 * no longer needed.
26045 * See also g_vasprintf(), which offers the same functionality, but
26046 * additionally returns the length of the allocated string.
26048 * Returns: a newly-allocated string holding the result
26054 * @str_array: a %NULL-terminated array of strings
26056 * Copies %NULL-terminated array of strings. The copy is a deep copy;
26057 * the new array should be freed by first freeing each string, then
26058 * the array itself. g_strfreev() does this for you. If called
26059 * on a %NULL value, g_strdupv() simply returns %NULL.
26061 * Returns: a new %NULL-terminated array of strings.
26067 * @errnum: the system error number. See the standard C %errno documentation
26069 * Returns a string corresponding to the given error code, e.g.
26070 * "no such process". You should use this function in preference to
26071 * strerror(), because it returns a string in UTF-8 encoding, and since
26072 * not all platforms support the strerror() function.
26074 * Returns: a UTF-8 string describing the error code. If the error code is unknown, it returns "unknown error (<code>)".
26080 * @source: a string to escape
26081 * @exceptions: a string of characters not to escape in @source
26083 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
26084 * and '"' in the string @source by inserting a '\' before
26085 * them. Additionally all characters in the range 0x01-0x1F (everything
26086 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
26087 * replaced with a '\' followed by their octal representation.
26088 * Characters supplied in @exceptions are not escaped.
26090 * g_strcompress() does the reverse conversion.
26092 * Returns: a newly-allocated copy of @source with certain characters escaped. See above.
26098 * @str_array: a %NULL-terminated array of strings to free
26100 * Frees a %NULL-terminated array of strings, and the array itself.
26101 * If called on a %NULL value, g_strfreev() simply returns.
26107 * @string: a #GString
26108 * @val: the string to append onto the end of @string
26110 * Adds a string onto the end of a #GString, expanding
26118 * g_string_append_c:
26119 * @string: a #GString
26120 * @c: the byte to append onto the end of @string
26122 * Adds a byte onto the end of a #GString, expanding
26130 * g_string_append_len:
26131 * @string: a #GString
26132 * @val: bytes to append
26133 * @len: number of bytes of @val to use
26135 * Appends @len bytes of @val to @string. Because @len is
26136 * provided, @val may contain embedded nuls and need not
26137 * be nul-terminated.
26139 * Since this function does not stop at nul bytes, it is
26140 * the caller's responsibility to ensure that @val has at
26141 * least @len addressable bytes.
26148 * g_string_append_printf:
26149 * @string: a #GString
26150 * @format: the string format. See the printf() documentation
26151 * @...: the parameters to insert into the format string
26153 * Appends a formatted string onto the end of a #GString.
26154 * This function is similar to g_string_printf() except
26155 * that the text is appended to the #GString.
26160 * g_string_append_unichar:
26161 * @string: a #GString
26162 * @wc: a Unicode character
26164 * Converts a Unicode character into UTF-8, and appends it
26172 * g_string_append_uri_escaped:
26173 * @string: a #GString
26174 * @unescaped: a string
26175 * @reserved_chars_allowed: a string of reserved characters allowed to be used, or %NULL
26176 * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
26178 * Appends @unescaped to @string, escaped any characters that
26179 * are reserved in URIs using URI-style escape sequences.
26187 * g_string_append_vprintf:
26188 * @string: a #GString
26189 * @format: the string format. See the printf() documentation
26190 * @args: the list of arguments to insert in the output
26192 * Appends a formatted string onto the end of a #GString.
26193 * This function is similar to g_string_append_printf()
26194 * except that the arguments to the format string are passed
26202 * g_string_ascii_down:
26203 * @string: a GString
26205 * Converts all uppercase ASCII letters to lowercase ASCII letters.
26207 * Returns: passed-in @string pointer, with all the uppercase characters converted to lowercase in place, with semantics that exactly match g_ascii_tolower().
26212 * g_string_ascii_up:
26213 * @string: a GString
26215 * Converts all lowercase ASCII letters to uppercase ASCII letters.
26217 * Returns: passed-in @string pointer, with all the lowercase characters converted to uppercase in place, with semantics that exactly match g_ascii_toupper().
26223 * @string: the destination #GString. Its current contents are destroyed.
26224 * @rval: the string to copy into @string
26226 * Copies the bytes from a string into a #GString,
26227 * destroying any previous contents. It is rather like
26228 * the standard strcpy() function, except that you do not
26229 * have to worry about having enough space to copy the string.
26236 * g_string_chunk_clear:
26237 * @chunk: a #GStringChunk
26239 * Frees all strings contained within the #GStringChunk.
26240 * After calling g_string_chunk_clear() it is not safe to
26241 * access any of the strings which were contained within it.
26248 * g_string_chunk_free:
26249 * @chunk: a #GStringChunk
26251 * Frees all memory allocated by the #GStringChunk.
26252 * After calling g_string_chunk_free() it is not safe to
26253 * access any of the strings which were contained within it.
26258 * g_string_chunk_insert:
26259 * @chunk: a #GStringChunk
26260 * @string: the string to add
26262 * Adds a copy of @string to the #GStringChunk.
26263 * It returns a pointer to the new copy of the string
26264 * in the #GStringChunk. The characters in the string
26265 * can be changed, if necessary, though you should not
26266 * change anything after the end of the string.
26268 * Unlike g_string_chunk_insert_const(), this function
26269 * does not check for duplicates. Also strings added
26270 * with g_string_chunk_insert() will not be searched
26271 * by g_string_chunk_insert_const() when looking for
26274 * Returns: a pointer to the copy of @string within the #GStringChunk
26279 * g_string_chunk_insert_const:
26280 * @chunk: a #GStringChunk
26281 * @string: the string to add
26283 * Adds a copy of @string to the #GStringChunk, unless the same
26284 * string has already been added to the #GStringChunk with
26285 * g_string_chunk_insert_const().
26287 * This function is useful if you need to copy a large number
26288 * of strings but do not want to waste space storing duplicates.
26289 * But you must remember that there may be several pointers to
26290 * the same string, and so any changes made to the strings
26291 * should be done very carefully.
26293 * Note that g_string_chunk_insert_const() will not return a
26294 * pointer to a string added with g_string_chunk_insert(), even
26295 * if they do match.
26297 * Returns: a pointer to the new or existing copy of @string within the #GStringChunk
26302 * g_string_chunk_insert_len:
26303 * @chunk: a #GStringChunk
26304 * @string: bytes to insert
26305 * @len: number of bytes of @string to insert, or -1 to insert a nul-terminated string
26307 * Adds a copy of the first @len bytes of @string to the #GStringChunk.
26308 * The copy is nul-terminated.
26310 * Since this function does not stop at nul bytes, it is the caller's
26311 * responsibility to ensure that @string has at least @len addressable
26314 * The characters in the returned string can be changed, if necessary,
26315 * though you should not change anything after the end of the string.
26317 * Returns: a pointer to the copy of @string within the #GStringChunk
26323 * g_string_chunk_new:
26324 * @size: the default size of the blocks of memory which are allocated to store the strings. If a particular string is larger than this default size, a larger block of memory will be allocated for it.
26326 * Creates a new #GStringChunk.
26328 * Returns: a new #GStringChunk
26334 * @string: a #GString
26336 * Converts a #GString to lowercase.
26338 * Returns: the #GString
26339 * Deprecated: 2.2: This function uses the locale-specific tolower() function, which is almost never the right thing. Use g_string_ascii_down() or g_utf8_strdown() instead.
26346 * @v2: another #GString
26348 * Compares two strings for equality, returning %TRUE if they are equal.
26349 * For use with #GHashTable.
26351 * Returns: %TRUE if they strings are the same length and contain the same bytes
26357 * @string: a #GString
26358 * @pos: the position of the content to remove
26359 * @len: the number of bytes to remove, or -1 to remove all following bytes
26361 * Removes @len bytes from a #GString, starting at position @pos.
26362 * The rest of the #GString is shifted down to fill the gap.
26370 * @string: a #GString
26371 * @free_segment: if %TRUE, the actual character data is freed as well
26373 * Frees the memory allocated for the #GString.
26374 * If @free_segment is %TRUE it also frees the character data. If
26375 * it's %FALSE, the caller gains ownership of the buffer and must
26376 * free it after use with g_free().
26378 * Returns: the character data of @string (i.e. %NULL if @free_segment is %TRUE)
26383 * g_string_free_to_bytes:
26384 * @string: (transfer full): a #GString
26386 * Transfers ownership of the contents of @string to a newly allocated
26387 * #GBytes. The #GString structure itself is deallocated, and it is
26388 * therefore invalid to use @string after invoking this function.
26390 * Note that while #GString ensures that its buffer always has a
26391 * trailing nul character (not reflected in its "len"), the returned
26392 * #GBytes does not include this extra nul; i.e. it has length exactly
26393 * equal to the "len" member.
26395 * Returns: A newly allocated #GBytes containing contents of @string; @string itself is freed
26402 * @str: a string to hash
26404 * Creates a hash code for @str; for use with #GHashTable.
26406 * Returns: hash code for @str
26412 * @string: a #GString
26413 * @pos: the position to insert the copy of the string
26414 * @val: the string to insert
26416 * Inserts a copy of a string into a #GString,
26417 * expanding it if necessary.
26424 * g_string_insert_c:
26425 * @string: a #GString
26426 * @pos: the position to insert the byte
26427 * @c: the byte to insert
26429 * Inserts a byte into a #GString, expanding it if necessary.
26436 * g_string_insert_len:
26437 * @string: a #GString
26438 * @pos: position in @string where insertion should happen, or -1 for at the end
26439 * @val: bytes to insert
26440 * @len: number of bytes of @val to insert
26442 * Inserts @len bytes of @val into @string at @pos.
26443 * Because @len is provided, @val may contain embedded
26444 * nuls and need not be nul-terminated. If @pos is -1,
26445 * bytes are inserted at the end of the string.
26447 * Since this function does not stop at nul bytes, it is
26448 * the caller's responsibility to ensure that @val has at
26449 * least @len addressable bytes.
26456 * g_string_insert_unichar:
26457 * @string: a #GString
26458 * @pos: the position at which to insert character, or -1 to append at the end of the string
26459 * @wc: a Unicode character
26461 * Converts a Unicode character into UTF-8, and insert it
26462 * into the string at the given position.
26470 * @init: the initial text to copy into the string
26472 * Creates a new #GString, initialized with the given string.
26474 * Returns: the new #GString
26479 * g_string_new_len:
26480 * @init: initial contents of the string
26481 * @len: length of @init to use
26483 * Creates a new #GString with @len bytes of the @init buffer.
26484 * Because a length is provided, @init need not be nul-terminated,
26485 * and can contain embedded nul bytes.
26487 * Since this function does not stop at nul bytes, it is the caller's
26488 * responsibility to ensure that @init has at least @len addressable
26491 * Returns: a new #GString
26496 * g_string_overwrite:
26497 * @string: a #GString
26498 * @pos: the position at which to start overwriting
26499 * @val: the string that will overwrite the @string starting at @pos
26501 * Overwrites part of a string, lengthening it if necessary.
26509 * g_string_overwrite_len:
26510 * @string: a #GString
26511 * @pos: the position at which to start overwriting
26512 * @val: the string that will overwrite the @string starting at @pos
26513 * @len: the number of bytes to write from @val
26515 * Overwrites part of a string, lengthening it if necessary.
26516 * This function will work with embedded nuls.
26524 * g_string_prepend:
26525 * @string: a #GString
26526 * @val: the string to prepend on the start of @string
26528 * Adds a string on to the start of a #GString,
26529 * expanding it if necessary.
26536 * g_string_prepend_c:
26537 * @string: a #GString
26538 * @c: the byte to prepend on the start of the #GString
26540 * Adds a byte onto the start of a #GString,
26541 * expanding it if necessary.
26548 * g_string_prepend_len:
26549 * @string: a #GString
26550 * @val: bytes to prepend
26551 * @len: number of bytes in @val to prepend
26553 * Prepends @len bytes of @val to @string.
26554 * Because @len is provided, @val may contain
26555 * embedded nuls and need not be nul-terminated.
26557 * Since this function does not stop at nul bytes,
26558 * it is the caller's responsibility to ensure that
26559 * @val has at least @len addressable bytes.
26566 * g_string_prepend_unichar:
26567 * @string: a #GString
26568 * @wc: a Unicode character
26570 * Converts a Unicode character into UTF-8, and prepends it
26579 * @string: a #GString
26580 * @format: the string format. See the printf() documentation
26581 * @...: the parameters to insert into the format string
26583 * Writes a formatted string into a #GString.
26584 * This is similar to the standard sprintf() function,
26585 * except that the #GString buffer automatically expands
26586 * to contain the results. The previous contents of the
26587 * #GString are destroyed.
26592 * g_string_set_size:
26593 * @string: a #GString
26594 * @len: the new length
26596 * Sets the length of a #GString. If the length is less than
26597 * the current length, the string will be truncated. If the
26598 * length is greater than the current length, the contents
26599 * of the newly added area are undefined. (However, as
26600 * always, string->str[string->len] will be a nul byte.)
26607 * g_string_sized_new:
26608 * @dfl_size: the default size of the space allocated to hold the string
26610 * Creates a new #GString, with enough space for @dfl_size
26611 * bytes. This is useful if you are going to add a lot of
26612 * text to the string and don't want it to be reallocated
26615 * Returns: the new #GString
26620 * g_string_sprintf:
26621 * @string: a #GString
26622 * @format: the string format. See the sprintf() documentation
26623 * @...: the parameters to insert into the format string
26625 * Writes a formatted string into a #GString.
26626 * This is similar to the standard sprintf() function,
26627 * except that the #GString buffer automatically expands
26628 * to contain the results. The previous contents of the
26629 * #GString are destroyed.
26631 * Deprecated: This function has been renamed to g_string_printf().
26636 * g_string_sprintfa:
26637 * @string: a #GString
26638 * @format: the string format. See the sprintf() documentation
26639 * @...: the parameters to insert into the format string
26641 * Appends a formatted string onto the end of a #GString.
26642 * This function is similar to g_string_sprintf() except that
26643 * the text is appended to the #GString.
26645 * Deprecated: This function has been renamed to g_string_append_printf()
26650 * g_string_truncate:
26651 * @string: a #GString
26652 * @len: the new size of @string
26654 * Cuts off the end of the GString, leaving the first @len bytes.
26662 * @string: a #GString
26664 * Converts a #GString to uppercase.
26667 * Deprecated: 2.2: This function uses the locale-specific toupper() function, which is almost never the right thing. Use g_string_ascii_up() or g_utf8_strup() instead.
26672 * g_string_vprintf:
26673 * @string: a #GString
26674 * @format: the string format. See the printf() documentation
26675 * @args: the parameters to insert into the format string
26677 * Writes a formatted string into a #GString.
26678 * This function is similar to g_string_printf() except that
26679 * the arguments to the format string are passed as a va_list.
26688 * @msgval: another string
26690 * An auxiliary function for gettext() support (see Q_()).
26692 * Returns: @msgval, unless @msgval is identical to @msgid and contains a '|' character, in which case a pointer to the substring of msgid after the first '|' character is returned.
26699 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
26700 * @...: a %NULL-terminated list of strings to join
26702 * Joins a number of strings together to form one long string, with the
26703 * optional @separator inserted between each of them. The returned string
26704 * should be freed with g_free().
26706 * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
26712 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
26713 * @str_array: a %NULL-terminated array of strings to join
26715 * Joins a number of strings together to form one long string, with the
26716 * optional @separator inserted between each of them. The returned string
26717 * should be freed with g_free().
26719 * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
26725 * @dest: destination buffer, already containing one nul-terminated string
26726 * @src: source buffer
26727 * @dest_size: length of @dest buffer in bytes (not length of existing string inside @dest)
26729 * Portability wrapper that calls strlcat() on systems which have it,
26730 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
26731 * guaranteeing nul-termination for @dest. The total size of @dest won't
26732 * exceed @dest_size.
26734 * At most dest_size - 1 characters will be copied.
26735 * Unlike strncat, dest_size is the full size of dest, not the space left over.
26736 * This function does NOT allocate memory.
26737 * This always NUL terminates (unless siz == 0 or there were no NUL characters
26738 * in the dest_size characters of dest to start with).
26740 * <note><para>Caveat: this is supposedly a more secure alternative to
26741 * strcat() or strncat(), but for real security g_strconcat() is harder
26742 * to mess up.</para></note>
26744 * Returns: size of attempted result, which is MIN (dest_size, strlen (original dest)) + strlen (src), so if retval >= dest_size, truncation occurred.
26750 * @dest: destination buffer
26751 * @src: source buffer
26752 * @dest_size: length of @dest in bytes
26754 * Portability wrapper that calls strlcpy() on systems which have it,
26755 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
26756 * guaranteed to be nul-terminated; @src must be nul-terminated;
26757 * @dest_size is the buffer size, not the number of chars to copy.
26759 * At most dest_size - 1 characters will be copied. Always nul-terminates
26760 * (unless dest_size == 0). This function does <emphasis>not</emphasis>
26761 * allocate memory. Unlike strncpy(), this function doesn't pad dest (so
26762 * it's often faster). It returns the size of the attempted result,
26763 * strlen (src), so if @retval >= @dest_size, truncation occurred.
26765 * <note><para>Caveat: strlcpy() is supposedly more secure than
26766 * strcpy() or strncpy(), but if you really want to avoid screwups,
26767 * g_strdup() is an even better idea.</para></note>
26769 * Returns: length of @src
26776 * @s2: a string to compare with @s1.
26777 * @n: the maximum number of characters to compare.
26779 * A case-insensitive string comparison, corresponding to the standard
26780 * strncasecmp() function on platforms which support it.
26781 * It is similar to g_strcasecmp() except it only compares the first @n
26782 * characters of the strings.
26784 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
26785 * Deprecated: 2.2: The problem with g_strncasecmp() is that it does the comparison by calling toupper()/tolower(). These functions are locale-specific and operate on single bytes. However, it is impossible to handle things correctly from an I18N standpoint by operating on bytes, since characters may be multibyte. Thus g_strncasecmp() is broken if your string is guaranteed to be ASCII, since it's locale-sensitive, and it's broken if your string is localized, since it doesn't work on many encodings at all, including UTF-8, EUC-JP, etc. There are therefore two replacement functions: g_ascii_strncasecmp(), which only works on ASCII and is not locale-sensitive, and g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
26791 * @str: the string to duplicate
26792 * @n: the maximum number of bytes to copy from @str
26794 * Duplicates the first @n bytes of a string, returning a newly-allocated
26795 * buffer @n + 1 bytes long which will always be nul-terminated.
26796 * If @str is less than @n bytes long the buffer is padded with nuls.
26797 * If @str is %NULL it returns %NULL.
26798 * The returned value should be freed when no longer needed.
26801 * To copy a number of characters from a UTF-8 encoded string, use
26802 * g_utf8_strncpy() instead.
26805 * Returns: a newly-allocated buffer containing the first @n bytes of @str, nul-terminated
26811 * @length: the length of the new string
26812 * @fill_char: the byte to fill the string with
26814 * Creates a new string @length bytes long filled with @fill_char.
26815 * The returned string should be freed when no longer needed.
26817 * Returns: a newly-allocated string filled the @fill_char
26823 * @string: the string to reverse
26825 * Reverses all of the bytes in a string. For example,
26826 * <literal>g_strreverse ("abcdef")</literal> will result
26829 * Note that g_strreverse() doesn't work on UTF-8 strings
26830 * containing multibyte characters. For that purpose, use
26831 * g_utf8_strreverse().
26833 * Returns: the same pointer passed in as @string
26839 * @haystack: a nul-terminated string
26840 * @needle: the nul-terminated string to search for
26842 * Searches the string @haystack for the last occurrence
26843 * of the string @needle.
26845 * Returns: a pointer to the found occurrence, or %NULL if not found.
26851 * @haystack: a nul-terminated string
26852 * @haystack_len: the maximum length of @haystack
26853 * @needle: the nul-terminated string to search for
26855 * Searches the string @haystack for the last occurrence
26856 * of the string @needle, limiting the length of the search
26857 * to @haystack_len.
26859 * Returns: a pointer to the found occurrence, or %NULL if not found.
26865 * @signum: the signal number. See the <literal>signal</literal> documentation
26867 * Returns a string describing the given signal, e.g. "Segmentation fault".
26868 * You should use this function in preference to strsignal(), because it
26869 * returns a string in UTF-8 encoding, and since not all platforms support
26870 * the strsignal() function.
26872 * Returns: a UTF-8 string describing the signal. If the signal is unknown, it returns "unknown signal (<signum>)".
26878 * @string: a string to split
26879 * @delimiter: a string which specifies the places at which to split the string. The delimiter is not included in any of the resulting strings, unless @max_tokens is reached.
26880 * @max_tokens: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
26882 * Splits a string into a maximum of @max_tokens pieces, using the given
26883 * @delimiter. If @max_tokens is reached, the remainder of @string is
26884 * appended to the last token.
26886 * As a special case, the result of splitting the empty string "" is an empty
26887 * vector, not a vector containing a single string. The reason for this
26888 * special case is that being able to represent a empty vector is typically
26889 * more useful than consistent handling of empty elements. If you do need
26890 * to represent empty elements, you'll need to check for the empty string
26891 * before calling g_strsplit().
26893 * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
26899 * @string: The string to be tokenized
26900 * @delimiters: A nul-terminated string containing bytes that are used to split the string.
26901 * @max_tokens: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
26903 * Splits @string into a number of tokens not containing any of the characters
26904 * in @delimiter. A token is the (possibly empty) longest string that does not
26905 * contain any of the characters in @delimiters. If @max_tokens is reached, the
26906 * remainder is appended to the last token.
26908 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
26909 * %NULL-terminated vector containing the three strings "abc", "def",
26912 * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
26913 * vector containing the four strings "", "def", "ghi", and "".
26915 * As a special case, the result of splitting the empty string "" is an empty
26916 * vector, not a vector containing a single string. The reason for this
26917 * special case is that being able to represent a empty vector is typically
26918 * more useful than consistent handling of empty elements. If you do need
26919 * to represent empty elements, you'll need to check for the empty string
26920 * before calling g_strsplit_set().
26922 * Note that this function works on bytes not characters, so it can't be used
26923 * to delimit UTF-8 strings for anything but ASCII characters.
26925 * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
26932 * @haystack: a string
26933 * @haystack_len: the maximum length of @haystack. Note that -1 is a valid length, if @haystack is nul-terminated, meaning it will search through the whole string.
26934 * @needle: the string to search for
26936 * Searches the string @haystack for the first occurrence
26937 * of the string @needle, limiting the length of the search
26938 * to @haystack_len.
26940 * Returns: a pointer to the found occurrence, or %NULL if not found.
26946 * @string: a string to remove the leading and trailing whitespace from
26948 * Removes leading and trailing whitespace from a string.
26949 * See g_strchomp() and g_strchug().
26957 * @nptr: the string to convert to a numeric value.
26958 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
26960 * Converts a string to a #gdouble value.
26961 * It calls the standard strtod() function to handle the conversion, but
26962 * if the string is not completely converted it attempts the conversion
26963 * again with g_ascii_strtod(), and returns the best match.
26965 * This function should seldom be used. The normal situation when reading
26966 * numbers not for human consumption is to use g_ascii_strtod(). Only when
26967 * you know that you must expect both locale formatted and C formatted numbers
26968 * should you use this. Make sure that you don't pass strings such as comma
26969 * separated lists of values, since the commas may be interpreted as a decimal
26970 * point in some locales, causing unexpected results.
26972 * Returns: the #gdouble value.
26978 * @string: the string to convert.
26980 * Converts a string to upper case.
26982 * Returns: the string
26983 * Deprecated: 2.2: This function is totally broken for the reasons discussed in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
26989 * @str_array: a %NULL-terminated array of strings
26991 * Returns the length of the given %NULL-terminated
26992 * string array @str_array.
26994 * Returns: length of @str_array.
27001 * @testpath: The test path for a new test case.
27002 * @Fixture: The type of a fixture data structure.
27003 * @tdata: Data argument for the test functions.
27004 * @fsetup: The function to set up the fixture data.
27005 * @ftest: The actual test function.
27006 * @fteardown: The function to tear down the fixture data.
27008 * Hook up a new test case at @testpath, similar to g_test_add_func().
27009 * A fixture data structure with setup and teardown function may be provided
27010 * though, similar to g_test_create_case().
27011 * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and
27012 * fteardown() callbacks can expect a @Fixture pointer as first argument in
27013 * a type safe manner.
27020 * g_test_add_data_func:
27021 * @testpath: /-separated test case path name for the test.
27022 * @test_data: Test data argument for the test function.
27023 * @test_func: The test function to invoke for this test.
27025 * Create a new test case, similar to g_test_create_case(). However
27026 * the test is assumed to use no fixture, and test suites are automatically
27027 * created on the fly and added to the root fixture, based on the
27028 * slash-separated portions of @testpath. The @test_data argument
27029 * will be passed as first argument to @test_func.
27036 * g_test_add_data_func_full:
27037 * @testpath: /-separated test case path name for the test.
27038 * @test_data: Test data argument for the test function.
27039 * @test_func: The test function to invoke for this test.
27040 * @data_free_func: #GDestroyNotify for @test_data.
27042 * Create a new test case, as with g_test_add_data_func(), but freeing
27043 * @test_data after the test run is complete.
27051 * @testpath: /-separated test case path name for the test.
27052 * @test_func: The test function to invoke for this test.
27054 * Create a new test case, similar to g_test_create_case(). However
27055 * the test is assumed to use no fixture, and test suites are automatically
27056 * created on the fly and added to the root fixture, based on the
27057 * slash-separated portions of @testpath.
27064 * g_test_assert_expected_messages:
27066 * Asserts that all messages previously indicated via
27067 * g_test_expect_message() have been seen and suppressed.
27075 * @bug_uri_snippet: Bug specific bug tracker URI portion.
27077 * This function adds a message to test reports that
27078 * associates a bug URI with a test case.
27079 * Bug URIs are constructed from a base URI set with g_test_bug_base()
27080 * and @bug_uri_snippet.
27088 * @uri_pattern: the base pattern for bug URIs
27090 * Specify the base URI for bug reports.
27092 * The base URI is used to construct bug report messages for
27093 * g_test_message() when g_test_bug() is called.
27094 * Calling this function outside of a test case sets the
27095 * default base URI for all test cases. Calling it from within
27096 * a test case changes the base URI for the scope of the test
27098 * Bug URIs are constructed by appending a bug specific URI
27099 * portion to @uri_pattern, or by replacing the special string
27100 * '\%s' within @uri_pattern if that is present.
27107 * g_test_create_case:
27108 * @test_name: the name for the test case
27109 * @data_size: the size of the fixture data structure
27110 * @test_data: test data argument for the test functions
27111 * @data_setup: the function to set up the fixture data
27112 * @data_test: the actual test function
27113 * @data_teardown: the function to teardown the fixture data
27115 * Create a new #GTestCase, named @test_name, this API is fairly
27116 * low level, calling g_test_add() or g_test_add_func() is preferable.
27117 * When this test is executed, a fixture structure of size @data_size
27118 * will be allocated and filled with 0s. Then @data_setup is called
27119 * to initialize the fixture. After fixture setup, the actual test
27120 * function @data_test is called. Once the test run completed, the
27121 * fixture structure is torn down by calling @data_teardown and
27122 * after that the memory is released.
27124 * Splitting up a test run into fixture setup, test function and
27125 * fixture teardown is most usful if the same fixture is used for
27126 * multiple tests. In this cases, g_test_create_case() will be
27127 * called with the same fixture, but varying @test_name and
27128 * @data_test arguments.
27130 * Returns: a newly allocated #GTestCase.
27136 * g_test_create_suite:
27137 * @suite_name: a name for the suite
27139 * Create a new test suite with the name @suite_name.
27141 * Returns: A newly allocated #GTestSuite instance.
27147 * g_test_expect_message:
27148 * @log_domain: the log domain of the message
27149 * @log_level: the log level of the message
27150 * @pattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27152 * Indicates that a message with the given @log_domain and @log_level,
27153 * with text matching @pattern, is expected to be logged. When this
27154 * message is logged, it will not be printed, and the test case will
27157 * Use g_test_assert_expected_messages() to assert that all
27158 * previously-expected messages have been seen and suppressed.
27160 * You can call this multiple times in a row, if multiple messages are
27161 * expected as a result of a single call. (The messages must appear in
27162 * the same order as the calls to g_test_expect_message().)
27167 * /* g_main_context_push_thread_default() should fail if the
27168 * * context is already owned by another thread.
27170 * g_test_expect_message (G_LOG_DOMAIN,
27171 * G_LOG_LEVEL_CRITICIAL,
27172 * "assertion.*acquired_context.*failed");
27173 * g_main_context_push_thread_default (bad_context);
27174 * g_test_assert_expected_messages ();
27177 * Note that you cannot use this to test g_error() messages, since
27178 * g_error() intentionally never returns even if the program doesn't
27179 * abort; use g_test_trap_fork() in this case.
27188 * Indicates that a test failed. This function can be called
27189 * multiple times from the same test. You can use this function
27190 * if your test failed in a recoverable way.
27192 * Do not use this function if the failure of a test could cause
27193 * other tests to malfunction.
27195 * Calling this function will not stop the test from running, you
27196 * need to return from the test function yourself. So you can
27197 * produce additional diagnostic messages or even continue running
27200 * If not called from inside a test, this function does nothing.
27209 * Get the toplevel test suite for the test path API.
27211 * Returns: the toplevel #GTestSuite
27218 * @argc: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
27219 * @argv: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
27220 * @...: Reserved for future extension. Currently, you must pass %NULL.
27222 * Initialize the GLib testing framework, e.g. by seeding the
27223 * test random number generator, the name for g_get_prgname()
27224 * and parsing test related command line args.
27225 * So far, the following arguments are understood:
27228 * <term><option>-l</option></term>
27230 * List test cases available in a test executable.
27231 * </para></listitem>
27234 * <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
27236 * Provide a random seed to reproduce test runs using random numbers.
27237 * </para></listitem>
27240 * <term><option>--verbose</option></term>
27241 * <listitem><para>Run tests verbosely.</para></listitem>
27244 * <term><option>-q</option>, <option>--quiet</option></term>
27245 * <listitem><para>Run tests quietly.</para></listitem>
27248 * <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
27250 * Execute all tests matching <replaceable>TESTPATH</replaceable>.
27251 * </para></listitem>
27254 * <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
27256 * Execute tests according to these test modes:
27259 * <term>perf</term>
27261 * Performance tests, may take long and report results.
27262 * </para></listitem>
27265 * <term>slow, thorough</term>
27267 * Slow and thorough tests, may take quite long and
27268 * maximize coverage.
27269 * </para></listitem>
27272 * <term>quick</term>
27274 * Quick tests, should run really quickly and give good coverage.
27275 * </para></listitem>
27278 * <term>undefined</term>
27280 * Tests for undefined behaviour, may provoke programming errors
27281 * under g_test_trap_fork() to check that appropriate assertions
27282 * or warnings are given
27283 * </para></listitem>
27286 * <term>no-undefined</term>
27288 * Avoid tests for undefined behaviour
27289 * </para></listitem>
27292 * </para></listitem>
27295 * <term><option>--debug-log</option></term>
27296 * <listitem><para>Debug test logging output.</para></listitem>
27305 * g_test_log_buffer_free:
27307 * Internal function for gtester to free test log messages, no ABI guarantees provided.
27312 * g_test_log_buffer_new:
27314 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27319 * g_test_log_buffer_pop:
27321 * Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
27326 * g_test_log_buffer_push:
27328 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27333 * g_test_log_msg_free:
27335 * Internal function for gtester to free test log messages, no ABI guarantees provided.
27340 * g_test_log_set_fatal_handler:
27341 * @log_func: the log handler function.
27342 * @user_data: data passed to the log handler.
27344 * Installs a non-error fatal log handler which can be
27345 * used to decide whether log messages which are counted
27346 * as fatal abort the program.
27348 * The use case here is that you are running a test case
27349 * that depends on particular libraries or circumstances
27350 * and cannot prevent certain known critical or warning
27351 * messages. So you install a handler that compares the
27352 * domain and message to precisely not abort in such a case.
27354 * Note that the handler is reset at the beginning of
27355 * any test case, so you have to set it inside each test
27356 * function which needs the special behavior.
27358 * This handler has no effect on g_error messages.
27365 * g_test_maximized_result:
27366 * @maximized_quantity: the reported value
27367 * @format: the format string of the report message
27368 * @...: arguments to pass to the printf() function
27370 * Report the result of a performance or measurement test.
27371 * The test should generally strive to maximize the reported
27372 * quantities (larger values are better than smaller ones),
27373 * this and @maximized_quantity can determine sorting
27374 * order for test result reports.
27382 * @format: the format string
27383 * @...: printf-like arguments to @format
27385 * Add a message to the test report.
27392 * g_test_minimized_result:
27393 * @minimized_quantity: the reported value
27394 * @format: the format string of the report message
27395 * @...: arguments to pass to the printf() function
27397 * Report the result of a performance or measurement test.
27398 * The test should generally strive to minimize the reported
27399 * quantities (smaller values are better than larger ones),
27400 * this and @minimized_quantity can determine sorting
27401 * order for test result reports.
27410 * Returns %TRUE if tests are run in performance mode.
27412 * Returns: %TRUE if in performance mode
27417 * g_test_queue_destroy:
27418 * @destroy_func: Destroy callback for teardown phase.
27419 * @destroy_data: Destroy callback data.
27421 * This function enqueus a callback @destroy_func to be executed
27422 * during the next test case teardown phase. This is most useful
27423 * to auto destruct allocted test resources at the end of a test run.
27424 * Resources are released in reverse queue order, that means enqueueing
27425 * callback A before callback B will cause B() to be called before
27426 * A() during teardown.
27433 * g_test_queue_free:
27434 * @gfree_pointer: the pointer to be stored.
27436 * Enqueue a pointer to be released with g_free() during the next
27437 * teardown phase. This is equivalent to calling g_test_queue_destroy()
27438 * with a destroy callback of g_free().
27445 * g_test_queue_unref:
27446 * @gobject: the object to unref
27448 * Enqueue an object to be released with g_object_unref() during
27449 * the next teardown phase. This is equivalent to calling
27450 * g_test_queue_destroy() with a destroy callback of g_object_unref().
27459 * Returns %TRUE if tests are run in quick mode.
27460 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
27461 * there is no "medium speed".
27463 * Returns: %TRUE if in quick mode
27470 * Returns %TRUE if tests are run in quiet mode.
27471 * The default is neither g_test_verbose() nor g_test_quiet().
27473 * Returns: %TRUE if in quiet mode
27480 * Get a reproducible random bit (0 or 1), see g_test_rand_int()
27481 * for details on test case random numbers.
27488 * g_test_rand_double:
27490 * Get a reproducible random floating point number,
27491 * see g_test_rand_int() for details on test case random numbers.
27493 * Returns: a random number from the seeded random number generator.
27499 * g_test_rand_double_range:
27500 * @range_start: the minimum value returned by this function
27501 * @range_end: the minimum value not returned by this function
27503 * Get a reproducible random floating pointer number out of a specified range,
27504 * see g_test_rand_int() for details on test case random numbers.
27506 * Returns: a number with @range_start <= number < @range_end.
27514 * Get a reproducible random integer number.
27516 * The random numbers generated by the g_test_rand_*() family of functions
27517 * change with every new test program start, unless the --seed option is
27518 * given when starting test programs.
27520 * For individual test cases however, the random number generator is
27521 * reseeded, to avoid dependencies between tests and to make --seed
27522 * effective for all test cases.
27524 * Returns: a random number from the seeded random number generator.
27530 * g_test_rand_int_range:
27531 * @begin: the minimum value returned by this function
27532 * @end: the smallest value not to be returned by this function
27534 * Get a reproducible random integer number out of a specified range,
27535 * see g_test_rand_int() for details on test case random numbers.
27537 * Returns: a number with @begin <= number < @end.
27545 * Runs all tests under the toplevel suite which can be retrieved
27546 * with g_test_get_root(). Similar to g_test_run_suite(), the test
27547 * cases to be run are filtered according to
27548 * test path arguments (-p <replaceable>testpath</replaceable>) as
27549 * parsed by g_test_init().
27550 * g_test_run_suite() or g_test_run() may only be called once
27553 * Returns: 0 on success
27559 * g_test_run_suite:
27560 * @suite: a #GTestSuite
27562 * Execute the tests within @suite and all nested #GTestSuites.
27563 * The test suites to be executed are filtered according to
27564 * test path arguments (-p <replaceable>testpath</replaceable>)
27565 * as parsed by g_test_init().
27566 * g_test_run_suite() or g_test_run() may only be called once
27569 * Returns: 0 on success
27577 * Returns %TRUE if tests are run in slow mode.
27578 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
27579 * there is no "medium speed".
27581 * Returns: the opposite of g_test_quick()
27586 * g_test_suite_add:
27587 * @suite: a #GTestSuite
27588 * @test_case: a #GTestCase
27590 * Adds @test_case to @suite.
27597 * g_test_suite_add_suite:
27598 * @suite: a #GTestSuite
27599 * @nestedsuite: another #GTestSuite
27601 * Adds @nestedsuite to @suite.
27610 * Returns %TRUE if tests are run in thorough mode, equivalent to
27613 * Returns: the same thing as g_test_slow()
27618 * g_test_timer_elapsed:
27620 * Get the time since the last start of the timer with g_test_timer_start().
27622 * Returns: the time since the last start of the timer, as a double
27628 * g_test_timer_last:
27630 * Report the last result of g_test_timer_elapsed().
27632 * Returns: the last result of g_test_timer_elapsed(), as a double
27638 * g_test_timer_start:
27640 * Start a timing test. Call g_test_timer_elapsed() when the task is supposed
27641 * to be done. Call this function again to restart the timer.
27648 * g_test_trap_assert_failed:
27650 * Assert that the last forked test failed.
27651 * See g_test_trap_fork().
27653 * This is sometimes used to test situations that are formally considered to
27654 * be undefined behaviour, like inputs that fail a g_return_if_fail()
27655 * check. In these situations you should skip the entire test, including the
27656 * call to g_test_trap_fork(), unless g_test_undefined() returns %TRUE
27657 * to indicate that undefined behaviour may be tested.
27664 * g_test_trap_assert_passed:
27666 * Assert that the last forked test passed.
27667 * See g_test_trap_fork().
27674 * g_test_trap_assert_stderr:
27675 * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27677 * Assert that the stderr output of the last forked test
27678 * matches @serrpattern. See g_test_trap_fork().
27680 * This is sometimes used to test situations that are formally considered to
27681 * be undefined behaviour, like inputs that fail a g_return_if_fail()
27682 * check. In these situations you should skip the entire test, including the
27683 * call to g_test_trap_fork(), unless g_test_undefined() returns %TRUE
27684 * to indicate that undefined behaviour may be tested.
27691 * g_test_trap_assert_stderr_unmatched:
27692 * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27694 * Assert that the stderr output of the last forked test
27695 * does not match @serrpattern. See g_test_trap_fork().
27702 * g_test_trap_assert_stdout:
27703 * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27705 * Assert that the stdout output of the last forked test matches
27706 * @soutpattern. See g_test_trap_fork().
27713 * g_test_trap_assert_stdout_unmatched:
27714 * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27716 * Assert that the stdout output of the last forked test
27717 * does not match @soutpattern. See g_test_trap_fork().
27724 * g_test_trap_fork:
27725 * @usec_timeout: Timeout for the forked test in micro seconds.
27726 * @test_trap_flags: Flags to modify forking behaviour.
27728 * Fork the current test program to execute a test case that might
27729 * not return or that might abort. The forked test case is aborted
27730 * and considered failing if its run time exceeds @usec_timeout.
27732 * The forking behavior can be configured with the #GTestTrapFlags flags.
27734 * In the following example, the test code forks, the forked child
27735 * process produces some sample output and exits successfully.
27736 * The forking parent process then asserts successful child program
27737 * termination and validates child program outputs.
27741 * test_fork_patterns (void)
27743 * if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
27745 * g_print ("some stdout text: somagic17\n");
27746 * g_printerr ("some stderr text: semagic43\n");
27747 * exit (0); /* successful test run */
27749 * g_test_trap_assert_passed();
27750 * g_test_trap_assert_stdout ("*somagic17*");
27751 * g_test_trap_assert_stderr ("*semagic43*");
27755 * This function is implemented only on Unix platforms.
27757 * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
27763 * g_test_trap_has_passed:
27765 * Check the result of the last g_test_trap_fork() call.
27767 * Returns: %TRUE if the last forked child terminated successfully.
27773 * g_test_trap_reached_timeout:
27775 * Check the result of the last g_test_trap_fork() call.
27777 * Returns: %TRUE if the last forked child got killed due to a fork timeout.
27783 * g_test_undefined:
27785 * Returns %TRUE if tests may provoke assertions and other formally-undefined
27786 * behaviour under g_test_trap_fork(), to verify that appropriate warnings
27787 * are given. It can be useful to turn this off if running tests under
27790 * Returns: %TRUE if tests may provoke programming errors
27797 * Returns %TRUE if tests are run in verbose mode.
27798 * The default is neither g_test_verbose() nor g_test_quiet().
27800 * Returns: %TRUE if in verbose mode
27806 * @retval: the return value of this thread
27808 * Terminates the current thread.
27810 * If another thread is waiting for us using g_thread_join() then the
27811 * waiting thread will be woken up and get @retval as the return value
27812 * of g_thread_join().
27814 * Calling <literal>g_thread_exit (retval)</literal> is equivalent to
27815 * returning @retval from the function @func, as given to g_thread_new().
27818 * You must only call g_thread_exit() from a thread that you created
27819 * yourself with g_thread_new() or related APIs. You must not call
27820 * this function from a thread created with another threading library
27821 * or or from within a #GThreadPool.
27828 * @thread: a #GThread
27830 * Waits until @thread finishes, i.e. the function @func, as
27831 * given to g_thread_new(), returns or g_thread_exit() is called.
27832 * If @thread has already terminated, then g_thread_join()
27833 * returns immediately.
27835 * Any thread can wait for any other thread by calling g_thread_join(),
27836 * not just its 'creator'. Calling g_thread_join() from multiple threads
27837 * for the same @thread leads to undefined behaviour.
27839 * The value returned by @func or given to g_thread_exit() is
27840 * returned by this function.
27842 * g_thread_join() consumes the reference to the passed-in @thread.
27843 * This will usually cause the #GThread struct and associated resources
27844 * to be freed. Use g_thread_ref() to obtain an extra reference if you
27845 * want to keep the GThread alive beyond the g_thread_join() call.
27847 * Returns: the return value of the thread
27853 * @name: a name for the new thread
27854 * @func: a function to execute in the new thread
27855 * @data: an argument to supply to the new thread
27857 * This function creates a new thread. The new thread starts by invoking
27858 * @func with the argument data. The thread will run until @func returns
27859 * or until g_thread_exit() is called from the new thread. The return value
27860 * of @func becomes the return value of the thread, which can be obtained
27861 * with g_thread_join().
27863 * The @name can be useful for discriminating threads in a debugger.
27864 * Some systems restrict the length of @name to 16 bytes.
27866 * If the thread can not be created the program aborts. See
27867 * g_thread_try_new() if you want to attempt to deal with failures.
27869 * To free the struct returned by this function, use g_thread_unref().
27870 * Note that g_thread_join() implicitly unrefs the #GThread as well.
27872 * Returns: the new #GThread
27878 * g_thread_pool_free:
27879 * @pool: a #GThreadPool
27880 * @immediate: should @pool shut down immediately?
27881 * @wait_: should the function wait for all tasks to be finished?
27883 * Frees all resources allocated for @pool.
27885 * If @immediate is %TRUE, no new task is processed for @pool.
27886 * Otherwise @pool is not freed before the last task is processed.
27887 * Note however, that no thread of this pool is interrupted while
27888 * processing a task. Instead at least all still running threads
27889 * can finish their tasks before the @pool is freed.
27891 * If @wait_ is %TRUE, the functions does not return before all
27892 * tasks to be processed (dependent on @immediate, whether all
27893 * or only the currently running) are ready.
27894 * Otherwise the function returns immediately.
27896 * After calling this function @pool must not be used anymore.
27901 * g_thread_pool_get_max_idle_time:
27903 * This function will return the maximum @interval that a
27904 * thread will wait in the thread pool for new tasks before
27907 * If this function returns 0, threads waiting in the thread
27908 * pool for new work are not stopped.
27910 * Returns: the maximum @interval (milliseconds) to wait for new tasks in the thread pool before stopping the thread
27916 * g_thread_pool_get_max_threads:
27917 * @pool: a #GThreadPool
27919 * Returns the maximal number of threads for @pool.
27921 * Returns: the maximal number of threads
27926 * g_thread_pool_get_max_unused_threads:
27928 * Returns the maximal allowed number of unused threads.
27930 * Returns: the maximal number of unused threads
27935 * g_thread_pool_get_num_threads:
27936 * @pool: a #GThreadPool
27938 * Returns the number of threads currently running in @pool.
27940 * Returns: the number of threads currently running
27945 * g_thread_pool_get_num_unused_threads:
27947 * Returns the number of currently unused threads.
27949 * Returns: the number of currently unused threads
27954 * g_thread_pool_new:
27955 * @func: a function to execute in the threads of the new thread pool
27956 * @user_data: user data that is handed over to @func every time it is called
27957 * @max_threads: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
27958 * @exclusive: should this thread pool be exclusive?
27959 * @error: return location for error, or %NULL
27961 * This function creates a new thread pool.
27963 * Whenever you call g_thread_pool_push(), either a new thread is
27964 * created or an unused one is reused. At most @max_threads threads
27965 * are running concurrently for this thread pool. @max_threads = -1
27966 * allows unlimited threads to be created for this thread pool. The
27967 * newly created or reused thread now executes the function @func
27968 * with the two arguments. The first one is the parameter to
27969 * g_thread_pool_push() and the second one is @user_data.
27971 * The parameter @exclusive determines whether the thread pool owns
27972 * all threads exclusive or shares them with other thread pools.
27973 * If @exclusive is %TRUE, @max_threads threads are started
27974 * immediately and they will run exclusively for this thread pool
27975 * until it is destroyed by g_thread_pool_free(). If @exclusive is
27976 * %FALSE, threads are created when needed and shared between all
27977 * non-exclusive thread pools. This implies that @max_threads may
27978 * not be -1 for exclusive thread pools.
27980 * @error can be %NULL to ignore errors, or non-%NULL to report
27981 * errors. An error can only occur when @exclusive is set to %TRUE
27982 * and not all @max_threads threads could be created.
27984 * Returns: the new #GThreadPool
27989 * g_thread_pool_push:
27990 * @pool: a #GThreadPool
27991 * @data: a new task for @pool
27992 * @error: return location for error, or %NULL
27994 * Inserts @data into the list of tasks to be executed by @pool.
27996 * When the number of currently running threads is lower than the
27997 * maximal allowed number of threads, a new thread is started (or
27998 * reused) with the properties given to g_thread_pool_new().
27999 * Otherwise, @data stays in the queue until a thread in this pool
28000 * finishes its previous task and processes @data.
28002 * @error can be %NULL to ignore errors, or non-%NULL to report
28003 * errors. An error can only occur when a new thread couldn't be
28004 * created. In that case @data is simply appended to the queue of
28007 * Before version 2.32, this function did not return a success status.
28009 * Returns: %TRUE on success, %FALSE if an error occurred
28014 * g_thread_pool_set_max_idle_time:
28015 * @interval: the maximum @interval (in milliseconds) a thread can be idle
28017 * This function will set the maximum @interval that a thread
28018 * waiting in the pool for new tasks can be idle for before
28019 * being stopped. This function is similar to calling
28020 * g_thread_pool_stop_unused_threads() on a regular timeout,
28021 * except this is done on a per thread basis.
28023 * By setting @interval to 0, idle threads will not be stopped.
28025 * The default value is 15000 (15 seconds).
28032 * g_thread_pool_set_max_threads:
28033 * @pool: a #GThreadPool
28034 * @max_threads: a new maximal number of threads for @pool, or -1 for unlimited
28035 * @error: return location for error, or %NULL
28037 * Sets the maximal allowed number of threads for @pool.
28038 * A value of -1 means that the maximal number of threads
28039 * is unlimited. If @pool is an exclusive thread pool, setting
28040 * the maximal number of threads to -1 is not allowed.
28042 * Setting @max_threads to 0 means stopping all work for @pool.
28043 * It is effectively frozen until @max_threads is set to a non-zero
28046 * A thread is never terminated while calling @func, as supplied by
28047 * g_thread_pool_new(). Instead the maximal number of threads only
28048 * has effect for the allocation of new threads in g_thread_pool_push().
28049 * A new thread is allocated, whenever the number of currently
28050 * running threads in @pool is smaller than the maximal number.
28052 * @error can be %NULL to ignore errors, or non-%NULL to report
28053 * errors. An error can only occur when a new thread couldn't be
28056 * Before version 2.32, this function did not return a success status.
28058 * Returns: %TRUE on success, %FALSE if an error occurred
28063 * g_thread_pool_set_max_unused_threads:
28064 * @max_threads: maximal number of unused threads
28066 * Sets the maximal number of unused threads to @max_threads.
28067 * If @max_threads is -1, no limit is imposed on the number
28068 * of unused threads.
28070 * The default value is 2.
28075 * g_thread_pool_set_sort_function:
28076 * @pool: a #GThreadPool
28077 * @func: the #GCompareDataFunc used to sort the list of tasks. This function is passed two tasks. It should return 0 if the order in which they are handled does not matter, a negative value if the first task should be processed before the second or a positive value if the second task should be processed first.
28078 * @user_data: user data passed to @func
28080 * Sets the function used to sort the list of tasks. This allows the
28081 * tasks to be processed by a priority determined by @func, and not
28082 * just in the order in which they were added to the pool.
28084 * Note, if the maximum number of threads is more than 1, the order
28085 * that threads are executed cannot be guaranteed 100%. Threads are
28086 * scheduled by the operating system and are executed at random. It
28087 * cannot be assumed that threads are executed in the order they are
28095 * g_thread_pool_stop_unused_threads:
28097 * Stops all currently unused threads. This does not change the
28098 * maximal number of unused threads. This function can be used to
28099 * regularly stop all unused threads e.g. from g_timeout_add().
28104 * g_thread_pool_unprocessed:
28105 * @pool: a #GThreadPool
28107 * Returns the number of tasks still unprocessed in @pool.
28109 * Returns: the number of unprocessed tasks
28115 * @thread: a #GThread
28117 * Increase the reference count on @thread.
28119 * Returns: a new reference to @thread
28127 * This functions returns the #GThread corresponding to the
28128 * current thread. Note that this function does not increase
28129 * the reference count of the returned struct.
28131 * This function will return a #GThread even for threads that
28132 * were not created by GLib (i.e. those created by other threading
28133 * APIs). This may be useful for thread identification purposes
28134 * (i.e. comparisons) but you must not use GLib functions (such
28135 * as g_thread_join()) on these threads.
28137 * Returns: the #GThread representing the current thread
28142 * g_thread_supported:
28144 * This macro returns %TRUE if the thread system is initialized,
28145 * and %FALSE if it is not.
28147 * For language bindings, g_thread_get_initialized() provides
28148 * the same functionality as a function.
28150 * Returns: %TRUE, if the thread system is initialized
28155 * g_thread_try_new:
28156 * @name: a name for the new thread
28157 * @func: a function to execute in the new thread
28158 * @data: an argument to supply to the new thread
28159 * @error: return location for error, or %NULL
28161 * This function is the same as g_thread_new() except that
28162 * it allows for the possibility of failure.
28164 * If a thread can not be created (due to resource limits),
28165 * @error is set and %NULL is returned.
28167 * Returns: the new #GThread, or %NULL if an error occurred
28174 * @thread: a #GThread
28176 * Decrease the reference count on @thread, possibly freeing all
28177 * resources associated with it.
28179 * Note that each thread holds a reference to its #GThread while
28180 * it is running, so it is safe to drop your own reference to it
28181 * if you don't need it anymore.
28190 * Causes the calling thread to voluntarily relinquish the CPU, so
28191 * that other threads can run.
28193 * This function is often used as a method to make busy wait less evil.
28199 * @time_: a #GTimeVal
28200 * @microseconds: number of microseconds to add to @time
28202 * Adds the given number of microseconds to @time_. @microseconds can
28203 * also be negative to decrease the value of @time_.
28208 * g_time_val_from_iso8601:
28209 * @iso_date: an ISO 8601 encoded date string
28210 * @time_: (out): a #GTimeVal
28212 * Converts a string containing an ISO 8601 encoded date and time
28213 * to a #GTimeVal and puts it into @time_.
28215 * @iso_date must include year, month, day, hours, minutes, and
28216 * seconds. It can optionally include fractions of a second and a time
28217 * zone indicator. (In the absence of any time zone indication, the
28218 * timestamp is assumed to be in local time.)
28220 * Returns: %TRUE if the conversion was successful.
28226 * g_time_val_to_iso8601:
28227 * @time_: a #GTimeVal
28229 * Converts @time_ into an RFC 3339 encoded string, relative to the
28230 * Coordinated Universal Time (UTC). This is one of the many formats
28231 * allowed by ISO 8601.
28233 * ISO 8601 allows a large number of date/time formats, with or without
28234 * punctuation and optional elements. The format returned by this function
28235 * is a complete date and time, with optional punctuation included, the
28236 * UTC time zone represented as "Z", and the @tv_usec part included if
28237 * and only if it is nonzero, i.e. either
28238 * "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
28240 * This corresponds to the Internet date/time format defined by
28241 * <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
28242 * to either of the two most-precise formats defined by
28243 * <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
28244 * "Date and Time Formats"</ulink>. Both of these documents are profiles of
28247 * Use g_date_time_format() or g_strdup_printf() if a different
28248 * variation of ISO 8601 format is required.
28250 * Returns: a newly allocated string containing an ISO 8601 date
28256 * g_time_zone_adjust_time:
28257 * @tz: a #GTimeZone
28258 * @type: the #GTimeType of @time_
28259 * @time_: a pointer to a number of seconds since January 1, 1970
28261 * Finds an interval within @tz that corresponds to the given @time_,
28262 * possibly adjusting @time_ if required to fit into an interval.
28263 * The meaning of @time_ depends on @type.
28265 * This function is similar to g_time_zone_find_interval(), with the
28266 * difference that it always succeeds (by making the adjustments
28267 * described below).
28269 * In any of the cases where g_time_zone_find_interval() succeeds then
28270 * this function returns the same value, without modifying @time_.
28272 * This function may, however, modify @time_ in order to deal with
28273 * non-existent times. If the non-existent local @time_ of 02:30 were
28274 * requested on March 14th 2010 in Toronto then this function would
28275 * adjust @time_ to be 03:00 and return the interval containing the
28278 * Returns: the interval containing @time_, never -1
28284 * g_time_zone_find_interval:
28285 * @tz: a #GTimeZone
28286 * @type: the #GTimeType of @time_
28287 * @time_: a number of seconds since January 1, 1970
28289 * Finds an the interval within @tz that corresponds to the given @time_.
28290 * The meaning of @time_ depends on @type.
28292 * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
28293 * succeed (since universal time is monotonic and continuous).
28295 * Otherwise @time_ is treated is local time. The distinction between
28296 * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
28297 * the case that the given @time_ is ambiguous. In Toronto, for example,
28298 * 01:30 on November 7th 2010 occurred twice (once inside of daylight
28299 * savings time and the next, an hour later, outside of daylight savings
28300 * time). In this case, the different value of @type would result in a
28301 * different interval being returned.
28303 * It is still possible for this function to fail. In Toronto, for
28304 * example, 02:00 on March 14th 2010 does not exist (due to the leap
28305 * forward to begin daylight savings time). -1 is returned in that
28308 * Returns: the interval containing @time_, or -1 in case of failure
28314 * g_time_zone_get_abbreviation:
28315 * @tz: a #GTimeZone
28316 * @interval: an interval within the timezone
28318 * Determines the time zone abbreviation to be used during a particular
28319 * @interval of time in the time zone @tz.
28321 * For example, in Toronto this is currently "EST" during the winter
28322 * months and "EDT" during the summer months when daylight savings time
28325 * Returns: the time zone abbreviation, which belongs to @tz
28331 * g_time_zone_get_offset:
28332 * @tz: a #GTimeZone
28333 * @interval: an interval within the timezone
28335 * Determines the offset to UTC in effect during a particular @interval
28336 * of time in the time zone @tz.
28338 * The offset is the number of seconds that you add to UTC time to
28339 * arrive at local time for @tz (ie: negative numbers for time zones
28340 * west of GMT, positive numbers for east).
28342 * Returns: the number of seconds that should be added to UTC to get the local time in @tz
28348 * g_time_zone_is_dst:
28349 * @tz: a #GTimeZone
28350 * @interval: an interval within the timezone
28352 * Determines if daylight savings time is in effect during a particular
28353 * @interval of time in the time zone @tz.
28355 * Returns: %TRUE if daylight savings time is in effect
28362 * @identifier: (allow-none): a timezone identifier
28364 * Creates a #GTimeZone corresponding to @identifier.
28366 * @identifier can either be an RFC3339/ISO 8601 time offset or
28367 * something that would pass as a valid value for the
28368 * <varname>TZ</varname> environment variable (including %NULL).
28370 * Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
28371 * <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
28372 * <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.
28374 * The <varname>TZ</varname> environment variable typically corresponds
28375 * to the name of a file in the zoneinfo database, but there are many
28376 * other possibilities. Note that those other possibilities are not
28377 * currently implemented, but are planned.
28379 * g_time_zone_new_local() calls this function with the value of the
28380 * <varname>TZ</varname> environment variable. This function itself is
28381 * independent of the value of <varname>TZ</varname>, but if @identifier
28382 * is %NULL then <filename>/etc/localtime</filename> will be consulted
28383 * to discover the correct timezone.
28386 * url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
28387 * §5.6</ulink> for a precise definition of valid RFC3339 time offsets
28388 * (the <varname>time-offset</varname> expansion) and ISO 8601 for the
28389 * full list of valid time offsets. See <ulink
28390 * url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
28391 * GNU C Library manual</ulink> for an explanation of the possible
28392 * values of the <varname>TZ</varname> environment variable.
28394 * You should release the return value by calling g_time_zone_unref()
28395 * when you are done with it.
28397 * Returns: the requested timezone
28403 * g_time_zone_new_local:
28405 * Creates a #GTimeZone corresponding to local time. The local time
28406 * zone may change between invocations to this function; for example,
28407 * if the system administrator changes it.
28409 * This is equivalent to calling g_time_zone_new() with the value of the
28410 * <varname>TZ</varname> environment variable (including the possibility
28413 * You should release the return value by calling g_time_zone_unref()
28414 * when you are done with it.
28416 * Returns: the local timezone
28422 * g_time_zone_new_utc:
28424 * Creates a #GTimeZone corresponding to UTC.
28426 * This is equivalent to calling g_time_zone_new() with a value like
28427 * "Z", "UTC", "+00", etc.
28429 * You should release the return value by calling g_time_zone_unref()
28430 * when you are done with it.
28432 * Returns: the universal timezone
28439 * @tz: a #GTimeZone
28441 * Increases the reference count on @tz.
28443 * Returns: a new reference to @tz.
28449 * g_time_zone_unref:
28450 * @tz: a #GTimeZone
28452 * Decreases the reference count on @tz.
28460 * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
28461 * @function: function to call
28462 * @data: data to pass to @function
28464 * Sets a function to be called at regular intervals, with the default
28465 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
28466 * until it returns %FALSE, at which point the timeout is automatically
28467 * destroyed and the function will not be called again. The first call
28468 * to the function will be at the end of the first @interval.
28470 * Note that timeout functions may be delayed, due to the processing of other
28471 * event sources. Thus they should not be relied on for precise timing.
28472 * After each call to the timeout function, the time of the next
28473 * timeout is recalculated based on the current time and the given interval
28474 * (it does not try to 'catch up' time lost in delays).
28476 * If you want to have a timer in the "seconds" range and do not care
28477 * about the exact time of the first call of the timer, use the
28478 * g_timeout_add_seconds() function; this function allows for more
28479 * optimizations and more efficient system power usage.
28481 * This internally creates a main loop source using g_timeout_source_new()
28482 * and attaches it to the main loop context using g_source_attach(). You can
28483 * do these steps manually if you need greater control.
28485 * The interval given is in terms of monotonic time, not wall clock
28486 * time. See g_get_monotonic_time().
28488 * Returns: the ID (greater than 0) of the event source.
28493 * g_timeout_add_full:
28494 * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
28495 * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
28496 * @function: function to call
28497 * @data: data to pass to @function
28498 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
28500 * Sets a function to be called at regular intervals, with the given
28501 * priority. The function is called repeatedly until it returns
28502 * %FALSE, at which point the timeout is automatically destroyed and
28503 * the function will not be called again. The @notify function is
28504 * called when the timeout is destroyed. The first call to the
28505 * function will be at the end of the first @interval.
28507 * Note that timeout functions may be delayed, due to the processing of other
28508 * event sources. Thus they should not be relied on for precise timing.
28509 * After each call to the timeout function, the time of the next
28510 * timeout is recalculated based on the current time and the given interval
28511 * (it does not try to 'catch up' time lost in delays).
28513 * This internally creates a main loop source using g_timeout_source_new()
28514 * and attaches it to the main loop context using g_source_attach(). You can
28515 * do these steps manually if you need greater control.
28517 * The interval given in terms of monotonic time, not wall clock time.
28518 * See g_get_monotonic_time().
28520 * Returns: the ID (greater than 0) of the event source.
28521 * Rename to: g_timeout_add
28526 * g_timeout_add_seconds:
28527 * @interval: the time between calls to the function, in seconds
28528 * @function: function to call
28529 * @data: data to pass to @function
28531 * Sets a function to be called at regular intervals with the default
28532 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
28533 * it returns %FALSE, at which point the timeout is automatically destroyed
28534 * and the function will not be called again.
28536 * This internally creates a main loop source using
28537 * g_timeout_source_new_seconds() and attaches it to the main loop context
28538 * using g_source_attach(). You can do these steps manually if you need
28539 * greater control. Also see g_timeout_add_seconds_full().
28541 * Note that the first call of the timer may not be precise for timeouts
28542 * of one second. If you need finer precision and have such a timeout,
28543 * you may want to use g_timeout_add() instead.
28545 * The interval given is in terms of monotonic time, not wall clock
28546 * time. See g_get_monotonic_time().
28548 * Returns: the ID (greater than 0) of the event source.
28554 * g_timeout_add_seconds_full:
28555 * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
28556 * @interval: the time between calls to the function, in seconds
28557 * @function: function to call
28558 * @data: data to pass to @function
28559 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
28561 * Sets a function to be called at regular intervals, with @priority.
28562 * The function is called repeatedly until it returns %FALSE, at which
28563 * point the timeout is automatically destroyed and the function will
28564 * not be called again.
28566 * Unlike g_timeout_add(), this function operates at whole second granularity.
28567 * The initial starting point of the timer is determined by the implementation
28568 * and the implementation is expected to group multiple timers together so that
28569 * they fire all at the same time.
28570 * To allow this grouping, the @interval to the first timer is rounded
28571 * and can deviate up to one second from the specified interval.
28572 * Subsequent timer iterations will generally run at the specified interval.
28574 * Note that timeout functions may be delayed, due to the processing of other
28575 * event sources. Thus they should not be relied on for precise timing.
28576 * After each call to the timeout function, the time of the next
28577 * timeout is recalculated based on the current time and the given @interval
28579 * If you want timing more precise than whole seconds, use g_timeout_add()
28582 * The grouping of timers to fire at the same time results in a more power
28583 * and CPU efficient behavior so if your timer is in multiples of seconds
28584 * and you don't require the first timer exactly one second from now, the
28585 * use of g_timeout_add_seconds() is preferred over g_timeout_add().
28587 * This internally creates a main loop source using
28588 * g_timeout_source_new_seconds() and attaches it to the main loop context
28589 * using g_source_attach(). You can do these steps manually if you need
28592 * The interval given is in terms of monotonic time, not wall clock
28593 * time. See g_get_monotonic_time().
28595 * Returns: the ID (greater than 0) of the event source.
28596 * Rename to: g_timeout_add_seconds
28602 * g_timeout_source_new:
28603 * @interval: the timeout interval in milliseconds.
28605 * Creates a new timeout source.
28607 * The source will not initially be associated with any #GMainContext
28608 * and must be added to one with g_source_attach() before it will be
28611 * The interval given is in terms of monotonic time, not wall clock
28612 * time. See g_get_monotonic_time().
28614 * Returns: the newly-created timeout source
28619 * g_timeout_source_new_seconds:
28620 * @interval: the timeout interval in seconds
28622 * Creates a new timeout source.
28624 * The source will not initially be associated with any #GMainContext
28625 * and must be added to one with g_source_attach() before it will be
28628 * The scheduling granularity/accuracy of this timeout source will be
28631 * The interval given in terms of monotonic time, not wall clock time.
28632 * See g_get_monotonic_time().
28634 * Returns: the newly-created timeout source
28640 * g_timer_continue:
28641 * @timer: a #GTimer.
28643 * Resumes a timer that has previously been stopped with
28644 * g_timer_stop(). g_timer_stop() must be called before using this
28653 * @timer: a #GTimer to destroy.
28655 * Destroys a timer, freeing associated resources.
28661 * @timer: a #GTimer.
28662 * @microseconds: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
28664 * If @timer has been started but not stopped, obtains the time since
28665 * the timer was started. If @timer has been stopped, obtains the
28666 * elapsed time between the time it was started and the time it was
28667 * stopped. The return value is the number of seconds elapsed,
28668 * including any fractional part. The @microseconds out parameter is
28669 * essentially useless.
28671 * Returns: seconds elapsed as a floating point value, including any fractional part.
28678 * Creates a new timer, and starts timing (i.e. g_timer_start() is
28679 * implicitly called for you).
28681 * Returns: a new #GTimer.
28687 * @timer: a #GTimer.
28689 * This function is useless; it's fine to call g_timer_start() on an
28690 * already-started timer to reset the start time, so g_timer_reset()
28691 * serves no purpose.
28697 * @timer: a #GTimer.
28699 * Marks a start time, so that future calls to g_timer_elapsed() will
28700 * report the time since g_timer_start() was called. g_timer_new()
28701 * automatically marks the start time, so no need to call
28702 * g_timer_start() immediately after creating the timer.
28708 * @timer: a #GTimer.
28710 * Marks an end time, so calls to g_timer_elapsed() will return the
28711 * difference between this end time and the start time.
28716 * g_trash_stack_height:
28717 * @stack_p: a #GTrashStack
28719 * Returns the height of a #GTrashStack.
28721 * Note that execution of this function is of O(N) complexity
28722 * where N denotes the number of items on the stack.
28724 * Returns: the height of the stack
28729 * g_trash_stack_peek:
28730 * @stack_p: a #GTrashStack
28732 * Returns the element at the top of a #GTrashStack
28733 * which may be %NULL.
28735 * Returns: the element at the top of the stack
28740 * g_trash_stack_pop:
28741 * @stack_p: a #GTrashStack
28743 * Pops a piece of memory off a #GTrashStack.
28745 * Returns: the element at the top of the stack
28750 * g_trash_stack_push:
28751 * @stack_p: a #GTrashStack
28752 * @data_p: the piece of memory to push on the stack
28754 * Pushes a piece of memory onto a #GTrashStack.
28762 * Removes all keys and values from the #GTree and decreases its
28763 * reference count by one. If keys and/or values are dynamically
28764 * allocated, you should either free them first or create the #GTree
28765 * using g_tree_new_full(). In the latter case the destroy functions
28766 * you supplied will be called on all keys and values before destroying
28774 * @func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
28775 * @user_data: user data to pass to the function.
28777 * Calls the given function for each of the key/value pairs in the #GTree.
28778 * The function is passed the key and value of each pair, and the given
28779 * @data parameter. The tree is traversed in sorted order.
28781 * The tree may not be modified while iterating over it (you can't
28782 * add/remove items). To remove all items matching a predicate, you need
28783 * to add each item to a list in your #GTraverseFunc as you walk over
28784 * the tree, then walk the list and remove each item.
28792 * Gets the height of a #GTree.
28794 * If the #GTree contains no nodes, the height is 0.
28795 * If the #GTree contains only one root node the height is 1.
28796 * If the root node has children the height is 2, etc.
28798 * Returns: the height of the #GTree.
28805 * @key: the key to insert.
28806 * @value: the value corresponding to the key.
28808 * Inserts a key/value pair into a #GTree. If the given key already exists
28809 * in the #GTree its corresponding value is set to the new value. If you
28810 * supplied a value_destroy_func when creating the #GTree, the old value is
28811 * freed using that function. If you supplied a @key_destroy_func when
28812 * creating the #GTree, the passed key is freed using that function.
28814 * The tree is automatically 'balanced' as new key/value pairs are added,
28815 * so that the distance from the root to every leaf is as small as possible.
28822 * @key: the key to look up.
28824 * Gets the value corresponding to the given key. Since a #GTree is
28825 * automatically balanced as key/value pairs are added, key lookup is very
28828 * Returns: the value corresponding to the key, or %NULL if the key was not found.
28833 * g_tree_lookup_extended:
28835 * @lookup_key: the key to look up.
28836 * @orig_key: returns the original key.
28837 * @value: returns the value associated with the key.
28839 * Looks up a key in the #GTree, returning the original key and the
28840 * associated value and a #gboolean which is %TRUE if the key was found. This
28841 * is useful if you need to free the memory allocated for the original key,
28842 * for example before calling g_tree_remove().
28844 * Returns: %TRUE if the key was found in the #GTree.
28850 * @key_compare_func: the function used to order the nodes in the #GTree. It should return values similar to the standard strcmp() function - 0 if the two arguments are equal, a negative value if the first argument comes before the second, or a positive value if the first argument comes after the second.
28852 * Creates a new #GTree.
28854 * Returns: a new #GTree.
28860 * @key_compare_func: qsort()-style comparison function.
28861 * @key_compare_data: data to pass to comparison function.
28862 * @key_destroy_func: a function to free the memory allocated for the key used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
28863 * @value_destroy_func: a function to free the memory allocated for the value used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
28865 * Creates a new #GTree like g_tree_new() and allows to specify functions
28866 * to free the memory allocated for the key and value that get called when
28867 * removing the entry from the #GTree.
28869 * Returns: a new #GTree.
28874 * g_tree_new_with_data:
28875 * @key_compare_func: qsort()-style comparison function.
28876 * @key_compare_data: data to pass to comparison function.
28878 * Creates a new #GTree with a comparison function that accepts user data.
28879 * See g_tree_new() for more details.
28881 * Returns: a new #GTree.
28889 * Gets the number of nodes in a #GTree.
28891 * Returns: the number of nodes in the #GTree.
28899 * Increments the reference count of @tree by one. It is safe to call
28900 * this function from any thread.
28902 * Returns: the passed in #GTree.
28910 * @key: the key to remove.
28912 * Removes a key/value pair from a #GTree.
28914 * If the #GTree was created using g_tree_new_full(), the key and value
28915 * are freed using the supplied destroy functions, otherwise you have to
28916 * make sure that any dynamically allocated values are freed yourself.
28917 * If the key does not exist in the #GTree, the function does nothing.
28919 * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
28926 * @key: the key to insert.
28927 * @value: the value corresponding to the key.
28929 * Inserts a new key and value into a #GTree similar to g_tree_insert().
28930 * The difference is that if the key already exists in the #GTree, it gets
28931 * replaced by the new key. If you supplied a @value_destroy_func when
28932 * creating the #GTree, the old value is freed using that function. If you
28933 * supplied a @key_destroy_func when creating the #GTree, the old key is
28934 * freed using that function.
28936 * The tree is automatically 'balanced' as new key/value pairs are added,
28937 * so that the distance from the root to every leaf is as small as possible.
28944 * @search_func: a function used to search the #GTree
28945 * @user_data: the data passed as the second argument to @search_func
28947 * Searches a #GTree using @search_func.
28949 * The @search_func is called with a pointer to the key of a key/value
28950 * pair in the tree, and the passed in @user_data. If @search_func returns
28951 * 0 for a key/value pair, then the corresponding value is returned as
28952 * the result of g_tree_search(). If @search_func returns -1, searching
28953 * will proceed among the key/value pairs that have a smaller key; if
28954 * @search_func returns 1, searching will proceed among the key/value
28955 * pairs that have a larger key.
28957 * Returns: the value corresponding to the found key, or %NULL if the key was not found.
28964 * @key: the key to remove.
28966 * Removes a key and its associated value from a #GTree without calling
28967 * the key and value destroy functions.
28969 * If the key does not exist in the #GTree, the function does nothing.
28971 * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
28978 * @traverse_func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
28979 * @traverse_type: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
28980 * @user_data: user data to pass to the function.
28982 * Calls the given function for each node in the #GTree.
28984 * Deprecated: 2.2: The order of a balanced tree is somewhat arbitrary. If you just want to visit all nodes in sorted order, use g_tree_foreach() instead. If you really need to visit nodes in a different order, consider using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
28992 * Decrements the reference count of @tree by one. If the reference count
28993 * drops to 0, all keys and values will be destroyed (if destroy
28994 * functions were specified) and all memory allocated by @tree will be
28997 * It is safe to call this function from any thread.
29005 * @n_bytes: number of bytes to allocate.
29007 * Attempts to allocate @n_bytes, and returns %NULL on failure.
29008 * Contrast with g_malloc(), which aborts the program on failure.
29010 * Returns: the allocated memory, or %NULL.
29016 * @n_bytes: number of bytes to allocate
29018 * Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
29019 * failure. Contrast with g_malloc0(), which aborts the program on failure.
29022 * Returns: the allocated memory, or %NULL
29028 * @n_blocks: the number of blocks to allocate
29029 * @n_block_bytes: the size of each block in bytes
29031 * This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
29032 * but care is taken to detect possible overflow during multiplication.
29035 * Returns: the allocated memory, or %NULL
29041 * @n_blocks: the number of blocks to allocate
29042 * @n_block_bytes: the size of each block in bytes
29044 * This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29045 * but care is taken to detect possible overflow during multiplication.
29048 * Returns: the allocated memory, or %NULL.
29054 * @mem: (allow-none): previously-allocated memory, or %NULL.
29055 * @n_bytes: number of bytes to allocate.
29057 * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
29058 * on failure. Contrast with g_realloc(), which aborts the program
29059 * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
29061 * Returns: the allocated memory, or %NULL.
29067 * @mem: (allow-none): previously-allocated memory, or %NULL.
29068 * @n_blocks: the number of blocks to allocate
29069 * @n_block_bytes: the size of each block in bytes
29071 * This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29072 * but care is taken to detect possible overflow during multiplication.
29075 * Returns: the allocated memory, or %NULL.
29081 * @str: a UCS-4 encoded string
29082 * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29083 * @items_read: (allow-none): location to store number of bytes read, or %NULL. If an error occurs then the index of the invalid input is stored here.
29084 * @items_written: (allow-none): location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
29085 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29087 * Convert a string from UCS-4 to UTF-16. A 0 character will be
29088 * added to the result after the converted text.
29090 * Returns: a pointer to a newly allocated UTF-16 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
29096 * @str: a UCS-4 encoded string
29097 * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29098 * @items_read: (allow-none): location to store number of characters read, or %NULL.
29099 * @items_written: (allow-none): location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
29100 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29102 * Convert a string from a 32-bit fixed width representation as UCS-4.
29103 * to UTF-8. The result will be terminated with a 0 byte.
29105 * Returns: a pointer to a newly allocated UTF-8 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set. In that case, @items_read will be set to the position of the first invalid input character.
29110 * g_unichar_break_type:
29111 * @c: a Unicode character
29113 * Determines the break type of @c. @c should be a Unicode character
29114 * (to derive a character from UTF-8 encoded text, use
29115 * g_utf8_get_char()). The break type is used to find word and line
29116 * breaks ("text boundaries"), Pango implements the Unicode boundary
29117 * resolution algorithms and normally you would use a function such
29118 * as pango_break() instead of caring about break types yourself.
29120 * Returns: the break type of @c
29125 * g_unichar_combining_class:
29126 * @uc: a Unicode character
29128 * Determines the canonical combining class of a Unicode character.
29130 * Returns: the combining class of the character
29136 * g_unichar_compose:
29137 * @a: a Unicode character
29138 * @b: a Unicode character
29139 * @ch: return location for the composed character
29141 * Performs a single composition step of the
29142 * Unicode canonical composition algorithm.
29144 * This function includes algorithmic Hangul Jamo composition,
29145 * but it is not exactly the inverse of g_unichar_decompose().
29146 * No composition can have either of @a or @b equal to zero.
29147 * To be precise, this function composes if and only if
29148 * there exists a Primary Composite P which is canonically
29149 * equivalent to the sequence <@a,@b>. See the Unicode
29150 * Standard for the definition of Primary Composite.
29152 * If @a and @b do not compose a new character, @ch is set to zero.
29154 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29157 * Returns: %TRUE if the characters could be composed
29163 * g_unichar_decompose:
29164 * @ch: a Unicode character
29165 * @a: return location for the first component of @ch
29166 * @b: return location for the second component of @ch
29168 * Performs a single decomposition step of the
29169 * Unicode canonical decomposition algorithm.
29171 * This function does not include compatibility
29172 * decompositions. It does, however, include algorithmic
29173 * Hangul Jamo decomposition, as well as 'singleton'
29174 * decompositions which replace a character by a single
29175 * other character. In the case of singletons *@b will
29178 * If @ch is not decomposable, *@a is set to @ch and *@b
29181 * Note that the way Unicode decomposition pairs are
29182 * defined, it is guaranteed that @b would not decompose
29183 * further, but @a may itself decompose. To get the full
29184 * canonical decomposition for @ch, one would need to
29185 * recursively call this function on @a. Or use
29186 * g_unichar_fully_decompose().
29188 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29191 * Returns: %TRUE if the character could be decomposed
29197 * g_unichar_digit_value:
29198 * @c: a Unicode character
29200 * Determines the numeric value of a character as a decimal
29203 * Returns: If @c is a decimal digit (according to g_unichar_isdigit()), its numeric value. Otherwise, -1.
29208 * g_unichar_fully_decompose:
29209 * @ch: a Unicode character.
29210 * @compat: whether perform canonical or compatibility decomposition
29211 * @result: (allow-none): location to store decomposed result, or %NULL
29212 * @result_len: length of @result
29214 * Computes the canonical or compatibility decomposition of a
29215 * Unicode character. For compatibility decomposition,
29216 * pass %TRUE for @compat; for canonical decomposition
29217 * pass %FALSE for @compat.
29219 * The decomposed sequence is placed in @result. Only up to
29220 * @result_len characters are written into @result. The length
29221 * of the full decomposition (irrespective of @result_len) is
29222 * returned by the function. For canonical decomposition,
29223 * currently all decompositions are of length at most 4, but
29224 * this may change in the future (very unlikely though).
29225 * At any rate, Unicode does guarantee that a buffer of length
29226 * 18 is always enough for both compatibility and canonical
29227 * decompositions, so that is the size recommended. This is provided
29228 * as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
29230 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29233 * Returns: the length of the full decomposition.
29239 * g_unichar_get_mirror_char:
29240 * @ch: a Unicode character
29241 * @mirrored_ch: location to store the mirrored character
29243 * In Unicode, some characters are <firstterm>mirrored</firstterm>. This
29244 * means that their images are mirrored horizontally in text that is laid
29245 * out from right to left. For instance, "(" would become its mirror image,
29246 * ")", in right-to-left text.
29248 * If @ch has the Unicode mirrored property and there is another unicode
29249 * character that typically has a glyph that is the mirror image of @ch's
29250 * glyph and @mirrored_ch is set, it puts that character in the address
29251 * pointed to by @mirrored_ch. Otherwise the original character is put.
29253 * Returns: %TRUE if @ch has a mirrored character, %FALSE otherwise
29259 * g_unichar_get_script:
29260 * @ch: a Unicode character
29262 * Looks up the #GUnicodeScript for a particular character (as defined
29263 * by Unicode Standard Annex \#24). No check is made for @ch being a
29264 * valid Unicode character; if you pass in invalid character, the
29265 * result is undefined.
29267 * This function is equivalent to pango_script_for_unichar() and the
29268 * two are interchangeable.
29270 * Returns: the #GUnicodeScript for the character.
29276 * g_unichar_isalnum:
29277 * @c: a Unicode character
29279 * Determines whether a character is alphanumeric.
29280 * Given some UTF-8 text, obtain a character value
29281 * with g_utf8_get_char().
29283 * Returns: %TRUE if @c is an alphanumeric character
29288 * g_unichar_isalpha:
29289 * @c: a Unicode character
29291 * Determines whether a character is alphabetic (i.e. a letter).
29292 * Given some UTF-8 text, obtain a character value with
29293 * g_utf8_get_char().
29295 * Returns: %TRUE if @c is an alphabetic character
29300 * g_unichar_iscntrl:
29301 * @c: a Unicode character
29303 * Determines whether a character is a control character.
29304 * Given some UTF-8 text, obtain a character value with
29305 * g_utf8_get_char().
29307 * Returns: %TRUE if @c is a control character
29312 * g_unichar_isdefined:
29313 * @c: a Unicode character
29315 * Determines if a given character is assigned in the Unicode
29318 * Returns: %TRUE if the character has an assigned value
29323 * g_unichar_isdigit:
29324 * @c: a Unicode character
29326 * Determines whether a character is numeric (i.e. a digit). This
29327 * covers ASCII 0-9 and also digits in other languages/scripts. Given
29328 * some UTF-8 text, obtain a character value with g_utf8_get_char().
29330 * Returns: %TRUE if @c is a digit
29335 * g_unichar_isgraph:
29336 * @c: a Unicode character
29338 * Determines whether a character is printable and not a space
29339 * (returns %FALSE for control characters, format characters, and
29340 * spaces). g_unichar_isprint() is similar, but returns %TRUE for
29341 * spaces. Given some UTF-8 text, obtain a character value with
29342 * g_utf8_get_char().
29344 * Returns: %TRUE if @c is printable unless it's a space
29349 * g_unichar_islower:
29350 * @c: a Unicode character
29352 * Determines whether a character is a lowercase letter.
29353 * Given some UTF-8 text, obtain a character value with
29354 * g_utf8_get_char().
29356 * Returns: %TRUE if @c is a lowercase letter
29361 * g_unichar_ismark:
29362 * @c: a Unicode character
29364 * Determines whether a character is a mark (non-spacing mark,
29365 * combining mark, or enclosing mark in Unicode speak).
29366 * Given some UTF-8 text, obtain a character value
29367 * with g_utf8_get_char().
29369 * Note: in most cases where isalpha characters are allowed,
29370 * ismark characters should be allowed to as they are essential
29371 * for writing most European languages as well as many non-Latin
29374 * Returns: %TRUE if @c is a mark character
29380 * g_unichar_isprint:
29381 * @c: a Unicode character
29383 * Determines whether a character is printable.
29384 * Unlike g_unichar_isgraph(), returns %TRUE for spaces.
29385 * Given some UTF-8 text, obtain a character value with
29386 * g_utf8_get_char().
29388 * Returns: %TRUE if @c is printable
29393 * g_unichar_ispunct:
29394 * @c: a Unicode character
29396 * Determines whether a character is punctuation or a symbol.
29397 * Given some UTF-8 text, obtain a character value with
29398 * g_utf8_get_char().
29400 * Returns: %TRUE if @c is a punctuation or symbol character
29405 * g_unichar_isspace:
29406 * @c: a Unicode character
29408 * Determines whether a character is a space, tab, or line separator
29409 * (newline, carriage return, etc.). Given some UTF-8 text, obtain a
29410 * character value with g_utf8_get_char().
29412 * (Note: don't use this to do word breaking; you have to use
29413 * Pango or equivalent to get word breaking right, the algorithm
29414 * is fairly complex.)
29416 * Returns: %TRUE if @c is a space character
29421 * g_unichar_istitle:
29422 * @c: a Unicode character
29424 * Determines if a character is titlecase. Some characters in
29425 * Unicode which are composites, such as the DZ digraph
29426 * have three case variants instead of just two. The titlecase
29427 * form is used at the beginning of a word where only the
29428 * first letter is capitalized. The titlecase form of the DZ
29429 * digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
29431 * Returns: %TRUE if the character is titlecase
29436 * g_unichar_isupper:
29437 * @c: a Unicode character
29439 * Determines if a character is uppercase.
29441 * Returns: %TRUE if @c is an uppercase character
29446 * g_unichar_iswide:
29447 * @c: a Unicode character
29449 * Determines if a character is typically rendered in a double-width
29452 * Returns: %TRUE if the character is wide
29457 * g_unichar_iswide_cjk:
29458 * @c: a Unicode character
29460 * Determines if a character is typically rendered in a double-width
29461 * cell under legacy East Asian locales. If a character is wide according to
29462 * g_unichar_iswide(), then it is also reported wide with this function, but
29463 * the converse is not necessarily true. See the
29464 * <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
29465 * Annex #11</ulink> for details.
29467 * If a character passes the g_unichar_iswide() test then it will also pass
29468 * this test, but not the other way around. Note that some characters may
29469 * pas both this test and g_unichar_iszerowidth().
29471 * Returns: %TRUE if the character is wide in legacy East Asian locales
29477 * g_unichar_isxdigit:
29478 * @c: a Unicode character.
29480 * Determines if a character is a hexidecimal digit.
29482 * Returns: %TRUE if the character is a hexadecimal digit
29487 * g_unichar_iszerowidth:
29488 * @c: a Unicode character
29490 * Determines if a given character typically takes zero width when rendered.
29491 * The return value is %TRUE for all non-spacing and enclosing marks
29492 * (e.g., combining accents), format characters, zero-width
29493 * space, but not U+00AD SOFT HYPHEN.
29495 * A typical use of this function is with one of g_unichar_iswide() or
29496 * g_unichar_iswide_cjk() to determine the number of cells a string occupies
29497 * when displayed on a grid display (terminals). However, note that not all
29498 * terminals support zero-width rendering of zero-width marks.
29500 * Returns: %TRUE if the character has zero width
29506 * g_unichar_to_utf8:
29507 * @c: a Unicode character code
29508 * @outbuf: output buffer, must have at least 6 bytes of space. If %NULL, the length will be computed and returned and nothing will be written to @outbuf.
29510 * Converts a single character to UTF-8.
29512 * Returns: number of bytes written
29517 * g_unichar_tolower:
29518 * @c: a Unicode character.
29520 * Converts a character to lower case.
29522 * Returns: the result of converting @c to lower case. If @c is not an upperlower or titlecase character, or has no lowercase equivalent @c is returned unchanged.
29527 * g_unichar_totitle:
29528 * @c: a Unicode character
29530 * Converts a character to the titlecase.
29532 * Returns: the result of converting @c to titlecase. If @c is not an uppercase or lowercase character, @c is returned unchanged.
29537 * g_unichar_toupper:
29538 * @c: a Unicode character
29540 * Converts a character to uppercase.
29542 * Returns: the result of converting @c to uppercase. If @c is not an lowercase or titlecase character, or has no upper case equivalent @c is returned unchanged.
29548 * @c: a Unicode character
29550 * Classifies a Unicode character by type.
29552 * Returns: the type of the character.
29557 * g_unichar_validate:
29558 * @ch: a Unicode character
29560 * Checks whether @ch is a valid Unicode character. Some possible
29561 * integer values of @ch will not be valid. 0 is considered a valid
29562 * character, though it's normally a string terminator.
29564 * Returns: %TRUE if @ch is a valid Unicode character
29569 * g_unichar_xdigit_value:
29570 * @c: a Unicode character
29572 * Determines the numeric value of a character as a hexidecimal
29575 * Returns: If @c is a hex digit (according to g_unichar_isxdigit()), its numeric value. Otherwise, -1.
29580 * g_unicode_canonical_decomposition:
29581 * @ch: a Unicode character.
29582 * @result_len: location to store the length of the return value.
29584 * Computes the canonical decomposition of a Unicode character.
29586 * Returns: a newly allocated string of Unicode characters. @result_len is set to the resulting length of the string.
29587 * Deprecated: 2.30: Use the more flexible g_unichar_fully_decompose() instead.
29592 * g_unicode_canonical_ordering:
29593 * @string: a UCS-4 encoded string.
29594 * @len: the maximum length of @string to use.
29596 * Computes the canonical ordering of a string in-place.
29597 * This rearranges decomposed characters in the string
29598 * according to their combining classes. See the Unicode
29599 * manual for more information.
29604 * g_unicode_script_from_iso15924:
29605 * @iso15924: a Unicode script
29607 * Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
29608 * codes to scripts. For example, the code for Arabic is 'Arab'.
29609 * This function accepts four letter codes encoded as a @guint32 in a
29610 * big-endian fashion. That is, the code expected for Arabic is
29611 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
29613 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
29614 * representation of names of scripts</ulink> for details.
29616 * Returns: the Unicode script for @iso15924, or of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
29622 * g_unicode_script_to_iso15924:
29623 * @script: a Unicode script
29625 * Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
29626 * codes to scripts. For example, the code for Arabic is 'Arab'. The
29627 * four letter codes are encoded as a @guint32 by this function in a
29628 * big-endian fashion. That is, the code returned for Arabic is
29629 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
29631 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
29632 * representation of names of scripts</ulink> for details.
29634 * Returns: the ISO 15924 code for @script, encoded as an integer, of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
29640 * g_unix_open_pipe:
29641 * @fds: Array of two integers
29642 * @flags: Bitfield of file descriptor flags, see "man 2 fcntl"
29643 * @error: a #GError
29645 * Similar to the UNIX pipe() call, but on modern systems like Linux
29646 * uses the pipe2() system call, which atomically creates a pipe with
29647 * the configured flags. The only supported flag currently is
29648 * <literal>FD_CLOEXEC</literal>. If for example you want to configure
29649 * <literal>O_NONBLOCK</literal>, that must still be done separately with
29652 * <note>This function does *not* take <literal>O_CLOEXEC</literal>, it takes
29653 * <literal>FD_CLOEXEC</literal> as if for fcntl(); these are
29654 * different on Linux/glibc.</note>
29656 * Returns: %TRUE on success, %FALSE if not (and errno will be set).
29662 * g_unix_set_fd_nonblocking:
29663 * @fd: A file descriptor
29664 * @nonblock: If %TRUE, set the descriptor to be non-blocking
29665 * @error: a #GError
29667 * Control the non-blocking state of the given file descriptor,
29668 * according to @nonblock. On most systems this uses <literal>O_NONBLOCK</literal>, but
29669 * on some older ones may use <literal>O_NDELAY</literal>.
29671 * Returns: %TRUE if successful
29677 * g_unix_signal_add:
29678 * @signum: Signal number
29679 * @handler: Callback
29680 * @user_data: Data for @handler
29682 * A convenience function for g_unix_signal_source_new(), which
29683 * attaches to the default #GMainContext. You can remove the watch
29684 * using g_source_remove().
29686 * Returns: An ID (greater than 0) for the event source
29692 * g_unix_signal_add_full:
29693 * @priority: the priority of the signal source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
29694 * @signum: Signal number
29695 * @handler: Callback
29696 * @user_data: Data for @handler
29697 * @notify: #GDestroyNotify for @handler
29699 * A convenience function for g_unix_signal_source_new(), which
29700 * attaches to the default #GMainContext. You can remove the watch
29701 * using g_source_remove().
29703 * Returns: An ID (greater than 0) for the event source
29709 * g_unix_signal_source_new:
29710 * @signum: A signal number
29712 * Create a #GSource that will be dispatched upon delivery of the UNIX
29713 * signal @signum. Currently only <literal>SIGHUP</literal>,
29714 * <literal>SIGINT</literal>, and <literal>SIGTERM</literal> can
29715 * be monitored. Note that unlike the UNIX default, all sources which
29716 * have created a watch will be dispatched, regardless of which
29717 * underlying thread invoked g_unix_signal_source_new().
29719 * For example, an effective use of this function is to handle <literal>SIGTERM</literal>
29720 * cleanly; flushing any outstanding files, and then calling
29721 * g_main_loop_quit (). It is not safe to do any of this a regular
29722 * UNIX signal handler; your handler may be invoked while malloc() or
29723 * another library function is running, causing reentrancy if you
29724 * attempt to use it from the handler. None of the GLib/GObject API
29725 * is safe against this kind of reentrancy.
29727 * The interaction of this source when combined with native UNIX
29728 * functions like sigprocmask() is not defined.
29730 * The source will not initially be associated with any #GMainContext
29731 * and must be added to one with g_source_attach() before it will be
29734 * Returns: A newly created #GSource
29741 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
29743 * A wrapper for the POSIX unlink() function. The unlink() function
29744 * deletes a name from the filesystem. If this was the last link to the
29745 * file and no processes have it opened, the diskspace occupied by the
29748 * See your C library manual for more details about unlink(). Note
29749 * that on Windows, it is in general not possible to delete files that
29750 * are open to some process, or mapped into memory.
29752 * Returns: 0 if the name was successfully deleted, -1 if an error occurred
29759 * @variable: the environment variable to remove, must not contain '='
29761 * Removes an environment variable from the environment.
29763 * Note that on some systems, when variables are overwritten, the
29764 * memory used for the previous variables and its value isn't reclaimed.
29767 * Environment variable handling in UNIX is not thread-safe, and your
29768 * program may crash if one thread calls g_unsetenv() while another
29769 * thread is calling getenv(). (And note that many functions, such as
29770 * gettext(), call getenv() internally.) This function is only safe
29771 * to use at the very start of your program, before creating any other
29772 * threads (or creating objects that create worker threads of their
29775 * If you need to set up the environment for a child process, you can
29776 * use g_get_environ() to get an environment array, modify that with
29777 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
29778 * array directly to execvpe(), g_spawn_async(), or the like.
29779 * </para></warning>
29786 * g_uri_escape_string:
29787 * @unescaped: the unescaped input string.
29788 * @reserved_chars_allowed: a string of reserved characters that are allowed to be used, or %NULL.
29789 * @allow_utf8: %TRUE if the result can include UTF-8 characters.
29791 * Escapes a string for use in a URI.
29793 * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
29794 * characters plus dash, dot, underscore and tilde) are escaped.
29795 * But if you specify characters in @reserved_chars_allowed they are not
29796 * escaped. This is useful for the "reserved" characters in the URI
29797 * specification, since those are allowed unescaped in some portions of
29800 * Returns: an escaped version of @unescaped. The returned string should be freed when no longer needed.
29806 * g_uri_list_extract_uris:
29807 * @uri_list: an URI list
29809 * Splits an URI list conforming to the text/uri-list
29810 * mime type defined in RFC 2483 into individual URIs,
29811 * discarding any comments. The URIs are not validated.
29813 * Returns: (transfer full): a newly allocated %NULL-terminated list of strings holding the individual URIs. The array should be freed with g_strfreev().
29819 * g_uri_parse_scheme:
29820 * @uri: a valid URI.
29822 * Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
29824 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
29825 * </programlisting>
29826 * Common schemes include "file", "http", "svn+ssh", etc.
29828 * Returns: The "Scheme" component of the URI, or %NULL on error. The returned string should be freed when no longer needed.
29834 * g_uri_unescape_segment:
29835 * @escaped_string: (allow-none): A string, may be %NULL
29836 * @escaped_string_end: (allow-none): Pointer to end of @escaped_string, may be %NULL
29837 * @illegal_characters: (allow-none): An optional string of illegal characters not to be allowed, may be %NULL
29839 * Unescapes a segment of an escaped string.
29841 * If any of the characters in @illegal_characters or the character zero appears
29842 * as an escaped character in @escaped_string then that is an error and %NULL
29843 * will be returned. This is useful it you want to avoid for instance having a
29844 * slash being expanded in an escaped path element, which might confuse pathname
29847 * Returns: an unescaped version of @escaped_string or %NULL on error. The returned string should be freed when no longer needed. As a special case if %NULL is given for @escaped_string, this function will return %NULL.
29853 * g_uri_unescape_string:
29854 * @escaped_string: an escaped string to be unescaped.
29855 * @illegal_characters: an optional string of illegal characters not to be allowed.
29857 * Unescapes a whole escaped string.
29859 * If any of the characters in @illegal_characters or the character zero appears
29860 * as an escaped character in @escaped_string then that is an error and %NULL
29861 * will be returned. This is useful it you want to avoid for instance having a
29862 * slash being expanded in an escaped path element, which might confuse pathname
29865 * Returns: an unescaped version of @escaped_string. The returned string should be freed when no longer needed.
29872 * @microseconds: number of microseconds to pause
29874 * Pauses the current thread for the given number of microseconds.
29876 * There are 1 million microseconds per second (represented by the
29877 * #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
29878 * depending on hardware and operating system; don't rely on the exact
29879 * length of the sleep.
29885 * @str: a UTF-16 encoded string
29886 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
29887 * @items_read: (allow-none): location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
29888 * @items_written: (allow-none): location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
29889 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29891 * Convert a string from UTF-16 to UCS-4. The result will be
29894 * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
29900 * @str: a UTF-16 encoded string
29901 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
29902 * @items_read: (allow-none): location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
29903 * @items_written: (allow-none): location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
29904 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29906 * Convert a string from UTF-16 to UTF-8. The result will be
29907 * terminated with a 0 byte.
29909 * Note that the input is expected to be already in native endianness,
29910 * an initial byte-order-mark character is not handled specially.
29911 * g_convert() can be used to convert a byte buffer of UTF-16 data of
29912 * ambiguous endianess.
29914 * Further note that this function does not validate the result
29915 * string; it may e.g. include embedded NUL characters. The only
29916 * validation done by this function is to ensure that the input can
29917 * be correctly interpreted as UTF-16, i.e. it doesn't contain
29918 * things unpaired surrogates.
29920 * Returns: a pointer to a newly allocated UTF-8 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
29926 * @str: a UTF-8 encoded string
29927 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
29929 * Converts a string into a form that is independent of case. The
29930 * result will not correspond to any particular case, but can be
29931 * compared for equality or ordered with the results of calling
29932 * g_utf8_casefold() on other strings.
29934 * Note that calling g_utf8_casefold() followed by g_utf8_collate() is
29935 * only an approximation to the correct linguistic case insensitive
29936 * ordering, though it is a fairly good one. Getting this exactly
29937 * right would require a more sophisticated collation function that
29938 * takes case sensitivity into account. GLib does not currently
29939 * provide such a function.
29941 * Returns: a newly allocated string, that is a case independent form of @str.
29947 * @str1: a UTF-8 encoded string
29948 * @str2: a UTF-8 encoded string
29950 * Compares two strings for ordering using the linguistically
29951 * correct rules for the <link linkend="setlocale">current locale</link>.
29952 * When sorting a large number of strings, it will be significantly
29953 * faster to obtain collation keys with g_utf8_collate_key() and
29954 * compare the keys with strcmp() when sorting instead of sorting
29955 * the original strings.
29957 * Returns: < 0 if @str1 compares before @str2, 0 if they compare equal, > 0 if @str1 compares after @str2.
29962 * g_utf8_collate_key:
29963 * @str: a UTF-8 encoded string.
29964 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
29966 * Converts a string into a collation key that can be compared
29967 * with other collation keys produced by the same function using
29970 * The results of comparing the collation keys of two strings
29971 * with strcmp() will always be the same as comparing the two
29972 * original keys with g_utf8_collate().
29974 * Note that this function depends on the
29975 * <link linkend="setlocale">current locale</link>.
29977 * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
29982 * g_utf8_collate_key_for_filename:
29983 * @str: a UTF-8 encoded string.
29984 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
29986 * Converts a string into a collation key that can be compared
29987 * with other collation keys produced by the same function using strcmp().
29989 * In order to sort filenames correctly, this function treats the dot '.'
29990 * as a special case. Most dictionary orderings seem to consider it
29991 * insignificant, thus producing the ordering "event.c" "eventgenerator.c"
29992 * "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
29993 * would like to treat numbers intelligently so that "file1" "file10" "file5"
29994 * is sorted as "file1" "file5" "file10".
29996 * Note that this function depends on the
29997 * <link linkend="setlocale">current locale</link>.
29999 * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
30005 * g_utf8_find_next_char:
30006 * @p: a pointer to a position within a UTF-8 encoded string
30007 * @end: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
30009 * Finds the start of the next UTF-8 character in the string after @p.
30011 * @p does not have to be at the beginning of a UTF-8 character. No check
30012 * is made to see if the character found is actually valid other than
30013 * it starts with an appropriate byte.
30015 * Returns: a pointer to the found character or %NULL
30020 * g_utf8_find_prev_char:
30021 * @str: pointer to the beginning of a UTF-8 encoded string
30022 * @p: pointer to some position within @str
30024 * Given a position @p with a UTF-8 encoded string @str, find the start
30025 * of the previous UTF-8 character starting before @p. Returns %NULL if no
30026 * UTF-8 characters are present in @str before @p.
30028 * @p does not have to be at the beginning of a UTF-8 character. No check
30029 * is made to see if the character found is actually valid other than
30030 * it starts with an appropriate byte.
30032 * Returns: a pointer to the found character or %NULL.
30038 * @p: a pointer to Unicode character encoded as UTF-8
30040 * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
30041 * If @p does not point to a valid UTF-8 encoded character, results are
30042 * undefined. If you are not sure that the bytes are complete
30043 * valid Unicode characters, you should use g_utf8_get_char_validated()
30046 * Returns: the resulting character
30051 * g_utf8_get_char_validated:
30052 * @p: a pointer to Unicode character encoded as UTF-8
30053 * @max_len: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
30055 * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
30056 * This function checks for incomplete characters, for invalid characters
30057 * such as characters that are out of the range of Unicode, and for
30058 * overlong encodings of valid characters.
30060 * Returns: the resulting character. If @p points to a partial sequence at the end of a string that could begin a valid character (or if @max_len is zero), returns (gunichar)-2; otherwise, if @p does not point to a valid UTF-8 encoded Unicode character, returns (gunichar)-1.
30065 * g_utf8_normalize:
30066 * @str: a UTF-8 encoded string.
30067 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30068 * @mode: the type of normalization to perform.
30070 * Converts a string into canonical form, standardizing
30071 * such issues as whether a character with an accent
30072 * is represented as a base character and combining
30073 * accent or as a single precomposed character. The
30074 * string has to be valid UTF-8, otherwise %NULL is
30075 * returned. You should generally call g_utf8_normalize()
30076 * before comparing two Unicode strings.
30078 * The normalization mode %G_NORMALIZE_DEFAULT only
30079 * standardizes differences that do not affect the
30080 * text content, such as the above-mentioned accent
30081 * representation. %G_NORMALIZE_ALL also standardizes
30082 * the "compatibility" characters in Unicode, such
30083 * as SUPERSCRIPT THREE to the standard forms
30084 * (in this case DIGIT THREE). Formatting information
30085 * may be lost but for most text operations such
30086 * characters should be considered the same.
30088 * %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
30089 * are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
30090 * but returned a result with composed forms rather
30091 * than a maximally decomposed form. This is often
30092 * useful if you intend to convert the string to
30093 * a legacy encoding or pass it to a system with
30094 * less capable Unicode handling.
30096 * Returns: a newly allocated string, that is the normalized form of @str, or %NULL if @str is not valid UTF-8.
30101 * g_utf8_offset_to_pointer:
30102 * @str: a UTF-8 encoded string
30103 * @offset: a character offset within @str
30105 * Converts from an integer character offset to a pointer to a position
30106 * within the string.
30108 * Since 2.10, this function allows to pass a negative @offset to
30109 * step backwards. It is usually worth stepping backwards from the end
30110 * instead of forwards if @offset is in the last fourth of the string,
30111 * since moving forward is about 3 times faster than moving backward.
30114 * This function doesn't abort when reaching the end of @str. Therefore
30115 * you should be sure that @offset is within string boundaries before
30116 * calling that function. Call g_utf8_strlen() when unsure.
30118 * This limitation exists as this function is called frequently during
30119 * text rendering and therefore has to be as fast as possible.
30122 * Returns: the resulting pointer
30127 * g_utf8_pointer_to_offset:
30128 * @str: a UTF-8 encoded string
30129 * @pos: a pointer to a position within @str
30131 * Converts from a pointer to position within a string to a integer
30132 * character offset.
30134 * Since 2.10, this function allows @pos to be before @str, and returns
30135 * a negative offset in this case.
30137 * Returns: the resulting character offset
30142 * g_utf8_prev_char:
30143 * @p: a pointer to a position within a UTF-8 encoded string
30145 * Finds the previous UTF-8 character in the string before @p.
30147 * @p does not have to be at the beginning of a UTF-8 character. No check
30148 * is made to see if the character found is actually valid other than
30149 * it starts with an appropriate byte. If @p might be the first
30150 * character of the string, you must use g_utf8_find_prev_char() instead.
30152 * Returns: a pointer to the found character.
30158 * @p: a nul-terminated UTF-8 encoded string
30159 * @len: the maximum length of @p
30160 * @c: a Unicode character
30162 * Finds the leftmost occurrence of the given Unicode character
30163 * in a UTF-8 encoded string, while limiting the search to @len bytes.
30164 * If @len is -1, allow unbounded search.
30166 * Returns: %NULL if the string does not contain the character, otherwise, a pointer to the start of the leftmost occurrence of the character in the string.
30172 * @str: a UTF-8 encoded string
30173 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30175 * Converts all Unicode characters in the string that have a case
30176 * to lowercase. The exact manner that this is done depends
30177 * on the current locale, and may result in the number of
30178 * characters in the string changing.
30180 * Returns: a newly allocated string, with all characters converted to lowercase.
30186 * @p: pointer to the start of a UTF-8 encoded string
30187 * @max: the maximum number of bytes to examine. If @max is less than 0, then the string is assumed to be nul-terminated. If @max is 0, @p will not be examined and may be %NULL. If @max is greater than 0, up to @max bytes are examined
30189 * Computes the length of the string in characters, not including
30190 * the terminating nul character. If the @max'th byte falls in the
30191 * middle of a character, the last (partial) character is not counted.
30193 * Returns: the length of the string in characters
30199 * @dest: buffer to fill with characters from @src
30200 * @src: UTF-8 encoded string
30201 * @n: character count
30203 * Like the standard C strncpy() function, but
30204 * copies a given number of characters instead of a given number of
30205 * bytes. The @src string must be valid UTF-8 encoded text.
30206 * (Use g_utf8_validate() on all text before trying to use UTF-8
30207 * utility functions with it.)
30215 * @p: a nul-terminated UTF-8 encoded string
30216 * @len: the maximum length of @p
30217 * @c: a Unicode character
30219 * Find the rightmost occurrence of the given Unicode character
30220 * in a UTF-8 encoded string, while limiting the search to @len bytes.
30221 * If @len is -1, allow unbounded search.
30223 * Returns: %NULL if the string does not contain the character, otherwise, a pointer to the start of the rightmost occurrence of the character in the string.
30228 * g_utf8_strreverse:
30229 * @str: a UTF-8 encoded string
30230 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30232 * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
30233 * (Use g_utf8_validate() on all text before trying to use UTF-8
30234 * utility functions with it.)
30236 * This function is intended for programmatic uses of reversed strings.
30237 * It pays no attention to decomposed characters, combining marks, byte
30238 * order marks, directional indicators (LRM, LRO, etc) and similar
30239 * characters which might need special handling when reversing a string
30240 * for display purposes.
30242 * Note that unlike g_strreverse(), this function returns
30243 * newly-allocated memory, which should be freed with g_free() when
30244 * no longer needed.
30246 * Returns: a newly-allocated string which is the reverse of @str.
30253 * @str: a UTF-8 encoded string
30254 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30256 * Converts all Unicode characters in the string that have a case
30257 * to uppercase. The exact manner that this is done depends
30258 * on the current locale, and may result in the number of
30259 * characters in the string increasing. (For instance, the
30260 * German ess-zet will be changed to SS.)
30262 * Returns: a newly allocated string, with all characters converted to uppercase.
30267 * g_utf8_substring:
30268 * @str: a UTF-8 encoded string
30269 * @start_pos: a character offset within @str
30270 * @end_pos: another character offset within @str
30272 * Copies a substring out of a UTF-8 encoded string.
30273 * The substring will contain @end_pos - @start_pos
30276 * Returns: a newly allocated copy of the requested substring. Free with g_free() when no longer needed.
30283 * @str: a UTF-8 encoded string
30284 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30285 * @items_read: (allow-none): location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30286 * @items_written: (allow-none): location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
30287 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30289 * Convert a string from UTF-8 to a 32-bit fixed width
30290 * representation as UCS-4. A trailing 0 character will be added to the
30291 * string after the converted text.
30293 * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30298 * g_utf8_to_ucs4_fast:
30299 * @str: a UTF-8 encoded string
30300 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30301 * @items_written: (allow-none): location to store the number of characters in the result, or %NULL.
30303 * Convert a string from UTF-8 to a 32-bit fixed width
30304 * representation as UCS-4, assuming valid UTF-8 input.
30305 * This function is roughly twice as fast as g_utf8_to_ucs4()
30306 * but does no error checking on the input. A trailing 0 character
30307 * will be added to the string after the converted text.
30309 * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free().
30315 * @str: a UTF-8 encoded string
30316 * @len: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
30317 * @items_read: (allow-none): location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30318 * @items_written: (allow-none): location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
30319 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30321 * Convert a string from UTF-8 to UTF-16. A 0 character will be
30322 * added to the result after the converted text.
30324 * Returns: a pointer to a newly allocated UTF-16 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30330 * @str: (array length=max_len) (element-type guint8): a pointer to character data
30331 * @max_len: max bytes to validate, or -1 to go until NUL
30332 * @end: (allow-none) (out) (transfer none): return location for end of valid data
30334 * Validates UTF-8 encoded text. @str is the text to validate;
30335 * if @str is nul-terminated, then @max_len can be -1, otherwise
30336 * @max_len should be the number of bytes to validate.
30337 * If @end is non-%NULL, then the end of the valid range
30338 * will be stored there (i.e. the start of the first invalid
30339 * character if some bytes were invalid, or the end of the text
30340 * being validated otherwise).
30342 * Note that g_utf8_validate() returns %FALSE if @max_len is
30343 * positive and any of the @max_len bytes are NUL.
30345 * Returns %TRUE if all of @str was valid. Many GLib and GTK+
30346 * routines <emphasis>require</emphasis> valid UTF-8 as input;
30347 * so data read from a file or the network should be checked
30348 * with g_utf8_validate() before doing anything else with it.
30350 * Returns: %TRUE if the text was valid UTF-8
30356 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
30357 * @utb: a pointer to a struct utimbuf.
30359 * A wrapper for the POSIX utime() function. The utime() function
30360 * sets the access and modification timestamps of a file.
30362 * See your C library manual for more details about how utime() works
30365 * Returns: 0 if the operation was successful, -1 if an error occurred
30371 * g_variant_builder_add: (skp)
30372 * @builder: a #GVariantBuilder
30373 * @format_string: a #GVariant varargs format string
30374 * @...: arguments, as per @format_string
30376 * Adds to a #GVariantBuilder.
30378 * This call is a convenience wrapper that is exactly equivalent to
30379 * calling g_variant_new() followed by g_variant_builder_add_value().
30381 * This function might be used as follows:
30385 * make_pointless_dictionary (void)
30387 * GVariantBuilder *builder;
30390 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
30391 * for (i = 0; i < 16; i++)
30395 * sprintf (buf, "%d", i);
30396 * g_variant_builder_add (builder, "{is}", i, buf);
30399 * return g_variant_builder_end (builder);
30401 * </programlisting>
30408 * g_variant_builder_add_parsed:
30409 * @builder: a #GVariantBuilder
30410 * @format: a text format #GVariant
30411 * @...: arguments as per @format
30413 * Adds to a #GVariantBuilder.
30415 * This call is a convenience wrapper that is exactly equivalent to
30416 * calling g_variant_new_parsed() followed by
30417 * g_variant_builder_add_value().
30419 * This function might be used as follows:
30423 * make_pointless_dictionary (void)
30425 * GVariantBuilder *builder;
30428 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
30429 * g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
30430 * g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
30431 * g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
30432 * return g_variant_builder_end (builder);
30434 * </programlisting>
30441 * g_variant_builder_add_value:
30442 * @builder: a #GVariantBuilder
30443 * @value: a #GVariant
30445 * Adds @value to @builder.
30447 * It is an error to call this function in any way that would create an
30448 * inconsistent value to be constructed. Some examples of this are
30449 * putting different types of items into an array, putting the wrong
30450 * types or number of items in a tuple, putting more than one value into
30453 * If @value is a floating reference (see g_variant_ref_sink()),
30454 * the @builder instance takes ownership of @value.
30461 * g_variant_builder_clear: (skip)
30462 * @builder: a #GVariantBuilder
30464 * Releases all memory associated with a #GVariantBuilder without
30465 * freeing the #GVariantBuilder structure itself.
30467 * It typically only makes sense to do this on a stack-allocated
30468 * #GVariantBuilder if you want to abort building the value part-way
30469 * through. This function need not be called if you call
30470 * g_variant_builder_end() and it also doesn't need to be called on
30471 * builders allocated with g_variant_builder_new (see
30472 * g_variant_builder_unref() for that).
30474 * This function leaves the #GVariantBuilder structure set to all-zeros.
30475 * It is valid to call this function on either an initialised
30476 * #GVariantBuilder or one that is set to all-zeros but it is not valid
30477 * to call this function on uninitialised memory.
30484 * g_variant_builder_close:
30485 * @builder: a #GVariantBuilder
30487 * Closes the subcontainer inside the given @builder that was opened by
30488 * the most recent call to g_variant_builder_open().
30490 * It is an error to call this function in any way that would create an
30491 * inconsistent value to be constructed (ie: too few values added to the
30499 * g_variant_builder_end:
30500 * @builder: a #GVariantBuilder
30502 * Ends the builder process and returns the constructed value.
30504 * It is not permissible to use @builder in any way after this call
30505 * except for reference counting operations (in the case of a
30506 * heap-allocated #GVariantBuilder) or by reinitialising it with
30507 * g_variant_builder_init() (in the case of stack-allocated).
30509 * It is an error to call this function in any way that would create an
30510 * inconsistent value to be constructed (ie: insufficient number of
30511 * items added to a container with a specific number of children
30512 * required). It is also an error to call this function if the builder
30513 * was created with an indefinite array or maybe type and no children
30514 * have been added; in this case it is impossible to infer the type of
30517 * Returns: (transfer none): a new, floating, #GVariant
30523 * g_variant_builder_init: (skip)
30524 * @builder: a #GVariantBuilder
30525 * @type: a container type
30527 * Initialises a #GVariantBuilder structure.
30529 * @type must be non-%NULL. It specifies the type of container to
30530 * construct. It can be an indefinite type such as
30531 * %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
30532 * Maybe, array, tuple, dictionary entry and variant-typed values may be
30535 * After the builder is initialised, values are added using
30536 * g_variant_builder_add_value() or g_variant_builder_add().
30538 * After all the child values are added, g_variant_builder_end() frees
30539 * the memory associated with the builder and returns the #GVariant that
30542 * This function completely ignores the previous contents of @builder.
30543 * On one hand this means that it is valid to pass in completely
30544 * uninitialised memory. On the other hand, this means that if you are
30545 * initialising over top of an existing #GVariantBuilder you need to
30546 * first call g_variant_builder_clear() in order to avoid leaking
30549 * You must not call g_variant_builder_ref() or
30550 * g_variant_builder_unref() on a #GVariantBuilder that was initialised
30551 * with this function. If you ever pass a reference to a
30552 * #GVariantBuilder outside of the control of your own code then you
30553 * should assume that the person receiving that reference may try to use
30554 * reference counting; you should use g_variant_builder_new() instead of
30562 * g_variant_builder_new:
30563 * @type: a container type
30565 * Allocates and initialises a new #GVariantBuilder.
30567 * You should call g_variant_builder_unref() on the return value when it
30568 * is no longer needed. The memory will not be automatically freed by
30571 * In most cases it is easier to place a #GVariantBuilder directly on
30572 * the stack of the calling function and initialise it with
30573 * g_variant_builder_init().
30575 * Returns: (transfer full): a #GVariantBuilder
30581 * g_variant_builder_open:
30582 * @builder: a #GVariantBuilder
30583 * @type: a #GVariantType
30585 * Opens a subcontainer inside the given @builder. When done adding
30586 * items to the subcontainer, g_variant_builder_close() must be called.
30588 * It is an error to call this function in any way that would cause an
30589 * inconsistent value to be constructed (ie: adding too many values or
30590 * a value of an incorrect type).
30597 * g_variant_builder_ref:
30598 * @builder: a #GVariantBuilder allocated by g_variant_builder_new()
30600 * Increases the reference count on @builder.
30602 * Don't call this on stack-allocated #GVariantBuilder instances or bad
30603 * things will happen.
30605 * Returns: (transfer full): a new reference to @builder
30611 * g_variant_builder_unref:
30612 * @builder: (transfer full): a #GVariantBuilder allocated by g_variant_builder_new()
30614 * Decreases the reference count on @builder.
30616 * In the event that there are no more references, releases all memory
30617 * associated with the #GVariantBuilder.
30619 * Don't call this on stack-allocated #GVariantBuilder instances or bad
30620 * things will happen.
30627 * g_variant_byteswap:
30628 * @value: a #GVariant
30630 * Performs a byteswapping operation on the contents of @value. The
30631 * result is that all multi-byte numeric data contained in @value is
30632 * byteswapped. That includes 16, 32, and 64bit signed and unsigned
30633 * integers as well as file handles and double precision floating point
30636 * This function is an identity mapping on any value that does not
30637 * contain multi-byte numeric data. That include strings, booleans,
30638 * bytes and containers containing only these things (recursively).
30640 * The returned value is always in normal form and is marked as trusted.
30642 * Returns: (transfer full): the byteswapped form of @value
30648 * g_variant_check_format_string:
30649 * @value: a #GVariant
30650 * @format_string: a valid #GVariant format string
30651 * @copy_only: %TRUE to ensure the format string makes deep copies
30653 * Checks if calling g_variant_get() with @format_string on @value would
30654 * be valid from a type-compatibility standpoint. @format_string is
30655 * assumed to be a valid format string (from a syntactic standpoint).
30657 * If @copy_only is %TRUE then this function additionally checks that it
30658 * would be safe to call g_variant_unref() on @value immediately after
30659 * the call to g_variant_get() without invalidating the result. This is
30660 * only possible if deep copies are made (ie: there are no pointers to
30661 * the data inside of the soon-to-be-freed #GVariant instance). If this
30662 * check fails then a g_critical() is printed and %FALSE is returned.
30664 * This function is meant to be used by functions that wish to provide
30665 * varargs accessors to #GVariant values of uncertain values (eg:
30666 * g_variant_lookup() or g_menu_model_get_item_attribute()).
30668 * Returns: %TRUE if @format_string is safe to use
30674 * g_variant_classify:
30675 * @value: a #GVariant
30677 * Classifies @value according to its top-level type.
30679 * Returns: the #GVariantClass of @value
30685 * g_variant_compare:
30686 * @one: (type GVariant): a basic-typed #GVariant instance
30687 * @two: (type GVariant): a #GVariant instance of the same type
30689 * Compares @one and @two.
30691 * The types of @one and @two are #gconstpointer only to allow use of
30692 * this function with #GTree, #GPtrArray, etc. They must each be a
30695 * Comparison is only defined for basic types (ie: booleans, numbers,
30696 * strings). For booleans, %FALSE is less than %TRUE. Numbers are
30697 * ordered in the usual way. Strings are in ASCII lexographical order.
30699 * It is a programmer error to attempt to compare container values or
30700 * two values that have types that are not exactly equal. For example,
30701 * you cannot compare a 32-bit signed integer with a 32-bit unsigned
30702 * integer. Also note that this function is not particularly
30703 * well-behaved when it comes to comparison of doubles; in particular,
30704 * the handling of incomparable values (ie: NaN) is undefined.
30706 * If you only require an equality comparison, g_variant_equal() is more
30709 * Returns: negative value if a < b; zero if a = b; positive value if a > b.
30715 * g_variant_dup_bytestring:
30716 * @value: an array-of-bytes #GVariant instance
30717 * @length: (out) (allow-none) (default NULL): a pointer to a #gsize, to store the length (not including the nul terminator)
30719 * Similar to g_variant_get_bytestring() except that instead of
30720 * returning a constant string, the string is duplicated.
30722 * The return value must be freed using g_free().
30724 * Returns: (transfer full) (array length=length zero-terminated=1) (element-type guint8): a newly allocated string
30730 * g_variant_dup_bytestring_array:
30731 * @value: an array of array of bytes #GVariant ('aay')
30732 * @length: (out) (allow-none): the length of the result, or %NULL
30734 * Gets the contents of an array of array of bytes #GVariant. This call
30735 * makes a deep copy; the return result should be released with
30738 * If @length is non-%NULL then the number of elements in the result is
30739 * stored there. In any case, the resulting array will be
30740 * %NULL-terminated.
30742 * For an empty array, @length will be set to 0 and a pointer to a
30743 * %NULL pointer will be returned.
30745 * Returns: (array length=length) (transfer full): an array of strings
30751 * g_variant_dup_objv:
30752 * @value: an array of object paths #GVariant
30753 * @length: (out) (allow-none): the length of the result, or %NULL
30755 * Gets the contents of an array of object paths #GVariant. This call
30756 * makes a deep copy; the return result should be released with
30759 * If @length is non-%NULL then the number of elements in the result
30760 * is stored there. In any case, the resulting array will be
30761 * %NULL-terminated.
30763 * For an empty array, @length will be set to 0 and a pointer to a
30764 * %NULL pointer will be returned.
30766 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
30772 * g_variant_dup_string:
30773 * @value: a string #GVariant instance
30774 * @length: (out): a pointer to a #gsize, to store the length
30776 * Similar to g_variant_get_string() except that instead of returning
30777 * a constant string, the string is duplicated.
30779 * The string will always be utf8 encoded.
30781 * The return value must be freed using g_free().
30783 * Returns: (transfer full): a newly allocated string, utf8 encoded
30789 * g_variant_dup_strv:
30790 * @value: an array of strings #GVariant
30791 * @length: (out) (allow-none): the length of the result, or %NULL
30793 * Gets the contents of an array of strings #GVariant. This call
30794 * makes a deep copy; the return result should be released with
30797 * If @length is non-%NULL then the number of elements in the result
30798 * is stored there. In any case, the resulting array will be
30799 * %NULL-terminated.
30801 * For an empty array, @length will be set to 0 and a pointer to a
30802 * %NULL pointer will be returned.
30804 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
30811 * @one: (type GVariant): a #GVariant instance
30812 * @two: (type GVariant): a #GVariant instance
30814 * Checks if @one and @two have the same type and value.
30816 * The types of @one and @two are #gconstpointer only to allow use of
30817 * this function with #GHashTable. They must each be a #GVariant.
30819 * Returns: %TRUE if @one and @two are equal
30825 * g_variant_get: (skip)
30826 * @value: a #GVariant instance
30827 * @format_string: a #GVariant format string
30828 * @...: arguments, as per @format_string
30830 * Deconstructs a #GVariant instance.
30832 * Think of this function as an analogue to scanf().
30834 * The arguments that are expected by this function are entirely
30835 * determined by @format_string. @format_string also restricts the
30836 * permissible types of @value. It is an error to give a value with
30837 * an incompatible type. See the section on <link
30838 * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
30839 * Please note that the syntax of the format string is very likely to be
30840 * extended in the future.
30842 * @format_string determines the C types that are used for unpacking
30843 * the values and also determines if the values are copied or borrowed,
30844 * see the section on
30845 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
30852 * g_variant_get_boolean:
30853 * @value: a boolean #GVariant instance
30855 * Returns the boolean value of @value.
30857 * It is an error to call this function with a @value of any type
30858 * other than %G_VARIANT_TYPE_BOOLEAN.
30860 * Returns: %TRUE or %FALSE
30866 * g_variant_get_byte:
30867 * @value: a byte #GVariant instance
30869 * Returns the byte value of @value.
30871 * It is an error to call this function with a @value of any type
30872 * other than %G_VARIANT_TYPE_BYTE.
30874 * Returns: a #guchar
30880 * g_variant_get_bytestring:
30881 * @value: an array-of-bytes #GVariant instance
30883 * Returns the string value of a #GVariant instance with an
30884 * array-of-bytes type. The string has no particular encoding.
30886 * If the array does not end with a nul terminator character, the empty
30887 * string is returned. For this reason, you can always trust that a
30888 * non-%NULL nul-terminated string will be returned by this function.
30890 * If the array contains a nul terminator character somewhere other than
30891 * the last byte then the returned string is the string, up to the first
30892 * such nul character.
30894 * It is an error to call this function with a @value that is not an
30897 * The return value remains valid as long as @value exists.
30899 * Returns: (transfer none) (array zero-terminated=1) (element-type guint8): the constant string
30905 * g_variant_get_bytestring_array:
30906 * @value: an array of array of bytes #GVariant ('aay')
30907 * @length: (out) (allow-none): the length of the result, or %NULL
30909 * Gets the contents of an array of array of bytes #GVariant. This call
30910 * makes a shallow copy; the return result should be released with
30911 * g_free(), but the individual strings must not be modified.
30913 * If @length is non-%NULL then the number of elements in the result is
30914 * stored there. In any case, the resulting array will be
30915 * %NULL-terminated.
30917 * For an empty array, @length will be set to 0 and a pointer to a
30918 * %NULL pointer will be returned.
30920 * Returns: (array length=length) (transfer container): an array of constant strings
30926 * g_variant_get_child: (skip)
30927 * @value: a container #GVariant
30928 * @index_: the index of the child to deconstruct
30929 * @format_string: a #GVariant format string
30930 * @...: arguments, as per @format_string
30932 * Reads a child item out of a container #GVariant instance and
30933 * deconstructs it according to @format_string. This call is
30934 * essentially a combination of g_variant_get_child_value() and
30937 * @format_string determines the C types that are used for unpacking
30938 * the values and also determines if the values are copied or borrowed,
30939 * see the section on
30940 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
30947 * g_variant_get_child_value:
30948 * @value: a container #GVariant
30949 * @index_: the index of the child to fetch
30951 * Reads a child item out of a container #GVariant instance. This
30952 * includes variants, maybes, arrays, tuples and dictionary
30953 * entries. It is an error to call this function on any other type of
30956 * It is an error if @index_ is greater than the number of child items
30957 * in the container. See g_variant_n_children().
30959 * The returned value is never floating. You should free it with
30960 * g_variant_unref() when you're done with it.
30962 * This function is O(1).
30964 * Returns: (transfer full): the child at the specified index
30970 * g_variant_get_data:
30971 * @value: a #GVariant instance
30973 * Returns a pointer to the serialised form of a #GVariant instance.
30974 * The returned data may not be in fully-normalised form if read from an
30975 * untrusted source. The returned data must not be freed; it remains
30976 * valid for as long as @value exists.
30978 * If @value is a fixed-sized value that was deserialised from a
30979 * corrupted serialised container then %NULL may be returned. In this
30980 * case, the proper thing to do is typically to use the appropriate
30981 * number of nul bytes in place of @value. If @value is not fixed-sized
30982 * then %NULL is never returned.
30984 * In the case that @value is already in serialised form, this function
30985 * is O(1). If the value is not already in serialised form,
30986 * serialisation occurs implicitly and is approximately O(n) in the size
30989 * To deserialise the data returned by this function, in addition to the
30990 * serialised data, you must know the type of the #GVariant, and (if the
30991 * machine might be different) the endianness of the machine that stored
30992 * it. As a result, file formats or network messages that incorporate
30993 * serialised #GVariant<!---->s must include this information either
30994 * implicitly (for instance "the file always contains a
30995 * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
30996 * explicitly (by storing the type and/or endianness in addition to the
30997 * serialised data).
30999 * Returns: (transfer none): the serialised form of @value, or %NULL
31005 * g_variant_get_data_as_bytes:
31006 * @value: a #GVariant
31008 * Returns a pointer to the serialised form of a #GVariant instance.
31009 * The semantics of this function are exactly the same as
31010 * g_variant_get_data(), except that the returned #GBytes holds
31011 * a reference to the variant data.
31013 * Returns: (transfer full): A new #GBytes representing the variant data
31019 * g_variant_get_double:
31020 * @value: a double #GVariant instance
31022 * Returns the double precision floating point value of @value.
31024 * It is an error to call this function with a @value of any type
31025 * other than %G_VARIANT_TYPE_DOUBLE.
31027 * Returns: a #gdouble
31033 * g_variant_get_fixed_array:
31034 * @value: a #GVariant array with fixed-sized elements
31035 * @n_elements: (out): a pointer to the location to store the number of items
31036 * @element_size: the size of each element
31038 * Provides access to the serialised data for an array of fixed-sized
31041 * @value must be an array with fixed-sized elements. Numeric types are
31042 * fixed-size, as are tuples containing only other fixed-sized types.
31044 * @element_size must be the size of a single element in the array,
31045 * as given by the section on
31046 * <link linkend='gvariant-serialised-data-memory'>Serialised Data
31049 * In particular, arrays of these fixed-sized types can be interpreted
31050 * as an array of the given C type, with @element_size set to
31051 * <code>sizeof</code> the appropriate type:
31054 * <tgroup cols='2'>
31055 * <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
31057 * <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
31058 * <entry>#gint16 (etc.)</entry></row>
31059 * <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
31060 * <entry>#guchar (not #gboolean!)</entry></row>
31061 * <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
31062 * <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
31063 * <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
31068 * For example, if calling this function for an array of 32 bit integers,
31069 * you might say <code>sizeof (gint32)</code>. This value isn't used
31070 * except for the purpose of a double-check that the form of the
31071 * serialised data matches the caller's expectation.
31073 * @n_elements, which must be non-%NULL is set equal to the number of
31074 * items in the array.
31076 * Returns: (array length=n_elements) (transfer none): a pointer to the fixed array
31082 * g_variant_get_handle:
31083 * @value: a handle #GVariant instance
31085 * Returns the 32-bit signed integer value of @value.
31087 * It is an error to call this function with a @value of any type other
31088 * than %G_VARIANT_TYPE_HANDLE.
31090 * By convention, handles are indexes into an array of file descriptors
31091 * that are sent alongside a D-Bus message. If you're not interacting
31092 * with D-Bus, you probably don't need them.
31094 * Returns: a #gint32
31100 * g_variant_get_int16:
31101 * @value: a int16 #GVariant instance
31103 * Returns the 16-bit signed integer value of @value.
31105 * It is an error to call this function with a @value of any type
31106 * other than %G_VARIANT_TYPE_INT16.
31108 * Returns: a #gint16
31114 * g_variant_get_int32:
31115 * @value: a int32 #GVariant instance
31117 * Returns the 32-bit signed integer value of @value.
31119 * It is an error to call this function with a @value of any type
31120 * other than %G_VARIANT_TYPE_INT32.
31122 * Returns: a #gint32
31128 * g_variant_get_int64:
31129 * @value: a int64 #GVariant instance
31131 * Returns the 64-bit signed integer value of @value.
31133 * It is an error to call this function with a @value of any type
31134 * other than %G_VARIANT_TYPE_INT64.
31136 * Returns: a #gint64
31142 * g_variant_get_maybe:
31143 * @value: a maybe-typed value
31145 * Given a maybe-typed #GVariant instance, extract its value. If the
31146 * value is Nothing, then this function returns %NULL.
31148 * Returns: (allow-none) (transfer full): the contents of @value, or %NULL
31154 * g_variant_get_normal_form:
31155 * @value: a #GVariant
31157 * Gets a #GVariant instance that has the same value as @value and is
31158 * trusted to be in normal form.
31160 * If @value is already trusted to be in normal form then a new
31161 * reference to @value is returned.
31163 * If @value is not already trusted, then it is scanned to check if it
31164 * is in normal form. If it is found to be in normal form then it is
31165 * marked as trusted and a new reference to it is returned.
31167 * If @value is found not to be in normal form then a new trusted
31168 * #GVariant is created with the same value as @value.
31170 * It makes sense to call this function if you've received #GVariant
31171 * data from untrusted sources and you want to ensure your serialised
31172 * output is definitely in normal form.
31174 * Returns: (transfer full): a trusted #GVariant
31180 * g_variant_get_objv:
31181 * @value: an array of object paths #GVariant
31182 * @length: (out) (allow-none): the length of the result, or %NULL
31184 * Gets the contents of an array of object paths #GVariant. This call
31185 * makes a shallow copy; the return result should be released with
31186 * g_free(), but the individual strings must not be modified.
31188 * If @length is non-%NULL then the number of elements in the result
31189 * is stored there. In any case, the resulting array will be
31190 * %NULL-terminated.
31192 * For an empty array, @length will be set to 0 and a pointer to a
31193 * %NULL pointer will be returned.
31195 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31201 * g_variant_get_size:
31202 * @value: a #GVariant instance
31204 * Determines the number of bytes that would be required to store @value
31205 * with g_variant_store().
31207 * If @value has a fixed-sized type then this function always returned
31210 * In the case that @value is already in serialised form or the size has
31211 * already been calculated (ie: this function has been called before)
31212 * then this function is O(1). Otherwise, the size is calculated, an
31213 * operation which is approximately O(n) in the number of values
31216 * Returns: the serialised size of @value
31222 * g_variant_get_string:
31223 * @value: a string #GVariant instance
31224 * @length: (allow-none) (default 0) (out): a pointer to a #gsize, to store the length
31226 * Returns the string value of a #GVariant instance with a string
31227 * type. This includes the types %G_VARIANT_TYPE_STRING,
31228 * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
31230 * The string will always be utf8 encoded.
31232 * If @length is non-%NULL then the length of the string (in bytes) is
31233 * returned there. For trusted values, this information is already
31234 * known. For untrusted values, a strlen() will be performed.
31236 * It is an error to call this function with a @value of any type
31237 * other than those three.
31239 * The return value remains valid as long as @value exists.
31241 * Returns: (transfer none): the constant string, utf8 encoded
31247 * g_variant_get_strv:
31248 * @value: an array of strings #GVariant
31249 * @length: (out) (allow-none): the length of the result, or %NULL
31251 * Gets the contents of an array of strings #GVariant. This call
31252 * makes a shallow copy; the return result should be released with
31253 * g_free(), but the individual strings must not be modified.
31255 * If @length is non-%NULL then the number of elements in the result
31256 * is stored there. In any case, the resulting array will be
31257 * %NULL-terminated.
31259 * For an empty array, @length will be set to 0 and a pointer to a
31260 * %NULL pointer will be returned.
31262 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31268 * g_variant_get_type:
31269 * @value: a #GVariant
31271 * Determines the type of @value.
31273 * The return value is valid for the lifetime of @value and must not
31276 * Returns: a #GVariantType
31282 * g_variant_get_type_string:
31283 * @value: a #GVariant
31285 * Returns the type string of @value. Unlike the result of calling
31286 * g_variant_type_peek_string(), this string is nul-terminated. This
31287 * string belongs to #GVariant and must not be freed.
31289 * Returns: the type string for the type of @value
31295 * g_variant_get_uint16:
31296 * @value: a uint16 #GVariant instance
31298 * Returns the 16-bit unsigned integer value of @value.
31300 * It is an error to call this function with a @value of any type
31301 * other than %G_VARIANT_TYPE_UINT16.
31303 * Returns: a #guint16
31309 * g_variant_get_uint32:
31310 * @value: a uint32 #GVariant instance
31312 * Returns the 32-bit unsigned integer value of @value.
31314 * It is an error to call this function with a @value of any type
31315 * other than %G_VARIANT_TYPE_UINT32.
31317 * Returns: a #guint32
31323 * g_variant_get_uint64:
31324 * @value: a uint64 #GVariant instance
31326 * Returns the 64-bit unsigned integer value of @value.
31328 * It is an error to call this function with a @value of any type
31329 * other than %G_VARIANT_TYPE_UINT64.
31331 * Returns: a #guint64
31337 * g_variant_get_va: (skip)
31338 * @value: a #GVariant
31339 * @format_string: a string that is prefixed with a format string
31340 * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
31341 * @app: a pointer to a #va_list
31343 * This function is intended to be used by libraries based on #GVariant
31344 * that want to provide g_variant_get()-like functionality to their
31347 * The API is more general than g_variant_get() to allow a wider range
31348 * of possible uses.
31350 * @format_string must still point to a valid format string, but it only
31351 * need to be nul-terminated if @endptr is %NULL. If @endptr is
31352 * non-%NULL then it is updated to point to the first character past the
31353 * end of the format string.
31355 * @app is a pointer to a #va_list. The arguments, according to
31356 * @format_string, are collected from this #va_list and the list is left
31357 * pointing to the argument following the last.
31359 * These two generalisations allow mixing of multiple calls to
31360 * g_variant_new_va() and g_variant_get_va() within a single actual
31361 * varargs call by the user.
31363 * @format_string determines the C types that are used for unpacking
31364 * the values and also determines if the values are copied or borrowed,
31365 * see the section on
31366 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31373 * g_variant_get_variant:
31374 * @value: a variant #GVariant instance
31376 * Unboxes @value. The result is the #GVariant instance that was
31377 * contained in @value.
31379 * Returns: (transfer full): the item contained in the variant
31386 * @value: (type GVariant): a basic #GVariant value as a #gconstpointer
31388 * Generates a hash value for a #GVariant instance.
31390 * The output of this function is guaranteed to be the same for a given
31391 * value only per-process. It may change between different processor
31392 * architectures or even different versions of GLib. Do not use this
31393 * function as a basis for building protocols or file formats.
31395 * The type of @value is #gconstpointer only to allow use of this
31396 * function with #GHashTable. @value must be a #GVariant.
31398 * Returns: a hash value corresponding to @value
31404 * g_variant_is_container:
31405 * @value: a #GVariant instance
31407 * Checks if @value is a container.
31409 * Returns: %TRUE if @value is a container
31415 * g_variant_is_floating:
31416 * @value: a #GVariant
31418 * Checks whether @value has a floating reference count.
31420 * This function should only ever be used to assert that a given variant
31421 * is or is not floating, or for debug purposes. To acquire a reference
31422 * to a variant that might be floating, always use g_variant_ref_sink()
31423 * or g_variant_take_ref().
31425 * See g_variant_ref_sink() for more information about floating reference
31428 * Returns: whether @value is floating
31434 * g_variant_is_normal_form:
31435 * @value: a #GVariant instance
31437 * Checks if @value is in normal form.
31439 * The main reason to do this is to detect if a given chunk of
31440 * serialised data is in normal form: load the data into a #GVariant
31441 * using g_variant_new_from_data() and then use this function to
31444 * If @value is found to be in normal form then it will be marked as
31445 * being trusted. If the value was already marked as being trusted then
31446 * this function will immediately return %TRUE.
31448 * Returns: %TRUE if @value is in normal form
31454 * g_variant_is_object_path:
31455 * @string: a normal C nul-terminated string
31457 * Determines if a given string is a valid D-Bus object path. You
31458 * should ensure that a string is a valid D-Bus object path before
31459 * passing it to g_variant_new_object_path().
31461 * A valid object path starts with '/' followed by zero or more
31462 * sequences of characters separated by '/' characters. Each sequence
31463 * must contain only the characters "[A-Z][a-z][0-9]_". No sequence
31464 * (including the one following the final '/' character) may be empty.
31466 * Returns: %TRUE if @string is a D-Bus object path
31472 * g_variant_is_of_type:
31473 * @value: a #GVariant instance
31474 * @type: a #GVariantType
31476 * Checks if a value has a type matching the provided type.
31478 * Returns: %TRUE if the type of @value matches @type
31484 * g_variant_is_signature:
31485 * @string: a normal C nul-terminated string
31487 * Determines if a given string is a valid D-Bus type signature. You
31488 * should ensure that a string is a valid D-Bus type signature before
31489 * passing it to g_variant_new_signature().
31491 * D-Bus type signatures consist of zero or more definite #GVariantType
31492 * strings in sequence.
31494 * Returns: %TRUE if @string is a D-Bus type signature
31500 * g_variant_iter_copy:
31501 * @iter: a #GVariantIter
31503 * Creates a new heap-allocated #GVariantIter to iterate over the
31504 * container that was being iterated over by @iter. Iteration begins on
31505 * the new iterator from the current position of the old iterator but
31506 * the two copies are independent past that point.
31508 * Use g_variant_iter_free() to free the return value when you no longer
31511 * A reference is taken to the container that @iter is iterating over
31512 * and will be releated only when g_variant_iter_free() is called.
31514 * Returns: (transfer full): a new heap-allocated #GVariantIter
31520 * g_variant_iter_free:
31521 * @iter: (transfer full): a heap-allocated #GVariantIter
31523 * Frees a heap-allocated #GVariantIter. Only call this function on
31524 * iterators that were returned by g_variant_iter_new() or
31525 * g_variant_iter_copy().
31532 * g_variant_iter_init: (skip)
31533 * @iter: a pointer to a #GVariantIter
31534 * @value: a container #GVariant
31536 * Initialises (without allocating) a #GVariantIter. @iter may be
31537 * completely uninitialised prior to this call; its old value is
31540 * The iterator remains valid for as long as @value exists, and need not
31541 * be freed in any way.
31543 * Returns: the number of items in @value
31549 * g_variant_iter_loop: (skip)
31550 * @iter: a #GVariantIter
31551 * @format_string: a GVariant format string
31552 * @...: the arguments to unpack the value into
31554 * Gets the next item in the container and unpacks it into the variable
31555 * argument list according to @format_string, returning %TRUE.
31557 * If no more items remain then %FALSE is returned.
31559 * On the first call to this function, the pointers appearing on the
31560 * variable argument list are assumed to point at uninitialised memory.
31561 * On the second and later calls, it is assumed that the same pointers
31562 * will be given and that they will point to the memory as set by the
31563 * previous call to this function. This allows the previous values to
31564 * be freed, as appropriate.
31566 * This function is intended to be used with a while loop as
31567 * demonstrated in the following example. This function can only be
31568 * used when iterating over an array. It is only valid to call this
31569 * function with a string constant for the format string and the same
31570 * string constant must be used each time. Mixing calls to this
31571 * function and g_variant_iter_next() or g_variant_iter_next_value() on
31572 * the same iterator causes undefined behavior.
31574 * If you break out of a such a while loop using g_variant_iter_loop() then
31575 * you must free or unreference all the unpacked values as you would with
31576 * g_variant_get(). Failure to do so will cause a memory leak.
31578 * See the section on <link linkend='gvariant-format-strings'>GVariant
31579 * Format Strings</link>.
31582 * <title>Memory management with g_variant_iter_loop()</title>
31584 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
31586 * iterate_dictionary (GVariant *dictionary)
31588 * GVariantIter iter;
31592 * g_variant_iter_init (&iter, dictionary);
31593 * while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
31595 * g_print ("Item '%s' has type '%s'\n", key,
31596 * g_variant_get_type_string (value));
31598 * /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
31599 * /<!-- -->* unless breaking out of this loop *<!-- -->/
31602 * </programlisting>
31605 * For most cases you should use g_variant_iter_next().
31607 * This function is really only useful when unpacking into #GVariant or
31608 * #GVariantIter in order to allow you to skip the call to
31609 * g_variant_unref() or g_variant_iter_free().
31611 * For example, if you are only looping over simple integer and string
31612 * types, g_variant_iter_next() is definitely preferred. For string
31613 * types, use the '&' prefix to avoid allocating any memory at all (and
31614 * thereby avoiding the need to free anything as well).
31616 * @format_string determines the C types that are used for unpacking
31617 * the values and also determines if the values are copied or borrowed,
31618 * see the section on
31619 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31621 * Returns: %TRUE if a value was unpacked, or %FALSE if there was no value
31627 * g_variant_iter_n_children:
31628 * @iter: a #GVariantIter
31630 * Queries the number of child items in the container that we are
31631 * iterating over. This is the total number of items -- not the number
31632 * of items remaining.
31634 * This function might be useful for preallocation of arrays.
31636 * Returns: the number of children in the container
31642 * g_variant_iter_new:
31643 * @value: a container #GVariant
31645 * Creates a heap-allocated #GVariantIter for iterating over the items
31648 * Use g_variant_iter_free() to free the return value when you no longer
31651 * A reference is taken to @value and will be released only when
31652 * g_variant_iter_free() is called.
31654 * Returns: (transfer full): a new heap-allocated #GVariantIter
31660 * g_variant_iter_next: (skip)
31661 * @iter: a #GVariantIter
31662 * @format_string: a GVariant format string
31663 * @...: the arguments to unpack the value into
31665 * Gets the next item in the container and unpacks it into the variable
31666 * argument list according to @format_string, returning %TRUE.
31668 * If no more items remain then %FALSE is returned.
31670 * All of the pointers given on the variable arguments list of this
31671 * function are assumed to point at uninitialised memory. It is the
31672 * responsibility of the caller to free all of the values returned by
31673 * the unpacking process.
31675 * See the section on <link linkend='gvariant-format-strings'>GVariant
31676 * Format Strings</link>.
31679 * <title>Memory management with g_variant_iter_next()</title>
31681 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
31683 * iterate_dictionary (GVariant *dictionary)
31685 * GVariantIter iter;
31689 * g_variant_iter_init (&iter, dictionary);
31690 * while (g_variant_iter_next (&iter, "{sv}", &key, &value))
31692 * g_print ("Item '%s' has type '%s'\n", key,
31693 * g_variant_get_type_string (value));
31695 * /<!-- -->* must free data for ourselves *<!-- -->/
31696 * g_variant_unref (value);
31700 * </programlisting>
31703 * For a solution that is likely to be more convenient to C programmers
31704 * when dealing with loops, see g_variant_iter_loop().
31706 * @format_string determines the C types that are used for unpacking
31707 * the values and also determines if the values are copied or borrowed,
31708 * see the section on
31709 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31711 * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value
31717 * g_variant_iter_next_value:
31718 * @iter: a #GVariantIter
31720 * Gets the next item in the container. If no more items remain then
31721 * %NULL is returned.
31723 * Use g_variant_unref() to drop your reference on the return value when
31724 * you no longer need it.
31727 * <title>Iterating with g_variant_iter_next_value()</title>
31729 * /<!-- -->* recursively iterate a container *<!-- -->/
31731 * iterate_container_recursive (GVariant *container)
31733 * GVariantIter iter;
31736 * g_variant_iter_init (&iter, container);
31737 * while ((child = g_variant_iter_next_value (&iter)))
31739 * g_print ("type '%s'\n", g_variant_get_type_string (child));
31741 * if (g_variant_is_container (child))
31742 * iterate_container_recursive (child);
31744 * g_variant_unref (child);
31747 * </programlisting>
31750 * Returns: (allow-none) (transfer full): a #GVariant, or %NULL
31756 * g_variant_lookup: (skip)
31757 * @dictionary: a dictionary #GVariant
31758 * @key: the key to lookup in the dictionary
31759 * @format_string: a GVariant format string
31760 * @...: the arguments to unpack the value into
31762 * Looks up a value in a dictionary #GVariant.
31764 * This function is a wrapper around g_variant_lookup_value() and
31765 * g_variant_get(). In the case that %NULL would have been returned,
31766 * this function returns %FALSE. Otherwise, it unpacks the returned
31767 * value and returns %TRUE.
31769 * @format_string determines the C types that are used for unpacking
31770 * the values and also determines if the values are copied or borrowed,
31771 * see the section on
31772 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31774 * Returns: %TRUE if a value was unpacked
31780 * g_variant_lookup_value:
31781 * @dictionary: a dictionary #GVariant
31782 * @key: the key to lookup in the dictionary
31783 * @expected_type: (allow-none): a #GVariantType, or %NULL
31785 * Looks up a value in a dictionary #GVariant.
31787 * This function works with dictionaries of the type
31788 * <literal>a{s*}</literal> (and equally well with type
31789 * <literal>a{o*}</literal>, but we only further discuss the string case
31790 * for sake of clarity).
31792 * In the event that @dictionary has the type <literal>a{sv}</literal>,
31793 * the @expected_type string specifies what type of value is expected to
31794 * be inside of the variant. If the value inside the variant has a
31795 * different type then %NULL is returned. In the event that @dictionary
31796 * has a value type other than <literal>v</literal> then @expected_type
31797 * must directly match the key type and it is used to unpack the value
31798 * directly or an error occurs.
31800 * In either case, if @key is not found in @dictionary, %NULL is
31803 * If the key is found and the value has the correct type, it is
31804 * returned. If @expected_type was specified then any non-%NULL return
31805 * value will have this type.
31807 * Returns: (transfer full): the value of the dictionary key, or %NULL
31813 * g_variant_n_children:
31814 * @value: a container #GVariant
31816 * Determines the number of children in a container #GVariant instance.
31817 * This includes variants, maybes, arrays, tuples and dictionary
31818 * entries. It is an error to call this function on any other type of
31821 * For variants, the return value is always 1. For values with maybe
31822 * types, it is always zero or one. For arrays, it is the length of the
31823 * array. For tuples it is the number of tuple items (which depends
31824 * only on the type). For dictionary entries, it is always 2
31826 * This function is O(1).
31828 * Returns: the number of children in the container
31834 * g_variant_new: (skip)
31835 * @format_string: a #GVariant format string
31836 * @...: arguments, as per @format_string
31838 * Creates a new #GVariant instance.
31840 * Think of this function as an analogue to g_strdup_printf().
31842 * The type of the created instance and the arguments that are
31843 * expected by this function are determined by @format_string. See the
31844 * section on <link linkend='gvariant-format-strings'>GVariant Format
31845 * Strings</link>. Please note that the syntax of the format string is
31846 * very likely to be extended in the future.
31848 * The first character of the format string must not be '*' '?' '@' or
31849 * 'r'; in essence, a new #GVariant must always be constructed by this
31850 * function (and not merely passed through it unmodified).
31852 * Returns: a new floating #GVariant instance
31858 * g_variant_new_array:
31859 * @child_type: (allow-none): the element type of the new array
31860 * @children: (allow-none) (array length=n_children): an array of #GVariant pointers, the children
31861 * @n_children: the length of @children
31863 * Creates a new #GVariant array from @children.
31865 * @child_type must be non-%NULL if @n_children is zero. Otherwise, the
31866 * child type is determined by inspecting the first element of the
31867 * @children array. If @child_type is non-%NULL then it must be a
31870 * The items of the array are taken from the @children array. No entry
31871 * in the @children array may be %NULL.
31873 * All items in the array must have the same type, which must be the
31874 * same as @child_type, if given.
31876 * If the @children are floating references (see g_variant_ref_sink()), the
31877 * new instance takes ownership of them as if via g_variant_ref_sink().
31879 * Returns: (transfer none): a floating reference to a new #GVariant array
31885 * g_variant_new_boolean:
31886 * @value: a #gboolean value
31888 * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
31890 * Returns: (transfer none): a floating reference to a new boolean #GVariant instance
31896 * g_variant_new_byte:
31897 * @value: a #guint8 value
31899 * Creates a new byte #GVariant instance.
31901 * Returns: (transfer none): a floating reference to a new byte #GVariant instance
31907 * g_variant_new_bytestring:
31908 * @string: (array zero-terminated=1) (element-type guint8): a normal nul-terminated string in no particular encoding
31910 * Creates an array-of-bytes #GVariant with the contents of @string.
31911 * This function is just like g_variant_new_string() except that the
31912 * string need not be valid utf8.
31914 * The nul terminator character at the end of the string is stored in
31917 * Returns: (transfer none): a floating reference to a new bytestring #GVariant instance
31923 * g_variant_new_bytestring_array:
31924 * @strv: (array length=length): an array of strings
31925 * @length: the length of @strv, or -1
31927 * Constructs an array of bytestring #GVariant from the given array of
31930 * If @length is -1 then @strv is %NULL-terminated.
31932 * Returns: (transfer none): a new floating #GVariant instance
31938 * g_variant_new_dict_entry: (constructor)
31939 * @key: a basic #GVariant, the key
31940 * @value: a #GVariant, the value
31942 * Creates a new dictionary entry #GVariant. @key and @value must be
31943 * non-%NULL. @key must be a value of a basic type (ie: not a container).
31945 * If the @key or @value are floating references (see g_variant_ref_sink()),
31946 * the new instance takes ownership of them as if via g_variant_ref_sink().
31948 * Returns: (transfer none): a floating reference to a new dictionary entry #GVariant
31954 * g_variant_new_double:
31955 * @value: a #gdouble floating point value
31957 * Creates a new double #GVariant instance.
31959 * Returns: (transfer none): a floating reference to a new double #GVariant instance
31965 * g_variant_new_fixed_array:
31966 * @element_type: the #GVariantType of each element
31967 * @elements: a pointer to the fixed array of contiguous elements
31968 * @n_elements: the number of elements
31969 * @element_size: the size of each element
31971 * Provides access to the serialised data for an array of fixed-sized
31974 * @value must be an array with fixed-sized elements. Numeric types are
31975 * fixed-size as are tuples containing only other fixed-sized types.
31977 * @element_size must be the size of a single element in the array. For
31978 * example, if calling this function for an array of 32 bit integers,
31979 * you might say <code>sizeof (gint32)</code>. This value isn't used
31980 * except for the purpose of a double-check that the form of the
31981 * serialised data matches the caller's expectation.
31983 * @n_elements, which must be non-%NULL is set equal to the number of
31984 * items in the array.
31986 * Returns: (transfer none): a floating reference to a new array #GVariant instance
31992 * g_variant_new_from_bytes:
31993 * @type: a #GVariantType
31994 * @bytes: a #GBytes
31995 * @trusted: if the contents of @bytes are trusted
31997 * Constructs a new serialised-mode #GVariant instance. This is the
31998 * inner interface for creation of new serialised values that gets
31999 * called from various functions in gvariant.c.
32001 * A reference is taken on @bytes.
32003 * Returns: a new #GVariant with a floating reference
32009 * g_variant_new_from_data:
32010 * @type: a definite #GVariantType
32011 * @data: (array length=size) (element-type guint8): the serialised data
32012 * @size: the size of @data
32013 * @trusted: %TRUE if @data is definitely in normal form
32014 * @notify: (scope async): function to call when @data is no longer needed
32015 * @user_data: data for @notify
32017 * Creates a new #GVariant instance from serialised data.
32019 * @type is the type of #GVariant instance that will be constructed.
32020 * The interpretation of @data depends on knowing the type.
32022 * @data is not modified by this function and must remain valid with an
32023 * unchanging value until such a time as @notify is called with
32024 * @user_data. If the contents of @data change before that time then
32025 * the result is undefined.
32027 * If @data is trusted to be serialised data in normal form then
32028 * @trusted should be %TRUE. This applies to serialised data created
32029 * within this process or read from a trusted location on the disk (such
32030 * as a file installed in /usr/lib alongside your application). You
32031 * should set trusted to %FALSE if @data is read from the network, a
32032 * file in the user's home directory, etc.
32034 * If @data was not stored in this machine's native endianness, any multi-byte
32035 * numeric values in the returned variant will also be in non-native
32036 * endianness. g_variant_byteswap() can be used to recover the original values.
32038 * @notify will be called with @user_data when @data is no longer
32039 * needed. The exact time of this call is unspecified and might even be
32040 * before this function returns.
32042 * Returns: (transfer none): a new floating #GVariant of type @type
32048 * g_variant_new_handle:
32049 * @value: a #gint32 value
32051 * Creates a new handle #GVariant instance.
32053 * By convention, handles are indexes into an array of file descriptors
32054 * that are sent alongside a D-Bus message. If you're not interacting
32055 * with D-Bus, you probably don't need them.
32057 * Returns: (transfer none): a floating reference to a new handle #GVariant instance
32063 * g_variant_new_int16:
32064 * @value: a #gint16 value
32066 * Creates a new int16 #GVariant instance.
32068 * Returns: (transfer none): a floating reference to a new int16 #GVariant instance
32074 * g_variant_new_int32:
32075 * @value: a #gint32 value
32077 * Creates a new int32 #GVariant instance.
32079 * Returns: (transfer none): a floating reference to a new int32 #GVariant instance
32085 * g_variant_new_int64:
32086 * @value: a #gint64 value
32088 * Creates a new int64 #GVariant instance.
32090 * Returns: (transfer none): a floating reference to a new int64 #GVariant instance
32096 * g_variant_new_maybe:
32097 * @child_type: (allow-none): the #GVariantType of the child, or %NULL
32098 * @child: (allow-none): the child value, or %NULL
32100 * Depending on if @child is %NULL, either wraps @child inside of a
32101 * maybe container or creates a Nothing instance for the given @type.
32103 * At least one of @child_type and @child must be non-%NULL.
32104 * If @child_type is non-%NULL then it must be a definite type.
32105 * If they are both non-%NULL then @child_type must be the type
32108 * If @child is a floating reference (see g_variant_ref_sink()), the new
32109 * instance takes ownership of @child.
32111 * Returns: (transfer none): a floating reference to a new #GVariant maybe instance
32117 * g_variant_new_object_path:
32118 * @object_path: a normal C nul-terminated string
32120 * Creates a D-Bus object path #GVariant with the contents of @string.
32121 * @string must be a valid D-Bus object path. Use
32122 * g_variant_is_object_path() if you're not sure.
32124 * Returns: (transfer none): a floating reference to a new object path #GVariant instance
32130 * g_variant_new_objv:
32131 * @strv: (array length=length) (element-type utf8): an array of strings
32132 * @length: the length of @strv, or -1
32134 * Constructs an array of object paths #GVariant from the given array of
32137 * Each string must be a valid #GVariant object path; see
32138 * g_variant_is_object_path().
32140 * If @length is -1 then @strv is %NULL-terminated.
32142 * Returns: (transfer none): a new floating #GVariant instance
32148 * g_variant_new_parsed:
32149 * @format: a text format #GVariant
32150 * @...: arguments as per @format
32152 * Parses @format and returns the result.
32154 * @format must be a text format #GVariant with one extension: at any
32155 * point that a value may appear in the text, a '%' character followed
32156 * by a GVariant format string (as per g_variant_new()) may appear. In
32157 * that case, the same arguments are collected from the argument list as
32158 * g_variant_new() would have collected.
32160 * Consider this simple example:
32162 * <informalexample><programlisting>
32163 * g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
32164 * </programlisting></informalexample>
32166 * In the example, the variable argument parameters are collected and
32167 * filled in as if they were part of the original string to produce the
32168 * result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
32170 * This function is intended only to be used with @format as a string
32171 * literal. Any parse error is fatal to the calling process. If you
32172 * want to parse data from untrusted sources, use g_variant_parse().
32174 * You may not use this function to return, unmodified, a single
32175 * #GVariant pointer from the argument list. ie: @format may not solely
32176 * be anything along the lines of "%*", "%?", "\%r", or anything starting
32179 * Returns: a new floating #GVariant instance
32184 * g_variant_new_parsed_va:
32185 * @format: a text format #GVariant
32186 * @app: a pointer to a #va_list
32188 * Parses @format and returns the result.
32190 * This is the version of g_variant_new_parsed() intended to be used
32193 * The return value will be floating if it was a newly created GVariant
32194 * instance. In the case that @format simply specified the collection
32195 * of a #GVariant pointer (eg: @format was "%*") then the collected
32196 * #GVariant pointer will be returned unmodified, without adding any
32197 * additional references.
32199 * In order to behave correctly in all cases it is necessary for the
32200 * calling function to g_variant_ref_sink() the return result before
32201 * returning control to the user that originally provided the pointer.
32202 * At this point, the caller will have their own full reference to the
32203 * result. This can also be done by adding the result to a container,
32204 * or by passing it to another g_variant_new() call.
32206 * Returns: a new, usually floating, #GVariant
32211 * g_variant_new_signature:
32212 * @signature: a normal C nul-terminated string
32214 * Creates a D-Bus type signature #GVariant with the contents of
32215 * @string. @string must be a valid D-Bus type signature. Use
32216 * g_variant_is_signature() if you're not sure.
32218 * Returns: (transfer none): a floating reference to a new signature #GVariant instance
32224 * g_variant_new_string:
32225 * @string: a normal utf8 nul-terminated string
32227 * Creates a string #GVariant with the contents of @string.
32229 * @string must be valid utf8.
32231 * Returns: (transfer none): a floating reference to a new string #GVariant instance
32237 * g_variant_new_strv:
32238 * @strv: (array length=length) (element-type utf8): an array of strings
32239 * @length: the length of @strv, or -1
32241 * Constructs an array of strings #GVariant from the given array of
32244 * If @length is -1 then @strv is %NULL-terminated.
32246 * Returns: (transfer none): a new floating #GVariant instance
32252 * g_variant_new_tuple:
32253 * @children: (array length=n_children): the items to make the tuple out of
32254 * @n_children: the length of @children
32256 * Creates a new tuple #GVariant out of the items in @children. The
32257 * type is determined from the types of @children. No entry in the
32258 * @children array may be %NULL.
32260 * If @n_children is 0 then the unit tuple is constructed.
32262 * If the @children are floating references (see g_variant_ref_sink()), the
32263 * new instance takes ownership of them as if via g_variant_ref_sink().
32265 * Returns: (transfer none): a floating reference to a new #GVariant tuple
32271 * g_variant_new_uint16:
32272 * @value: a #guint16 value
32274 * Creates a new uint16 #GVariant instance.
32276 * Returns: (transfer none): a floating reference to a new uint16 #GVariant instance
32282 * g_variant_new_uint32:
32283 * @value: a #guint32 value
32285 * Creates a new uint32 #GVariant instance.
32287 * Returns: (transfer none): a floating reference to a new uint32 #GVariant instance
32293 * g_variant_new_uint64:
32294 * @value: a #guint64 value
32296 * Creates a new uint64 #GVariant instance.
32298 * Returns: (transfer none): a floating reference to a new uint64 #GVariant instance
32304 * g_variant_new_va: (skip)
32305 * @format_string: a string that is prefixed with a format string
32306 * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
32307 * @app: a pointer to a #va_list
32309 * This function is intended to be used by libraries based on
32310 * #GVariant that want to provide g_variant_new()-like functionality
32313 * The API is more general than g_variant_new() to allow a wider range
32314 * of possible uses.
32316 * @format_string must still point to a valid format string, but it only
32317 * needs to be nul-terminated if @endptr is %NULL. If @endptr is
32318 * non-%NULL then it is updated to point to the first character past the
32319 * end of the format string.
32321 * @app is a pointer to a #va_list. The arguments, according to
32322 * @format_string, are collected from this #va_list and the list is left
32323 * pointing to the argument following the last.
32325 * These two generalisations allow mixing of multiple calls to
32326 * g_variant_new_va() and g_variant_get_va() within a single actual
32327 * varargs call by the user.
32329 * The return value will be floating if it was a newly created GVariant
32330 * instance (for example, if the format string was "(ii)"). In the case
32331 * that the format_string was '*', '?', 'r', or a format starting with
32332 * '@' then the collected #GVariant pointer will be returned unmodified,
32333 * without adding any additional references.
32335 * In order to behave correctly in all cases it is necessary for the
32336 * calling function to g_variant_ref_sink() the return result before
32337 * returning control to the user that originally provided the pointer.
32338 * At this point, the caller will have their own full reference to the
32339 * result. This can also be done by adding the result to a container,
32340 * or by passing it to another g_variant_new() call.
32342 * Returns: a new, usually floating, #GVariant
32348 * g_variant_new_variant: (constructor)
32349 * @value: a #GVariant instance
32351 * Boxes @value. The result is a #GVariant instance representing a
32352 * variant containing the original value.
32354 * If @child is a floating reference (see g_variant_ref_sink()), the new
32355 * instance takes ownership of @child.
32357 * Returns: (transfer none): a floating reference to a new variant #GVariant instance
32364 * @type: (allow-none): a #GVariantType, or %NULL
32365 * @text: a string containing a GVariant in text form
32366 * @limit: (allow-none): a pointer to the end of @text, or %NULL
32367 * @endptr: (allow-none): a location to store the end pointer, or %NULL
32368 * @error: (allow-none): a pointer to a %NULL #GError pointer, or %NULL
32370 * Parses a #GVariant from a text representation.
32372 * A single #GVariant is parsed from the content of @text.
32374 * The format is described <link linkend='gvariant-text'>here</link>.
32376 * The memory at @limit will never be accessed and the parser behaves as
32377 * if the character at @limit is the nul terminator. This has the
32378 * effect of bounding @text.
32380 * If @endptr is non-%NULL then @text is permitted to contain data
32381 * following the value that this function parses and @endptr will be
32382 * updated to point to the first character past the end of the text
32383 * parsed by this function. If @endptr is %NULL and there is extra data
32384 * then an error is returned.
32386 * If @type is non-%NULL then the value will be parsed to have that
32387 * type. This may result in additional parse errors (in the case that
32388 * the parsed value doesn't fit the type) but may also result in fewer
32389 * errors (in the case that the type would have been ambiguous, such as
32390 * with empty arrays).
32392 * In the event that the parsing is successful, the resulting #GVariant
32395 * In case of any error, %NULL will be returned. If @error is non-%NULL
32396 * then it will be set to reflect the error that occurred.
32398 * Officially, the language understood by the parser is "any string
32399 * produced by g_variant_print()".
32401 * Returns: a reference to a #GVariant, or %NULL
32407 * @value: a #GVariant
32408 * @type_annotate: %TRUE if type information should be included in the output
32410 * Pretty-prints @value in the format understood by g_variant_parse().
32412 * The format is described <link linkend='gvariant-text'>here</link>.
32414 * If @type_annotate is %TRUE, then type information is included in
32417 * Returns: (transfer full): a newly-allocated string holding the result.
32423 * g_variant_print_string: (skip)
32424 * @value: a #GVariant
32425 * @string: (allow-none) (default NULL): a #GString, or %NULL
32426 * @type_annotate: %TRUE if type information should be included in the output
32428 * Behaves as g_variant_print(), but operates on a #GString.
32430 * If @string is non-%NULL then it is appended to and returned. Else,
32431 * a new empty #GString is allocated and it is returned.
32433 * Returns: a #GString containing the string
32440 * @value: a #GVariant
32442 * Increases the reference count of @value.
32444 * Returns: the same @value
32450 * g_variant_ref_sink:
32451 * @value: a #GVariant
32453 * #GVariant uses a floating reference count system. All functions with
32454 * names starting with <literal>g_variant_new_</literal> return floating
32457 * Calling g_variant_ref_sink() on a #GVariant with a floating reference
32458 * will convert the floating reference into a full reference. Calling
32459 * g_variant_ref_sink() on a non-floating #GVariant results in an
32460 * additional normal reference being added.
32462 * In other words, if the @value is floating, then this call "assumes
32463 * ownership" of the floating reference, converting it to a normal
32464 * reference. If the @value is not floating, then this call adds a
32465 * new normal reference increasing the reference count by one.
32467 * All calls that result in a #GVariant instance being inserted into a
32468 * container will call g_variant_ref_sink() on the instance. This means
32469 * that if the value was just created (and has only its floating
32470 * reference) then the container will assume sole ownership of the value
32471 * at that point and the caller will not need to unreference it. This
32472 * makes certain common styles of programming much easier while still
32473 * maintaining normal refcounting semantics in situations where values
32474 * are not floating.
32476 * Returns: the same @value
32483 * @value: the #GVariant to store
32484 * @data: the location to store the serialised data at
32486 * Stores the serialised form of @value at @data. @data should be
32487 * large enough. See g_variant_get_size().
32489 * The stored data is in machine native byte order but may not be in
32490 * fully-normalised form if read from an untrusted source. See
32491 * g_variant_get_normal_form() for a solution.
32493 * As with g_variant_get_data(), to be able to deserialise the
32494 * serialised variant successfully, its type and (if the destination
32495 * machine might be different) its endianness must also be available.
32497 * This function is approximately O(n) in the size of @data.
32504 * g_variant_take_ref:
32505 * @value: a #GVariant
32507 * If @value is floating, sink it. Otherwise, do nothing.
32509 * Typically you want to use g_variant_ref_sink() in order to
32510 * automatically do the correct thing with respect to floating or
32511 * non-floating references, but there is one specific scenario where
32512 * this function is helpful.
32514 * The situation where this function is helpful is when creating an API
32515 * that allows the user to provide a callback function that returns a
32516 * #GVariant. We certainly want to allow the user the flexibility to
32517 * return a non-floating reference from this callback (for the case
32518 * where the value that is being returned already exists).
32520 * At the same time, the style of the #GVariant API makes it likely that
32521 * for newly-created #GVariant instances, the user can be saved some
32522 * typing if they are allowed to return a #GVariant with a floating
32525 * Using this function on the return value of the user's callback allows
32526 * the user to do whichever is more convenient for them. The caller
32527 * will alway receives exactly one full reference to the value: either
32528 * the one that was returned in the first place, or a floating reference
32529 * that has been converted to a full reference.
32531 * This function has an odd interaction when combined with
32532 * g_variant_ref_sink() running at the same time in another thread on
32533 * the same #GVariant instance. If g_variant_ref_sink() runs first then
32534 * the result will be that the floating reference is converted to a hard
32535 * reference. If g_variant_take_ref() runs first then the result will
32536 * be that the floating reference is converted to a hard reference and
32537 * an additional reference on top of that one is added. It is best to
32538 * avoid this situation.
32540 * Returns: the same @value
32545 * g_variant_type_copy:
32546 * @type: a #GVariantType
32548 * Makes a copy of a #GVariantType. It is appropriate to call
32549 * g_variant_type_free() on the return value. @type may not be %NULL.
32551 * Returns: (transfer full): a new #GVariantType Since 2.24
32556 * g_variant_type_dup_string:
32557 * @type: a #GVariantType
32559 * Returns a newly-allocated copy of the type string corresponding to
32560 * @type. The returned string is nul-terminated. It is appropriate to
32561 * call g_free() on the return value.
32563 * Returns: (transfer full): the corresponding type string Since 2.24
32568 * g_variant_type_element:
32569 * @type: an array or maybe #GVariantType
32571 * Determines the element type of an array or maybe type.
32573 * This function may only be used with array or maybe types.
32575 * Returns: (transfer none): the element type of @type Since 2.24
32580 * g_variant_type_equal:
32581 * @type1: (type GVariantType): a #GVariantType
32582 * @type2: (type GVariantType): a #GVariantType
32584 * Compares @type1 and @type2 for equality.
32586 * Only returns %TRUE if the types are exactly equal. Even if one type
32587 * is an indefinite type and the other is a subtype of it, %FALSE will
32588 * be returned if they are not exactly equal. If you want to check for
32589 * subtypes, use g_variant_type_is_subtype_of().
32591 * The argument types of @type1 and @type2 are only #gconstpointer to
32592 * allow use with #GHashTable without function pointer casting. For
32593 * both arguments, a valid #GVariantType must be provided.
32595 * Returns: %TRUE if @type1 and @type2 are exactly equal Since 2.24
32600 * g_variant_type_first:
32601 * @type: a tuple or dictionary entry #GVariantType
32603 * Determines the first item type of a tuple or dictionary entry
32606 * This function may only be used with tuple or dictionary entry types,
32607 * but must not be used with the generic tuple type
32608 * %G_VARIANT_TYPE_TUPLE.
32610 * In the case of a dictionary entry type, this returns the type of
32613 * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
32615 * This call, together with g_variant_type_next() provides an iterator
32616 * interface over tuple and dictionary entry types.
32618 * Returns: (transfer none): the first item type of @type, or %NULL Since 2.24
32623 * g_variant_type_free:
32624 * @type: (allow-none): a #GVariantType, or %NULL
32626 * Frees a #GVariantType that was allocated with
32627 * g_variant_type_copy(), g_variant_type_new() or one of the container
32628 * type constructor functions.
32630 * In the case that @type is %NULL, this function does nothing.
32637 * g_variant_type_get_string_length:
32638 * @type: a #GVariantType
32640 * Returns the length of the type string corresponding to the given
32641 * @type. This function must be used to determine the valid extent of
32642 * the memory region returned by g_variant_type_peek_string().
32644 * Returns: the length of the corresponding type string Since 2.24
32649 * g_variant_type_hash:
32650 * @type: (type GVariantType): a #GVariantType
32654 * The argument type of @type is only #gconstpointer to allow use with
32655 * #GHashTable without function pointer casting. A valid
32656 * #GVariantType must be provided.
32658 * Returns: the hash value Since 2.24
32663 * g_variant_type_is_array:
32664 * @type: a #GVariantType
32666 * Determines if the given @type is an array type. This is true if the
32667 * type string for @type starts with an 'a'.
32669 * This function returns %TRUE for any indefinite type for which every
32670 * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
32673 * Returns: %TRUE if @type is an array type Since 2.24
32678 * g_variant_type_is_basic:
32679 * @type: a #GVariantType
32681 * Determines if the given @type is a basic type.
32683 * Basic types are booleans, bytes, integers, doubles, strings, object
32684 * paths and signatures.
32686 * Only a basic type may be used as the key of a dictionary entry.
32688 * This function returns %FALSE for all indefinite types except
32689 * %G_VARIANT_TYPE_BASIC.
32691 * Returns: %TRUE if @type is a basic type Since 2.24
32696 * g_variant_type_is_container:
32697 * @type: a #GVariantType
32699 * Determines if the given @type is a container type.
32701 * Container types are any array, maybe, tuple, or dictionary
32702 * entry types plus the variant type.
32704 * This function returns %TRUE for any indefinite type for which every
32705 * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
32708 * Returns: %TRUE if @type is a container type Since 2.24
32713 * g_variant_type_is_definite:
32714 * @type: a #GVariantType
32716 * Determines if the given @type is definite (ie: not indefinite).
32718 * A type is definite if its type string does not contain any indefinite
32719 * type characters ('*', '?', or 'r').
32721 * A #GVariant instance may not have an indefinite type, so calling
32722 * this function on the result of g_variant_get_type() will always
32723 * result in %TRUE being returned. Calling this function on an
32724 * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
32725 * %FALSE being returned.
32727 * Returns: %TRUE if @type is definite Since 2.24
32732 * g_variant_type_is_dict_entry:
32733 * @type: a #GVariantType
32735 * Determines if the given @type is a dictionary entry type. This is
32736 * true if the type string for @type starts with a '{'.
32738 * This function returns %TRUE for any indefinite type for which every
32739 * definite subtype is a dictionary entry type --
32740 * %G_VARIANT_TYPE_DICT_ENTRY, for example.
32742 * Returns: %TRUE if @type is a dictionary entry type Since 2.24
32747 * g_variant_type_is_maybe:
32748 * @type: a #GVariantType
32750 * Determines if the given @type is a maybe type. This is true if the
32751 * type string for @type starts with an 'm'.
32753 * This function returns %TRUE for any indefinite type for which every
32754 * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
32757 * Returns: %TRUE if @type is a maybe type Since 2.24
32762 * g_variant_type_is_subtype_of:
32763 * @type: a #GVariantType
32764 * @supertype: a #GVariantType
32766 * Checks if @type is a subtype of @supertype.
32768 * This function returns %TRUE if @type is a subtype of @supertype. All
32769 * types are considered to be subtypes of themselves. Aside from that,
32770 * only indefinite types can have subtypes.
32772 * Returns: %TRUE if @type is a subtype of @supertype Since 2.24
32777 * g_variant_type_is_tuple:
32778 * @type: a #GVariantType
32780 * Determines if the given @type is a tuple type. This is true if the
32781 * type string for @type starts with a '(' or if @type is
32782 * %G_VARIANT_TYPE_TUPLE.
32784 * This function returns %TRUE for any indefinite type for which every
32785 * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
32788 * Returns: %TRUE if @type is a tuple type Since 2.24
32793 * g_variant_type_is_variant:
32794 * @type: a #GVariantType
32796 * Determines if the given @type is the variant type.
32798 * Returns: %TRUE if @type is the variant type Since 2.24
32803 * g_variant_type_key:
32804 * @type: a dictionary entry #GVariantType
32806 * Determines the key type of a dictionary entry type.
32808 * This function may only be used with a dictionary entry type. Other
32809 * than the additional restriction, this call is equivalent to
32810 * g_variant_type_first().
32812 * Returns: (transfer none): the key type of the dictionary entry Since 2.24
32817 * g_variant_type_n_items:
32818 * @type: a tuple or dictionary entry #GVariantType
32820 * Determines the number of items contained in a tuple or
32821 * dictionary entry type.
32823 * This function may only be used with tuple or dictionary entry types,
32824 * but must not be used with the generic tuple type
32825 * %G_VARIANT_TYPE_TUPLE.
32827 * In the case of a dictionary entry type, this function will always
32830 * Returns: the number of items in @type Since 2.24
32835 * g_variant_type_new:
32836 * @type_string: a valid GVariant type string
32838 * Creates a new #GVariantType corresponding to the type string given
32839 * by @type_string. It is appropriate to call g_variant_type_free() on
32840 * the return value.
32842 * It is a programmer error to call this function with an invalid type
32843 * string. Use g_variant_type_string_is_valid() if you are unsure.
32845 * Returns: (transfer full): a new #GVariantType
32851 * g_variant_type_new_array: (constructor)
32852 * @element: a #GVariantType
32854 * Constructs the type corresponding to an array of elements of the
32857 * It is appropriate to call g_variant_type_free() on the return value.
32859 * Returns: (transfer full): a new array #GVariantType Since 2.24
32864 * g_variant_type_new_dict_entry: (constructor)
32865 * @key: a basic #GVariantType
32866 * @value: a #GVariantType
32868 * Constructs the type corresponding to a dictionary entry with a key
32869 * of type @key and a value of type @value.
32871 * It is appropriate to call g_variant_type_free() on the return value.
32873 * Returns: (transfer full): a new dictionary entry #GVariantType Since 2.24
32878 * g_variant_type_new_maybe: (constructor)
32879 * @element: a #GVariantType
32881 * Constructs the type corresponding to a maybe instance containing
32882 * type @type or Nothing.
32884 * It is appropriate to call g_variant_type_free() on the return value.
32886 * Returns: (transfer full): a new maybe #GVariantType Since 2.24
32891 * g_variant_type_new_tuple:
32892 * @items: (array length=length): an array of #GVariantTypes, one for each item
32893 * @length: the length of @items, or -1
32895 * Constructs a new tuple type, from @items.
32897 * @length is the number of items in @items, or -1 to indicate that
32898 * @items is %NULL-terminated.
32900 * It is appropriate to call g_variant_type_free() on the return value.
32902 * Returns: (transfer full): a new tuple #GVariantType Since 2.24
32907 * g_variant_type_next:
32908 * @type: a #GVariantType from a previous call
32910 * Determines the next item type of a tuple or dictionary entry
32913 * @type must be the result of a previous call to
32914 * g_variant_type_first() or g_variant_type_next().
32916 * If called on the key type of a dictionary entry then this call
32917 * returns the value type. If called on the value type of a dictionary
32918 * entry then this call returns %NULL.
32920 * For tuples, %NULL is returned when @type is the last item in a tuple.
32922 * Returns: (transfer none): the next #GVariantType after @type, or %NULL Since 2.24
32927 * g_variant_type_peek_string: (skip)
32928 * @type: a #GVariantType
32930 * Returns the type string corresponding to the given @type. The
32931 * result is not nul-terminated; in order to determine its length you
32932 * must call g_variant_type_get_string_length().
32934 * To get a nul-terminated string, see g_variant_type_dup_string().
32936 * Returns: the corresponding type string (not nul-terminated) Since 2.24
32941 * g_variant_type_string_is_valid:
32942 * @type_string: a pointer to any string
32944 * Checks if @type_string is a valid GVariant type string. This call is
32945 * equivalent to calling g_variant_type_string_scan() and confirming
32946 * that the following character is a nul terminator.
32948 * Returns: %TRUE if @type_string is exactly one valid type string Since 2.24
32953 * g_variant_type_string_scan:
32954 * @string: a pointer to any string
32955 * @limit: (allow-none): the end of @string, or %NULL
32956 * @endptr: (out) (allow-none): location to store the end pointer, or %NULL
32958 * Scan for a single complete and valid GVariant type string in @string.
32959 * The memory pointed to by @limit (or bytes beyond it) is never
32962 * If a valid type string is found, @endptr is updated to point to the
32963 * first character past the end of the string that was found and %TRUE
32966 * If there is no valid type string starting at @string, or if the type
32967 * string does not end before @limit then %FALSE is returned.
32969 * For the simple case of checking if a string is a valid type string,
32970 * see g_variant_type_string_is_valid().
32972 * Returns: %TRUE if a valid type string was found
32978 * g_variant_type_value:
32979 * @type: a dictionary entry #GVariantType
32981 * Determines the value type of a dictionary entry type.
32983 * This function may only be used with a dictionary entry type.
32985 * Returns: (transfer none): the value type of the dictionary entry Since 2.24
32991 * @value: a #GVariant
32993 * Decreases the reference count of @value. When its reference count
32994 * drops to 0, the memory used by the variant is freed.
33002 * @string: the return location for the newly-allocated string.
33003 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33004 * @args: the list of arguments to insert in the output.
33006 * An implementation of the GNU vasprintf() function which supports
33007 * positional parameters, as specified in the Single Unix Specification.
33008 * This function is similar to g_vsprintf(), except that it allocates a
33009 * string to hold the output, instead of putting the output in a buffer
33010 * you allocate in advance.
33012 * Returns: the number of bytes printed.
33019 * @file: the stream to write to.
33020 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33021 * @args: the list of arguments to insert in the output.
33023 * An implementation of the standard fprintf() function which supports
33024 * positional parameters, as specified in the Single Unix Specification.
33026 * Returns: the number of bytes printed.
33033 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33034 * @args: the list of arguments to insert in the output.
33036 * An implementation of the standard vprintf() function which supports
33037 * positional parameters, as specified in the Single Unix Specification.
33039 * Returns: the number of bytes printed.
33046 * @string: the buffer to hold the output.
33047 * @n: the maximum number of bytes to produce (including the terminating nul character).
33048 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33049 * @args: the list of arguments to insert in the output.
33051 * A safer form of the standard vsprintf() function. The output is guaranteed
33052 * to not exceed @n characters (including the terminating nul character), so
33053 * it is easy to ensure that a buffer overflow cannot occur.
33055 * See also g_strdup_vprintf().
33057 * In versions of GLib prior to 1.2.3, this function may return -1 if the
33058 * output was truncated, and the truncated string may not be nul-terminated.
33059 * In versions prior to 1.3.12, this function returns the length of the output
33062 * The return value of g_vsnprintf() conforms to the vsnprintf() function
33063 * as standardized in ISO C99. Note that this is different from traditional
33064 * vsnprintf(), which returns the length of the output string.
33066 * The format string may contain positional parameters, as specified in
33067 * the Single Unix Specification.
33069 * Returns: the number of bytes which would be produced if the buffer was large enough.
33075 * @string: the buffer to hold the output.
33076 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33077 * @args: the list of arguments to insert in the output.
33079 * An implementation of the standard vsprintf() function which supports
33080 * positional parameters, as specified in the Single Unix Specification.
33082 * Returns: the number of bytes printed.
33088 * g_wakeup_acknowledge:
33089 * @wakeup: a #GWakeup
33091 * Acknowledges receipt of a wakeup signal on @wakeup.
33093 * You must call this after @wakeup polls as ready. If not, it will
33094 * continue to poll as ready until you do so.
33096 * If you call this function and @wakeup is not signaled, nothing
33105 * @wakeup: a #GWakeup
33109 * You must not currently be polling on the #GPollFD returned by
33110 * g_wakeup_get_pollfd(), or the result is undefined.
33115 * g_wakeup_get_pollfd:
33116 * @wakeup: a #GWakeup
33117 * @poll_fd: a #GPollFD
33119 * Prepares a @poll_fd such that polling on it will succeed when
33120 * g_wakeup_signal() has been called on @wakeup.
33122 * @poll_fd is valid until @wakeup is freed.
33131 * Creates a new #GWakeup.
33133 * You should use g_wakeup_free() to free it when you are done.
33135 * Returns: a new #GWakeup
33142 * @wakeup: a #GWakeup
33146 * Any future (or present) polling on the #GPollFD returned by
33147 * g_wakeup_get_pollfd() will immediately succeed until such a time as
33148 * g_wakeup_acknowledge() is called.
33150 * This function is safe to call from a UNIX signal handler.
33158 * @...: format string, followed by parameters to insert into the format string (as with printf())
33160 * A convenience function/macro to log a warning message.
33162 * You can make warnings fatal at runtime by setting the
33163 * <envar>G_DEBUG</envar> environment variable (see
33164 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
33169 * g_win32_error_message:
33170 * @error: error code.
33172 * Translate a Win32 error code (as returned by GetLastError()) into
33173 * the corresponding message. The message is either language neutral,
33174 * or in the thread's language, or the user's language, the system's
33175 * language, or US English (see docs for FormatMessage()). The
33176 * returned string is in UTF-8. It should be deallocated with
33179 * Returns: newly-allocated error message
33184 * g_win32_get_package_installation_directory:
33185 * @package: (allow-none): You should pass %NULL for this.
33186 * @dll_name: (allow-none): The name of a DLL that a package provides in UTF-8, or %NULL.
33188 * Try to determine the installation directory for a software package.
33190 * This function is deprecated. Use
33191 * g_win32_get_package_installation_directory_of_module() instead.
33193 * The use of @package is deprecated. You should always pass %NULL. A
33194 * warning is printed if non-NULL is passed as @package.
33196 * The original intended use of @package was for a short identifier of
33197 * the package, typically the same identifier as used for
33198 * <literal>GETTEXT_PACKAGE</literal> in software configured using GNU
33199 * autotools. The function first looks in the Windows Registry for the
33200 * value <literal>#InstallationDirectory</literal> in the key
33201 * <literal>#HKLM\Software\@package</literal>, and if that value
33202 * exists and is a string, returns that.
33204 * It is strongly recommended that packagers of GLib-using libraries
33205 * for Windows do not store installation paths in the Registry to be
33206 * used by this function as that interfers with having several
33207 * parallel installations of the library. Enabling multiple
33208 * installations of different versions of some GLib-using library, or
33209 * GLib itself, is desirable for various reasons.
33211 * For this reason it is recommeded to always pass %NULL as
33212 * @package to this function, to avoid the temptation to use the
33213 * Registry. In version 2.20 of GLib the @package parameter
33214 * will be ignored and this function won't look in the Registry at all.
33216 * If @package is %NULL, or the above value isn't found in the
33217 * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
33218 * into the current process. Typically that would be the name of the
33219 * DLL calling this function, looking for its installation
33220 * directory. The function then asks Windows what directory that DLL
33221 * was loaded from. If that directory's last component is "bin" or
33222 * "lib", the parent directory is returned, otherwise the directory
33223 * itself. If that DLL isn't loaded, the function proceeds as if
33224 * @dll_name was %NULL.
33226 * If both @package and @dll_name are %NULL, the directory from where
33227 * the main executable of the process was loaded is used instead in
33228 * the same way as above.
33230 * Returns: a string containing the installation directory for @package. The string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when not needed any longer. If the function fails %NULL is returned.
33231 * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to g_win32_get_package_installation_directory_of_module() instead.
33236 * g_win32_get_package_installation_directory_of_module:
33237 * @hmodule: (allow-none): The Win32 handle for a DLL loaded into the current process, or %NULL
33239 * This function tries to determine the installation directory of a
33240 * software package based on the location of a DLL of the software
33243 * @hmodule should be the handle of a loaded DLL or %NULL. The
33244 * function looks up the directory that DLL was loaded from. If
33245 * @hmodule is NULL, the directory the main executable of the current
33246 * process is looked up. If that directory's last component is "bin"
33247 * or "lib", its parent directory is returned, otherwise the directory
33250 * It thus makes sense to pass only the handle to a "public" DLL of a
33251 * software package to this function, as such DLLs typically are known
33252 * to be installed in a "bin" or occasionally "lib" subfolder of the
33253 * installation folder. DLLs that are of the dynamically loaded module
33254 * or plugin variety are often located in more private locations
33255 * deeper down in the tree, from which it is impossible for GLib to
33256 * deduce the root of the package installation.
33258 * The typical use case for this function is to have a DllMain() that
33259 * saves the handle for the DLL. Then when code in the DLL needs to
33260 * construct names of files in the installation tree it calls this
33261 * function passing the DLL handle.
33263 * Returns: a string containing the guessed installation directory for the software package @hmodule is from. The string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when not needed any longer. If the function fails %NULL is returned.
33269 * g_win32_get_package_installation_subdirectory:
33270 * @package: (allow-none): You should pass %NULL for this.
33271 * @dll_name: (allow-none): The name of a DLL that a package provides, in UTF-8, or %NULL.
33272 * @subdir: A subdirectory of the package installation directory, also in UTF-8
33274 * This function is deprecated. Use
33275 * g_win32_get_package_installation_directory_of_module() and
33276 * g_build_filename() instead.
33278 * Returns a newly-allocated string containing the path of the
33279 * subdirectory @subdir in the return value from calling
33280 * g_win32_get_package_installation_directory() with the @package and
33281 * @dll_name parameters. See the documentation for
33282 * g_win32_get_package_installation_directory() for more details. In
33283 * particular, note that it is deprecated to pass anything except NULL
33286 * Returns: a string containing the complete path to @subdir inside the installation directory of @package. The returned string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when no longer needed. If something goes wrong, %NULL is returned.
33287 * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to g_win32_get_package_installation_directory_of_module() instead, and then construct a subdirectory pathname with g_build_filename().
33292 * g_win32_get_windows_version:
33294 * Returns version information for the Windows operating system the
33295 * code is running on. See MSDN documentation for the GetVersion()
33296 * function. To summarize, the most significant bit is one on Win9x,
33297 * and zero on NT-based systems. Since version 2.14, GLib works only
33298 * on NT-based systems, so checking whether your are running on Win9x
33299 * in your own software is moot. The least significant byte is 4 on
33300 * Windows NT 4, and 5 on Windows XP. Software that needs really
33301 * detailed version and feature information should use Win32 API like
33302 * GetVersionEx() and VerifyVersionInfo().
33304 * Returns: The version information.
33310 * g_win32_getlocale:
33312 * The setlocale() function in the Microsoft C library uses locale
33313 * names of the form "English_United States.1252" etc. We want the
33314 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
33315 * current thread locale from Windows - without any encoding info -
33316 * and returns it as a string of the above form for use in forming
33317 * file names etc. The returned string should be deallocated with
33320 * Returns: newly-allocated locale name.
33325 * g_win32_locale_filename_from_utf8:
33326 * @utf8filename: a UTF-8 encoded filename.
33328 * Converts a filename from UTF-8 to the system codepage.
33330 * On NT-based Windows, on NTFS file systems, file names are in
33331 * Unicode. It is quite possible that Unicode file names contain
33332 * characters not representable in the system codepage. (For instance,
33333 * Greek or Cyrillic characters on Western European or US Windows
33334 * installations, or various less common CJK characters on CJK Windows
33337 * In such a case, and if the filename refers to an existing file, and
33338 * the file system stores alternate short (8.3) names for directory
33339 * entries, the short form of the filename is returned. Note that the
33340 * "short" name might in fact be longer than the Unicode name if the
33341 * Unicode name has very short pathname components containing
33342 * non-ASCII characters. If no system codepage name for the file is
33343 * possible, %NULL is returned.
33345 * The return value is dynamically allocated and should be freed with
33346 * g_free() when no longer needed.
33348 * Returns: The converted filename, or %NULL on conversion failure and lack of short names.
33356 * A standard boolean type.
33357 * Variables of this type should only contain the value
33365 * Corresponds to the standard C <type>char</type> type.
33372 * An untyped pointer to constant data.
33373 * The data pointed to should not be changed.
33375 * This is typically used in function prototypes to indicate
33376 * that the data pointed to will not be altered by the function.
33383 * Corresponds to the standard C <type>double</type> type.
33384 * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
33391 * Corresponds to the standard C <type>float</type> type.
33392 * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
33399 * Corresponds to the standard C <type>int</type> type.
33400 * Values of this type can range from #G_MININT to #G_MAXINT.
33407 * A signed integer guaranteed to be 16 bits on all platforms.
33408 * Values of this type can range from #G_MININT16 (= -32,768) to
33409 * #G_MAXINT16 (= 32,767).
33411 * To print or scan values of this type, use
33412 * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
33419 * A signed integer guaranteed to be 32 bits on all platforms.
33420 * Values of this type can range from #G_MININT32 (= -2,147,483,648)
33421 * to #G_MAXINT32 (= 2,147,483,647).
33423 * To print or scan values of this type, use
33424 * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
33431 * A signed integer guaranteed to be 64 bits on all platforms.
33432 * Values of this type can range from #G_MININT64
33433 * (= -9,223,372,036,854,775,808) to #G_MAXINT64
33434 * (= 9,223,372,036,854,775,807).
33436 * To print or scan values of this type, use
33437 * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
33444 * A signed integer guaranteed to be 8 bits on all platforms.
33445 * Values of this type can range from #G_MININT8 (= -128) to
33446 * #G_MAXINT8 (= 127).
33453 * Corresponds to the C99 type <type>intptr_t</type>,
33454 * a signed integer type that can hold any pointer.
33456 * To print or scan values of this type, use
33457 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
33465 * @arg: Do not use this argument
33467 * Do not call this function; it is used to share private
33468 * API between glib, gobject, and gio.
33473 * glib_check_version:
33474 * @required_major: the required major version.
33475 * @required_minor: the required minor version.
33476 * @required_micro: the required micro version.
33478 * Checks that the GLib library in use is compatible with the
33479 * given version. Generally you would pass in the constants
33480 * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
33481 * as the three arguments to this function; that produces
33482 * a check that the library in use is compatible with
33483 * the version of GLib the application or module was compiled
33486 * Compatibility is defined by two things: first the version
33487 * of the running library is newer than the version
33488 * @required_major.required_minor.@required_micro. Second
33489 * the running library must be binary compatible with the
33490 * version @required_major.required_minor.@required_micro
33491 * (same major version.)
33493 * Returns: %NULL if the GLib library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by GLib and must not be modified or freed.
33500 * @str: The string to be translated
33502 * Returns the translated string from the glib translations.
33503 * This is an internal function and should only be used by
33504 * the internals of glib (such as libgio).
33506 * Returns: the transation of @str to the current locale
33511 * glib_mem_profiler_table:
33513 * A #GMemVTable containing profiling variants of the memory
33514 * allocation functions. Use them together with g_mem_profile()
33515 * in order to get information about the memory allocation pattern
33522 * @msgctxtid: a combined message context and message id, separated by a \004 character
33523 * @msgidoffset: the offset of the message id in @msgctxid
33525 * This function is a variant of glib_gettext() which supports
33526 * a disambiguating message context. See g_dpgettext() for full
33529 * This is an internal function and should only be used by
33530 * the internals of glib (such as libgio).
33532 * Returns: the translation of @str to the current locale
33539 * Corresponds to the standard C <type>long</type> type.
33540 * Values of this type can range from #G_MINLONG to #G_MAXLONG.
33547 * A signed integer type that is used for file offsets,
33548 * corresponding to the C99 type <type>off64_t</type>.
33549 * Values of this type can range from #G_MINOFFSET to
33552 * To print or scan values of this type, use
33553 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
33562 * An untyped pointer.
33563 * #gpointer looks better and is easier to use
33564 * than <type>void*</type>.
33571 * Corresponds to the standard C <type>short</type> type.
33572 * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
33579 * An unsigned integer type of the result of the sizeof operator,
33580 * corresponding to the <type>size_t</type> type defined in C99.
33581 * This type is wide enough to hold the numeric value of a pointer,
33582 * so it is usually 32bit wide on a 32bit platform and 64bit wide
33583 * on a 64bit platform. Values of this type can range from 0 to
33586 * To print or scan values of this type, use
33587 * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
33594 * A signed variant of #gsize, corresponding to the
33595 * <type>ssize_t</type> defined on most platforms.
33596 * Values of this type can range from #G_MINSSIZE
33599 * To print or scan values of this type, use
33600 * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
33607 * Corresponds to the standard C <type>unsigned char</type> type.
33614 * Corresponds to the standard C <type>unsigned int</type> type.
33615 * Values of this type can range from 0 to #G_MAXUINT.
33622 * An unsigned integer guaranteed to be 16 bits on all platforms.
33623 * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
33625 * To print or scan values of this type, use
33626 * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
33633 * An unsigned integer guaranteed to be 32 bits on all platforms.
33634 * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
33636 * To print or scan values of this type, use
33637 * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
33644 * An unsigned integer guaranteed to be 64 bits on all platforms.
33645 * Values of this type can range from 0 to #G_MAXUINT64
33646 * (= 18,446,744,073,709,551,615).
33648 * To print or scan values of this type, use
33649 * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
33656 * An unsigned integer guaranteed to be 8 bits on all platforms.
33657 * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
33664 * Corresponds to the C99 type <type>uintptr_t</type>,
33665 * an unsigned integer type that can hold any pointer.
33667 * To print or scan values of this type, use
33668 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
33677 * Corresponds to the standard C <type>unsigned long</type> type.
33678 * Values of this type can range from 0 to #G_MAXULONG.
33685 * Corresponds to the standard C <type>unsigned short</type> type.
33686 * Values of this type can range from 0 to #G_MAXUSHORT.
33691 /************************************************************/
33692 /* THIS FILE IS GENERATED DO NOT EDIT */
33693 /************************************************************/