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 * @G_TEST_DIST: a file that was included in the distribution tarball
1766 * @G_TEST_BUILT: a file that was built on the compiling machine
1768 * The type of file to return the filename for, when used with
1769 * g_test_build_filename().
1771 * These two options correspond rather directly to the 'dist' and
1772 * 'built' terminology that automake uses and are explicitly used to
1773 * distinguish between the 'srcdir' and 'builddir' being separate. All
1774 * files in your project should either be dist (in the
1775 * <literal>DIST_EXTRA</literal> or <literal>dist_schema_DATA</literal>
1776 * sense, in which case they will always be in the srcdir) or built (in
1777 * the <literal>BUILT_SOURCES</literal> sense, in which case they will
1778 * always be in the builddir).
1780 * Note: as a general rule of automake, files that are generated only as
1781 * part of the build-from-git process (but then are distributed with the
1782 * tarball) always go in srcdir (even if doing a srcdir != builddir
1783 * build from git) and are considered as distributed files.
1791 * @fixture: the test fixture
1792 * @user_data: the data provided when registering the test
1794 * The type used for functions that operate on test fixtures. This is
1795 * used for the fixture setup and teardown functions as well as for the
1796 * testcases themselves.
1798 * @user_data is a pointer to the data that was given when registering
1801 * @fixture will be a pointer to the area of memory allocated by the
1802 * test framework, of the size requested. If the requested size was
1803 * zero then @fixture will be equal to @user_data.
1812 * The type used for test case functions.
1819 * GTestSubprocessFlags:
1820 * @G_TEST_SUBPROCESS_INHERIT_STDIN: If this flag is given, the child process will inherit the parent's stdin. Otherwise, the child's stdin is redirected to <filename>/dev/null</filename>.
1821 * @G_TEST_SUBPROCESS_INHERIT_STDOUT: If this flag is given, the child process will inherit the parent's stdout. Otherwise, the child's stdout will not be visible, but it will be captured to allow later tests with g_test_trap_assert_stdout().
1822 * @G_TEST_SUBPROCESS_INHERIT_STDERR: If this flag is given, the child process will inherit the parent's stderr. Otherwise, the child's stderr will not be visible, but it will be captured to allow later tests with g_test_trap_assert_stderr().
1824 * Flags to pass to g_test_trap_subprocess() to control input and output.
1826 * Note that in contrast with g_test_trap_fork(), the default is to
1827 * not show stdout and stderr.
1834 * An opaque structure representing a test suite.
1840 * @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().
1841 * @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().
1842 * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the child process is shared with stdin of its parent process. It is redirected to <filename>/dev/null</filename> otherwise.
1844 * Test traps are guards around forked tests.
1845 * These flags determine what traps to set.
1847 * Deprecated: #GTestTrapFlags is used only with g_test_trap_fork(), which is deprecated. g_test_trap_subprocess() uses #GTestTrapSubprocessFlags.
1854 * The #GThread struct represents a running thread. This struct
1855 * is returned by g_thread_new() or g_thread_try_new(). You can
1856 * obtain the #GThread struct representing the current thead by
1857 * calling g_thread_self().
1859 * GThread is refcounted, see g_thread_ref() and g_thread_unref().
1860 * The thread represented by it holds a reference while it is running,
1861 * and g_thread_join() consumes the reference that it is given, so
1862 * it is normally not necessary to manage GThread references
1865 * The structure is opaque -- none of its fields may be directly
1872 * @G_THREAD_ERROR_AGAIN: a thread couldn't be created due to resource shortage. Try again later.
1874 * Possible errors of thread related functions.
1880 * @data: data passed to the thread
1882 * Specifies the type of the @func functions passed to g_thread_new()
1883 * or g_thread_try_new().
1885 * Returns: the return value of the thread
1891 * @func: the function to execute in the threads of this pool
1892 * @user_data: the user data for the threads of this pool
1893 * @exclusive: are all threads exclusive to this pool
1895 * The #GThreadPool struct represents a thread pool. It has three
1896 * public read-only members, but the underlying struct is bigger,
1897 * so you must not copy this struct.
1904 * Simply a replacement for <type>time_t</type>. It has been deprecated
1905 * since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
1906 * on 64-bit platforms with a 64-bit <type>time_t</type>.
1907 * Unrelated to #GTimer.
1909 * Note that <type>GTime</type> is defined to always be a 32bit integer,
1910 * unlike <type>time_t</type> which may be 64bit on some systems.
1911 * Therefore, <type>GTime</type> will overflow in the year 2038, and
1912 * you cannot use the address of a <type>GTime</type> variable as argument
1913 * to the UNIX time() function. Instead, do the following:
1918 * time (&ttime);
1919 * gtime = (GTime)ttime;
1927 * @tv_usec: microseconds
1929 * Represents a precise time, with seconds and microseconds.
1930 * Similar to the <structname>struct timeval</structname> returned by
1931 * the gettimeofday() UNIX system call.
1933 * GLib is attempting to unify around the use of 64bit integers to
1934 * represent microsecond-precision time. As such, this type will be
1935 * removed from a future version of GLib.
1942 * #GTimeZone is an opaque structure whose members cannot be accessed
1952 * Opaque datatype that records a start time.
1958 * @G_TOKEN_EOF: the end of the file
1959 * @G_TOKEN_LEFT_PAREN: a '(' character
1960 * @G_TOKEN_LEFT_CURLY: a '{' character
1961 * @G_TOKEN_LEFT_BRACE: a '[' character
1962 * @G_TOKEN_RIGHT_CURLY: a '}' character
1963 * @G_TOKEN_RIGHT_PAREN: a ')' character
1964 * @G_TOKEN_RIGHT_BRACE: a ']' character
1965 * @G_TOKEN_EQUAL_SIGN: a '=' character
1966 * @G_TOKEN_COMMA: a ',' character
1967 * @G_TOKEN_NONE: not a token
1968 * @G_TOKEN_ERROR: an error occurred
1969 * @G_TOKEN_CHAR: a character
1970 * @G_TOKEN_BINARY: a binary integer
1971 * @G_TOKEN_OCTAL: an octal integer
1972 * @G_TOKEN_INT: an integer
1973 * @G_TOKEN_HEX: a hex integer
1974 * @G_TOKEN_FLOAT: a floating point number
1975 * @G_TOKEN_STRING: a string
1976 * @G_TOKEN_SYMBOL: a symbol
1977 * @G_TOKEN_IDENTIFIER: an identifier
1978 * @G_TOKEN_IDENTIFIER_NULL: a null identifier
1979 * @G_TOKEN_COMMENT_SINGLE: one line comment
1980 * @G_TOKEN_COMMENT_MULTI: multi line comment
1982 * The possible types of token returned from each
1983 * g_scanner_get_next_token() call.
1989 * @v_symbol: token symbol value
1990 * @v_identifier: token identifier value
1991 * @v_binary: token binary integer value
1992 * @v_octal: octal integer value
1993 * @v_int: integer value
1994 * @v_int64: 64-bit integer value
1995 * @v_float: floating point value
1996 * @v_hex: hex integer value
1997 * @v_string: string value
1998 * @v_comment: comment value
1999 * @v_char: character value
2000 * @v_error: error value
2002 * A union holding the value of the token.
2008 * @next: pointer to the previous element of the stack, gets stored in the first <literal>sizeof (gpointer)</literal> bytes of the element
2010 * Each piece of memory that is pushed onto the stack
2011 * is cast to a <structname>GTrashStack*</structname>.
2017 * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has been introduced in 2.6, for older version use %G_TRAVERSE_LEAFS.
2018 * @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.
2019 * @G_TRAVERSE_ALL: all nodes should be visited.
2020 * @G_TRAVERSE_MASK: a mask of all traverse flags.
2021 * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
2022 * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
2024 * Specifies which nodes are visited during several of the tree
2025 * functions, including g_node_traverse() and g_node_find().
2031 * @key: a key of a #GTree node.
2032 * @value: the value corresponding to the key.
2033 * @data: user data passed to g_tree_traverse().
2035 * Specifies the type of function passed to g_tree_traverse(). It is
2036 * passed the key and value of each node, together with the @user_data
2037 * parameter passed to g_tree_traverse(). If the function returns
2038 * %TRUE, the traversal is stopped.
2040 * Returns: %TRUE to stop the traversal.
2046 * @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.
2047 * @G_PRE_ORDER: visits a node, then its children.
2048 * @G_POST_ORDER: visits the node's children, then the node itself.
2049 * @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.
2051 * Specifies the type of traveral performed by g_tree_traverse(),
2052 * g_node_traverse() and g_node_find().
2059 * The <structname>GTree</structname> struct is an opaque data
2060 * structure representing a <link
2061 * linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
2062 * should be accessed only by using the following functions.
2068 * @val: a #guint16 value in big-endian byte order
2070 * Converts a #guint16 value from big-endian to host byte order.
2072 * Returns: @val converted to host byte order
2078 * @val: a #guint16 value in little-endian byte order
2080 * Converts a #guint16 value from little-endian to host byte order.
2082 * Returns: @val converted to host byte order
2087 * GUINT16_SWAP_BE_PDP:
2088 * @val: a #guint16 value in big-endian or pdp-endian byte order
2090 * Converts a #guint16 value between big-endian and pdp-endian byte order.
2091 * The conversion is symmetric so it can be used both ways.
2093 * Returns: @val converted to the opposite byte order
2098 * GUINT16_SWAP_LE_BE:
2099 * @val: a #guint16 value in little-endian or big-endian byte order
2101 * Converts a #guint16 value between little-endian and big-endian byte order.
2102 * The conversion is symmetric so it can be used both ways.
2104 * Returns: @val converted to the opposite byte order
2109 * GUINT16_SWAP_LE_PDP:
2110 * @val: a #guint16 value in little-endian or pdp-endian byte order
2112 * Converts a #guint16 value between little-endian and pdp-endian byte order.
2113 * The conversion is symmetric so it can be used both ways.
2115 * Returns: @val converted to the opposite byte order
2121 * @val: a #guint16 value in host byte order
2123 * Converts a #guint16 value from host byte order to big-endian.
2125 * Returns: @val converted to big-endian
2131 * @val: a #guint16 value in host byte order
2133 * Converts a #guint16 value from host byte order to little-endian.
2135 * Returns: @val converted to little-endian
2141 * @val: a #guint32 value in big-endian byte order
2143 * Converts a #guint32 value from big-endian to host byte order.
2145 * Returns: @val converted to host byte order
2151 * @val: a #guint32 value in little-endian byte order
2153 * Converts a #guint32 value from little-endian to host byte order.
2155 * Returns: @val converted to host byte order
2160 * GUINT32_SWAP_BE_PDP:
2161 * @val: a #guint32 value in big-endian or pdp-endian byte order
2163 * Converts a #guint32 value between big-endian and pdp-endian byte order.
2164 * The conversion is symmetric so it can be used both ways.
2166 * Returns: @val converted to the opposite byte order
2171 * GUINT32_SWAP_LE_BE:
2172 * @val: a #guint32 value in little-endian or big-endian byte order
2174 * Converts a #guint32 value between little-endian and big-endian byte order.
2175 * The conversion is symmetric so it can be used both ways.
2177 * Returns: @val converted to the opposite byte order
2182 * GUINT32_SWAP_LE_PDP:
2183 * @val: a #guint32 value in little-endian or pdp-endian byte order
2185 * Converts a #guint32 value between little-endian and pdp-endian byte order.
2186 * The conversion is symmetric so it can be used both ways.
2188 * Returns: @val converted to the opposite byte order
2194 * @val: a #guint32 value in host byte order
2196 * Converts a #guint32 value from host byte order to big-endian.
2198 * Returns: @val converted to big-endian
2204 * @val: a #guint32 value in host byte order
2206 * Converts a #guint32 value from host byte order to little-endian.
2208 * Returns: @val converted to little-endian
2214 * @val: a #guint64 value in big-endian byte order
2216 * Converts a #guint64 value from big-endian to host byte order.
2218 * Returns: @val converted to host byte order
2224 * @val: a #guint64 value in little-endian byte order
2226 * Converts a #guint64 value from little-endian to host byte order.
2228 * Returns: @val converted to host byte order
2233 * GUINT64_SWAP_LE_BE:
2234 * @val: a #guint64 value in little-endian or big-endian byte order
2236 * Converts a #guint64 value between little-endian and big-endian byte order.
2237 * The conversion is symmetric so it can be used both ways.
2239 * Returns: @val converted to the opposite byte order
2245 * @val: a #guint64 value in host byte order
2247 * Converts a #guint64 value from host byte order to big-endian.
2249 * Returns: @val converted to big-endian
2255 * @val: a #guint64 value in host byte order
2257 * Converts a #guint64 value from host byte order to little-endian.
2259 * Returns: @val converted to little-endian
2265 * @val: a #guint value in big-endian byte order
2267 * Converts a #guint value from big-endian to host byte order.
2269 * Returns: @val converted to host byte order
2275 * @val: a #guint value in little-endian byte order
2277 * Converts a #guint value from little-endian to host byte order.
2279 * Returns: @val converted to host byte order
2285 * @val: a #guint value in host byte order
2287 * Converts a #guint value from host byte order to big-endian.
2289 * Returns: @val converted to big-endian byte order
2295 * @val: a #guint value in host byte order
2297 * Converts a #guint value from host byte order to little-endian.
2299 * Returns: @val converted to little-endian byte order.
2305 * @u: unsigned integer to stuff into the pointer
2307 * Stuffs an unsigned integer into a pointer type.
2313 * @val: a #gulong value in big-endian byte order
2315 * Converts a #gulong value from big-endian to host byte order.
2317 * Returns: @val converted to host byte order
2323 * @val: a #gulong value in little-endian byte order
2325 * Converts a #gulong value from little-endian to host byte order.
2327 * Returns: @val converted to host byte order
2333 * @val: a #gulong value in host byte order
2335 * Converts a #gulong value from host byte order to big-endian.
2337 * Returns: @val converted to big-endian
2343 * @val: a #gulong value in host byte order
2345 * Converts a #gulong value from host byte order to little-endian.
2347 * Returns: @val converted to little-endian
2354 * #GVariant is an opaque data structure and can only be accessed
2355 * using the following functions.
2364 * A utility type for constructing container-type #GVariant instances.
2366 * This is an opaque structure and may only be accessed using the
2367 * following functions.
2369 * #GVariantBuilder is not threadsafe in any way. Do not attempt to
2370 * access it from more than one thread.
2376 * @G_VARIANT_CLASS_BOOLEAN: The #GVariant is a boolean.
2377 * @G_VARIANT_CLASS_BYTE: The #GVariant is a byte.
2378 * @G_VARIANT_CLASS_INT16: The #GVariant is a signed 16 bit integer.
2379 * @G_VARIANT_CLASS_UINT16: The #GVariant is an unsigned 16 bit integer.
2380 * @G_VARIANT_CLASS_INT32: The #GVariant is a signed 32 bit integer.
2381 * @G_VARIANT_CLASS_UINT32: The #GVariant is an unsigned 32 bit integer.
2382 * @G_VARIANT_CLASS_INT64: The #GVariant is a signed 64 bit integer.
2383 * @G_VARIANT_CLASS_UINT64: The #GVariant is an unsigned 64 bit integer.
2384 * @G_VARIANT_CLASS_HANDLE: The #GVariant is a file handle index.
2385 * @G_VARIANT_CLASS_DOUBLE: The #GVariant is a double precision floating point value.
2386 * @G_VARIANT_CLASS_STRING: The #GVariant is a normal string.
2387 * @G_VARIANT_CLASS_OBJECT_PATH: The #GVariant is a D-Bus object path string.
2388 * @G_VARIANT_CLASS_SIGNATURE: The #GVariant is a D-Bus signature string.
2389 * @G_VARIANT_CLASS_VARIANT: The #GVariant is a variant.
2390 * @G_VARIANT_CLASS_MAYBE: The #GVariant is a maybe-typed value.
2391 * @G_VARIANT_CLASS_ARRAY: The #GVariant is an array.
2392 * @G_VARIANT_CLASS_TUPLE: The #GVariant is a tuple.
2393 * @G_VARIANT_CLASS_DICT_ENTRY: The #GVariant is a dictionary entry.
2395 * The range of possible top-level types of #GVariant instances.
2402 * GVariantIter: (skip)
2404 * #GVariantIter is an opaque data structure and can only be accessed
2405 * using the following functions.
2410 * GVariantParseError:
2411 * @G_VARIANT_PARSE_ERROR_FAILED: generic error (unused)
2412 * @G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED: a non-basic #GVariantType was given where a basic type was expected
2413 * @G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE: cannot infer the #GVariantType
2414 * @G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED: an indefinite #GVariantType was given where a definite type was expected
2415 * @G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END: extra data after parsing finished
2416 * @G_VARIANT_PARSE_ERROR_INVALID_CHARACTER: invalid character in number or unicode escape
2417 * @G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING: not a valid #GVariant format string
2418 * @G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH: not a valid object path
2419 * @G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE: not a valid type signature
2420 * @G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING: not a valid #GVariant type string
2421 * @G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE: could not find a common type for array entries
2422 * @G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE: the numerical value is out of range of the given type
2423 * @G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG: the numerical value is out of range for any type
2424 * @G_VARIANT_PARSE_ERROR_TYPE_ERROR: cannot parse as variant of the specified type
2425 * @G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN: an unexpected token was encountered
2426 * @G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD: an unknown keyword was encountered
2427 * @G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT: unterminated string constant
2428 * @G_VARIANT_PARSE_ERROR_VALUE_EXPECTED: no value given
2430 * Error codes returned by parsing text-format GVariants.
2435 * G_ASCII_DTOSTR_BUF_SIZE:
2437 * A good size for a buffer to be passed into g_ascii_dtostr().
2438 * It is guaranteed to be enough for all output of that function
2439 * on systems with 64bit IEEE-compatible doubles.
2441 * The typical usage would be something like:
2443 * char buf[G_ASCII_DTOSTR_BUF_SIZE];
2445 * fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
2451 * G_ATOMIC_LOCK_FREE:
2453 * This macro is defined if the atomic operations of GLib are
2454 * implemented using real hardware atomic operations. This means that
2455 * the GLib atomic API can be used between processes and safely mixed
2456 * with other (hardware) atomic APIs.
2458 * If this macro is not defined, the atomic operations may be
2459 * emulated using a mutex. In that case, the GLib atomic operations are
2460 * only atomic relative to themselves and within a single process.
2467 * Used (along with #G_END_DECLS) to bracket header files. If the
2468 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2469 * around the header.
2476 * Specifies one of the possible types of byte order.
2477 * See #G_BYTE_ORDER.
2484 * The host byte order.
2485 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
2486 * #G_PDP_ENDIAN may be added in future.)
2493 * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
2494 * to nothing. By default, the macro expands to <literal>const</literal>.
2495 * The macro should be used in place of <literal>const</literal> for
2496 * functions that return a value that should not be modified. The
2497 * purpose of this macro is to allow us to turn on <literal>const</literal>
2498 * for returned constant strings by default, while allowing programmers
2499 * who find that annoying to turn it off. This macro should only be used
2500 * for return values and for <emphasis>out</emphasis> parameters, it doesn't
2501 * make sense for <emphasis>in</emphasis> parameters.
2503 * Deprecated: 2.30: API providers should replace all existing uses with <literal>const</literal> and API consumers should adjust their code accordingly
2510 * The set of uppercase ASCII alphabet characters.
2511 * Used for specifying valid identifier characters
2512 * in #GScannerConfig.
2519 * The set of uppercase ISO 8859-1 alphabet characters
2520 * which are not ASCII characters.
2521 * Used for specifying valid identifier characters
2522 * in #GScannerConfig.
2529 * The set of lowercase ISO 8859-1 alphabet characters
2530 * which are not ASCII characters.
2531 * Used for specifying valid identifier characters
2532 * in #GScannerConfig.
2539 * The set of lowercase ASCII alphabet characters.
2540 * Used for specifying valid identifier characters
2541 * in #GScannerConfig.
2548 * Represents an invalid #GDateDay.
2553 * G_DATE_BAD_JULIAN:
2555 * Represents an invalid Julian day number.
2562 * Represents an invalid year.
2568 * @QN: the name to return a #GQuark for
2569 * @q_n: prefix for the function name
2571 * A convenience macro which defines a function returning the
2572 * #GQuark for the name @QN. The function will be named
2573 * @q_n<!-- -->_quark().
2574 * Note that the quark name will be stringified automatically in the
2575 * macro, so you shouldn't use double quotes.
2584 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2585 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2586 * meant to be portable across different compilers and must be placed
2587 * before the function declaration.
2595 * @f: the name of the function that this function was deprecated for
2597 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2598 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2599 * meant to be portable across different compilers and must be placed
2600 * before the function declaration.
2609 * The directory separator character.
2610 * This is '/' on UNIX machines and '\' under Windows.
2615 * G_DIR_SEPARATOR_S:
2617 * The directory separator as a string.
2618 * This is "/" on UNIX machines and "\" under Windows.
2625 * The base of natural logarithms.
2632 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
2633 * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2634 * around the header.
2641 * Error domain for file operations. Errors in this domain will
2642 * be from the #GFileError enumeration. See #GError for information
2650 * This is the platform dependent conversion specifier for scanning and
2651 * printing values of type #gint16. It is a string literal, but doesn't
2652 * include the percent-sign, such that you can add precision and length
2653 * modifiers between percent-sign and conversion specifier.
2658 * sscanf ("42", "%" G_GINT16_FORMAT, &in)
2660 * g_print ("%" G_GINT32_FORMAT, out);
2666 * G_GINT16_MODIFIER:
2668 * The platform dependent length modifier for conversion specifiers
2669 * for scanning and printing values of type #gint16 or #guint16. It
2670 * is a string literal, but doesn't include the percent-sign, such
2671 * that you can add precision and length modifiers between percent-sign
2672 * and conversion specifier and append a conversion specifier.
2674 * The following example prints "0x7b";
2676 * gint16 value = 123;
2677 * g_print ("%#" G_GINT16_MODIFIER "x", value);
2687 * This is the platform dependent conversion specifier for scanning
2688 * and printing values of type #gint32. See also #G_GINT16_FORMAT.
2693 * G_GINT32_MODIFIER:
2695 * The platform dependent length modifier for conversion specifiers
2696 * for scanning and printing values of type #gint32 or #guint32. It
2697 * is a string literal. See also #G_GINT16_MODIFIER.
2704 * G_GINT64_CONSTANT:
2705 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
2707 * This macro is used to insert 64-bit integer literals
2708 * into the source code.
2715 * This is the platform dependent conversion specifier for scanning
2716 * and printing values of type #gint64. See also #G_GINT16_FORMAT.
2719 * Some platforms do not support scanning and printing 64 bit integers,
2720 * even though the types are supported. On such platforms #G_GINT64_FORMAT
2721 * is not defined. Note that scanf() may not support 64 bit integers, even
2722 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
2723 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
2730 * G_GINT64_MODIFIER:
2732 * The platform dependent length modifier for conversion specifiers
2733 * for scanning and printing values of type #gint64 or #guint64.
2734 * It is a string literal.
2737 * Some platforms do not support printing 64 bit integers, even
2738 * though the types are supported. On such platforms #G_GINT64_MODIFIER
2749 * This is the platform dependent conversion specifier for scanning
2750 * and printing values of type #gintptr.
2757 * G_GINTPTR_MODIFIER:
2759 * The platform dependent length modifier for conversion specifiers
2760 * for scanning and printing values of type #gintptr or #guintptr.
2761 * It is a string literal.
2768 * G_GNUC_ALLOC_SIZE:
2769 * @x: the index of the argument specifying the allocation size
2771 * Expands to the GNU C <literal>alloc_size</literal> function attribute
2772 * if the compiler is a new enough <command>gcc</command>. This attribute
2773 * tells the compiler that the function returns a pointer to memory of a
2774 * size that is specified by the @x<!-- -->th function parameter.
2776 * Place the attribute after the function declaration, just before the
2779 * See the GNU C documentation for more details.
2786 * G_GNUC_ALLOC_SIZE2:
2787 * @x: the index of the argument specifying one factor of the allocation size
2788 * @y: the index of the argument specifying the second factor of the allocation size
2790 * Expands to the GNU C <literal>alloc_size</literal> function attribute
2791 * if the compiler is a new enough <command>gcc</command>. This attribute
2792 * tells the compiler that the function returns a pointer to memory of a
2793 * size that is specified by the product of two function parameters.
2795 * Place the attribute after the function declaration, just before the
2798 * See the GNU C documentation for more details.
2805 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2807 * Tells <command>gcc</command> (if it is a new enough version) to
2808 * temporarily stop emitting warnings when functions marked with
2809 * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
2810 * useful for when you have one deprecated function calling another
2811 * one, or when you still have regression tests for deprecated
2814 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2815 * are not compiling with <literal>-Wdeprecated-declarations</literal>
2816 * then neither macro has any effect.)
2818 * This macro can be used either inside or outside of a function body,
2819 * but must appear on a line by itself.
2828 * Expands to the GNU C <literal>const</literal> function attribute if
2829 * the compiler is <command>gcc</command>. Declaring a function as const
2830 * enables better optimization of calls to the function. A const function
2831 * doesn't examine any values except its parameters, and has no effects
2832 * except its return value.
2834 * Place the attribute after the declaration, just before the semicolon.
2836 * See the GNU C documentation for more details.
2839 * A function that has pointer arguments and examines the data pointed to
2840 * must <emphasis>not</emphasis> be declared const. Likewise, a function
2841 * that calls a non-const function usually must not be const. It doesn't
2842 * make sense for a const function to return void.
2848 * G_GNUC_DEPRECATED:
2850 * Expands to the GNU C <literal>deprecated</literal> attribute if the
2851 * compiler is <command>gcc</command>. It can be used to mark typedefs,
2852 * variables and functions as deprecated. When called with the
2853 * <option>-Wdeprecated-declarations</option> option, the compiler will
2854 * generate warnings when deprecated interfaces are used.
2856 * Place the attribute after the declaration, just before the semicolon.
2858 * See the GNU C documentation for more details.
2865 * G_GNUC_DEPRECATED_FOR:
2866 * @f: the intended replacement for the deprecated symbol, such as the name of a function
2868 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
2869 * deprecated symbol if the version of <command>gcc</command> in use is
2870 * new enough to support custom deprecation messages.
2872 * Place the attribute after the declaration, just before the semicolon.
2874 * See the GNU C documentation for more details.
2876 * Note that if @f is a macro, it will be expanded in the warning message.
2877 * You can enclose it in quotes to prevent this. (The quotes will show up
2878 * in the warning, but it's better than showing the macro expansion.)
2885 * G_GNUC_END_IGNORE_DEPRECATIONS:
2887 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2888 * <command>gcc</command> to begin outputting warnings again
2889 * (assuming those warnings had been enabled to begin with).
2891 * This macro can be used either inside or outside of a function body,
2892 * but must appear on a line by itself.
2901 * Expands to <literal>__extension__</literal> when <command>gcc</command>
2902 * is used as the compiler. This simply tells <command>gcc</command> not
2903 * to warn about the following non-standard code when compiling with the
2904 * <option>-pedantic</option> option.
2910 * @arg_idx: the index of the argument
2912 * Expands to the GNU C <literal>format_arg</literal> function attribute
2913 * if the compiler is <command>gcc</command>. This function attribute
2914 * specifies that a function takes a format string for a printf(),
2915 * scanf(), strftime() or strfmon() style function and modifies it,
2916 * so that the result can be passed to a printf(), scanf(), strftime()
2917 * or strfmon() style function (with the remaining arguments to the
2918 * format function the same as they would have been for the unmodified
2921 * Place the attribute after the function declaration, just before the
2924 * See the GNU C documentation for more details.
2927 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2935 * Expands to "" on all modern compilers, and to
2936 * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
2939 * Deprecated: 2.16: Use #G_STRFUNC instead
2946 * This attribute can be used for marking library functions as being used
2947 * internally to the library only, which may allow the compiler to handle
2948 * function calls more efficiently. Note that static functions do not need
2949 * to be marked as internal in this way. See the GNU C documentation for
2952 * When using a compiler that supports the GNU C hidden visibility attribute,
2953 * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
2954 * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
2956 * Note that for portability, the attribute should be placed before the
2957 * function declaration. While GCC allows the macro after the declaration,
2958 * Sun Studio does not.
2962 * void _g_log_fallback_handler (const gchar *log_domain,
2963 * GLogLevelFlags log_level,
2964 * const gchar *message,
2965 * gpointer unused_data);
2975 * Expands to the GNU C <literal>malloc</literal> function attribute if the
2976 * compiler is <command>gcc</command>. Declaring a function as malloc enables
2977 * better optimization of the function. A function can have the malloc
2978 * attribute if it returns a pointer which is guaranteed to not alias with
2979 * any other pointer when the function returns (in practice, this means newly
2980 * allocated memory).
2982 * Place the attribute after the declaration, just before the semicolon.
2984 * See the GNU C documentation for more details.
2993 * Expands to the GNU C <literal>may_alias</literal> type attribute
2994 * if the compiler is <command>gcc</command>. Types with this attribute
2995 * will not be subjected to type-based alias analysis, but are assumed
2996 * to alias with any other type, just like char.
2997 * See the GNU C documentation for details.
3006 * Expands to the GNU C <literal>noreturn</literal> function attribute
3007 * if the compiler is <command>gcc</command>. It is used for declaring
3008 * functions which never return. It enables optimization of the function,
3009 * and avoids possible compiler warnings.
3011 * Place the attribute after the declaration, just before the semicolon.
3013 * See the GNU C documentation for more details.
3018 * G_GNUC_NO_INSTRUMENT:
3020 * Expands to the GNU C <literal>no_instrument_function</literal> function
3021 * attribute if the compiler is <command>gcc</command>. Functions with this
3022 * attribute will not be instrumented for profiling, when the compiler is
3023 * called with the <option>-finstrument-functions</option> option.
3025 * Place the attribute after the declaration, just before the semicolon.
3027 * See the GNU C documentation for more details.
3032 * G_GNUC_NULL_TERMINATED:
3034 * Expands to the GNU C <literal>sentinel</literal> function attribute
3035 * if the compiler is <command>gcc</command>, or "" if it isn't. This
3036 * function attribute only applies to variadic functions and instructs
3037 * the compiler to check that the argument list is terminated with an
3040 * Place the attribute after the declaration, just before the semicolon.
3042 * See the GNU C documentation for more details.
3049 * G_GNUC_PRETTY_FUNCTION:
3051 * Expands to "" on all modern compilers, and to
3052 * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
3053 * version 2.x. Don't use it.
3055 * Deprecated: 2.16: Use #G_STRFUNC instead
3061 * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3062 * @arg_idx: the index of the first of the format arguments
3064 * Expands to the GNU C <literal>format</literal> function attribute
3065 * if the compiler is <command>gcc</command>. This is used for declaring
3066 * functions which take a variable number of arguments, with the same
3067 * syntax as printf(). It allows the compiler to type-check the arguments
3068 * passed to the function.
3070 * Place the attribute after the function declaration, just before the
3073 * See the GNU C documentation for more details.
3076 * gint g_snprintf (gchar *string,
3078 * gchar const *format,
3079 * ...) G_GNUC_PRINTF (3, 4);
3087 * Expands to the GNU C <literal>pure</literal> function attribute if the
3088 * compiler is <command>gcc</command>. Declaring a function as pure enables
3089 * better optimization of calls to the function. A pure function has no
3090 * effects except its return value and the return value depends only on
3091 * the parameters and/or global variables.
3093 * Place the attribute after the declaration, just before the semicolon.
3095 * See the GNU C documentation for more details.
3101 * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3102 * @arg_idx: the index of the first of the format arguments
3104 * Expands to the GNU C <literal>format</literal> function attribute
3105 * if the compiler is <command>gcc</command>. This is used for declaring
3106 * functions which take a variable number of arguments, with the same
3107 * syntax as scanf(). It allows the compiler to type-check the arguments
3108 * passed to the function. See the GNU C documentation for details.
3115 * Expands to the GNU C <literal>unused</literal> function attribute if
3116 * the compiler is <command>gcc</command>. It is used for declaring
3117 * functions and arguments which may never be used. It avoids possible compiler
3120 * For functions, place the attribute after the declaration, just before the
3121 * semicolon. For arguments, place the attribute at the beginning of the
3122 * argument declaration.
3125 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
3126 * gint other_argument) G_GNUC_UNUSED;
3129 * See the GNU C documentation for more details.
3134 * G_GNUC_WARN_UNUSED_RESULT:
3136 * Expands to the GNU C <literal>warn_unused_result</literal> function
3137 * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
3138 * This function attribute makes the compiler emit a warning if the result
3139 * of a function call is ignored.
3141 * Place the attribute after the declaration, just before the semicolon.
3143 * See the GNU C documentation for more details.
3150 * G_GOFFSET_CONSTANT:
3151 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
3153 * This macro is used to insert #goffset 64-bit integer literals
3154 * into the source code.
3156 * See also #G_GINT64_CONSTANT.
3165 * This is the platform dependent conversion specifier for scanning
3166 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
3173 * G_GOFFSET_MODIFIER:
3175 * The platform dependent length modifier for conversion specifiers
3176 * for scanning and printing values of type #goffset. It is a string
3177 * literal. See also #G_GINT64_MODIFIER.
3186 * This is the platform dependent conversion specifier for scanning
3187 * and printing values of type #gsize. See also #G_GINT16_FORMAT.
3196 * The platform dependent length modifier for conversion specifiers
3197 * for scanning and printing values of type #gsize or #gssize. It
3198 * is a string literal.
3207 * This is the platform dependent conversion specifier for scanning
3208 * and printing values of type #gssize. See also #G_GINT16_FORMAT.
3217 * This is the platform dependent conversion specifier for scanning
3218 * and printing values of type #guint16. See also #G_GINT16_FORMAT
3225 * This is the platform dependent conversion specifier for scanning
3226 * and printing values of type #guint32. See also #G_GINT16_FORMAT.
3231 * G_GUINT64_CONSTANT:
3232 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
3234 * This macro is used to insert 64-bit unsigned integer
3235 * literals into the source code.
3244 * This is the platform dependent conversion specifier for scanning
3245 * and printing values of type #guint64. See also #G_GINT16_FORMAT.
3248 * Some platforms do not support scanning and printing 64 bit integers,
3249 * even though the types are supported. On such platforms #G_GUINT64_FORMAT
3250 * is not defined. Note that scanf() may not support 64 bit integers, even
3251 * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
3252 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
3259 * G_GUINTPTR_FORMAT:
3261 * This is the platform dependent conversion specifier
3262 * for scanning and printing values of type #guintptr.
3272 * Casts a pointer to a <literal>GHook*</literal>.
3280 * Returns %TRUE if the #GHook is active, which is normally the case
3281 * until the #GHook is destroyed.
3283 * Returns: %TRUE if the #GHook is active
3291 * Gets the flags of a hook.
3296 * G_HOOK_FLAG_USER_SHIFT:
3298 * The position of the first bit which is not reserved for internal
3299 * use be the #GHook implementation, i.e.
3300 * <literal>1 << G_HOOK_FLAG_USER_SHIFT</literal> is the first
3301 * bit which can be used for application-defined flags.
3309 * Returns %TRUE if the #GHook function is currently executing.
3311 * Returns: %TRUE if the #GHook function is currently executing
3316 * G_HOOK_IS_UNLINKED:
3319 * Returns %TRUE if the #GHook is not in a #GHookList.
3321 * Returns: %TRUE if the #GHook is not in a #GHookList
3329 * Returns %TRUE if the #GHook is valid, i.e. it is in a #GHookList,
3330 * it is active and it has not been destroyed.
3332 * Returns: %TRUE if the #GHook is valid
3337 * G_IEEE754_DOUBLE_BIAS:
3339 * The bias by which exponents in double-precision floats are offset.
3344 * G_IEEE754_FLOAT_BIAS:
3346 * The bias by which exponents in single-precision floats are offset.
3353 * This macro is used to export function prototypes so they can be linked
3354 * with an external version when no inlining is performed. The file which
3355 * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
3356 * before including the headers which contain %G_INLINE_FUNC declarations.
3357 * Since inlining is very compiler-dependent using these macros correctly
3358 * is very difficult. Their use is strongly discouraged.
3360 * This macro is often mistaken for a replacement for the inline keyword;
3361 * inline is already declared in a portable manner in the GLib headers
3362 * and can be used normally.
3367 * G_IO_CHANNEL_ERROR:
3369 * Error domain for #GIOChannel operations. Errors in this domain will
3370 * be from the #GIOChannelError enumeration. See #GError for
3371 * information on error domains.
3376 * G_IO_FLAG_IS_WRITEABLE:
3378 * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
3379 * before the spelling was fixed in GLib 2.30. It is kept here for
3380 * compatibility reasons.
3382 * Deprecated: 2.30:Use G_IO_FLAG_IS_WRITABLE instead.
3387 * G_IS_DIR_SEPARATOR:
3390 * Checks whether a character is a directory
3391 * separator. It returns %TRUE for '/' on UNIX
3392 * machines and for '\' or '/' under Windows.
3399 * G_KEY_FILE_DESKTOP_GROUP:
3401 * The name of the main group of a desktop entry file, as defined in the
3402 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
3403 * Entry Specification</ulink>. Consult the specification for more
3404 * details about the meanings of the keys below.
3411 * G_KEY_FILE_DESKTOP_KEY_CATEGORIES:
3413 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3414 * of strings giving the categories in which the desktop entry
3415 * should be shown in a menu.
3422 * G_KEY_FILE_DESKTOP_KEY_COMMENT:
3424 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3425 * string giving the tooltip for the desktop entry.
3432 * G_KEY_FILE_DESKTOP_KEY_EXEC:
3434 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3435 * giving the command line to execute. It is only valid for desktop
3436 * entries with the <literal>Application</literal> type.
3443 * G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME:
3445 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3446 * string giving the generic name of the desktop entry.
3453 * G_KEY_FILE_DESKTOP_KEY_HIDDEN:
3455 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3456 * stating whether the desktop entry has been deleted by the user.
3463 * G_KEY_FILE_DESKTOP_KEY_ICON:
3465 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3466 * string giving the name of the icon to be displayed for the desktop
3474 * G_KEY_FILE_DESKTOP_KEY_MIME_TYPE:
3476 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3477 * of strings giving the MIME types supported by this desktop entry.
3484 * G_KEY_FILE_DESKTOP_KEY_NAME:
3486 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3487 * string giving the specific name of the desktop entry.
3494 * G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN:
3496 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3497 * strings identifying the environments that should not display the
3505 * G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY:
3507 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3508 * stating whether the desktop entry should be shown in menus.
3515 * G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN:
3517 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3518 * strings identifying the environments that should display the
3526 * G_KEY_FILE_DESKTOP_KEY_PATH:
3528 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3529 * containing the working directory to run the program in. It is only
3530 * valid for desktop entries with the <literal>Application</literal> type.
3537 * G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY:
3539 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3540 * stating whether the application supports the <ulink
3541 * url="http://www.freedesktop.org/Standards/startup-notification-spec">Startup
3542 * Notification Protocol Specification</ulink>.
3549 * G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS:
3551 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is string
3552 * identifying the WM class or name hint of a window that the application
3553 * will create, which can be used to emulate Startup Notification with
3554 * older applications.
3561 * G_KEY_FILE_DESKTOP_KEY_TERMINAL:
3563 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3564 * stating whether the program should be run in a terminal window.
3565 * It is only valid for desktop entries with the
3566 * <literal>Application</literal> type.
3573 * G_KEY_FILE_DESKTOP_KEY_TRY_EXEC:
3575 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3576 * giving the file name of a binary on disk used to determine if the
3577 * program is actually installed. It is only valid for desktop entries
3578 * with the <literal>Application</literal> type.
3585 * G_KEY_FILE_DESKTOP_KEY_TYPE:
3587 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3588 * giving the type of the desktop entry. Usually
3589 * #G_KEY_FILE_DESKTOP_TYPE_APPLICATION,
3590 * #G_KEY_FILE_DESKTOP_TYPE_LINK, or
3591 * #G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.
3598 * G_KEY_FILE_DESKTOP_KEY_URL:
3600 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3601 * giving the URL to access. It is only valid for desktop entries
3602 * with the <literal>Link</literal> type.
3609 * G_KEY_FILE_DESKTOP_KEY_VERSION:
3611 * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3612 * giving the version of the Desktop Entry Specification used for
3613 * the desktop entry file.
3620 * G_KEY_FILE_DESKTOP_TYPE_APPLICATION:
3622 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3623 * entries representing applications.
3630 * G_KEY_FILE_DESKTOP_TYPE_DIRECTORY:
3632 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3633 * entries representing directories.
3640 * G_KEY_FILE_DESKTOP_TYPE_LINK:
3642 * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3643 * entries representing links to documents.
3652 * Error domain for key file parsing. Errors in this domain will
3653 * be from the #GKeyFileError enumeration.
3655 * See #GError for information on error domains.
3661 * @expr: the expression
3663 * Hints the compiler that the expression is likely to evaluate to
3664 * a true value. The compiler may use this information for optimizations.
3667 * if (G_LIKELY (random () != 1))
3668 * g_print ("not one");
3671 * Returns: the value of @expr
3679 * Specifies one of the possible types of byte order.
3680 * See #G_BYTE_ORDER.
3687 * The natural logarithm of 10.
3694 * The natural logarithm of 2.
3700 * @name: the name of the lock
3702 * Works like g_mutex_lock(), but for a lock defined with
3709 * @name: the name of the lock
3711 * The <literal>G_LOCK_*</literal> macros provide a convenient interface to #GMutex.
3712 * #G_LOCK_DEFINE defines a lock. It can appear in any place where
3713 * variable definitions may appear in programs, i.e. in the first block
3714 * of a function or outside of functions. The @name parameter will be
3715 * mangled to get the name of the #GMutex. This means that you
3716 * can use names of existing variables as the parameter - e.g. the name
3717 * of the variable you intend to protect with the lock. Look at our
3718 * <function>give_me_next_number()</function> example using the
3719 * <literal>G_LOCK_*</literal> macros:
3722 * <title>Using the <literal>G_LOCK_*</literal> convenience macros</title>
3724 * G_LOCK_DEFINE (current_number);
3727 * give_me_next_number (void)
3729 * static int current_number = 0;
3732 * G_LOCK (current_number);
3733 * ret_val = current_number = calc_next_number (current_number);
3734 * G_UNLOCK (current_number);
3744 * G_LOCK_DEFINE_STATIC:
3745 * @name: the name of the lock
3747 * This works like #G_LOCK_DEFINE, but it creates a static object.
3753 * @name: the name of the lock
3755 * This declares a lock, that is defined with #G_LOCK_DEFINE in another
3763 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
3770 * Defines the log domain.
3772 * For applications, this is typically left as the default %NULL
3773 * (or "") domain. Libraries should define this so that any messages
3774 * which they log can be differentiated from messages from other
3775 * libraries and application code. But be careful not to define
3776 * it in any public header files.
3778 * For example, GTK+ uses this in its Makefile.am:
3780 * INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
3788 * GLib log levels that are considered fatal by default.
3795 * The maximum value which can be held in a #gdouble.
3802 * The maximum value which can be held in a #gfloat.
3809 * The maximum value which can be held in a #gint.
3816 * The maximum value which can be held in a #gint16.
3825 * The maximum value which can be held in a #gint32.
3834 * The maximum value which can be held in a #gint64.
3841 * The maximum value which can be held in a #gint8.
3850 * The maximum value which can be held in a #glong.
3857 * The maximum value which can be held in a #goffset.
3864 * The maximum value which can be held in a #gshort.
3871 * The maximum value which can be held in a #gsize.
3880 * The maximum value which can be held in a #gssize.
3889 * The maximum value which can be held in a #guint.
3896 * The maximum value which can be held in a #guint16.
3905 * The maximum value which can be held in a #guint32.
3914 * The maximum value which can be held in a #guint64.
3921 * The maximum value which can be held in a #guint8.
3930 * The maximum value which can be held in a #gulong.
3937 * The maximum value which can be held in a #gushort.
3944 * The minimum positive value which can be held in a #gdouble.
3946 * If you are interested in the smallest value which can be held
3947 * in a #gdouble, use -G_MAXDOUBLE.
3954 * The minimum positive value which can be held in a #gfloat.
3956 * If you are interested in the smallest value which can be held
3957 * in a #gfloat, use -G_MAXFLOAT.
3964 * The minimum value which can be held in a #gint.
3971 * The minimum value which can be held in a #gint16.
3980 * The minimum value which can be held in a #gint32.
3989 * The minimum value which can be held in a #gint64.
3996 * The minimum value which can be held in a #gint8.
4005 * The minimum value which can be held in a #glong.
4012 * The minimum value which can be held in a #goffset.
4019 * The minimum value which can be held in a #gshort.
4026 * The minimum value which can be held in a #gssize.
4036 * Determines the number of elements in an array. The array must be
4037 * declared so the compiler knows its size at compile-time; this
4038 * macro will not work on an array allocated on the heap, only static
4039 * arrays or arrays on the stack.
4046 * A #GOnce must be initialized with this macro before it can be used.
4049 * GOnce my_once = G_ONCE_INIT;
4059 * This macro is defined only on BeOS. So you can bracket
4060 * BeOS-specific code in "#ifdef G_OS_BEOS".
4067 * This macro is defined only on UNIX. So you can bracket
4068 * UNIX-specific code in "#ifdef G_OS_UNIX".
4075 * This macro is defined only on Windows. So you can bracket
4076 * Windows-specific code in "#ifdef G_OS_WIN32".
4082 * @identifier1: an identifier
4083 * @identifier2: an identifier
4085 * Yields a new preprocessor pasted identifier
4086 * <code>identifier1identifier2</code> from its expanded
4087 * arguments @identifier1 and @identifier2. For example,
4088 * the following code:
4090 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
4091 * const gchar *name = GET (traveller, name);
4092 * const gchar *quest = GET (traveller, quest);
4093 * GdkColor *favourite = GET (traveller, favourite_colour);
4096 * is transformed by the preprocessor into:
4098 * const gchar *name = traveller_get_name (traveller);
4099 * const gchar *quest = traveller_get_quest (traveller);
4100 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
4110 * Specifies one of the possible types of byte order
4111 * (currently unused). See #G_BYTE_ORDER.
4118 * The value of pi (ratio of circle's circumference to its diameter).
4138 * @notify: a #GDestroyNotify
4140 * A macro to assist with the static initialisation of a #GPrivate.
4142 * This macro is useful for the case that a #GDestroyNotify function
4143 * should be associated the key. This is needed when the key will be
4144 * used to point at memory that should be deallocated when the thread
4147 * Additionally, the #GDestroyNotify will also be called on the previous
4148 * value stored in the key when g_private_replace() is used.
4150 * If no #GDestroyNotify is needed, then use of this macro is not
4151 * required -- if the #GPrivate is declared in static scope then it will
4152 * be properly initialised by default (ie: to all zeros). See the
4156 * static GPrivate name_key = G_PRIVATE_INIT (g_free);
4158 * // return value should not be freed
4160 * get_local_name (void)
4162 * return g_private_get (&name_key);
4166 * set_local_name (const gchar *name)
4168 * g_private_replace (&name_key, g_strdup (name));
4172 * static GPrivate count_key; // no free function
4175 * get_local_count (void)
4177 * return GPOINTER_TO_INT (g_private_get (&count_key));
4181 * set_local_count (gint count)
4183 * g_private_set (&count_key, GINT_TO_POINTER (count));
4192 * G_SEARCHPATH_SEPARATOR:
4194 * The search path separator character.
4195 * This is ':' on UNIX machines and ';' under Windows.
4200 * G_SEARCHPATH_SEPARATOR_S:
4202 * The search path separator as a string.
4203 * This is ":" on UNIX machines and ";" under Windows.
4210 * Error domain for shell functions. Errors in this domain will be from
4211 * the #GShellError enumeration. See #GError for information on error
4219 * The square root of two.
4225 * @expr: a constant expression
4227 * The G_STATIC_ASSERT macro lets the programmer check
4228 * a condition at compile time, the condition needs to
4229 * be compile time computable. The macro can be used in
4230 * any place where a <literal>typedef</literal> is valid.
4233 * A <literal>typedef</literal> is generally allowed in
4234 * exactly the same places that a variable declaration is
4235 * allowed. For this reason, you should not use
4236 * <literal>G_STATIC_ASSERT</literal> in the middle of
4240 * The macro should only be used once per source code line.
4247 * G_STATIC_ASSERT_EXPR:
4248 * @expr: a constant expression
4250 * The G_STATIC_ASSERT_EXPR macro lets the programmer check
4251 * a condition at compile time. The condition needs to be
4252 * compile time computable.
4254 * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
4255 * evaluates to an expression and, as such, can be used in
4256 * the middle of other expressions. Its value should be
4257 * ignored. This can be accomplished by placing it as
4258 * the first argument of a comma expression.
4261 * #define ADD_ONE_TO_INT(x) \
4262 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
4272 * Used within multi-statement macros so that they can be used in places
4273 * where only one statement is expected by the compiler.
4280 * Used within multi-statement macros so that they can be used in places
4281 * where only one statement is expected by the compiler.
4288 * Expands to a string identifying the current function.
4296 * @macro_or_string: a macro or a string
4298 * Accepts a macro or a string and converts it into a string after
4299 * preprocessor argument expansion. For example, the following code:
4303 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
4306 * is transformed by the preprocessor into (code equivalent to):
4309 * const gchar *greeting = "27 today!";
4317 * Expands to a string identifying the current code position.
4323 * @member_type: the type of the struct field
4324 * @struct_p: a pointer to a struct
4325 * @struct_offset: the offset of the field from the start of the struct, in bytes
4327 * Returns a member of a structure at a given offset, using the given type.
4329 * Returns: the struct member
4334 * G_STRUCT_MEMBER_P:
4335 * @struct_p: a pointer to a struct
4336 * @struct_offset: the offset from the start of the struct, in bytes
4338 * Returns an untyped pointer to a given offset of a struct.
4340 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
4346 * @struct_type: a structure type, e.g. <structname>GtkWidget</structname>
4347 * @member: a field in the structure, e.g. <structfield>window</structfield>
4349 * Returns the offset, in bytes, of a member of a struct.
4351 * Returns: the offset of @member from the start of @struct_type
4358 * The standard delimiters, used in g_strdelimit().
4365 * The error domain of the GLib thread subsystem.
4371 * @name: the name of the lock
4373 * Works like g_mutex_trylock(), but for a lock defined with
4376 * Returns: %TRUE, if the lock could be locked.
4382 * @maj: the major version that introduced the symbol
4383 * @min: the minor version that introduced the symbol
4385 * This macro can be used to mark a function declaration as unavailable.
4386 * It must be placed before the function declaration. Use of a function
4387 * that has been annotated with this macros will produce a compiler warning.
4395 * @expr: the expression
4397 * Hints the compiler that the expression is unlikely to evaluate to
4398 * a true value. The compiler may use this information for optimizations.
4401 * if (G_UNLIKELY (random () == 1))
4402 * g_print ("a random one");
4405 * Returns: the value of @expr
4412 * @name: the name of the lock
4414 * Works like g_mutex_unlock(), but for a lock defined with
4422 * Number of microseconds in one second (1 million).
4423 * This macro is provided for code readability.
4428 * G_VARIANT_PARSE_ERROR:
4430 * Error domain for GVariant text format parsing. Specific error codes
4431 * are not currently defined for this domain. See #GError for
4432 * information on error domains.
4438 * @ap1: the <type>va_list</type> variable to place a copy of @ap2 in
4439 * @ap2: a <type>va_list</type>
4441 * Portable way to copy <type>va_list</type> variables.
4443 * In order to use this function, you must include
4444 * <filename>string.h</filename> yourself, because this macro may
4445 * use memmove() and GLib does not include <filename>string.h</filename>
4451 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
4452 * @static: empty or "static"
4453 * @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
4455 * On Windows, this macro defines a DllMain() function that stores
4456 * the actual DLL name that the code being compiled will be included in.
4458 * On non-Windows platforms, expands to nothing.
4463 * G_WIN32_HAVE_WIDECHAR_API:
4465 * On Windows, this macro defines an expression which evaluates to
4466 * %TRUE if the code is running on a version of Windows where the wide
4467 * character versions of the Win32 API functions, and the wide character
4468 * versions of the C library functions work. (They are always present in
4469 * the DLLs, but don't work on Windows 9x and Me.)
4471 * On non-Windows platforms, it is not defined.
4478 * G_WIN32_IS_NT_BASED:
4480 * On Windows, this macro defines an expression which evaluates to
4481 * %TRUE if the code is running on an NT-based Windows operating system.
4483 * On non-Windows platforms, it is not defined.
4491 * @a: a numeric value
4492 * @b: a numeric value
4494 * Calculates the maximum of @a and @b.
4496 * Returns: the maximum of @a and @b.
4503 * Provided for UNIX emulation on Windows; equivalent to UNIX
4504 * macro %MAXPATHLEN, which is the maximum length of a filename
4505 * (including full path).
4511 * @a: a numeric value
4512 * @b: a numeric value
4514 * Calculates the minimum of @a and @b.
4516 * Returns: the minimum of @a and @b.
4522 * @Context: a message context, must be a string literal
4523 * @String: a message id, must be a string literal
4525 * Only marks a string for translation, with context.
4526 * This is useful in situations where the translated strings can't
4527 * be directly used, e.g. in string array initializers. To get the
4528 * translated string, you should call g_dpgettext2() at runtime.
4532 * static const char *messages[] = {
4533 * NC_("some context", "some very meaningful message"),
4534 * NC_("some context", "and another one")
4536 * const char *string;
4539 * = index > 1 ? g_dpgettext2 (NULL, "some context", "a default message")
4540 * : g_dpgettext2 (NULL, "some context", messages[index]);
4547 * <note><para>If you are using the NC_() macro, you need to make sure
4548 * that you pass <option>--keyword=NC_:1c,2</option> to xgettext when
4549 * extracting messages. Note that this only works with GNU gettext >= 0.15.
4550 * Intltool has support for the NC_() macro since version 0.40.1.
4560 * Defines the standard %NULL pointer.
4566 * @String: the string to be translated
4568 * Only marks a string for translation. This is useful in situations
4569 * where the translated strings can't be directly used, e.g. in string
4570 * array initializers. To get the translated string, call gettext()
4574 * static const char *messages[] = {
4575 * N_("some very meaningful message"),
4576 * N_("and another one")
4578 * const char *string;
4581 * = index > 1 ? _("a default message") : gettext (messages[index]);
4594 * @String: the string to be translated, with a '|'-separated prefix which must not be translated
4596 * Like _(), but handles context in message ids. This has the advantage
4597 * that the string can be adorned with a prefix to guarantee uniqueness
4598 * and provide context to the translator.
4600 * One use case given in the gettext manual is GUI translation, where one
4601 * could e.g. disambiguate two "Open" menu entries as "File|Open" and
4602 * "Printer|Open". Another use case is the string "Russian" which may
4603 * have to be translated differently depending on whether it's the name
4604 * of a character set or a language. This could be solved by using
4605 * "charset|Russian" and "language|Russian".
4607 * See the C_() macro for a different way to mark up translatable strings
4610 * <note><para>If you are using the Q_() macro, you need to make sure
4611 * that you pass <option>--keyword=Q_</option> to xgettext when extracting
4612 * messages. If you are using GNU gettext >= 0.15, you can also use
4613 * <option>--keyword=Q_:1g</option> to let xgettext split the context
4614 * string off into a msgctxt line in the po file.</para></note>
4616 * Returns: the translated message
4624 * @short_description: arrays of arbitrary elements which grow automatically as elements are added
4626 * Arrays are similar to standard C arrays, except that they grow
4627 * automatically as elements are added.
4629 * Array elements can be of any size (though all elements of one array
4630 * are the same size), and the array can be automatically cleared to
4631 * '0's and zero-terminated.
4633 * To create a new array use g_array_new().
4635 * To add elements to an array, use g_array_append_val(),
4636 * g_array_append_vals(), g_array_prepend_val(), and
4637 * g_array_prepend_vals().
4639 * To access an element of an array, use g_array_index().
4641 * To set the size of an array, use g_array_set_size().
4643 * To free an array, use g_array_free().
4646 * <title>Using a #GArray to store #gint values</title>
4650 * /<!-- -->* We create a new array to store gint values.
4651 * We don't want it zero-terminated or cleared to 0's. *<!-- -->/
4652 * garray = g_array_new (FALSE, FALSE, sizeof (gint));
4653 * for (i = 0; i < 10000; i++)
4654 * g_array_append_val (garray, i);
4655 * for (i = 0; i < 10000; i++)
4656 * if (g_array_index (garray, gint, i) != i)
4657 * g_print ("ERROR: got %d instead of %d\n",
4658 * g_array_index (garray, gint, i), i);
4659 * g_array_free (garray, TRUE);
4666 * SECTION:arrays_byte
4667 * @title: Byte Arrays
4668 * @short_description: arrays of bytes
4670 * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
4671 * of bytes which grow automatically as elements are added.
4673 * To create a new #GByteArray use g_byte_array_new(). To add elements to a
4674 * #GByteArray, use g_byte_array_append(), and g_byte_array_prepend().
4676 * To set the size of a #GByteArray, use g_byte_array_set_size().
4678 * To free a #GByteArray, use g_byte_array_free().
4681 * <title>Using a #GByteArray</title>
4683 * GByteArray *gbarray;
4686 * gbarray = g_byte_array_new (<!-- -->);
4687 * for (i = 0; i < 10000; i++)
4688 * g_byte_array_append (gbarray, (guint8*) "abcd", 4);
4690 * for (i = 0; i < 10000; i++)
4692 * g_assert (gbarray->data[4*i] == 'a');
4693 * g_assert (gbarray->data[4*i+1] == 'b');
4694 * g_assert (gbarray->data[4*i+2] == 'c');
4695 * g_assert (gbarray->data[4*i+3] == 'd');
4698 * g_byte_array_free (gbarray, TRUE);
4702 * See #GBytes if you are interested in an immutable object representing a
4703 * sequence of bytes.
4708 * SECTION:arrays_pointer
4709 * @title: Pointer Arrays
4710 * @short_description: arrays of pointers to any type of data, which grow automatically as new elements are added
4712 * Pointer Arrays are similar to Arrays but are used only for storing
4715 * <note><para>If you remove elements from the array, elements at the
4716 * end of the array are moved into the space previously occupied by the
4717 * removed element. This means that you should not rely on the index of
4718 * particular elements remaining the same. You should also be careful
4719 * when deleting elements while iterating over the array.</para></note>
4721 * To create a pointer array, use g_ptr_array_new().
4723 * To add elements to a pointer array, use g_ptr_array_add().
4725 * To remove elements from a pointer array, use g_ptr_array_remove(),
4726 * g_ptr_array_remove_index() or g_ptr_array_remove_index_fast().
4728 * To access an element of a pointer array, use g_ptr_array_index().
4730 * To set the size of a pointer array, use g_ptr_array_set_size().
4732 * To free a pointer array, use g_ptr_array_free().
4735 * <title>Using a #GPtrArray</title>
4737 * GPtrArray *gparray;
4738 * gchar *string1 = "one", *string2 = "two", *string3 = "three";
4740 * gparray = g_ptr_array_new (<!-- -->);
4741 * g_ptr_array_add (gparray, (gpointer) string1);
4742 * g_ptr_array_add (gparray, (gpointer) string2);
4743 * g_ptr_array_add (gparray, (gpointer) string3);
4745 * if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
4746 * g_print ("ERROR: got %p instead of %p\n",
4747 * g_ptr_array_index (gparray, 0), string1);
4749 * g_ptr_array_free (gparray, TRUE);
4756 * SECTION:async_queues
4757 * @title: Asynchronous Queues
4758 * @short_description: asynchronous communication between threads
4759 * @see_also: #GThreadPool
4761 * Often you need to communicate between different threads. In general
4762 * it's safer not to do this by shared memory, but by explicit message
4763 * passing. These messages only make sense asynchronously for
4764 * multi-threaded applications though, as a synchronous operation could
4765 * as well be done in the same thread.
4767 * Asynchronous queues are an exception from most other GLib data
4768 * structures, as they can be used simultaneously from multiple threads
4769 * without explicit locking and they bring their own builtin reference
4770 * counting. This is because the nature of an asynchronous queue is that
4771 * it will always be used by at least 2 concurrent threads.
4773 * For using an asynchronous queue you first have to create one with
4774 * g_async_queue_new(). #GAsyncQueue structs are reference counted,
4775 * use g_async_queue_ref() and g_async_queue_unref() to manage your
4778 * A thread which wants to send a message to that queue simply calls
4779 * g_async_queue_push() to push the message to the queue.
4781 * A thread which is expecting messages from an asynchronous queue
4782 * simply calls g_async_queue_pop() for that queue. If no message is
4783 * available in the queue at that point, the thread is now put to sleep
4784 * until a message arrives. The message will be removed from the queue
4785 * and returned. The functions g_async_queue_try_pop() and
4786 * g_async_queue_timeout_pop() can be used to only check for the presence
4787 * of messages or to only wait a certain time for messages respectively.
4789 * For almost every function there exist two variants, one that locks
4790 * the queue and one that doesn't. That way you can hold the queue lock
4791 * (acquire it with g_async_queue_lock() and release it with
4792 * g_async_queue_unlock()) over multiple queue accessing instructions.
4793 * This can be necessary to ensure the integrity of the queue, but should
4794 * only be used when really necessary, as it can make your life harder
4795 * if used unwisely. Normally you should only use the locking function
4796 * variants (those without the _unlocked suffix).
4798 * In many cases, it may be more convenient to use #GThreadPool when
4799 * you need to distribute work to a set of worker threads instead of
4800 * using #GAsyncQueue manually. #GThreadPool uses a GAsyncQueue
4806 * SECTION:atomic_operations
4807 * @title: Atomic Operations
4808 * @short_description: basic atomic integer and pointer operations
4809 * @see_also: #GMutex
4811 * The following is a collection of compiler macros to provide atomic
4812 * access to integer and pointer-sized values.
4814 * The macros that have 'int' in the name will operate on pointers to
4815 * #gint and #guint. The macros with 'pointer' in the name will operate
4816 * on pointers to any pointer-sized value, including #gsize. There is
4817 * no support for 64bit operations on platforms with 32bit pointers
4818 * because it is not generally possible to perform these operations
4821 * The get, set and exchange operations for integers and pointers
4822 * nominally operate on #gint and #gpointer, respectively. Of the
4823 * arithmetic operations, the 'add' operation operates on (and returns)
4824 * signed integer values (#gint and #gssize) and the 'and', 'or', and
4825 * 'xor' operations operate on (and return) unsigned integer values
4826 * (#guint and #gsize).
4828 * All of the operations act as a full compiler and (where appropriate)
4829 * hardware memory barrier. Acquire and release or producer and
4830 * consumer barrier semantics are not available through this API.
4832 * It is very important that all accesses to a particular integer or
4833 * pointer be performed using only this API and that different sizes of
4834 * operation are not mixed or used on overlapping memory regions. Never
4835 * read or assign directly from or to a value -- always use this API.
4837 * For simple reference counting purposes you should use
4838 * g_atomic_int_inc() and g_atomic_int_dec_and_test(). Other uses that
4839 * fall outside of simple reference counting patterns are prone to
4840 * subtle bugs and occasionally undefined behaviour. It is also worth
4841 * noting that since all of these operations require global
4842 * synchronisation of the entire machine, they can be quite slow. In
4843 * the case of performing multiple atomic operations it can often be
4844 * faster to simply acquire a mutex lock around the critical area,
4845 * perform the operations normally and then release the lock.
4851 * @title: Base64 Encoding
4852 * @short_description: encodes and decodes data in Base64 format
4854 * Base64 is an encoding that allows a sequence of arbitrary bytes to be
4855 * encoded as a sequence of printable ASCII characters. For the definition
4856 * of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
4857 * 1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
4858 * 2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
4861 * GLib supports incremental encoding using g_base64_encode_step() and
4862 * g_base64_encode_close(). Incremental decoding can be done with
4863 * g_base64_decode_step(). To encode or decode data in one go, use
4864 * g_base64_encode() or g_base64_decode(). To avoid memory allocation when
4865 * decoding, you can use g_base64_decode_inplace().
4867 * Support for Base64 encoding has been added in GLib 2.12.
4872 * SECTION:bookmarkfile
4873 * @title: Bookmark file parser
4874 * @short_description: parses files containing bookmarks
4876 * GBookmarkFile lets you parse, edit or create files containing bookmarks
4877 * to URI, along with some meta-data about the resource pointed by the URI
4878 * like its MIME type, the application that is registering the bookmark and
4879 * the icon that should be used to represent the bookmark. The data is stored
4881 * <ulink url="http://www.gnome.org/~ebassi/bookmark-spec">Desktop Bookmark
4882 * Specification</ulink>.
4884 * The syntax of the bookmark files is described in detail inside the Desktop
4885 * Bookmark Specification, here is a quick summary: bookmark files use a
4886 * sub-class of the <ulink url="">XML Bookmark Exchange Language</ulink>
4887 * specification, consisting of valid UTF-8 encoded XML, under the
4888 * <literal>xbel</literal> root element; each bookmark is stored inside a
4889 * <literal>bookmark</literal> element, using its URI: no relative paths can
4890 * be used inside a bookmark file. The bookmark may have a user defined title
4891 * and description, to be used instead of the URI. Under the
4892 * <literal>metadata</literal> element, with its <literal>owner</literal>
4893 * attribute set to <literal>http://freedesktop.org</literal>, is stored the
4894 * meta-data about a resource pointed by its URI. The meta-data consists of
4895 * the resource's MIME type; the applications that have registered a bookmark;
4896 * the groups to which a bookmark belongs to; a visibility flag, used to set
4897 * the bookmark as "private" to the applications and groups that has it
4898 * registered; the URI and MIME type of an icon, to be used when displaying
4899 * the bookmark inside a GUI.
4900 * |[<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>]|
4902 * A bookmark file might contain more than one bookmark; each bookmark
4903 * is accessed through its URI.
4905 * The important caveat of bookmark files is that when you add a new
4906 * bookmark you must also add the application that is registering it, using
4907 * g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
4908 * If a bookmark has no applications then it won't be dumped when creating
4909 * the on disk representation, using g_bookmark_file_to_data() or
4910 * g_bookmark_file_to_file().
4912 * The #GBookmarkFile parser was added in GLib 2.12.
4917 * SECTION:byte_order
4918 * @title: Byte Order Macros
4919 * @short_description: a portable way to convert between different byte orders
4921 * These macros provide a portable way to determine the host byte order
4922 * and to convert values between different byte orders.
4924 * The byte order is the order in which bytes are stored to create larger
4925 * data types such as the #gint and #glong values.
4926 * The host byte order is the byte order used on the current machine.
4928 * Some processors store the most significant bytes (i.e. the bytes that
4929 * hold the largest part of the value) first. These are known as big-endian
4930 * processors. Other processors (notably the x86 family) store the most
4931 * significant byte last. These are known as little-endian processors.
4933 * Finally, to complicate matters, some other processors store the bytes in
4934 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
4935 * most significant byte is stored first, then the 4th, then the 1st and
4938 * Obviously there is a problem when these different processors communicate
4939 * with each other, for example over networks or by using binary file formats.
4940 * This is where these macros come in. They are typically used to convert
4941 * values into a byte order which has been agreed on for use when
4942 * communicating between different processors. The Internet uses what is
4943 * known as 'network byte order' as the standard byte order (which is in
4944 * fact the big-endian byte order).
4946 * Note that the byte order conversion macros may evaluate their arguments
4947 * multiple times, thus you should not use them with arguments which have
4954 * @title: Data Checksums
4955 * @short_description: computes the checksum for data
4957 * GLib provides a generic API for computing checksums (or "digests")
4958 * for a sequence of arbitrary bytes, using various hashing algorithms
4959 * like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
4960 * environments and specifications.
4962 * GLib supports incremental checksums using the GChecksum data
4963 * structure, by calling g_checksum_update() as long as there's data
4964 * available and then using g_checksum_get_string() or
4965 * g_checksum_get_digest() to compute the checksum and return it either
4966 * as a string in hexadecimal form, or as a raw sequence of bytes. To
4967 * compute the checksum for binary blobs and NUL-terminated strings in
4968 * one go, use the convenience functions g_compute_checksum_for_data()
4969 * and g_compute_checksum_for_string(), respectively.
4971 * Support for checksums has been added in GLib 2.16
4976 * SECTION:conversions
4977 * @title: Character Set Conversion
4978 * @short_description: convert strings between different character sets
4980 * The g_convert() family of function wraps the functionality of iconv(). In
4981 * addition to pure character set conversions, GLib has functions to deal
4982 * with the extra complications of encodings for file names.
4984 * <refsect2 id="file-name-encodings">
4985 * <title>File Name Encodings</title>
4987 * Historically, Unix has not had a defined encoding for file
4988 * names: a file name is valid as long as it does not have path
4989 * separators in it ("/"). However, displaying file names may
4990 * require conversion: from the character set in which they were
4991 * created, to the character set in which the application
4992 * operates. Consider the Spanish file name
4993 * "<filename>Presentación.sxi</filename>". If the
4994 * application which created it uses ISO-8859-1 for its encoding,
4996 * <programlisting id="filename-iso8859-1">
4997 * Character: P r e s e n t a c i ó n . s x i
4998 * Hex code: 50 72 65 73 65 6e 74 61 63 69 f3 6e 2e 73 78 69
5001 * However, if the application use UTF-8, the actual file name on
5002 * disk would look like this:
5004 * <programlisting id="filename-utf-8">
5005 * Character: P r e s e n t a c i ó n . s x i
5006 * Hex code: 50 72 65 73 65 6e 74 61 63 69 c3 b3 6e 2e 73 78 69
5009 * Glib uses UTF-8 for its strings, and GUI toolkits like GTK+
5010 * that use Glib do the same thing. If you get a file name from
5011 * the file system, for example, from readdir(3) or from g_dir_read_name(),
5012 * and you wish to display the file name to the user, you
5013 * <emphasis>will</emphasis> need to convert it into UTF-8. The
5014 * opposite case is when the user types the name of a file he
5015 * wishes to save: the toolkit will give you that string in
5016 * UTF-8 encoding, and you will need to convert it to the
5017 * character set used for file names before you can create the
5018 * file with open(2) or fopen(3).
5021 * By default, Glib assumes that file names on disk are in UTF-8
5022 * encoding. This is a valid assumption for file systems which
5023 * were created relatively recently: most applications use UTF-8
5024 * encoding for their strings, and that is also what they use for
5025 * the file names they create. However, older file systems may
5026 * still contain file names created in "older" encodings, such as
5027 * ISO-8859-1. In this case, for compatibility reasons, you may
5028 * want to instruct Glib to use that particular encoding for file
5029 * names rather than UTF-8. You can do this by specifying the
5030 * encoding for file names in the <link
5031 * linkend="G_FILENAME_ENCODING"><envar>G_FILENAME_ENCODING</envar></link>
5032 * environment variable. For example, if your installation uses
5033 * ISO-8859-1 for file names, you can put this in your
5034 * <filename>~/.profile</filename>:
5037 * export G_FILENAME_ENCODING=ISO-8859-1
5040 * Glib provides the functions g_filename_to_utf8() and
5041 * g_filename_from_utf8() to perform the necessary conversions. These
5042 * functions convert file names from the encoding specified in
5043 * <envar>G_FILENAME_ENCODING</envar> to UTF-8 and vice-versa.
5044 * <xref linkend="file-name-encodings-diagram"/> illustrates how
5045 * these functions are used to convert between UTF-8 and the
5046 * encoding for file names in the file system.
5048 * <figure id="file-name-encodings-diagram">
5049 * <title>Conversion between File Name Encodings</title>
5050 * <graphic fileref="file-name-encodings.png" format="PNG"/>
5052 * <refsect3 id="file-name-encodings-checklist">
5053 * <title>Checklist for Application Writers</title>
5055 * This section is a practical summary of the detailed
5056 * description above. You can use this as a checklist of
5057 * things to do to make sure your applications process file
5058 * name encodings correctly.
5062 * If you get a file name from the file system from a function
5063 * such as readdir(3) or gtk_file_chooser_get_filename(),
5064 * you do not need to do any conversion to pass that
5065 * file name to functions like open(2), rename(2), or
5066 * fopen(3) — those are "raw" file names which the file
5067 * system understands.
5068 * </para></listitem>
5070 * If you need to display a file name, convert it to UTF-8 first by
5071 * using g_filename_to_utf8(). If conversion fails, display a string like
5072 * "<literal>Unknown file name</literal>". <emphasis>Do not</emphasis>
5073 * convert this string back into the encoding used for file names if you
5074 * wish to pass it to the file system; use the original file name instead.
5075 * For example, the document window of a word processor could display
5076 * "Unknown file name" in its title bar but still let the user save the
5077 * file, as it would keep the raw file name internally. This can happen
5078 * if the user has not set the <envar>G_FILENAME_ENCODING</envar>
5079 * environment variable even though he has files whose names are not
5081 * </para></listitem>
5083 * If your user interface lets the user type a file name for saving or
5084 * renaming, convert it to the encoding used for file names in the file
5085 * system by using g_filename_from_utf8(). Pass the converted file name
5086 * to functions like fopen(3). If conversion fails, ask the user to enter
5087 * a different file name. This can happen if the user types Japanese
5088 * characters when <envar>G_FILENAME_ENCODING</envar> is set to
5089 * <literal>ISO-8859-1</literal>, for example.
5090 * </para></listitem>
5099 * @title: Keyed Data Lists
5100 * @short_description: lists of data elements which are accessible by a string or GQuark identifier
5102 * Keyed data lists provide lists of arbitrary data elements which can
5103 * be accessed either with a string or with a #GQuark corresponding to
5106 * The #GQuark methods are quicker, since the strings have to be
5107 * converted to #GQuarks anyway.
5109 * Data lists are used for associating arbitrary data with #GObjects,
5110 * using g_object_set_data() and related functions.
5112 * To create a datalist, use g_datalist_init().
5114 * To add data elements to a datalist use g_datalist_id_set_data(),
5115 * g_datalist_id_set_data_full(), g_datalist_set_data() and
5116 * g_datalist_set_data_full().
5118 * To get data elements from a datalist use g_datalist_id_get_data()
5119 * and g_datalist_get_data().
5121 * To iterate over all data elements in a datalist use
5122 * g_datalist_foreach() (not thread-safe).
5124 * To remove data elements from a datalist use
5125 * g_datalist_id_remove_data() and g_datalist_remove_data().
5127 * To remove all data elements from a datalist, use g_datalist_clear().
5134 * @short_description: associate groups of data elements with particular memory locations
5136 * Datasets associate groups of data elements with particular memory
5137 * locations. These are useful if you need to associate data with a
5138 * structure returned from an external library. Since you cannot modify
5139 * the structure, you use its location in memory as the key into a
5140 * dataset, where you can associate any number of data elements with it.
5142 * There are two forms of most of the dataset functions. The first form
5143 * uses strings to identify the data elements associated with a
5144 * location. The second form uses #GQuark identifiers, which are
5145 * created with a call to g_quark_from_string() or
5146 * g_quark_from_static_string(). The second form is quicker, since it
5147 * does not require looking up the string in the hash table of #GQuark
5150 * There is no function to create a dataset. It is automatically
5151 * created as soon as you add elements to it.
5153 * To add data elements to a dataset use g_dataset_id_set_data(),
5154 * g_dataset_id_set_data_full(), g_dataset_set_data() and
5155 * g_dataset_set_data_full().
5157 * To get data elements from a dataset use g_dataset_id_get_data() and
5158 * g_dataset_get_data().
5160 * To iterate over all data elements in a dataset use
5161 * g_dataset_foreach() (not thread-safe).
5163 * To remove data elements from a dataset use
5164 * g_dataset_id_remove_data() and g_dataset_remove_data().
5166 * To destroy a dataset, use g_dataset_destroy().
5172 * @title: Date and Time Functions
5173 * @short_description: calendrical calculations and miscellaneous time stuff
5175 * The #GDate data structure represents a day between January 1, Year 1,
5176 * and sometime a few thousand years in the future (right now it will go
5177 * to the year 65535 or so, but g_date_set_parse() only parses up to the
5178 * year 8000 or so - just count on "a few thousand"). #GDate is meant to
5179 * represent everyday dates, not astronomical dates or historical dates
5180 * or ISO timestamps or the like. It extrapolates the current Gregorian
5181 * calendar forward and backward in time; there is no attempt to change
5182 * the calendar to match time periods or locations. #GDate does not store
5183 * time information; it represents a <emphasis>day</emphasis>.
5185 * The #GDate implementation has several nice features; it is only a
5186 * 64-bit struct, so storing large numbers of dates is very efficient. It
5187 * can keep both a Julian and day-month-year representation of the date,
5188 * since some calculations are much easier with one representation or the
5189 * other. A Julian representation is simply a count of days since some
5190 * fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
5191 * ("Julian" dates in the #GDate API aren't really Julian dates in the
5192 * technical sense; technically, Julian dates count from the start of the
5193 * Julian period, Jan 1, 4713 BC).
5195 * #GDate is simple to use. First you need a "blank" date; you can get a
5196 * dynamically allocated date from g_date_new(), or you can declare an
5197 * automatic variable or array and initialize it to a sane state by
5198 * calling g_date_clear(). A cleared date is sane; it's safe to call
5199 * g_date_set_dmy() and the other mutator functions to initialize the
5200 * value of a cleared date. However, a cleared date is initially
5201 * <emphasis>invalid</emphasis>, meaning that it doesn't represent a day
5202 * that exists. It is undefined to call any of the date calculation
5203 * routines on an invalid date. If you obtain a date from a user or other
5204 * unpredictable source, you should check its validity with the
5205 * g_date_valid() predicate. g_date_valid() is also used to check for
5206 * errors with g_date_set_parse() and other functions that can
5207 * fail. Dates can be invalidated by calling g_date_clear() again.
5209 * <emphasis>It is very important to use the API to access the #GDate
5210 * struct.</emphasis> Often only the day-month-year or only the Julian
5211 * representation is valid. Sometimes neither is valid. Use the API.
5213 * GLib also features #GDateTime which represents a precise time.
5220 * @short_description: a structure representing Date and Time
5221 * @see_also: #GTimeZone
5223 * #GDateTime is a structure that combines a Gregorian date and time
5224 * into a single structure. It provides many conversion and methods to
5225 * manipulate dates and times. Time precision is provided down to
5226 * microseconds and the time can range (proleptically) from 0001-01-01
5227 * 00:00:00 to 9999-12-31 23:59:59.999999. #GDateTime follows POSIX
5228 * time in the sense that it is oblivious to leap seconds.
5230 * #GDateTime is an immutable object; once it has been created it cannot
5231 * be modified further. All modifiers will create a new #GDateTime.
5232 * Nearly all such functions can fail due to the date or time going out
5233 * of range, in which case %NULL will be returned.
5235 * #GDateTime is reference counted: the reference count is increased by calling
5236 * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
5237 * reference count drops to 0, the resources allocated by the #GDateTime
5238 * structure are released.
5240 * Many parts of the API may produce non-obvious results. As an
5241 * example, adding two months to January 31st will yield March 31st
5242 * whereas adding one month and then one month again will yield either
5243 * March 28th or March 29th. Also note that adding 24 hours is not
5244 * always the same as adding one day (since days containing daylight
5245 * savings time transitions are either 23 or 25 hours in length).
5247 * #GDateTime is available since GLib 2.26.
5252 * SECTION:error_reporting
5253 * @Title: Error Reporting
5254 * @Short_description: a system for reporting errors
5256 * GLib provides a standard method of reporting errors from a called
5257 * function to the calling code. (This is the same problem solved by
5258 * exceptions in other languages.) It's important to understand that
5259 * this method is both a <emphasis>data type</emphasis> (the #GError
5260 * object) and a <emphasis>set of rules.</emphasis> If you use #GError
5261 * incorrectly, then your code will not properly interoperate with other
5262 * code that uses #GError, and users of your API will probably get confused.
5264 * First and foremost: <emphasis>#GError should only be used to report
5265 * recoverable runtime errors, never to report programming
5266 * errors.</emphasis> If the programmer has screwed up, then you should
5267 * use g_warning(), g_return_if_fail(), g_assert(), g_error(), or some
5268 * similar facility. (Incidentally, remember that the g_error() function
5269 * should <emphasis>only</emphasis> be used for programming errors, it
5270 * should not be used to print any error reportable via #GError.)
5272 * Examples of recoverable runtime errors are "file not found" or
5273 * "failed to parse input." Examples of programming errors are "NULL
5274 * passed to strcmp()" or "attempted to free the same pointer twice."
5275 * These two kinds of errors are fundamentally different: runtime errors
5276 * should be handled or reported to the user, programming errors should
5277 * be eliminated by fixing the bug in the program. This is why most
5278 * functions in GLib and GTK+ do not use the #GError facility.
5280 * Functions that can fail take a return location for a #GError as their
5281 * last argument. For example:
5283 * gboolean g_file_get_contents (const gchar *filename,
5288 * If you pass a non-%NULL value for the <literal>error</literal>
5289 * argument, it should point to a location where an error can be placed.
5293 * GError *err = NULL;
5294 * g_file_get_contents ("foo.txt", &contents, NULL, &err);
5295 * g_assert ((contents == NULL && err != NULL) || (contents != NULL && err == NULL));
5298 * /* Report error to user, and free error */
5299 * g_assert (contents == NULL);
5300 * fprintf (stderr, "Unable to read file: %s\n", err->message);
5301 * g_error_free (err);
5305 * /* Use file contents */
5306 * g_assert (contents != NULL);
5309 * Note that <literal>err != NULL</literal> in this example is a
5310 * <emphasis>reliable</emphasis> indicator of whether
5311 * g_file_get_contents() failed. Additionally, g_file_get_contents()
5312 * returns a boolean which indicates whether it was successful.
5314 * Because g_file_get_contents() returns %FALSE on failure, if you
5315 * are only interested in whether it failed and don't need to display
5316 * an error message, you can pass %NULL for the <literal>error</literal>
5319 * if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /* ignore errors */
5320 * /* no error occurred */ ;
5322 * /* error */ ;
5325 * The #GError object contains three fields: <literal>domain</literal>
5326 * indicates the module the error-reporting function is located in,
5327 * <literal>code</literal> indicates the specific error that occurred,
5328 * and <literal>message</literal> is a user-readable error message with
5329 * as many details as possible. Several functions are provided to deal
5330 * with an error received from a called function: g_error_matches()
5331 * returns %TRUE if the error matches a given domain and code,
5332 * g_propagate_error() copies an error into an error location (so the
5333 * calling function will receive it), and g_clear_error() clears an
5334 * error location by freeing the error and resetting the location to
5335 * %NULL. To display an error to the user, simply display
5336 * <literal>error->message</literal>, perhaps along with additional
5337 * context known only to the calling function (the file being opened,
5338 * or whatever -- though in the g_file_get_contents() case,
5339 * <literal>error->message</literal> already contains a filename).
5341 * When implementing a function that can report errors, the basic
5342 * tool is g_set_error(). Typically, if a fatal error occurs you
5343 * want to g_set_error(), then return immediately. g_set_error()
5344 * does nothing if the error location passed to it is %NULL.
5345 * Here's an example:
5348 * foo_open_file (GError **error)
5352 * fd = open ("file.txt", O_RDONLY);
5356 * g_set_error (error,
5357 * FOO_ERROR, /* error domain */
5358 * FOO_ERROR_BLAH, /* error code */
5359 * "Failed to open file: %s", /* error message format string */
5360 * g_strerror (errno));
5368 * Things are somewhat more complicated if you yourself call another
5369 * function that can report a #GError. If the sub-function indicates
5370 * fatal errors in some way other than reporting a #GError, such as
5371 * by returning %TRUE on success, you can simply do the following:
5374 * my_function_that_can_fail (GError **err)
5376 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5378 * if (!sub_function_that_can_fail (err))
5380 * /* assert that error was set by the sub-function */
5381 * g_assert (err == NULL || *err != NULL);
5385 * /* otherwise continue, no error occurred */
5386 * g_assert (err == NULL || *err == NULL);
5390 * If the sub-function does not indicate errors other than by
5391 * reporting a #GError, you need to create a temporary #GError
5392 * since the passed-in one may be %NULL. g_propagate_error() is
5393 * intended for use in this case.
5396 * my_function_that_can_fail (GError **err)
5398 * GError *tmp_error;
5400 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5403 * sub_function_that_can_fail (&tmp_error);
5405 * if (tmp_error != NULL)
5407 * /* store tmp_error in err, if err != NULL,
5408 * * otherwise call g_error_free() on tmp_error
5410 * g_propagate_error (err, tmp_error);
5414 * /* otherwise continue, no error occurred */
5418 * Error pileups are always a bug. For example, this code is incorrect:
5421 * my_function_that_can_fail (GError **err)
5423 * GError *tmp_error;
5425 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5428 * sub_function_that_can_fail (&tmp_error);
5429 * other_function_that_can_fail (&tmp_error);
5431 * if (tmp_error != NULL)
5433 * g_propagate_error (err, tmp_error);
5438 * <literal>tmp_error</literal> should be checked immediately after
5439 * sub_function_that_can_fail(), and either cleared or propagated
5440 * upward. The rule is: <emphasis>after each error, you must either
5441 * handle the error, or return it to the calling function</emphasis>.
5442 * Note that passing %NULL for the error location is the equivalent
5443 * of handling an error by always doing nothing about it. So the
5444 * following code is fine, assuming errors in sub_function_that_can_fail()
5445 * are not fatal to my_function_that_can_fail():
5448 * my_function_that_can_fail (GError **err)
5450 * GError *tmp_error;
5452 * g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5454 * sub_function_that_can_fail (NULL); /* ignore errors */
5457 * other_function_that_can_fail (&tmp_error);
5459 * if (tmp_error != NULL)
5461 * g_propagate_error (err, tmp_error);
5467 * Note that passing %NULL for the error location
5468 * <emphasis>ignores</emphasis> errors; it's equivalent to
5469 * <literal>try { sub_function_that_can_fail (); } catch (...) {}</literal>
5470 * in C++. It does <emphasis>not</emphasis> mean to leave errors
5471 * unhandled; it means to handle them by doing nothing.
5473 * Error domains and codes are conventionally named as follows:
5476 * The error domain is called
5477 * <literal><NAMESPACE>_<MODULE>_ERROR</literal>,
5478 * for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
5480 * #define G_SPAWN_ERROR g_spawn_error_quark ()
5483 * g_spawn_error_quark (void)
5485 * return g_quark_from_static_string ("g-spawn-error-quark");
5488 * </para></listitem>
5490 * The quark function for the error domain is called
5491 * <literal><namespace>_<module>_error_quark</literal>,
5492 * for example g_spawn_error_quark() or g_thread_error_quark().
5493 * </para></listitem>
5495 * The error codes are in an enumeration called
5496 * <literal><Namespace><Module>Error</literal>;
5497 * for example,#GThreadError or #GSpawnError.
5498 * </para></listitem>
5500 * Members of the error code enumeration are called
5501 * <literal><NAMESPACE>_<MODULE>_ERROR_<CODE></literal>,
5502 * for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
5503 * </para></listitem>
5505 * If there's a "generic" or "unknown" error code for unrecoverable
5506 * errors it doesn't make sense to distinguish with specific codes,
5507 * it should be called <literal><NAMESPACE>_<MODULE>_ERROR_FAILED</literal>,
5508 * for example %G_SPAWN_ERROR_FAILED.
5509 * </para></listitem>
5512 * Summary of rules for use of #GError:
5515 * Do not report programming errors via #GError.
5516 * </para></listitem>
5518 * The last argument of a function that returns an error should
5519 * be a location where a #GError can be placed (i.e. "#GError** error").
5520 * If #GError is used with varargs, the #GError** should be the last
5521 * argument before the "...".
5522 * </para></listitem>
5524 * The caller may pass %NULL for the #GError** if they are not interested
5525 * in details of the exact error that occurred.
5526 * </para></listitem>
5528 * If %NULL is passed for the #GError** argument, then errors should
5529 * not be returned to the caller, but your function should still
5530 * abort and return if an error occurs. That is, control flow should
5531 * not be affected by whether the caller wants to get a #GError.
5532 * </para></listitem>
5534 * If a #GError is reported, then your function by definition
5535 * <emphasis>had a fatal failure and did not complete whatever
5536 * it was supposed to do</emphasis>. If the failure was not fatal,
5537 * then you handled it and you should not report it. If it was fatal,
5538 * then you must report it and discontinue whatever you were doing
5540 * </para></listitem>
5542 * If a #GError is reported, out parameters are not guaranteed to
5543 * be set to any defined value.
5544 * </para></listitem>
5546 * A #GError* must be initialized to %NULL before passing its address
5547 * to a function that can report errors.
5548 * </para></listitem>
5550 * "Piling up" errors is always a bug. That is, if you assign a
5551 * new #GError to a #GError* that is non-%NULL, thus overwriting
5552 * the previous error, it indicates that you should have aborted
5553 * the operation instead of continuing. If you were able to continue,
5554 * you should have cleared the previous error with g_clear_error().
5555 * g_set_error() will complain if you pile up errors.
5556 * </para></listitem>
5558 * By convention, if you return a boolean value indicating success
5559 * then %TRUE means success and %FALSE means failure. If %FALSE is
5560 * returned, the error <emphasis>must</emphasis> be set to a non-%NULL
5562 * </para></listitem>
5564 * A %NULL return value is also frequently used to mean that an error
5565 * occurred. You should make clear in your documentation whether %NULL
5566 * is a valid return value in non-error cases; if %NULL is a valid value,
5567 * then users must check whether an error was returned to see if the
5568 * function succeeded.
5569 * </para></listitem>
5571 * When implementing a function that can report errors, you may want
5572 * to add a check at the top of your function that the error return
5573 * location is either %NULL or contains a %NULL error (e.g.
5574 * <literal>g_return_if_fail (error == NULL || *error == NULL);</literal>).
5575 * </para></listitem>
5582 * @title: File Utilities
5583 * @short_description: various file-related functions
5585 * There is a group of functions which wrap the common POSIX functions
5586 * dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(),
5587 * g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these
5588 * wrappers is to make it possible to handle file names with any Unicode
5589 * characters in them on Windows without having to use ifdefs and the
5590 * wide character API in the application code.
5592 * The pathname argument should be in the GLib file name encoding.
5593 * On POSIX this is the actual on-disk encoding which might correspond
5594 * to the locale settings of the process (or the
5595 * <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
5597 * On Windows the GLib file name encoding is UTF-8. Note that the
5598 * Microsoft C library does not use UTF-8, but has separate APIs for
5599 * current system code page and wide characters (UTF-16). The GLib
5600 * wrappers call the wide character API if present (on modern Windows
5601 * systems), otherwise convert to/from the system code page.
5603 * Another group of functions allows to open and read directories
5604 * in the GLib file name encoding. These are g_dir_open(),
5605 * g_dir_read_name(), g_dir_rewind(), g_dir_close().
5610 * SECTION:ghostutils
5611 * @short_description: Internet hostname utilities
5613 * Functions for manipulating internet hostnames; in particular, for
5614 * converting between Unicode and ASCII-encoded forms of
5615 * Internationalized Domain Names (IDNs).
5618 * url="http://www.ietf.org/rfc/rfc3490.txt">Internationalized Domain
5619 * Names for Applications (IDNA)</ulink> standards allow for the use
5620 * of Unicode domain names in applications, while providing
5621 * backward-compatibility with the old ASCII-only DNS, by defining an
5622 * ASCII-Compatible Encoding of any given Unicode name, which can be
5623 * used with non-IDN-aware applications and protocols. (For example,
5624 * "Παν語.org" maps to "xn--4wa8awb4637h.org".)
5630 * @title: Perl-compatible regular expressions
5631 * @short_description: matches strings against regular expressions
5632 * @see_also: <xref linkend="glib-regex-syntax"/>
5634 * The <function>g_regex_*()</function> functions implement regular
5635 * expression pattern matching using syntax and semantics similar to
5636 * Perl regular expression.
5638 * Some functions accept a @start_position argument, setting it differs
5639 * from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
5640 * in the case of a pattern that begins with any kind of lookbehind assertion.
5641 * For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
5642 * in the middle of words. ("\B" matches only if the current position in the
5643 * subject is not a word boundary.) When applied to the string "Mississipi"
5644 * from the fourth byte, namely "issipi", it does not match, because "\B" is
5645 * always false at the start of the subject, which is deemed to be a word
5646 * boundary. However, if the entire string is passed , but with
5647 * @start_position set to 4, it finds the second occurrence of "iss" because
5648 * it is able to look behind the starting point to discover that it is
5649 * preceded by a letter.
5651 * Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
5652 * to these functions must be encoded in UTF-8. The lengths and the positions
5653 * inside the strings are in bytes and not in characters, so, for instance,
5654 * "\xc3\xa0" (i.e. "à") is two bytes long but it is treated as a
5655 * single character. If you set #G_REGEX_RAW the strings can be non-valid
5656 * UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
5657 * bytes and two characters long.
5659 * When matching a pattern, "\n" matches only against a "\n" character in
5660 * the string, and "\r" matches only a "\r" character. To match any newline
5661 * sequence use "\R". This particular group matches either the two-character
5662 * sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
5663 * U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
5664 * CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
5665 * separator, U+2028), or PS (paragraph separator, U+2029).
5667 * The behaviour of the dot, circumflex, and dollar metacharacters are
5668 * affected by newline characters, the default is to recognize any newline
5669 * character (the same characters recognized by "\R"). This can be changed
5670 * with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
5671 * compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
5672 * #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
5673 * #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
5674 * relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
5675 * unescaped "#" outside a character class is encountered. This indicates
5676 * a comment that lasts until after the next newline.
5678 * When setting the %G_REGEX_JAVASCRIPT_COMPAT flag, pattern syntax and pattern
5679 * matching is changed to be compatible with the way that regular expressions
5680 * work in JavaScript. More precisely, a lonely ']' character in the pattern
5681 * is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
5682 * you must use the '\u' escape sequence with 4 hex digits to specify a unicode
5683 * codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
5684 * the specified number of hex digits, they match 'x' and 'u' literally; also
5685 * '\U' always matches 'U' instead of being an error in the pattern. Finally,
5686 * pattern matching is modified so that back references to an unset subpattern
5687 * group produces a match with the empty string instead of an error. See
5688 * <ulink>man:pcreapi(3)</ulink> for more information.
5690 * Creating and manipulating the same #GRegex structure from different
5691 * threads is not a problem as #GRegex does not modify its internal
5692 * state between creation and destruction, on the other hand #GMatchInfo
5693 * is not threadsafe.
5695 * The regular expressions low-level functionalities are obtained through
5696 * the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
5697 * written by Philip Hazel.
5703 * @title: UNIX-specific utilities and integration
5704 * @short_description: pipes, signal handling
5705 * @include: glib-unix.h
5707 * Most of GLib is intended to be portable; in contrast, this set of
5708 * functions is designed for programs which explicitly target UNIX,
5709 * or are using it to build higher level abstractions which would be
5710 * conditionally compiled if the platform matches G_OS_UNIX.
5712 * To use these functions, you must explicitly include the
5713 * "glib-unix.h" header.
5719 * @title: URI Functions
5720 * @short_description: manipulating URIs
5722 * Functions for manipulating Universal Resource Identifiers (URIs) as
5723 * defined by <ulink url="http://www.ietf.org/rfc/rfc3986.txt">
5724 * RFC 3986</ulink>. It is highly recommended that you have read and
5725 * understand RFC 3986 for understanding this API.
5732 * @short_description: strongly typed value datatype
5733 * @see_also: GVariantType
5735 * #GVariant is a variant datatype; it stores a value along with
5736 * information about the type of that value. The range of possible
5737 * values is determined by the type. The type system used by #GVariant
5740 * #GVariant instances always have a type and a value (which are given
5741 * at construction time). The type and value of a #GVariant instance
5742 * can never change other than by the #GVariant itself being
5743 * destroyed. A #GVariant cannot contain a pointer.
5745 * #GVariant is reference counted using g_variant_ref() and
5746 * g_variant_unref(). #GVariant also has floating reference counts --
5747 * see g_variant_ref_sink().
5749 * #GVariant is completely threadsafe. A #GVariant instance can be
5750 * concurrently accessed in any way from any number of threads without
5753 * #GVariant is heavily optimised for dealing with data in serialised
5754 * form. It works particularly well with data located in memory-mapped
5755 * files. It can perform nearly all deserialisation operations in a
5756 * small constant time, usually touching only a single memory page.
5757 * Serialised #GVariant data can also be sent over the network.
5759 * #GVariant is largely compatible with D-Bus. Almost all types of
5760 * #GVariant instances can be sent over D-Bus. See #GVariantType for
5761 * exceptions. (However, #GVariant's serialisation format is not the same
5762 * as the serialisation format of a D-Bus message body: use #GDBusMessage,
5763 * in the gio library, for those.)
5765 * For space-efficiency, the #GVariant serialisation format does not
5766 * automatically include the variant's type or endianness, which must
5767 * either be implied from context (such as knowledge that a particular
5768 * file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
5769 * or supplied out-of-band (for instance, a type and/or endianness
5770 * indicator could be placed at the beginning of a file, network message
5771 * or network stream).
5773 * A #GVariant's size is limited mainly by any lower level operating
5774 * system constraints, such as the number of bits in #gsize. For
5775 * example, it is reasonable to have a 2GB file mapped into memory
5776 * with #GMappedFile, and call g_variant_new_from_data() on it.
5778 * For convenience to C programmers, #GVariant features powerful
5779 * varargs-based value construction and destruction. This feature is
5780 * designed to be embedded in other libraries.
5782 * There is a Python-inspired text language for describing #GVariant
5783 * values. #GVariant includes a printer for this language and a parser
5784 * with type inferencing.
5787 * <title>Memory Use</title>
5789 * #GVariant tries to be quite efficient with respect to memory use.
5790 * This section gives a rough idea of how much memory is used by the
5791 * current implementation. The information here is subject to change
5795 * The memory allocated by #GVariant can be grouped into 4 broad
5796 * purposes: memory for serialised data, memory for the type
5797 * information cache, buffer management memory and memory for the
5798 * #GVariant structure itself.
5800 * <refsect3 id="gvariant-serialised-data-memory">
5801 * <title>Serialised Data Memory</title>
5803 * This is the memory that is used for storing GVariant data in
5804 * serialised form. This is what would be sent over the network or
5805 * what would end up on disk.
5808 * The amount of memory required to store a boolean is 1 byte. 16,
5809 * 32 and 64 bit integers and double precision floating point numbers
5810 * use their "natural" size. Strings (including object path and
5811 * signature strings) are stored with a nul terminator, and as such
5812 * use the length of the string plus 1 byte.
5815 * Maybe types use no space at all to represent the null value and
5816 * use the same amount of space (sometimes plus one byte) as the
5817 * equivalent non-maybe-typed value to represent the non-null case.
5820 * Arrays use the amount of space required to store each of their
5821 * members, concatenated. Additionally, if the items stored in an
5822 * array are not of a fixed-size (ie: strings, other arrays, etc)
5823 * then an additional framing offset is stored for each item. The
5824 * size of this offset is either 1, 2 or 4 bytes depending on the
5825 * overall size of the container. Additionally, extra padding bytes
5826 * are added as required for alignment of child values.
5829 * Tuples (including dictionary entries) use the amount of space
5830 * required to store each of their members, concatenated, plus one
5831 * framing offset (as per arrays) for each non-fixed-sized item in
5832 * the tuple, except for the last one. Additionally, extra padding
5833 * bytes are added as required for alignment of child values.
5836 * Variants use the same amount of space as the item inside of the
5837 * variant, plus 1 byte, plus the length of the type string for the
5838 * item inside the variant.
5841 * As an example, consider a dictionary mapping strings to variants.
5842 * In the case that the dictionary is empty, 0 bytes are required for
5843 * the serialisation.
5846 * If we add an item "width" that maps to the int32 value of 500 then
5847 * we will use 4 byte to store the int32 (so 6 for the variant
5848 * containing it) and 6 bytes for the string. The variant must be
5849 * aligned to 8 after the 6 bytes of the string, so that's 2 extra
5850 * bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
5851 * for the dictionary entry. An additional 1 byte is added to the
5852 * array as a framing offset making a total of 15 bytes.
5855 * If we add another entry, "title" that maps to a nullable string
5856 * that happens to have a value of null, then we use 0 bytes for the
5857 * null value (and 3 bytes for the variant to contain it along with
5858 * its type string) plus 6 bytes for the string. Again, we need 2
5859 * padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
5862 * We now require extra padding between the two items in the array.
5863 * After the 14 bytes of the first item, that's 2 bytes required. We
5864 * now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
5865 * + 2 = 29 bytes to encode the entire two-item dictionary.
5869 * <title>Type Information Cache</title>
5871 * For each GVariant type that currently exists in the program a type
5872 * information structure is kept in the type information cache. The
5873 * type information structure is required for rapid deserialisation.
5876 * Continuing with the above example, if a #GVariant exists with the
5877 * type "a{sv}" then a type information struct will exist for
5878 * "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
5879 * will share the same type information. Additionally, all
5880 * single-digit types are stored in read-only static memory and do
5881 * not contribute to the writable memory footprint of a program using
5885 * Aside from the type information structures stored in read-only
5886 * memory, there are two forms of type information. One is used for
5887 * container types where there is a single element type: arrays and
5888 * maybe types. The other is used for container types where there
5889 * are multiple element types: tuples and dictionary entries.
5892 * Array type info structures are 6 * sizeof (void *), plus the
5893 * memory required to store the type string itself. This means that
5894 * on 32bit systems, the cache entry for "a{sv}" would require 30
5895 * bytes of memory (plus malloc overhead).
5898 * Tuple type info structures are 6 * sizeof (void *), plus 4 *
5899 * sizeof (void *) for each item in the tuple, plus the memory
5900 * required to store the type string itself. A 2-item tuple, for
5901 * example, would have a type information structure that consumed
5902 * writable memory in the size of 14 * sizeof (void *) (plus type
5903 * string) This means that on 32bit systems, the cache entry for
5904 * "{sv}" would require 61 bytes of memory (plus malloc overhead).
5907 * This means that in total, for our "a{sv}" example, 91 bytes of
5908 * type information would be allocated.
5911 * The type information cache, additionally, uses a #GHashTable to
5912 * store and lookup the cached items and stores a pointer to this
5913 * hash table in static storage. The hash table is freed when there
5914 * are zero items in the type cache.
5917 * Although these sizes may seem large it is important to remember
5918 * that a program will probably only have a very small number of
5919 * different types of values in it and that only one type information
5920 * structure is required for many different values of the same type.
5924 * <title>Buffer Management Memory</title>
5926 * #GVariant uses an internal buffer management structure to deal
5927 * with the various different possible sources of serialised data
5928 * that it uses. The buffer is responsible for ensuring that the
5929 * correct call is made when the data is no longer in use by
5930 * #GVariant. This may involve a g_free() or a g_slice_free() or
5931 * even g_mapped_file_unref().
5934 * One buffer management structure is used for each chunk of
5935 * serialised data. The size of the buffer management structure is 4
5936 * * (void *). On 32bit systems, that's 16 bytes.
5940 * <title>GVariant structure</title>
5942 * The size of a #GVariant structure is 6 * (void *). On 32 bit
5943 * systems, that's 24 bytes.
5946 * #GVariant structures only exist if they are explicitly created
5947 * with API calls. For example, if a #GVariant is constructed out of
5948 * serialised data for the example given above (with the dictionary)
5949 * then although there are 9 individual values that comprise the
5950 * entire dictionary (two keys, two values, two variants containing
5951 * the values, two dictionary entries, plus the dictionary itself),
5952 * only 1 #GVariant instance exists -- the one referring to the
5956 * If calls are made to start accessing the other values then
5957 * #GVariant instances will exist for those values only for as long
5958 * as they are in use (ie: until you call g_variant_unref()). The
5959 * type information is shared. The serialised data and the buffer
5960 * management structure for that serialised data is shared by the
5965 * <title>Summary</title>
5967 * To put the entire example together, for our dictionary mapping
5968 * strings to variants (with two entries, as given above), we are
5969 * using 91 bytes of memory for type information, 29 byes of memory
5970 * for the serialised data, 16 bytes for buffer management and 24
5971 * bytes for the #GVariant instance, or a total of 160 bytes, plus
5972 * malloc overhead. If we were to use g_variant_get_child_value() to
5973 * access the two dictionary entries, we would use an additional 48
5974 * bytes. If we were to have other dictionaries of the same type, we
5975 * would use more memory for the serialised data and buffer
5976 * management for those dictionaries, but the type information would
5985 * SECTION:gvarianttype
5986 * @title: GVariantType
5987 * @short_description: introduction to the GVariant type system
5988 * @see_also: #GVariantType, #GVariant
5990 * This section introduces the GVariant type system. It is based, in
5991 * large part, on the D-Bus type system, with two major changes and some minor
5992 * lifting of restrictions. The <ulink
5993 * url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
5994 * specification</ulink>, therefore, provides a significant amount of
5995 * information that is useful when working with GVariant.
5997 * The first major change with respect to the D-Bus type system is the
5998 * introduction of maybe (or "nullable") types. Any type in GVariant can be
5999 * converted to a maybe type, in which case, "nothing" (or "null") becomes a
6000 * valid value. Maybe types have been added by introducing the
6001 * character "<literal>m</literal>" to type strings.
6003 * The second major change is that the GVariant type system supports the
6004 * concept of "indefinite types" -- types that are less specific than
6005 * the normal types found in D-Bus. For example, it is possible to speak
6006 * of "an array of any type" in GVariant, where the D-Bus type system
6007 * would require you to speak of "an array of integers" or "an array of
6008 * strings". Indefinite types have been added by introducing the
6009 * characters "<literal>*</literal>", "<literal>?</literal>" and
6010 * "<literal>r</literal>" to type strings.
6012 * Finally, all arbitrary restrictions relating to the complexity of
6013 * types are lifted along with the restriction that dictionary entries
6014 * may only appear nested inside of arrays.
6016 * Just as in D-Bus, GVariant types are described with strings ("type
6017 * strings"). Subject to the differences mentioned above, these strings
6018 * are of the same form as those found in DBus. Note, however: D-Bus
6019 * always works in terms of messages and therefore individual type
6020 * strings appear nowhere in its interface. Instead, "signatures"
6021 * are a concatenation of the strings of the type of each argument in a
6022 * message. GVariant deals with single values directly so GVariant type
6023 * strings always describe the type of exactly one value. This means
6024 * that a D-Bus signature string is generally not a valid GVariant type
6025 * string -- except in the case that it is the signature of a message
6026 * containing exactly one argument.
6028 * An indefinite type is similar in spirit to what may be called an
6029 * abstract type in other type systems. No value can exist that has an
6030 * indefinite type as its type, but values can exist that have types
6031 * that are subtypes of indefinite types. That is to say,
6032 * g_variant_get_type() will never return an indefinite type, but
6033 * calling g_variant_is_of_type() with an indefinite type may return
6034 * %TRUE. For example, you cannot have a value that represents "an
6035 * array of no particular type", but you can have an "array of integers"
6036 * which certainly matches the type of "an array of no particular type",
6037 * since "array of integers" is a subtype of "array of no particular
6040 * This is similar to how instances of abstract classes may not
6041 * directly exist in other type systems, but instances of their
6042 * non-abstract subtypes may. For example, in GTK, no object that has
6043 * the type of #GtkBin can exist (since #GtkBin is an abstract class),
6044 * but a #GtkWindow can certainly be instantiated, and you would say
6045 * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
6048 * A detailed description of GVariant type strings is given here:
6050 * <refsect2 id='gvariant-typestrings'>
6051 * <title>GVariant Type Strings</title>
6053 * A GVariant type string can be any of the following:
6058 * any basic type string (listed below)
6063 * "<literal>v</literal>", "<literal>r</literal>" or
6064 * "<literal>*</literal>"
6069 * one of the characters '<literal>a</literal>' or
6070 * '<literal>m</literal>', followed by another type string
6075 * the character '<literal>(</literal>', followed by a concatenation
6076 * of zero or more other type strings, followed by the character
6077 * '<literal>)</literal>'
6082 * the character '<literal>{</literal>', followed by a basic type
6083 * string (see below), followed by another type string, followed by
6084 * the character '<literal>}</literal>'
6089 * A basic type string describes a basic type (as per
6090 * g_variant_type_is_basic()) and is always a single
6091 * character in length. The valid basic type strings are
6092 * "<literal>b</literal>", "<literal>y</literal>",
6093 * "<literal>n</literal>", "<literal>q</literal>",
6094 * "<literal>i</literal>", "<literal>u</literal>",
6095 * "<literal>x</literal>", "<literal>t</literal>",
6096 * "<literal>h</literal>", "<literal>d</literal>",
6097 * "<literal>s</literal>", "<literal>o</literal>",
6098 * "<literal>g</literal>" and "<literal>?</literal>".
6101 * The above definition is recursive to arbitrary depth.
6102 * "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
6103 * are both valid type strings, as is
6104 * "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
6107 * The meaning of each of the characters is as follows:
6115 * <emphasis role='strong'>Character</emphasis>
6120 * <emphasis role='strong'>Meaning</emphasis>
6127 * <literal>b</literal>
6132 * the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
6139 * <literal>y</literal>
6144 * the type string of %G_VARIANT_TYPE_BYTE; a byte.
6151 * <literal>n</literal>
6156 * the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
6164 * <literal>q</literal>
6169 * the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
6177 * <literal>i</literal>
6182 * the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
6190 * <literal>u</literal>
6195 * the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
6203 * <literal>x</literal>
6208 * the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
6216 * <literal>t</literal>
6221 * the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
6229 * <literal>h</literal>
6234 * the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
6235 * value that, by convention, is used as an index into an array
6236 * of file descriptors that are sent alongside a D-Bus message.
6243 * <literal>d</literal>
6248 * the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
6249 * floating point value.
6256 * <literal>s</literal>
6261 * the type string of %G_VARIANT_TYPE_STRING; a string.
6268 * <literal>o</literal>
6273 * the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
6274 * the form of a D-Bus object path.
6281 * <literal>g</literal>
6286 * the type string of %G_VARIANT_TYPE_STRING; a string in the
6287 * form of a D-Bus type signature.
6294 * <literal>?</literal>
6299 * the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
6300 * that is a supertype of any of the basic types.
6307 * <literal>v</literal>
6312 * the type string of %G_VARIANT_TYPE_VARIANT; a container type
6313 * that contain any other type of value.
6320 * <literal>a</literal>
6325 * used as a prefix on another type string to mean an array of
6326 * that type; the type string "<literal>ai</literal>", for
6327 * example, is the type of an array of 32 bit signed integers.
6334 * <literal>m</literal>
6339 * used as a prefix on another type string to mean a "maybe", or
6340 * "nullable", version of that type; the type string
6341 * "<literal>ms</literal>", for example, is the type of a value
6342 * that maybe contains a string, or maybe contains nothing.
6349 * <literal>()</literal>
6354 * used to enclose zero or more other concatenated type strings
6355 * to create a tuple type; the type string
6356 * "<literal>(is)</literal>", for example, is the type of a pair
6357 * of an integer and a string.
6364 * <literal>r</literal>
6369 * the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
6370 * that is a supertype of any tuple type, regardless of the
6378 * <literal>{}</literal>
6383 * used to enclose a basic type string concatenated with another
6384 * type string to create a dictionary entry type, which usually
6385 * appears inside of an array to form a dictionary; the type
6386 * string "<literal>a{sd}</literal>", for example, is the type of
6387 * a dictionary that maps strings to double precision floating
6391 * The first type (the basic type) is the key type and the second
6392 * type is the value type. The reason that the first type is
6393 * restricted to being a basic type is so that it can easily be
6401 * <literal>*</literal>
6406 * the type string of %G_VARIANT_TYPE_ANY; the indefinite type
6407 * that is a supertype of all types. Note that, as with all type
6408 * strings, this character represents exactly one type. It
6409 * cannot be used inside of tuples to mean "any number of items".
6417 * Any type string of a container that contains an indefinite type is,
6418 * itself, an indefinite type. For example, the type string
6419 * "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
6420 * an indefinite type that is a supertype of every array type.
6421 * "<literal>(*s)</literal>" is a supertype of all tuples that
6422 * contain exactly two items where the second item is a string.
6425 * "<literal>a{?*}</literal>" is an indefinite type that is a
6426 * supertype of all arrays containing dictionary entries where the key
6427 * is any basic type and the value is any type at all. This is, by
6428 * definition, a dictionary, so this type string corresponds to
6429 * %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
6430 * the key of a dictionary entry must be a basic type,
6431 * "<literal>{**}</literal>" is not a valid type string.
6438 * SECTION:hash_tables
6439 * @title: Hash Tables
6440 * @short_description: associations between keys and values so that given a key the value can be found quickly
6442 * A #GHashTable provides associations between keys and values which is
6443 * optimized so that given a key, the associated value can be found
6446 * Note that neither keys nor values are copied when inserted into the
6447 * #GHashTable, so they must exist for the lifetime of the #GHashTable.
6448 * This means that the use of static strings is OK, but temporary
6449 * strings (i.e. those created in buffers and those returned by GTK+
6450 * widgets) should be copied with g_strdup() before being inserted.
6452 * If keys or values are dynamically allocated, you must be careful to
6453 * ensure that they are freed when they are removed from the
6454 * #GHashTable, and also when they are overwritten by new insertions
6455 * into the #GHashTable. It is also not advisable to mix static strings
6456 * and dynamically-allocated strings in a #GHashTable, because it then
6457 * becomes difficult to determine whether the string should be freed.
6459 * To create a #GHashTable, use g_hash_table_new().
6461 * To insert a key and value into a #GHashTable, use
6462 * g_hash_table_insert().
6464 * To lookup a value corresponding to a given key, use
6465 * g_hash_table_lookup() and g_hash_table_lookup_extended().
6467 * g_hash_table_lookup_extended() can also be used to simply
6468 * check if a key is present in the hash table.
6470 * To remove a key and value, use g_hash_table_remove().
6472 * To call a function for each key and value pair use
6473 * g_hash_table_foreach() or use a iterator to iterate over the
6474 * key/value pairs in the hash table, see #GHashTableIter.
6476 * To destroy a #GHashTable use g_hash_table_destroy().
6478 * A common use-case for hash tables is to store information about a
6479 * set of keys, without associating any particular value with each
6480 * key. GHashTable optimizes one way of doing so: If you store only
6481 * key-value pairs where key == value, then GHashTable does not
6482 * allocate memory to store the values, which can be a considerable
6483 * space saving, if your set is large. The functions
6484 * g_hash_table_add() and g_hash_table_contains() are designed to be
6485 * used when using #GHashTable this way.
6491 * @title: Secure HMAC Digests
6492 * @short_description: computes the HMAC for data
6494 * HMACs should be used when producing a cookie or hash based on data
6495 * and a key. Simple mechanisms for using SHA1 and other algorithms to
6496 * digest a key and data together are vulnerable to various security
6497 * issues. <ulink url="http://en.wikipedia.org/wiki/HMAC">HMAC</ulink>
6498 * uses algorithms like SHA1 in a secure way to produce a digest of a
6501 * Both the key and data are arbitrary byte arrays of bytes or characters.
6503 * Support for HMAC Digests has been added in GLib 2.30.
6509 * @title: Hook Functions
6510 * @short_description: support for manipulating lists of hook functions
6512 * The #GHookList, #GHook and their related functions provide support for
6513 * lists of hook functions. Functions can be added and removed from the lists,
6514 * and the list of hook functions can be invoked.
6520 * @title: Internationalization
6521 * @short_description: gettext support macros
6522 * @see_also: the gettext manual
6524 * GLib doesn't force any particular localization method upon its users.
6525 * But since GLib itself is localized using the gettext() mechanism, it seems
6526 * natural to offer the de-facto standard gettext() support macros in an
6529 * In order to use these macros in an application, you must include
6530 * <filename>glib/gi18n.h</filename>. For use in a library, you must include
6531 * <filename>glib/gi18n-lib.h</filename> <emphasis>after</emphasis> defining
6532 * the GETTEXT_PACKAGE macro suitably for your library:
6534 * #define GETTEXT_PACKAGE "gtk20"
6535 * #include <glib/gi18n-lib.h>
6537 * For an application, note that you also have to call bindtextdomain(),
6538 * bind_textdomain_codeset(), textdomain() and setlocale() early on in your
6539 * main() to make gettext() work.
6541 * For a library, you only have to call bindtextdomain() and
6542 * bind_textdomain_codeset() in your initialization function. If your library
6543 * doesn't have an initialization function, you can call the functions before
6544 * the first translated message.
6546 * The gettext manual covers details of how to set up message extraction
6552 * SECTION:iochannels
6553 * @title: IO Channels
6554 * @short_description: portable support for using files, pipes and sockets
6555 * @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>
6557 * The #GIOChannel data type aims to provide a portable method for
6558 * using file descriptors, pipes, and sockets, and integrating them
6559 * into the <link linkend="glib-The-Main-Event-Loop">main event
6560 * loop</link>. Currently full support is available on UNIX platforms,
6561 * support for Windows is only partially complete.
6563 * To create a new #GIOChannel on UNIX systems use
6564 * g_io_channel_unix_new(). This works for plain file descriptors,
6565 * pipes and sockets. Alternatively, a channel can be created for a
6566 * file in a system independent manner using g_io_channel_new_file().
6568 * Once a #GIOChannel has been created, it can be used in a generic
6569 * manner with the functions g_io_channel_read_chars(),
6570 * g_io_channel_write_chars(), g_io_channel_seek_position(), and
6571 * g_io_channel_shutdown().
6573 * To add a #GIOChannel to the <link
6574 * linkend="glib-The-Main-Event-Loop">main event loop</link> use
6575 * g_io_add_watch() or g_io_add_watch_full(). Here you specify which
6576 * events you are interested in on the #GIOChannel, and provide a
6577 * function to be called whenever these events occur.
6579 * #GIOChannel instances are created with an initial reference count of
6580 * 1. g_io_channel_ref() and g_io_channel_unref() can be used to
6581 * increment or decrement the reference count respectively. When the
6582 * reference count falls to 0, the #GIOChannel is freed. (Though it
6583 * isn't closed automatically, unless it was created using
6584 * g_io_channel_new_file().) Using g_io_add_watch() or
6585 * g_io_add_watch_full() increments a channel's reference count.
6587 * The new functions g_io_channel_read_chars(),
6588 * g_io_channel_read_line(), g_io_channel_read_line_string(),
6589 * g_io_channel_read_to_end(), g_io_channel_write_chars(),
6590 * g_io_channel_seek_position(), and g_io_channel_flush() should not be
6591 * mixed with the deprecated functions g_io_channel_read(),
6592 * g_io_channel_write(), and g_io_channel_seek() on the same channel.
6598 * @title: Key-value file parser
6599 * @short_description: parses .ini-like config files
6601 * #GKeyFile lets you parse, edit or create files containing groups of
6602 * key-value pairs, which we call <firstterm>key files</firstterm> for
6603 * lack of a better name. Several freedesktop.org specifications use
6604 * key files now, e.g the
6605 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6606 * Entry Specification</ulink> and the
6607 * <ulink url="http://freedesktop.org/Standards/icon-theme-spec">Icon
6608 * Theme Specification</ulink>.
6610 * The syntax of key files is described in detail in the
6611 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6612 * Entry Specification</ulink>, here is a quick summary: Key files
6613 * consists of groups of key-value pairs, interspersed with comments.
6616 * # this is just an example
6617 * # there can be comments before the first group
6621 * Name=Key File Example\tthis value shows\nescaping
6623 * # localized strings are stored in multiple key-value pairs
6626 * Welcome[fr_FR]=Bonjour
6628 * Welcome[be@latin]=Hello
6632 * Numbers=2;20;-200;0
6634 * Booleans=true;false;true;true
6637 * Lines beginning with a '#' and blank lines are considered comments.
6639 * Groups are started by a header line containing the group name enclosed
6640 * in '[' and ']', and ended implicitly by the start of the next group or
6641 * the end of the file. Each key-value pair must be contained in a group.
6643 * Key-value pairs generally have the form <literal>key=value</literal>,
6644 * with the exception of localized strings, which have the form
6645 * <literal>key[locale]=value</literal>, with a locale identifier of the
6646 * form <literal>lang_COUNTRY@MODIFIER</literal> where
6647 * <literal>COUNTRY</literal> and <literal>MODIFIER</literal> are optional.
6648 * Space before and after the '=' character are ignored. Newline, tab,
6649 * carriage return and backslash characters in value are escaped as \n,
6650 * \t, \r, and \\, respectively. To preserve leading spaces in values,
6651 * these can also be escaped as \s.
6653 * Key files can store strings (possibly with localized variants), integers,
6654 * booleans and lists of these. Lists are separated by a separator character,
6655 * typically ';' or ','. To use the list separator character in a value in
6656 * a list, it has to be escaped by prefixing it with a backslash.
6658 * This syntax is obviously inspired by the .ini files commonly met
6659 * on Windows, but there are some important differences:
6661 * <listitem>.ini files use the ';' character to begin comments,
6662 * key files use the '#' character.</listitem>
6663 * <listitem>Key files do not allow for ungrouped keys meaning only
6664 * comments can precede the first group.</listitem>
6665 * <listitem>Key files are always encoded in UTF-8.</listitem>
6666 * <listitem>Key and Group names are case-sensitive. For example, a
6667 * group called <literal>[GROUP]</literal> is a different from
6668 * <literal>[group]</literal>.</listitem>
6669 * <listitem>.ini files don't have a strongly typed boolean entry type,
6670 * they only have GetProfileInt(). In key files, only
6671 * <literal>true</literal> and <literal>false</literal> (in lower case)
6672 * are allowed.</listitem>
6675 * Note that in contrast to the
6676 * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6677 * Entry Specification</ulink>, groups in key files may contain the same
6678 * key multiple times; the last entry wins. Key files may also contain
6679 * multiple groups with the same name; they are merged together.
6680 * Another difference is that keys and group names in key files are not
6681 * restricted to ASCII characters.
6686 * SECTION:linked_lists_double
6687 * @title: Doubly-Linked Lists
6688 * @short_description: linked lists that can be iterated over in both directions
6690 * The #GList structure and its associated functions provide a standard
6691 * doubly-linked list data structure.
6693 * Each element in the list contains a piece of data, together with
6694 * pointers which link to the previous and next elements in the list.
6695 * Using these pointers it is possible to move through the list in both
6696 * directions (unlike the <link
6697 * linkend="glib-Singly-Linked-Lists">Singly-Linked Lists</link> which
6698 * only allows movement through the list in the forward direction).
6700 * The data contained in each element can be either integer values, by
6701 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6702 * Conversion Macros</link>, or simply pointers to any type of data.
6704 * List elements are allocated from the <link
6705 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6706 * efficient than allocating elements individually.
6708 * Note that most of the #GList functions expect to be passed a pointer
6709 * to the first element in the list. The functions which insert
6710 * elements return the new start of the list, which may have changed.
6712 * There is no function to create a #GList. %NULL is considered to be
6713 * the empty list so you simply set a #GList* to %NULL.
6715 * To add elements, use g_list_append(), g_list_prepend(),
6716 * g_list_insert() and g_list_insert_sorted().
6718 * To remove elements, use g_list_remove().
6720 * To find elements in the list use g_list_first(), g_list_last(),
6721 * g_list_next(), g_list_previous(), g_list_nth(), g_list_nth_data(),
6722 * g_list_find() and g_list_find_custom().
6724 * To find the index of an element use g_list_position() and
6727 * To call a function for each element in the list use g_list_foreach().
6729 * To free the entire list, use g_list_free().
6734 * SECTION:linked_lists_single
6735 * @title: Singly-Linked Lists
6736 * @short_description: linked lists that can be iterated in one direction
6738 * The #GSList structure and its associated functions provide a
6739 * standard singly-linked list data structure.
6741 * Each element in the list contains a piece of data, together with a
6742 * pointer which links to the next element in the list. Using this
6743 * pointer it is possible to move through the list in one direction
6744 * only (unlike the <link
6745 * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
6746 * allow movement in both directions).
6748 * The data contained in each element can be either integer values, by
6749 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6750 * Conversion Macros</link>, or simply pointers to any type of data.
6752 * List elements are allocated from the <link
6753 * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6754 * efficient than allocating elements individually.
6756 * Note that most of the #GSList functions expect to be passed a
6757 * pointer to the first element in the list. The functions which insert
6758 * elements return the new start of the list, which may have changed.
6760 * There is no function to create a #GSList. %NULL is considered to be
6761 * the empty list so you simply set a #GSList* to %NULL.
6763 * To add elements, use g_slist_append(), g_slist_prepend(),
6764 * g_slist_insert() and g_slist_insert_sorted().
6766 * To remove elements, use g_slist_remove().
6768 * To find elements in the list use g_slist_last(), g_slist_next(),
6769 * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
6770 * g_slist_find_custom().
6772 * To find the index of an element use g_slist_position() and
6775 * To call a function for each element in the list use
6776 * g_slist_foreach().
6778 * To free the entire list, use g_slist_free().
6784 * @title: Standard Macros
6785 * @short_description: commonly-used macros
6787 * These macros provide a few commonly-used features.
6792 * SECTION:macros_misc
6793 * @title: Miscellaneous Macros
6794 * @short_description: specialized macros which are not used often
6796 * These macros provide more specialized features which are not
6797 * needed so often by application programmers.
6803 * @title: The Main Event Loop
6804 * @short_description: manages all available sources of events
6806 * The main event loop manages all the available sources of events for
6807 * GLib and GTK+ applications. These events can come from any number of
6808 * different types of sources such as file descriptors (plain files,
6809 * pipes or sockets) and timeouts. New types of event sources can also
6810 * be added using g_source_attach().
6812 * To allow multiple independent sets of sources to be handled in
6813 * different threads, each source is associated with a #GMainContext.
6814 * A GMainContext can only be running in a single thread, but
6815 * sources can be added to it and removed from it from other threads.
6817 * Each event source is assigned a priority. The default priority,
6818 * #G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
6819 * Values greater than 0 denote lower priorities. Events from high priority
6820 * sources are always processed before events from lower priority sources.
6822 * Idle functions can also be added, and assigned a priority. These will
6823 * be run whenever no events with a higher priority are ready to be processed.
6825 * The #GMainLoop data type represents a main event loop. A GMainLoop is
6826 * created with g_main_loop_new(). After adding the initial event sources,
6827 * g_main_loop_run() is called. This continuously checks for new events from
6828 * each of the event sources and dispatches them. Finally, the processing of
6829 * an event from one of the sources leads to a call to g_main_loop_quit() to
6830 * exit the main loop, and g_main_loop_run() returns.
6832 * It is possible to create new instances of #GMainLoop recursively.
6833 * This is often used in GTK+ applications when showing modal dialog
6834 * boxes. Note that event sources are associated with a particular
6835 * #GMainContext, and will be checked and dispatched for all main
6836 * loops associated with that GMainContext.
6838 * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
6839 * gtk_main_quit() and gtk_events_pending().
6841 * <refsect2><title>Creating new source types</title>
6842 * <para>One of the unusual features of the #GMainLoop functionality
6843 * is that new types of event source can be created and used in
6844 * addition to the builtin type of event source. A new event source
6845 * type is used for handling GDK events. A new source type is created
6846 * by <firstterm>deriving</firstterm> from the #GSource structure.
6847 * The derived type of source is represented by a structure that has
6848 * the #GSource structure as a first element, and other elements specific
6849 * to the new source type. To create an instance of the new source type,
6850 * call g_source_new() passing in the size of the derived structure and
6851 * a table of functions. These #GSourceFuncs determine the behavior of
6852 * the new source type.</para>
6853 * <para>New source types basically interact with the main context
6854 * in two ways. Their prepare function in #GSourceFuncs can set a timeout
6855 * to determine the maximum amount of time that the main loop will sleep
6856 * before checking the source again. In addition, or as well, the source
6857 * can add file descriptors to the set that the main context checks using
6858 * g_source_add_poll().</para>
6860 * <refsect2><title>Customizing the main loop iteration</title>
6861 * <para>Single iterations of a #GMainContext can be run with
6862 * g_main_context_iteration(). In some cases, more detailed control
6863 * of exactly how the details of the main loop work is desired, for
6864 * instance, when integrating the #GMainLoop with an external main loop.
6865 * In such cases, you can call the component functions of
6866 * g_main_context_iteration() directly. These functions are
6867 * g_main_context_prepare(), g_main_context_query(),
6868 * g_main_context_check() and g_main_context_dispatch().</para>
6869 * <para>The operation of these functions can best be seen in terms
6870 * of a state diagram, as shown in <xref linkend="mainloop-states"/>.</para>
6871 * <figure id="mainloop-states"><title>States of a Main Context</title>
6872 * <graphic fileref="mainloop-states.gif" format="GIF"></graphic>
6876 * On Unix, the GLib mainloop is incompatible with fork(). Any program
6877 * using the mainloop must either exec() or exit() from the child
6878 * without returning to the mainloop.
6884 * @Title: Simple XML Subset Parser
6885 * @Short_description: parses a subset of XML
6886 * @See_also: <ulink url="http://www.w3.org/TR/REC-xml/">XML Specification</ulink>
6888 * The "GMarkup" parser is intended to parse a simple markup format
6889 * that's a subset of XML. This is a small, efficient, easy-to-use
6890 * parser. It should not be used if you expect to interoperate with
6891 * other applications generating full-scale XML. However, it's very
6892 * useful for application data files, config files, etc. where you
6893 * know your application will be the only one writing the file.
6894 * Full-scale XML parsers should be able to parse the subset used by
6895 * GMarkup, so you can easily migrate to full-scale XML at a later
6896 * time if the need arises.
6898 * GMarkup is not guaranteed to signal an error on all invalid XML;
6899 * the parser may accept documents that an XML parser would not.
6900 * However, XML documents which are not well-formed<footnote
6901 * id="wellformed">Being wellformed is a weaker condition than being
6902 * valid. See the <ulink url="http://www.w3.org/TR/REC-xml/">XML
6903 * specification</ulink> for definitions of these terms.</footnote>
6904 * are not considered valid GMarkup documents.
6906 * Simplifications to XML include:
6908 * <listitem>Only UTF-8 encoding is allowed</listitem>
6909 * <listitem>No user-defined entities</listitem>
6910 * <listitem>Processing instructions, comments and the doctype declaration
6911 * are "passed through" but are not interpreted in any way</listitem>
6912 * <listitem>No DTD or validation.</listitem>
6915 * The markup format does support:
6917 * <listitem>Elements</listitem>
6918 * <listitem>Attributes</listitem>
6919 * <listitem>5 standard entities:
6920 * <literal>&amp; &lt; &gt; &quot; &apos;</literal>
6922 * <listitem>Character references</listitem>
6923 * <listitem>Sections marked as CDATA</listitem>
6930 * @Short_Description: general memory-handling
6931 * @Title: Memory Allocation
6933 * These functions provide support for allocating and freeing memory.
6936 * If any call to allocate memory fails, the application is terminated.
6937 * This also means that there is no need to check if the call succeeded.
6941 * It's important to match g_malloc() with g_free(), plain malloc() with free(),
6942 * and (if you're using C++) new with delete and new[] with delete[]. Otherwise
6943 * bad things can happen, since these allocators may use different memory
6944 * pools (and new/delete call constructors and destructors). See also
6945 * g_mem_set_vtable().
6951 * SECTION:memory_slices
6952 * @title: Memory Slices
6953 * @short_description: efficient way to allocate groups of equal-sized chunks of memory
6955 * Memory slices provide a space-efficient and multi-processing scalable
6956 * way to allocate equal-sized pieces of memory, just like the original
6957 * #GMemChunks (from GLib 2.8), while avoiding their excessive
6958 * memory-waste, scalability and performance problems.
6960 * To achieve these goals, the slice allocator uses a sophisticated,
6961 * layered design that has been inspired by Bonwick's slab allocator
6963 * <ulink url="http://citeseer.ist.psu.edu/bonwick94slab.html">[Bonwick94]</ulink> Jeff Bonwick, The slab allocator: An object-caching kernel
6964 * memory allocator. USENIX 1994, and
6965 * <ulink url="http://citeseer.ist.psu.edu/bonwick01magazines.html">[Bonwick01]</ulink> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
6966 * slab allocator to many cpu's and arbitrary resources. USENIX 2001
6967 * </para></footnote>.
6968 * It uses posix_memalign() to optimize allocations of many equally-sized
6969 * chunks, and has per-thread free lists (the so-called magazine layer)
6970 * to quickly satisfy allocation requests of already known structure sizes.
6971 * This is accompanied by extra caching logic to keep freed memory around
6972 * for some time before returning it to the system. Memory that is unused
6973 * due to alignment constraints is used for cache colorization (random
6974 * distribution of chunk addresses) to improve CPU cache utilization. The
6975 * caching layer of the slice allocator adapts itself to high lock contention
6976 * to improve scalability.
6978 * The slice allocator can allocate blocks as small as two pointers, and
6979 * unlike malloc(), it does not reserve extra space per block. For large block
6980 * sizes, g_slice_new() and g_slice_alloc() will automatically delegate to the
6981 * system malloc() implementation. For newly written code it is recommended
6982 * to use the new <literal>g_slice</literal> API instead of g_malloc() and
6983 * friends, as long as objects are not resized during their lifetime and the
6984 * object size used at allocation time is still available when freeing.
6987 * <title>Using the slice allocator</title>
6989 * gchar *mem[10000];
6992 * /* Allocate 10000 blocks. */
6993 * for (i = 0; i < 10000; i++)
6995 * mem[i] = g_slice_alloc (50);
6997 * /* Fill in the memory with some junk. */
6998 * for (j = 0; j < 50; j++)
6999 * mem[i][j] = i * j;
7002 * /* Now free all of the blocks. */
7003 * for (i = 0; i < 10000; i++)
7005 * g_slice_free1 (50, mem[i]);
7007 * </programlisting></example>
7010 * <title>Using the slice allocator with data structures</title>
7012 * GRealArray *array;
7014 * /* Allocate one block, using the g_slice_new() macro. */
7015 * array = g_slice_new (GRealArray);
7017 * /* We can now use array just like a normal pointer to a structure. */
7018 * array->data = NULL;
7021 * array->zero_terminated = (zero_terminated ? 1 : 0);
7022 * array->clear = (clear ? 1 : 0);
7023 * array->elt_size = elt_size;
7025 * /* We can free the block, so it can be reused. */
7026 * g_slice_free (GRealArray, array);
7027 * </programlisting></example>
7033 * @title: Message Logging
7034 * @short_description: versatile support for logging messages with different levels of importance
7036 * These functions provide support for logging error messages
7037 * or messages used for debugging.
7039 * There are several built-in levels of messages, defined in
7040 * #GLogLevelFlags. These can be extended with user-defined levels.
7045 * SECTION:misc_utils
7046 * @title: Miscellaneous Utility Functions
7047 * @short_description: a selection of portable utility functions
7049 * These are portable utility functions.
7055 * @title: Numerical Definitions
7056 * @short_description: mathematical constants, and floating point decomposition
7058 * GLib offers mathematical constants such as #G_PI for the value of pi;
7059 * many platforms have these in the C library, but some don't, the GLib
7060 * versions always exist.
7062 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
7063 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
7064 * defined as appropriate for a given platform. IEEE floats and doubles are
7065 * supported (used for storage) by at least Intel, PPC and Sparc. See
7066 * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
7067 * for more information about IEEE number formats.
7073 * @Short_description: parses commandline options
7074 * @Title: Commandline option parser
7076 * The GOption commandline parser is intended to be a simpler replacement
7077 * for the popt library. It supports short and long commandline options,
7078 * as shown in the following example:
7080 * <literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
7082 * The example demonstrates a number of features of the GOption
7083 * commandline parser
7084 * <itemizedlist><listitem><para>
7085 * Options can be single letters, prefixed by a single dash. Multiple
7086 * short options can be grouped behind a single dash.
7087 * </para></listitem><listitem><para>
7088 * Long options are prefixed by two consecutive dashes.
7089 * </para></listitem><listitem><para>
7090 * Options can have an extra argument, which can be a number, a string or
7091 * a filename. For long options, the extra argument can be appended with
7092 * an equals sign after the option name, which is useful if the extra
7093 * argument starts with a dash, which would otherwise cause it to be
7094 * interpreted as another option.
7095 * </para></listitem><listitem><para>
7096 * Non-option arguments are returned to the application as rest arguments.
7097 * </para></listitem><listitem><para>
7098 * An argument consisting solely of two dashes turns off further parsing,
7099 * any remaining arguments (even those starting with a dash) are returned
7100 * to the application as rest arguments.
7101 * </para></listitem></itemizedlist>
7103 * Another important feature of GOption is that it can automatically
7104 * generate nicely formatted help output. Unless it is explicitly turned
7105 * off with g_option_context_set_help_enabled(), GOption will recognize
7106 * the <option>--help</option>, <option>-?</option>,
7107 * <option>--help-all</option> and
7108 * <option>--help-</option><replaceable>groupname</replaceable> options
7109 * (where <replaceable>groupname</replaceable> is the name of a
7110 * #GOptionGroup) and write a text similar to the one shown in the
7111 * following example to stdout.
7113 * <informalexample><screen>
7115 * testtreemodel [OPTION...] - test tree model performance
7118 * -h, --help Show help options
7119 * --help-all Show all help options
7120 * --help-gtk Show GTK+ Options
7122 * Application Options:
7123 * -r, --repeats=N Average over N repetitions
7124 * -m, --max-size=M Test up to 2^M items
7125 * --display=DISPLAY X display to use
7126 * -v, --verbose Be verbose
7127 * -b, --beep Beep when done
7128 * --rand Randomize the data
7129 * </screen></informalexample>
7131 * GOption groups options in #GOptionGroup<!-- -->s, which makes it easy to
7132 * incorporate options from multiple sources. The intended use for this is
7133 * to let applications collect option groups from the libraries it uses,
7134 * add them to their #GOptionContext, and parse all options by a single call
7135 * to g_option_context_parse(). See gtk_get_option_group() for an example.
7137 * If an option is declared to be of type string or filename, GOption takes
7138 * care of converting it to the right encoding; strings are returned in
7139 * UTF-8, filenames are returned in the GLib filename encoding. Note that
7140 * this only works if setlocale() has been called before
7141 * g_option_context_parse().
7143 * Here is a complete example of setting up GOption to parse the example
7144 * commandline above and produce the example help output.
7146 * <informalexample><programlisting>
7147 * static gint repeats = 2;
7148 * static gint max_size = 8;
7149 * static gboolean verbose = FALSE;
7150 * static gboolean beep = FALSE;
7151 * static gboolean rand = FALSE;
7153 * static GOptionEntry entries[] =
7155 * { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" },
7156 * { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" },
7157 * { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
7158 * { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
7159 * { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL },
7164 * main (int argc, char *argv[])
7166 * GError *error = NULL;
7167 * GOptionContext *context;
7169 * context = g_option_context_new ("- test tree model performance");
7170 * g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
7171 * g_option_context_add_group (context, gtk_get_option_group (TRUE));
7172 * if (!g_option_context_parse (context, &argc, &argv, &error))
7174 * g_print ("option parsing failed: %s\n", error->message);
7181 * </programlisting></informalexample>
7187 * @title: Glob-style pattern matching
7188 * @short_description: matches strings against patterns containing '*' (wildcard) and '?' (joker)
7190 * The <function>g_pattern_match*</function> functions match a string
7191 * against a pattern containing '*' and '?' wildcards with similar
7192 * semantics as the standard glob() function: '*' matches an arbitrary,
7193 * possibly empty, string, '?' matches an arbitrary character.
7195 * Note that in contrast to glob(), the '/' character
7196 * <emphasis>can</emphasis> be matched by the wildcards, there are no
7197 * '[...]' character ranges and '*' and '?' can
7198 * <emphasis>not</emphasis> be escaped to include them literally in a
7201 * When multiple strings must be matched against the same pattern, it
7202 * is better to compile the pattern to a #GPatternSpec using
7203 * g_pattern_spec_new() and use g_pattern_match_string() instead of
7204 * g_pattern_match_simple(). This avoids the overhead of repeated
7205 * pattern compilation.
7212 * @short_description: a 2-way association between a string and a unique integer identifier
7214 * Quarks are associations between strings and integer identifiers.
7215 * Given either the string or the #GQuark identifier it is possible to
7216 * retrieve the other.
7218 * Quarks are used for both <link
7219 * linkend="glib-Datasets">Datasets</link> and <link
7220 * linkend="glib-Keyed-Data-Lists">Keyed Data Lists</link>.
7222 * To create a new quark from a string, use g_quark_from_string() or
7223 * g_quark_from_static_string().
7225 * To find the string corresponding to a given #GQuark, use
7226 * g_quark_to_string().
7228 * To find the #GQuark corresponding to a given string, use
7229 * g_quark_try_string().
7231 * Another use for the string pool maintained for the quark functions
7232 * is string interning, using g_intern_string() or
7233 * g_intern_static_string(). An interned string is a canonical
7234 * representation for a string. One important advantage of interned
7235 * strings is that they can be compared for equality by a simple
7236 * pointer comparison, rather than using strcmp().
7242 * @Title: Double-ended Queues
7243 * @Short_description: double-ended queue data structure
7245 * The #GQueue structure and its associated functions provide a standard
7246 * queue data structure. Internally, GQueue uses the same data structure
7247 * as #GList to store elements.
7249 * The data contained in each element can be either integer values, by
7250 * using one of the <link linkend="glib-Type-Conversion-Macros">Type
7251 * Conversion Macros</link>, or simply pointers to any type of data.
7253 * To create a new GQueue, use g_queue_new().
7255 * To initialize a statically-allocated GQueue, use #G_QUEUE_INIT or
7258 * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
7259 * g_queue_push_tail() and g_queue_push_tail_link().
7261 * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
7263 * To free the entire queue, use g_queue_free().
7268 * SECTION:random_numbers
7269 * @title: Random Numbers
7270 * @short_description: pseudo-random number generator
7272 * The following functions allow you to use a portable, fast and good
7273 * pseudo-random number generator (PRNG). It uses the Mersenne Twister
7274 * PRNG, which was originally developed by Makoto Matsumoto and Takuji
7275 * Nishimura. Further information can be found at
7276 * <ulink url="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
7277 * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</ulink>.
7279 * If you just need a random number, you simply call the
7280 * <function>g_random_*</function> functions, which will create a
7281 * globally used #GRand and use the according
7282 * <function>g_rand_*</function> functions internally. Whenever you
7283 * need a stream of reproducible random numbers, you better create a
7284 * #GRand yourself and use the <function>g_rand_*</function> functions
7285 * directly, which will also be slightly faster. Initializing a #GRand
7286 * with a certain seed will produce exactly the same series of random
7287 * numbers on all platforms. This can thus be used as a seed for e.g.
7290 * The <function>g_rand*_range</function> functions will return high
7291 * quality equally distributed random numbers, whereas for example the
7292 * <literal>(g_random_int()%max)</literal> approach often
7293 * doesn't yield equally distributed numbers.
7295 * GLib changed the seeding algorithm for the pseudo-random number
7296 * generator Mersenne Twister, as used by
7297 * <structname>GRand</structname> and <structname>GRandom</structname>.
7298 * This was necessary, because some seeds would yield very bad
7299 * pseudo-random streams. Also the pseudo-random integers generated by
7300 * <function>g_rand*_int_range()</function> will have a slightly better
7301 * equal distribution with the new version of GLib.
7303 * The original seeding and generation algorithms, as found in GLib
7304 * 2.0.x, can be used instead of the new ones by setting the
7305 * environment variable <envar>G_RANDOM_VERSION</envar> to the value of
7306 * '2.0'. Use the GLib-2.0 algorithms only if you have sequences of
7307 * numbers generated with Glib-2.0 that you need to reproduce exactly.
7313 * @title: Lexical Scanner
7314 * @short_description: a general purpose lexical scanner
7316 * The #GScanner and its associated functions provide a
7317 * general purpose lexical scanner.
7324 * @short_description: scalable lists
7326 * The #GSequence data structure has the API of a list, but is
7327 * implemented internally with a balanced binary tree. This means that
7328 * it is possible to maintain a sorted list of n elements in time O(n
7329 * log n). The data contained in each element can be either integer
7330 * values, by using of the <link
7331 * linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
7332 * or simply pointers to any type of data.
7334 * A #GSequence is accessed through <firstterm>iterators</firstterm>,
7335 * represented by a #GSequenceIter. An iterator represents a position
7336 * between two elements of the sequence. For example, the
7337 * <firstterm>begin</firstterm> iterator represents the gap immediately
7338 * before the first element of the sequence, and the
7339 * <firstterm>end</firstterm> iterator represents the gap immediately
7340 * after the last element. In an empty sequence, the begin and end
7341 * iterators are the same.
7343 * Some methods on #GSequence operate on ranges of items. For example
7344 * g_sequence_foreach_range() will call a user-specified function on
7345 * each element with the given range. The range is delimited by the
7346 * gaps represented by the passed-in iterators, so if you pass in the
7347 * begin and end iterators, the range in question is the entire
7350 * The function g_sequence_get() is used with an iterator to access the
7351 * element immediately following the gap that the iterator represents.
7352 * The iterator is said to <firstterm>point</firstterm> to that element.
7354 * Iterators are stable across most operations on a #GSequence. For
7355 * example an iterator pointing to some element of a sequence will
7356 * continue to point to that element even after the sequence is sorted.
7357 * Even moving an element to another sequence using for example
7358 * g_sequence_move_range() will not invalidate the iterators pointing
7359 * to it. The only operation that will invalidate an iterator is when
7360 * the element it points to is removed from any sequence.
7366 * @title: Shell-related Utilities
7367 * @short_description: shell-like commandline handling
7373 * @Short_description: process launching
7374 * @Title: Spawning Processes
7379 * SECTION:string_chunks
7380 * @title: String Chunks
7381 * @short_description: efficient storage of groups of strings
7383 * String chunks are used to store groups of strings. Memory is
7384 * allocated in blocks, and as strings are added to the #GStringChunk
7385 * they are copied into the next free position in a block. When a block
7386 * is full a new block is allocated.
7388 * When storing a large number of strings, string chunks are more
7389 * efficient than using g_strdup() since fewer calls to malloc() are
7390 * needed, and less memory is wasted in memory allocation overheads.
7392 * By adding strings with g_string_chunk_insert_const() it is also
7393 * possible to remove duplicates.
7395 * To create a new #GStringChunk use g_string_chunk_new().
7397 * To add strings to a #GStringChunk use g_string_chunk_insert().
7399 * To add strings to a #GStringChunk, but without duplicating strings
7400 * which are already in the #GStringChunk, use
7401 * g_string_chunk_insert_const().
7403 * To free the entire #GStringChunk use g_string_chunk_free(). It is
7404 * not possible to free individual strings.
7409 * SECTION:string_utils
7410 * @title: String Utility Functions
7411 * @short_description: various string-related functions
7413 * This section describes a number of utility functions for creating,
7414 * duplicating, and manipulating strings.
7416 * Note that the functions g_printf(), g_fprintf(), g_sprintf(),
7417 * g_snprintf(), g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf()
7418 * are declared in the header <filename>gprintf.h</filename> which is
7419 * <emphasis>not</emphasis> included in <filename>glib.h</filename>
7420 * (otherwise using <filename>glib.h</filename> would drag in
7421 * <filename>stdio.h</filename>), so you'll have to explicitly include
7422 * <literal><glib/gprintf.h></literal> in order to use the GLib
7423 * printf() functions.
7425 * <para id="string-precision">While you may use the printf() functions
7426 * to format UTF-8 strings, notice that the precision of a
7427 * <literal>%Ns</literal> parameter is interpreted as the
7428 * number of <emphasis>bytes</emphasis>, not <emphasis>characters</emphasis>
7429 * to print. On top of that, the GNU libc implementation of the printf()
7430 * functions has the "feature" that it checks that the string given for
7431 * the <literal>%Ns</literal> parameter consists of a whole number
7432 * of characters in the current encoding. So, unless you are sure you are
7433 * always going to be in an UTF-8 locale or your know your text is restricted
7434 * to ASCII, avoid using <literal>%Ns</literal>. If your intention is
7435 * to format strings for a certain number of columns, then
7436 * <literal>%Ns</literal> is not a correct solution anyway, since it
7437 * fails to take wide characters (see g_unichar_iswide()) into account.
7445 * @short_description: text buffers which grow automatically as text is added
7447 * A #GString is an object that handles the memory management of a C
7448 * string for you. The emphasis of #GString is on text, typically
7449 * UTF-8. Crucially, the "str" member of a #GString is guaranteed to
7450 * have a trailing nul character, and it is therefore always safe to
7451 * call functions such as strchr() or g_strdup() on it.
7453 * However, a #GString can also hold arbitrary binary data, because it
7454 * has a "len" member, which includes any possible embedded nul
7455 * characters in the data. Conceptually then, #GString is like a
7456 * #GByteArray with the addition of many convenience methods for text,
7457 * and a guaranteed nul terminator.
7464 * @short_description: a test framework
7465 * @see_also: <link linkend="gtester">gtester</link>, <link linkend="gtester-report">gtester-report</link>
7467 * GLib provides a framework for writing and maintaining unit tests
7468 * in parallel to the code they are testing. The API is designed according
7469 * to established concepts found in the other test frameworks (JUnit, NUnit,
7470 * RUnit), which in turn is based on smalltalk unit testing concepts.
7474 * <term>Test case</term>
7475 * <listitem>Tests (test methods) are grouped together with their
7476 * fixture into test cases.</listitem>
7479 * <term>Fixture</term>
7480 * <listitem>A test fixture consists of fixture data and setup and
7481 * teardown methods to establish the environment for the test
7482 * functions. We use fresh fixtures, i.e. fixtures are newly set
7483 * up and torn down around each test invocation to avoid dependencies
7484 * between tests.</listitem>
7487 * <term>Test suite</term>
7488 * <listitem>Test cases can be grouped into test suites, to allow
7489 * subsets of the available tests to be run. Test suites can be
7490 * grouped into other test suites as well.</listitem>
7493 * The API is designed to handle creation and registration of test suites
7494 * and test cases implicitly. A simple call like
7496 * g_test_add_func ("/misc/assertions", test_assertions);
7498 * creates a test suite called "misc" with a single test case named
7499 * "assertions", which consists of running the test_assertions function.
7501 * In addition to the traditional g_assert(), the test framework provides
7502 * an extended set of assertions for string and numerical comparisons:
7503 * g_assert_cmpfloat(), g_assert_cmpint(), g_assert_cmpuint(),
7504 * g_assert_cmphex(), g_assert_cmpstr(). The advantage of these variants
7505 * over plain g_assert() is that the assertion messages can be more
7506 * elaborate, and include the values of the compared entities.
7508 * GLib ships with two utilities called gtester and gtester-report to
7509 * facilitate running tests and producing nicely formatted test reports.
7514 * SECTION:thread_pools
7515 * @title: Thread Pools
7516 * @short_description: pools of threads to execute work concurrently
7517 * @see_also: #GThread
7519 * Sometimes you wish to asynchronously fork out the execution of work
7520 * and continue working in your own thread. If that will happen often,
7521 * the overhead of starting and destroying a thread each time might be
7522 * too high. In such cases reusing already started threads seems like a
7523 * good idea. And it indeed is, but implementing this can be tedious
7526 * Therefore GLib provides thread pools for your convenience. An added
7527 * advantage is, that the threads can be shared between the different
7528 * subsystems of your program, when they are using GLib.
7530 * To create a new thread pool, you use g_thread_pool_new().
7531 * It is destroyed by g_thread_pool_free().
7533 * If you want to execute a certain task within a thread pool,
7534 * you call g_thread_pool_push().
7536 * To get the current number of running threads you call
7537 * g_thread_pool_get_num_threads(). To get the number of still
7538 * unprocessed tasks you call g_thread_pool_unprocessed(). To control
7539 * the maximal number of threads for a thread pool, you use
7540 * g_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().
7542 * Finally you can control the number of unused threads, that are kept
7543 * alive by GLib for future use. The current number can be fetched with
7544 * g_thread_pool_get_num_unused_threads(). The maximal number can be
7545 * controlled by g_thread_pool_get_max_unused_threads() and
7546 * g_thread_pool_set_max_unused_threads(). All currently unused threads
7547 * can be stopped by calling g_thread_pool_stop_unused_threads().
7554 * @short_description: portable support for threads, mutexes, locks, conditions and thread private data
7555 * @see_also: #GThreadPool, #GAsyncQueue
7557 * Threads act almost like processes, but unlike processes all threads
7558 * of one process share the same memory. This is good, as it provides
7559 * easy communication between the involved threads via this shared
7560 * memory, and it is bad, because strange things (so called
7561 * "Heisenbugs") might happen if the program is not carefully designed.
7562 * In particular, due to the concurrent nature of threads, no
7563 * assumptions on the order of execution of code running in different
7564 * threads can be made, unless order is explicitly forced by the
7565 * programmer through synchronization primitives.
7567 * The aim of the thread-related functions in GLib is to provide a
7568 * portable means for writing multi-threaded software. There are
7569 * primitives for mutexes to protect the access to portions of memory
7570 * (#GMutex, #GRecMutex and #GRWLock). There is a facility to use
7571 * individual bits for locks (g_bit_lock()). There are primitives
7572 * for condition variables to allow synchronization of threads (#GCond).
7573 * There are primitives for thread-private data - data that every
7574 * thread has a private instance of (#GPrivate). There are facilities
7575 * for one-time initialization (#GOnce, g_once_init_enter()). Finally,
7576 * there are primitives to create and manage threads (#GThread).
7578 * The GLib threading system used to be initialized with g_thread_init().
7579 * This is no longer necessary. Since version 2.32, the GLib threading
7580 * system is automatically initialized at the start of your program,
7581 * and all thread-creation functions and synchronization primitives
7582 * are available right away.
7584 * Note that it is not safe to assume that your program has no threads
7585 * even if you don't call g_thread_new() yourself. GLib and GIO can
7586 * and will create threads for their own purposes in some cases, such
7587 * as when using g_unix_signal_source_new() or when using GDBus.
7589 * Originally, UNIX did not have threads, and therefore some traditional
7590 * UNIX APIs are problematic in threaded programs. Some notable examples
7594 * C library functions that return data in statically allocated
7595 * buffers, such as strtok() or strerror(). For many of these,
7596 * there are thread-safe variants with a _r suffix, or you can
7597 * look at corresponding GLib APIs (like g_strsplit() or g_strerror()).
7600 * setenv() and unsetenv() manipulate the process environment in
7601 * a not thread-safe way, and may interfere with getenv() calls
7602 * in other threads. Note that getenv() calls may be
7603 * <quote>hidden</quote> behind other APIs. For example, GNU gettext()
7604 * calls getenv() under the covers. In general, it is best to treat
7605 * the environment as readonly. If you absolutely have to modify the
7606 * environment, do it early in main(), when no other threads are around yet.
7609 * setlocale() changes the locale for the entire process, affecting
7610 * all threads. Temporary changes to the locale are often made to
7611 * change the behavior of string scanning or formatting functions
7612 * like scanf() or printf(). GLib offers a number of string APIs
7613 * (like g_ascii_formatd() or g_ascii_strtod()) that can often be
7614 * used as an alternative. Or you can use the uselocale() function
7615 * to change the locale only for the current thread.
7618 * fork() only takes the calling thread into the child's copy of the
7619 * process image. If other threads were executing in critical
7620 * sections they could have left mutexes locked which could easily
7621 * cause deadlocks in the new child. For this reason, you should
7622 * call exit() or exec() as soon as possible in the child and only
7623 * make signal-safe library calls before that.
7626 * daemon() uses fork() in a way contrary to what is described
7627 * above. It should not be used with GLib programs.
7631 * GLib itself is internally completely thread-safe (all global data is
7632 * automatically locked), but individual data structure instances are
7633 * not automatically locked for performance reasons. For example,
7634 * you must coordinate accesses to the same #GHashTable from multiple
7635 * threads. The two notable exceptions from this rule are #GMainLoop
7636 * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
7637 * need no further application-level locking to be accessed from
7638 * multiple threads. Most refcounting functions such as g_object_ref()
7639 * are also thread-safe.
7646 * @short_description: keep track of elapsed time
7648 * #GTimer records a start time, and counts microseconds elapsed since
7649 * that time. This is done somewhat differently on different platforms,
7650 * and can be tricky to get exactly right, so #GTimer provides a
7651 * portable/convenient interface.
7658 * @short_description: a structure representing a time zone
7659 * @see_also: #GDateTime
7661 * #GTimeZone is a structure that represents a time zone, at no
7662 * particular point in time. It is refcounted and immutable.
7664 * A time zone contains a number of intervals. Each interval has
7665 * an abbreviation to describe it, an offet to UTC and a flag indicating
7666 * if the daylight savings time is in effect during that interval. A
7667 * time zone always has at least one interval -- interval 0.
7669 * Every UTC time is contained within exactly one interval, but a given
7670 * local time may be contained within zero, one or two intervals (due to
7671 * incontinuities associated with daylight savings time).
7673 * An interval may refer to a specific period of time (eg: the duration
7674 * of daylight savings time during 2010) or it may refer to many periods
7675 * of time that share the same properties (eg: all periods of daylight
7676 * savings time). It is also possible (usually for political reasons)
7677 * that some properties (like the abbreviation) change between intervals
7678 * without other properties changing.
7680 * #GTimeZone is available since GLib 2.26.
7685 * SECTION:trash_stack
7686 * @title: Trash Stacks
7687 * @short_description: maintain a stack of unused allocated memory chunks
7689 * A #GTrashStack is an efficient way to keep a stack of unused allocated
7690 * memory chunks. Each memory chunk is required to be large enough to hold
7691 * a #gpointer. This allows the stack to be maintained without any space
7692 * overhead, since the stack pointers can be stored inside the memory chunks.
7694 * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
7695 * is a perfectly valid empty stack.
7700 * SECTION:trees-binary
7701 * @title: Balanced Binary Trees
7702 * @short_description: a sorted collection of key/value pairs optimized for searching and traversing in order
7704 * The #GTree structure and its associated functions provide a sorted
7705 * collection of key/value pairs optimized for searching and traversing
7708 * To create a new #GTree use g_tree_new().
7710 * To insert a key/value pair into a #GTree use g_tree_insert().
7712 * To lookup the value corresponding to a given key, use
7713 * g_tree_lookup() and g_tree_lookup_extended().
7715 * To find out the number of nodes in a #GTree, use g_tree_nnodes(). To
7716 * get the height of a #GTree, use g_tree_height().
7718 * To traverse a #GTree, calling a function for each node visited in
7719 * the traversal, use g_tree_foreach().
7721 * To remove a key/value pair use g_tree_remove().
7723 * To destroy a #GTree, use g_tree_destroy().
7728 * SECTION:trees-nary
7729 * @title: N-ary Trees
7730 * @short_description: trees of data with any number of branches
7732 * The #GNode struct and its associated functions provide a N-ary tree
7733 * data structure, where nodes in the tree can contain arbitrary data.
7735 * To create a new tree use g_node_new().
7737 * To insert a node into a tree use g_node_insert(),
7738 * g_node_insert_before(), g_node_append() and g_node_prepend().
7740 * To create a new node and insert it into a tree use
7741 * g_node_insert_data(), g_node_insert_data_after(),
7742 * g_node_insert_data_before(), g_node_append_data()
7743 * and g_node_prepend_data().
7745 * To reverse the children of a node use g_node_reverse_children().
7747 * To find a node use g_node_get_root(), g_node_find(),
7748 * g_node_find_child(), g_node_child_index(), g_node_child_position(),
7749 * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
7750 * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
7751 * or g_node_last_sibling().
7753 * To get information about a node or tree use G_NODE_IS_LEAF(),
7754 * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
7755 * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
7757 * To traverse a tree, calling a function for each node visited in the
7758 * traversal, use g_node_traverse() or g_node_children_foreach().
7760 * To remove a node or subtree from a tree use g_node_unlink() or
7766 * SECTION:type_conversion
7767 * @title: Type Conversion Macros
7768 * @short_description: portably storing integers in pointer variables
7770 * Many times GLib, GTK+, and other libraries allow you to pass "user
7771 * data" to a callback, in the form of a void pointer. From time to time
7772 * you want to pass an integer instead of a pointer. You could allocate
7773 * an integer, with something like:
7775 * int *ip = g_new (int, 1);
7778 * But this is inconvenient, and it's annoying to have to free the
7779 * memory at some later time.
7781 * Pointers are always at least 32 bits in size (on all platforms GLib
7782 * intends to support). Thus you can store at least 32-bit integer values
7783 * in a pointer value. Naively, you might try this, but it's incorrect:
7790 * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
7791 * The problem is that on some systems you need to do this:
7795 * p = (void*) (long) 42;
7796 * i = (int) (long) p;
7798 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
7799 * to do the right thing on the every platform.
7801 * <warning><para>You may not store pointers in integers. This is not
7802 * portable in any way, shape or form. These macros <emphasis>only</emphasis>
7803 * allow storing integers in pointers, and only preserve 32 bits of the
7804 * integer; values outside the range of a 32-bit integer will be mangled.
7811 * @title: Basic Types
7812 * @short_description: standard GLib types, defined for ease-of-use and portability
7814 * GLib defines a number of commonly used types, which can be divided
7816 * - New types which are not part of standard C (but are defined in
7817 * various C standard library header files) - #gboolean, #gsize,
7818 * #gssize, #goffset, #gintptr, #guintptr.
7819 * - Integer types which are guaranteed to be the same size across
7820 * all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
7821 * #guint32, #gint64, #guint64.
7822 * - Types which are easier to use than their standard C counterparts -
7823 * #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
7824 * - Types which correspond exactly to standard C types, but are
7825 * included for completeness - #gchar, #gint, #gshort, #glong,
7826 * #gfloat, #gdouble.
7828 * GLib also defines macros for the limits of some of the standard
7829 * integer and floating point types, as well as macros for suitable
7830 * printf() formats for these types.
7836 * @Title: Unicode Manipulation
7837 * @Short_description: functions operating on Unicode characters and UTF-8 strings
7838 * @See_also: g_locale_to_utf8(), g_locale_from_utf8()
7840 * This section describes a number of functions for dealing with
7841 * Unicode characters and strings. There are analogues of the
7842 * traditional <filename>ctype.h</filename> character classification
7843 * and case conversion functions, UTF-8 analogues of some string utility
7844 * functions, functions to perform normalization, case conversion and
7845 * collation on UTF-8 strings and finally functions to convert between
7846 * the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
7848 * The implementations of the Unicode functions in GLib are based
7849 * on the Unicode Character Data tables, which are available from
7850 * <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
7851 * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
7852 * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
7853 * GLib 2.30 supports Unicode 6.0.
7859 * @Title: Version Information
7860 * @Short_description: variables and functions to check the GLib version
7862 * GLib provides version information, primarily useful in configure
7863 * checks for builds that have a configure script. Applications will
7864 * not typically use the features described here.
7866 * The GLib headers annotate deprecated APIs in a way that produces
7867 * compiler warnings if these deprecated APIs are used. The warnings
7868 * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
7869 * before including the glib.h header.
7871 * GLib also provides support for building applications against
7872 * defined subsets of deprecated or new GLib APIs. Define the macro
7873 * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
7874 * you want to receive warnings about deprecated APIs. Define the
7875 * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
7876 * GLib whose API you want to use.
7882 * @Title: Message Output and Debugging Functions
7883 * @Short_description: functions to output messages and help debug applications
7885 * These functions provide support for outputting messages.
7887 * The <function>g_return</function> family of macros (g_return_if_fail(),
7888 * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached())
7889 * should only be used for programming errors, a typical use case is
7890 * checking for invalid parameters at the beginning of a public function.
7891 * They should not be used if you just mean "if (error) return", they
7892 * should only be used if you mean "if (bug in program) return".
7893 * The program behavior is generally considered undefined after one
7894 * of these checks fails. They are not intended for normal control
7895 * flow, only to give a perhaps-helpful warning before giving up.
7901 * @title: Windows Compatibility Functions
7902 * @short_description: UNIX emulation on Windows
7904 * These functions provide some level of UNIX emulation on the
7905 * Windows platform. If your application really needs the POSIX
7906 * APIs, we suggest you try the Cygwin project.
7913 * Defines the %TRUE value for the #gboolean type.
7919 * @String: the string to be translated
7921 * Marks a string for translation, gets replaced with the translated string
7929 * _glib_get_locale_dir:
7931 * Return the path to the share\locale or lib\locale subfolder of the
7932 * GLib installation folder. The path is in the system codepage. We
7933 * have to use system codepage as bindtextdomain() doesn't have a
7940 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
7941 * @mode: as in access()
7943 * A wrapper for the POSIX access() function. This function is used to
7944 * test a pathname for one or several of read, write or execute
7945 * permissions, or just existence.
7947 * On Windows, the file protection mechanism is not at all POSIX-like,
7948 * and the underlying function in the C library only checks the
7949 * FAT-style READONLY attribute, and does not look at the ACL of a
7950 * file at all. This function is this in practise almost useless on
7951 * Windows. Software that needs to handle file permissions on Windows
7952 * more exactly should use the Win32 API.
7954 * See your C library manual for more details about access().
7956 * Returns: zero if the pathname refers to an existing file system object that has all the tested permissions, or -1 otherwise or on error.
7962 * g_array_append_val:
7964 * @v: the value to append to the #GArray.
7966 * Adds the value on to the end of the array. The array will grow in
7967 * size automatically if necessary.
7969 * <note><para>g_array_append_val() is a macro which uses a reference
7970 * to the value parameter @v. This means that you cannot use it with
7971 * literal values such as "27". You must use variables.</para></note>
7973 * Returns: the #GArray.
7978 * g_array_append_vals:
7979 * @array: a #GArray.
7980 * @data: a pointer to the elements to append to the end of the array.
7981 * @len: the number of elements to append.
7983 * Adds @len elements onto the end of the array.
7985 * Returns: the #GArray.
7991 * @array: a #GArray.
7992 * @free_segment: if %TRUE the actual element data is freed as well.
7994 * Frees the memory allocated for the #GArray. If @free_segment is
7995 * %TRUE it frees the memory block holding the elements as well and
7996 * also each element if @array has a @element_free_func set. Pass
7997 * %FALSE if you want to free the #GArray wrapper but preserve the
7998 * underlying array for use elsewhere. If the reference count of @array
7999 * is greater than one, the #GArray wrapper is preserved but the size
8000 * of @array will be set to zero.
8002 * <note><para>If array elements contain dynamically-allocated memory,
8003 * they should be freed separately.</para></note>
8005 * Returns: the element data if @free_segment is %FALSE, otherwise %NULL. The element data should be freed using g_free().
8010 * g_array_get_element_size:
8011 * @array: A #GArray.
8013 * Gets the size of the elements in @array.
8015 * Returns: Size of each element, in bytes.
8023 * @t: the type of the elements.
8024 * @i: the index of the element to return.
8026 * Returns the element of a #GArray at the given index. The return
8027 * value is cast to the given type.
8030 * <title>Getting a pointer to an element in a #GArray</title>
8032 * EDayViewEvent *event;
8033 * /<!-- -->* This gets a pointer to the 4th element
8034 * in the array of EDayViewEvent structs. *<!-- -->/
8035 * event = &g_array_index (events, EDayViewEvent, 3);
8039 * Returns: the element of the #GArray at the index given by @i.
8044 * g_array_insert_val:
8046 * @i: the index to place the element at.
8047 * @v: the value to insert into the array.
8049 * Inserts an element into an array at the given index.
8051 * <note><para>g_array_insert_val() is a macro which uses a reference
8052 * to the value parameter @v. This means that you cannot use it with
8053 * literal values such as "27". You must use variables.</para></note>
8055 * Returns: the #GArray.
8060 * g_array_insert_vals:
8061 * @array: a #GArray.
8062 * @index_: the index to place the elements at.
8063 * @data: a pointer to the elements to insert.
8064 * @len: the number of elements to insert.
8066 * Inserts @len elements into a #GArray at the given index.
8068 * Returns: the #GArray.
8074 * @zero_terminated: %TRUE if the array should have an extra element at the end which is set to 0.
8075 * @clear_: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
8076 * @element_size: the size of each element in bytes.
8078 * Creates a new #GArray with a reference count of 1.
8080 * Returns: the new #GArray.
8085 * g_array_prepend_val:
8087 * @v: the value to prepend to the #GArray.
8089 * Adds the value on to the start of the array. The array will grow in
8090 * size automatically if necessary.
8092 * This operation is slower than g_array_append_val() since the
8093 * existing elements in the array have to be moved to make space for
8096 * <note><para>g_array_prepend_val() is a macro which uses a reference
8097 * to the value parameter @v. This means that you cannot use it with
8098 * literal values such as "27". You must use variables.</para></note>
8100 * Returns: the #GArray.
8105 * g_array_prepend_vals:
8106 * @array: a #GArray.
8107 * @data: a pointer to the elements to prepend to the start of the array.
8108 * @len: the number of elements to prepend.
8110 * Adds @len elements onto the start of the array.
8112 * This operation is slower than g_array_append_vals() since the
8113 * existing elements in the array have to be moved to make space for
8116 * Returns: the #GArray.
8122 * @array: A #GArray.
8124 * Atomically increments the reference count of @array by one. This
8125 * function is MT-safe and may be called from any thread.
8127 * Returns: The passed in #GArray.
8133 * g_array_remove_index:
8134 * @array: a #GArray.
8135 * @index_: the index of the element to remove.
8137 * Removes the element at the given index from a #GArray. The following
8138 * elements are moved down one place.
8140 * Returns: the #GArray.
8145 * g_array_remove_index_fast:
8146 * @array: a @GArray.
8147 * @index_: the index of the element to remove.
8149 * Removes the element at the given index from a #GArray. The last
8150 * element in the array is used to fill in the space, so this function
8151 * does not preserve the order of the #GArray. But it is faster than
8152 * g_array_remove_index().
8154 * Returns: the #GArray.
8159 * g_array_remove_range:
8160 * @array: a @GArray.
8161 * @index_: the index of the first element to remove.
8162 * @length: the number of elements to remove.
8164 * Removes the given number of elements starting at the given index
8165 * from a #GArray. The following elements are moved to close the gap.
8167 * Returns: the #GArray.
8173 * g_array_set_clear_func:
8175 * @clear_func: a function to clear an element of @array
8177 * Sets a function to clear an element of @array.
8179 * The @clear_func will be called when an element in the array
8180 * data segment is removed and when the array is freed and data
8181 * segment is deallocated as well.
8183 * Note that in contrast with other uses of #GDestroyNotify
8184 * functions, @clear_func is expected to clear the contents of
8185 * the array element it is given, but not free the element itself.
8193 * @array: a #GArray.
8194 * @length: the new size of the #GArray.
8196 * Sets the size of the array, expanding it if necessary. If the array
8197 * was created with @clear_ set to %TRUE, the new elements are set to 0.
8199 * Returns: the #GArray.
8204 * g_array_sized_new:
8205 * @zero_terminated: %TRUE if the array should have an extra element at the end with all bits cleared.
8206 * @clear_: %TRUE if all bits in the array should be cleared to 0 on allocation.
8207 * @element_size: size of each element in the array.
8208 * @reserved_size: number of elements preallocated.
8210 * Creates a new #GArray with @reserved_size elements preallocated and
8211 * a reference count of 1. This avoids frequent reallocation, if you
8212 * are going to add many elements to the array. Note however that the
8213 * size of the array is still 0.
8215 * Returns: the new #GArray.
8221 * @array: a #GArray.
8222 * @compare_func: comparison function.
8224 * Sorts a #GArray using @compare_func which should be a qsort()-style
8225 * comparison function (returns less than zero for first arg is less
8226 * than second arg, zero for equal, greater zero if first arg is
8227 * greater than second arg).
8229 * This is guaranteed to be a stable sort since version 2.32.
8234 * g_array_sort_with_data:
8235 * @array: a #GArray.
8236 * @compare_func: comparison function.
8237 * @user_data: data to pass to @compare_func.
8239 * Like g_array_sort(), but the comparison function receives an extra
8240 * user data argument.
8242 * This is guaranteed to be a stable sort since version 2.32.
8244 * There used to be a comment here about making the sort stable by
8245 * using the addresses of the elements in the comparison function.
8246 * This did not actually work, so any such code should be removed.
8252 * @array: A #GArray.
8254 * Atomically decrements the reference count of @array by one. If the
8255 * reference count drops to 0, all memory allocated by the array is
8256 * released. This function is MT-safe and may be called from any
8264 * g_ascii_digit_value:
8265 * @c: an ASCII character.
8267 * Determines the numeric value of a character as a decimal
8268 * digit. Differs from g_unichar_digit_value() because it takes
8269 * a char, so there's no worry about sign extension if characters
8272 * Returns: If @c is a decimal digit (according to g_ascii_isdigit()), its numeric value. Otherwise, -1.
8278 * @buffer: A buffer to place the resulting string in
8279 * @buf_len: The length of the buffer.
8280 * @d: The #gdouble to convert
8282 * Converts a #gdouble to a string, using the '.' as
8285 * This functions generates enough precision that converting
8286 * the string back using g_ascii_strtod() gives the same machine-number
8287 * (on machines with IEEE compatible 64bit doubles). It is
8288 * guaranteed that the size of the resulting string will never
8289 * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
8291 * Returns: The pointer to the buffer with the converted string.
8297 * @buffer: A buffer to place the resulting string in
8298 * @buf_len: The length of the buffer.
8299 * @format: The printf()-style format to use for the code to use for converting.
8300 * @d: The #gdouble to convert
8302 * Converts a #gdouble to a string, using the '.' as
8303 * decimal point. To format the number you pass in
8304 * a printf()-style format string. Allowed conversion
8305 * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
8307 * If you just want to want to serialize the value into a
8308 * string, use g_ascii_dtostr().
8310 * Returns: The pointer to the buffer with the converted string.
8318 * Determines whether a character is alphanumeric.
8320 * Unlike the standard C library isalnum() function, this only
8321 * recognizes standard ASCII letters and ignores the locale,
8322 * returning %FALSE for all non-ASCII characters. Also, unlike
8323 * the standard library function, this takes a <type>char</type>,
8324 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8325 * cast to #guchar before passing a possibly non-ASCII character in.
8327 * Returns: %TRUE if @c is an ASCII alphanumeric character
8335 * Determines whether a character is alphabetic (i.e. a letter).
8337 * Unlike the standard C library isalpha() function, this only
8338 * recognizes standard ASCII letters and ignores the locale,
8339 * returning %FALSE for all non-ASCII characters. Also, unlike
8340 * the standard library function, this takes a <type>char</type>,
8341 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8342 * cast to #guchar before passing a possibly non-ASCII character in.
8344 * Returns: %TRUE if @c is an ASCII alphabetic character
8352 * Determines whether a character is a control character.
8354 * Unlike the standard C library iscntrl() function, this only
8355 * recognizes standard ASCII control characters and ignores the
8356 * locale, returning %FALSE for all non-ASCII characters. Also,
8357 * unlike the standard library function, this takes a <type>char</type>,
8358 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8359 * cast to #guchar before passing a possibly non-ASCII character in.
8361 * Returns: %TRUE if @c is an ASCII control character.
8369 * Determines whether a character is digit (0-9).
8371 * Unlike the standard C library isdigit() function, this takes
8372 * a <type>char</type>, not an <type>int</type>, so don't call it
8373 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a possibly
8374 * non-ASCII character in.
8376 * Returns: %TRUE if @c is an ASCII digit.
8384 * Determines whether a character is a printing character and not a space.
8386 * Unlike the standard C library isgraph() function, this only
8387 * recognizes standard ASCII characters and ignores the locale,
8388 * returning %FALSE for all non-ASCII characters. Also, unlike
8389 * the standard library function, this takes a <type>char</type>,
8390 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8391 * to cast to #guchar before passing a possibly non-ASCII character in.
8393 * Returns: %TRUE if @c is an ASCII printing character other than space.
8401 * Determines whether a character is an ASCII lower case letter.
8403 * Unlike the standard C library islower() function, this only
8404 * recognizes standard ASCII letters and ignores the locale,
8405 * returning %FALSE for all non-ASCII characters. Also, unlike
8406 * the standard library function, this takes a <type>char</type>,
8407 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8408 * to worry about casting to #guchar before passing a possibly
8409 * non-ASCII character in.
8411 * Returns: %TRUE if @c is an ASCII lower case letter
8419 * Determines whether a character is a printing character.
8421 * Unlike the standard C library isprint() function, this only
8422 * recognizes standard ASCII characters and ignores the locale,
8423 * returning %FALSE for all non-ASCII characters. Also, unlike
8424 * the standard library function, this takes a <type>char</type>,
8425 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8426 * to cast to #guchar before passing a possibly non-ASCII character in.
8428 * Returns: %TRUE if @c is an ASCII printing character.
8436 * Determines whether a character is a punctuation character.
8438 * Unlike the standard C library ispunct() function, this only
8439 * recognizes standard ASCII letters and ignores the locale,
8440 * returning %FALSE for all non-ASCII characters. Also, unlike
8441 * the standard library function, this takes a <type>char</type>,
8442 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8443 * cast to #guchar before passing a possibly non-ASCII character in.
8445 * Returns: %TRUE if @c is an ASCII punctuation character.
8453 * Determines whether a character is a white-space character.
8455 * Unlike the standard C library isspace() function, this only
8456 * recognizes standard ASCII white-space and ignores the locale,
8457 * returning %FALSE for all non-ASCII characters. Also, unlike
8458 * the standard library function, this takes a <type>char</type>,
8459 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8460 * cast to #guchar before passing a possibly non-ASCII character in.
8462 * Returns: %TRUE if @c is an ASCII white-space character
8470 * Determines whether a character is an ASCII upper case letter.
8472 * Unlike the standard C library isupper() function, this only
8473 * recognizes standard ASCII letters and ignores the locale,
8474 * returning %FALSE for all non-ASCII characters. Also, unlike
8475 * the standard library function, this takes a <type>char</type>,
8476 * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8477 * worry about casting to #guchar before passing a possibly non-ASCII
8480 * Returns: %TRUE if @c is an ASCII upper case letter
8488 * Determines whether a character is a hexadecimal-digit character.
8490 * Unlike the standard C library isxdigit() function, this takes
8491 * a <type>char</type>, not an <type>int</type>, so don't call it
8492 * on <literal>EOF</literal>, but no need to cast to #guchar before passing a
8493 * possibly non-ASCII character in.
8495 * Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
8500 * g_ascii_strcasecmp:
8501 * @s1: string to compare with @s2.
8502 * @s2: string to compare with @s1.
8504 * Compare two strings, ignoring the case of ASCII characters.
8506 * Unlike the BSD strcasecmp() function, this only recognizes standard
8507 * ASCII letters and ignores the locale, treating all non-ASCII
8508 * bytes as if they are not letters.
8510 * This function should be used only on strings that are known to be
8511 * in encodings where the bytes corresponding to ASCII letters always
8512 * represent themselves. This includes UTF-8 and the ISO-8859-*
8513 * charsets, but not for instance double-byte encodings like the
8514 * Windows Codepage 932, where the trailing bytes of double-byte
8515 * characters include all ASCII letters. If you compare two CP932
8516 * strings using this function, you will get false matches.
8518 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
8525 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8527 * Converts all upper case ASCII letters to lower case ASCII letters.
8529 * 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.)
8534 * g_ascii_strncasecmp:
8535 * @s1: string to compare with @s2.
8536 * @s2: string to compare with @s1.
8537 * @n: number of characters to compare.
8539 * Compare @s1 and @s2, ignoring the case of ASCII characters and any
8540 * characters after the first @n in each string.
8542 * Unlike the BSD strcasecmp() function, this only recognizes standard
8543 * ASCII letters and ignores the locale, treating all non-ASCII
8544 * characters as if they are not letters.
8546 * The same warning as in g_ascii_strcasecmp() applies: Use this
8547 * function only on strings known to be in encodings where bytes
8548 * corresponding to ASCII letters always represent themselves.
8550 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
8556 * @nptr: the string to convert to a numeric value.
8557 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8559 * Converts a string to a #gdouble value.
8561 * This function behaves like the standard strtod() function
8562 * does in the C locale. It does this without actually changing
8563 * the current locale, since that would not be thread-safe.
8564 * A limitation of the implementation is that this function
8565 * will still accept localized versions of infinities and NANs.
8567 * This function is typically used when reading configuration
8568 * files or other non-user input that should be locale independent.
8569 * To handle input from the user you should normally use the
8570 * locale-sensitive system strtod() function.
8572 * To convert from a #gdouble to a string in a locale-insensitive
8573 * way, use g_ascii_dtostr().
8575 * If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
8576 * is returned (according to the sign of the value), and <literal>ERANGE</literal> is
8577 * stored in <literal>errno</literal>. If the correct value would cause underflow,
8578 * zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8580 * This function resets <literal>errno</literal> before calling strtod() so that
8581 * you can reliably detect overflow and underflow.
8583 * Returns: the #gdouble value.
8589 * @nptr: the string to convert to a numeric value.
8590 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8591 * @base: to be used for the conversion, 2..36 or 0
8593 * Converts a string to a #gint64 value.
8594 * This function behaves like the standard strtoll() function
8595 * does in the C locale. It does this without actually
8596 * changing the current locale, since that would not be
8599 * This function is typically used when reading configuration
8600 * files or other non-user input that should be locale independent.
8601 * To handle input from the user you should normally use the
8602 * locale-sensitive system strtoll() function.
8604 * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
8605 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8606 * If the base is outside the valid range, zero is returned, and
8607 * <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
8608 * string conversion fails, zero is returned, and @endptr returns @nptr
8609 * (if @endptr is non-%NULL).
8611 * Returns: the #gint64 value or zero on error.
8618 * @nptr: the string to convert to a numeric value.
8619 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8620 * @base: to be used for the conversion, 2..36 or 0
8622 * Converts a string to a #guint64 value.
8623 * This function behaves like the standard strtoull() function
8624 * does in the C locale. It does this without actually
8625 * changing the current locale, since that would not be
8628 * This function is typically used when reading configuration
8629 * files or other non-user input that should be locale independent.
8630 * To handle input from the user you should normally use the
8631 * locale-sensitive system strtoull() function.
8633 * If the correct value would cause overflow, %G_MAXUINT64
8634 * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8635 * If the base is outside the valid range, zero is returned, and
8636 * <literal>EINVAL</literal> is stored in <literal>errno</literal>.
8637 * If the string conversion fails, zero is returned, and @endptr returns
8638 * @nptr (if @endptr is non-%NULL).
8640 * Returns: the #guint64 value or zero on error.
8648 * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8650 * Converts all lower case ASCII letters to upper case ASCII letters.
8652 * 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.)
8658 * @c: any character.
8660 * Convert a character to ASCII lower case.
8662 * Unlike the standard C library tolower() function, this only
8663 * recognizes standard ASCII letters and ignores the locale, returning
8664 * all non-ASCII characters unchanged, even if they are lower case
8665 * letters in a particular character set. Also unlike the standard
8666 * library function, this takes and returns a char, not an int, so
8667 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8668 * before passing a possibly non-ASCII character in.
8670 * Returns: the result of converting @c to lower case. If @c is not an ASCII upper case letter, @c is returned unchanged.
8676 * @c: any character.
8678 * Convert a character to ASCII upper case.
8680 * Unlike the standard C library toupper() function, this only
8681 * recognizes standard ASCII letters and ignores the locale, returning
8682 * all non-ASCII characters unchanged, even if they are upper case
8683 * letters in a particular character set. Also unlike the standard
8684 * library function, this takes and returns a char, not an int, so
8685 * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8686 * before passing a possibly non-ASCII character in.
8688 * Returns: the result of converting @c to upper case. If @c is not an ASCII lower case letter, @c is returned unchanged.
8693 * g_ascii_xdigit_value:
8694 * @c: an ASCII character.
8696 * Determines the numeric value of a character as a hexidecimal
8697 * digit. Differs from g_unichar_xdigit_value() because it takes
8698 * a char, so there's no worry about sign extension if characters
8701 * Returns: If @c is a hex digit (according to g_ascii_isxdigit()), its numeric value. Otherwise, -1.
8707 * @expr: the expression to check
8709 * Debugging macro to terminate the application if the assertion
8710 * fails. If the assertion fails (i.e. the expression is not true),
8711 * an error message is logged and the application is terminated.
8713 * The macro can be turned off in final releases of code by defining
8714 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8719 * g_assert_cmpfloat:
8720 * @n1: an floating point number
8721 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8722 * @n2: another floating point number
8724 * Debugging macro to compare two floating point numbers.
8726 * The effect of <literal>g_assert_cmpfloat (n1, op, n2)</literal> is
8727 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8728 * of this macro is that it can produce a message that includes the
8729 * actual values of @n1 and @n2.
8737 * @n1: an unsigned integer
8738 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8739 * @n2: another unsigned integer
8741 * Debugging macro to compare to unsigned integers.
8743 * This is a variant of g_assert_cmpuint() that displays the numbers
8744 * in hexadecimal notation in the message.
8753 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8754 * @n2: another integer
8756 * Debugging macro to compare two integers.
8758 * The effect of <literal>g_assert_cmpint (n1, op, n2)</literal> is
8759 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8760 * of this macro is that it can produce a message that includes the
8761 * actual values of @n1 and @n2.
8769 * @s1: a string (may be %NULL)
8770 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8771 * @s2: another string (may be %NULL)
8773 * Debugging macro to compare two strings. If the comparison fails,
8774 * an error message is logged and the application is either terminated
8775 * or the testcase marked as failed.
8776 * The strings are compared using g_strcmp0().
8778 * The effect of <literal>g_assert_cmpstr (s1, op, s2)</literal> is
8779 * the same as <literal>g_assert_true (g_strcmp0 (s1, s2) op 0)</literal>.
8780 * The advantage of this macro is that it can produce a message that
8781 * includes the actual values of @s1 and @s2.
8784 * g_assert_cmpstr (mystring, ==, "fubar");
8793 * @n1: an unsigned integer
8794 * @cmp: The comparison operator to use. One of ==, !=, <, >, <=, >=.
8795 * @n2: another unsigned integer
8797 * Debugging macro to compare two unsigned integers.
8799 * The effect of <literal>g_assert_cmpuint (n1, op, n2)</literal> is
8800 * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8801 * of this macro is that it can produce a message that includes the
8802 * actual values of @n1 and @n2.
8810 * @err: a #GError, possibly %NULL
8811 * @dom: the expected error domain (a #GQuark)
8812 * @c: the expected error code
8814 * Debugging macro to check that a method has returned
8815 * the correct #GError.
8817 * The effect of <literal>g_assert_error (err, dom, c)</literal> is
8818 * the same as <literal>g_assert_true (err != NULL && err->domain
8819 * == dom && err->code == c)</literal>. The advantage of this
8820 * macro is that it can produce a message that includes the incorrect
8821 * error message and code.
8823 * This can only be used to test for a specific error. If you want to
8824 * test that @err is set, but don't care what it's set to, just use
8825 * <literal>g_assert (err != NULL)</literal>
8833 * @expr: the expression to check
8835 * Debugging macro to check an expression is false.
8837 * If the assertion fails (i.e. the expression is not false),
8838 * an error message is logged and the application is either
8839 * terminated or the testcase marked as failed.
8841 * See g_test_set_nonfatal_assertions().
8848 * g_assert_no_error:
8849 * @err: a #GError, possibly %NULL
8851 * Debugging macro to check that a #GError is not set.
8853 * The effect of <literal>g_assert_no_error (err)</literal> is
8854 * the same as <literal>g_assert_true (err == NULL)</literal>. The advantage
8855 * of this macro is that it can produce a message that includes
8856 * the error message and code.
8863 * g_assert_not_reached:
8865 * Debugging macro to terminate the application if it is ever
8866 * reached. If it is reached, an error message is logged and the
8867 * application is terminated.
8869 * The macro can be turned off in final releases of code by defining
8870 * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8876 * @expr: the expression to check
8878 * Debugging macro to check an expression is %NULL.
8880 * If the assertion fails (i.e. the expression is not %NULL),
8881 * an error message is logged and the application is either
8882 * terminated or the testcase marked as failed.
8884 * See g_test_set_nonfatal_assertions().
8892 * @expr: the expression to check
8894 * Debugging macro to check that an expression is true.
8896 * If the assertion fails (i.e. the expression is not true),
8897 * an error message is logged and the application is either
8898 * terminated or the testcase marked as failed.
8900 * See g_test_set_nonfatal_assertions().
8907 * g_async_queue_length:
8908 * @queue: a #GAsyncQueue.
8910 * Returns the length of the queue.
8912 * Actually this function returns the number of data items in
8913 * the queue minus the number of waiting threads, so a negative
8914 * value means waiting threads, and a positive value means available
8915 * entries in the @queue. A return value of 0 could mean n entries
8916 * in the queue and n threads waiting. This can happen due to locking
8917 * of the queue or due to scheduling.
8919 * Returns: the length of the @queue
8924 * g_async_queue_length_unlocked:
8925 * @queue: a #GAsyncQueue
8927 * Returns the length of the queue.
8929 * Actually this function returns the number of data items in
8930 * the queue minus the number of waiting threads, so a negative
8931 * value means waiting threads, and a positive value means available
8932 * entries in the @queue. A return value of 0 could mean n entries
8933 * in the queue and n threads waiting. This can happen due to locking
8934 * of the queue or due to scheduling.
8936 * This function must be called while holding the @queue's lock.
8938 * Returns: the length of the @queue.
8943 * g_async_queue_lock:
8944 * @queue: a #GAsyncQueue
8946 * Acquires the @queue's lock. If another thread is already
8947 * holding the lock, this call will block until the lock
8948 * becomes available.
8950 * Call g_async_queue_unlock() to drop the lock again.
8952 * While holding the lock, you can only call the
8953 * <function>g_async_queue_*_unlocked()</function> functions
8954 * on @queue. Otherwise, deadlock may occur.
8959 * g_async_queue_new:
8961 * Creates a new asynchronous queue.
8963 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8968 * g_async_queue_new_full:
8969 * @item_free_func: function to free queue elements
8971 * Creates a new asynchronous queue and sets up a destroy notify
8972 * function that is used to free any remaining queue items when
8973 * the queue is destroyed after the final unref.
8975 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8981 * g_async_queue_pop:
8982 * @queue: a #GAsyncQueue
8984 * Pops data from the @queue. If @queue is empty, this function
8985 * blocks until data becomes available.
8987 * Returns: data from the queue
8992 * g_async_queue_pop_unlocked:
8993 * @queue: a #GAsyncQueue
8995 * Pops data from the @queue. If @queue is empty, this function
8996 * blocks until data becomes available.
8998 * This function must be called while holding the @queue's lock.
9000 * Returns: data from the queue.
9005 * g_async_queue_push:
9006 * @queue: a #GAsyncQueue
9007 * @data: @data to push into the @queue
9009 * Pushes the @data into the @queue. @data must not be %NULL.
9014 * g_async_queue_push_sorted:
9015 * @queue: a #GAsyncQueue
9016 * @data: the @data to push into the @queue
9017 * @func: the #GCompareDataFunc is used to sort @queue
9018 * @user_data: user data passed to @func.
9020 * Inserts @data into @queue using @func to determine the new
9023 * This function requires that the @queue is sorted before pushing on
9024 * new elements, see g_async_queue_sort().
9026 * This function will lock @queue before it sorts the queue and unlock
9027 * it when it is finished.
9029 * For an example of @func see g_async_queue_sort().
9036 * g_async_queue_push_sorted_unlocked:
9037 * @queue: a #GAsyncQueue
9038 * @data: the @data to push into the @queue
9039 * @func: the #GCompareDataFunc is used to sort @queue
9040 * @user_data: user data passed to @func.
9042 * Inserts @data into @queue using @func to determine the new
9045 * The sort function @func is passed two elements of the @queue.
9046 * It should return 0 if they are equal, a negative value if the
9047 * first element should be higher in the @queue or a positive value
9048 * if the first element should be lower in the @queue than the second
9051 * This function requires that the @queue is sorted before pushing on
9052 * new elements, see g_async_queue_sort().
9054 * This function must be called while holding the @queue's lock.
9056 * For an example of @func see g_async_queue_sort().
9063 * g_async_queue_push_unlocked:
9064 * @queue: a #GAsyncQueue
9065 * @data: @data to push into the @queue
9067 * Pushes the @data into the @queue. @data must not be %NULL.
9069 * This function must be called while holding the @queue's lock.
9074 * g_async_queue_ref:
9075 * @queue: a #GAsyncQueue
9077 * Increases the reference count of the asynchronous @queue by 1.
9078 * You do not need to hold the lock to call this function.
9080 * Returns: the @queue that was passed in (since 2.6)
9085 * g_async_queue_ref_unlocked:
9086 * @queue: a #GAsyncQueue
9088 * Increases the reference count of the asynchronous @queue by 1.
9090 * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_ref() can be used regardless of the @queue's lock.
9095 * g_async_queue_sort:
9096 * @queue: a #GAsyncQueue
9097 * @func: the #GCompareDataFunc is used to sort @queue
9098 * @user_data: user data passed to @func
9100 * Sorts @queue using @func.
9102 * The sort function @func is passed two elements of the @queue.
9103 * It should return 0 if they are equal, a negative value if the
9104 * first element should be higher in the @queue or a positive value
9105 * if the first element should be lower in the @queue than the second
9108 * This function will lock @queue before it sorts the queue and unlock
9109 * it when it is finished.
9111 * If you were sorting a list of priority numbers to make sure the
9112 * lowest priority would be at the top of the queue, you could use:
9117 * id1 = GPOINTER_TO_INT (element1);
9118 * id2 = GPOINTER_TO_INT (element2);
9120 * return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
9128 * g_async_queue_sort_unlocked:
9129 * @queue: a #GAsyncQueue
9130 * @func: the #GCompareDataFunc is used to sort @queue
9131 * @user_data: user data passed to @func
9133 * Sorts @queue using @func.
9135 * The sort function @func is passed two elements of the @queue.
9136 * It should return 0 if they are equal, a negative value if the
9137 * first element should be higher in the @queue or a positive value
9138 * if the first element should be lower in the @queue than the second
9141 * This function must be called while holding the @queue's lock.
9148 * g_async_queue_timed_pop:
9149 * @queue: a #GAsyncQueue
9150 * @end_time: a #GTimeVal, determining the final time
9152 * Pops data from the @queue. If the queue is empty, blocks until
9153 * @end_time or until data becomes available.
9155 * If no data is received before @end_time, %NULL is returned.
9157 * To easily calculate @end_time, a combination of g_get_current_time()
9158 * and g_time_val_add() can be used.
9160 * Returns: data from the queue or %NULL, when no data is received before @end_time.
9161 * Deprecated: use g_async_queue_timeout_pop().
9166 * g_async_queue_timed_pop_unlocked:
9167 * @queue: a #GAsyncQueue
9168 * @end_time: a #GTimeVal, determining the final time
9170 * Pops data from the @queue. If the queue is empty, blocks until
9171 * @end_time or until data becomes available.
9173 * If no data is received before @end_time, %NULL is returned.
9175 * To easily calculate @end_time, a combination of g_get_current_time()
9176 * and g_time_val_add() can be used.
9178 * This function must be called while holding the @queue's lock.
9180 * Returns: data from the queue or %NULL, when no data is received before @end_time.
9181 * Deprecated: use g_async_queue_timeout_pop_unlocked().
9186 * g_async_queue_timeout_pop:
9187 * @queue: a #GAsyncQueue
9188 * @timeout: the number of microseconds to wait
9190 * Pops data from the @queue. If the queue is empty, blocks for
9191 * @timeout microseconds, or until data becomes available.
9193 * If no data is received before the timeout, %NULL is returned.
9195 * Returns: data from the queue or %NULL, when no data is received before the timeout.
9200 * g_async_queue_timeout_pop_unlocked:
9201 * @queue: a #GAsyncQueue
9202 * @timeout: the number of microseconds to wait
9204 * Pops data from the @queue. If the queue is empty, blocks for
9205 * @timeout microseconds, or until data becomes available.
9207 * If no data is received before the timeout, %NULL is returned.
9209 * This function must be called while holding the @queue's lock.
9211 * Returns: data from the queue or %NULL, when no data is received before the timeout.
9216 * g_async_queue_try_pop:
9217 * @queue: a #GAsyncQueue
9219 * Tries to pop data from the @queue. If no data is available,
9220 * %NULL is returned.
9222 * Returns: data from the queue or %NULL, when no data is available immediately.
9227 * g_async_queue_try_pop_unlocked:
9228 * @queue: a #GAsyncQueue
9230 * Tries to pop data from the @queue. If no data is available,
9231 * %NULL is returned.
9233 * This function must be called while holding the @queue's lock.
9235 * Returns: data from the queue or %NULL, when no data is available immediately.
9240 * g_async_queue_unlock:
9241 * @queue: a #GAsyncQueue
9243 * Releases the queue's lock.
9245 * Calling this function when you have not acquired
9246 * the with g_async_queue_lock() leads to undefined
9252 * g_async_queue_unref:
9253 * @queue: a #GAsyncQueue.
9255 * Decreases the reference count of the asynchronous @queue by 1.
9257 * If the reference count went to 0, the @queue will be destroyed
9258 * and the memory allocated will be freed. So you are not allowed
9259 * to use the @queue afterwards, as it might have disappeared.
9260 * You do not need to hold the lock to call this function.
9265 * g_async_queue_unref_and_unlock:
9266 * @queue: a #GAsyncQueue
9268 * Decreases the reference count of the asynchronous @queue by 1
9269 * and releases the lock. This function must be called while holding
9270 * the @queue's lock. If the reference count went to 0, the @queue
9271 * will be destroyed and the memory allocated will be freed.
9273 * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_unref() can be used regardless of the @queue's lock.
9279 * @func: (scope async): the function to call on normal program termination.
9281 * Specifies a function to be called at normal program termination.
9283 * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
9284 * macro that maps to a call to the atexit() function in the C
9285 * library. This means that in case the code that calls g_atexit(),
9286 * i.e. atexit(), is in a DLL, the function will be called when the
9287 * DLL is detached from the program. This typically makes more sense
9288 * than that the function is called when the GLib DLL is detached,
9289 * which happened earlier when g_atexit() was a function in the GLib
9292 * The behaviour of atexit() in the context of dynamically loaded
9293 * modules is not formally specified and varies wildly.
9295 * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
9296 * loaded module which is unloaded before the program terminates might
9297 * well cause a crash at program exit.
9299 * Some POSIX systems implement atexit() like Windows, and have each
9300 * dynamically loaded module maintain an own atexit chain that is
9301 * called when the module is unloaded.
9303 * On other POSIX systems, before a dynamically loaded module is
9304 * unloaded, the registered atexit functions (if any) residing in that
9305 * module are called, regardless where the code that registered them
9306 * resided. This is presumably the most robust approach.
9308 * As can be seen from the above, for portability it's best to avoid
9309 * calling g_atexit() (or atexit()) except in the main executable of a
9312 * Deprecated: 2.32: It is best to avoid g_atexit().
9318 * @atomic: a pointer to a #gint or #guint
9319 * @val: the value to add
9321 * Atomically adds @val to the value of @atomic.
9323 * Think of this operation as an atomic version of
9324 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9326 * This call acts as a full compiler and hardware memory barrier.
9328 * Before version 2.30, this function did not return a value
9329 * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
9331 * Returns: the value of @atomic before the add, signed
9338 * @atomic: a pointer to a #gint or #guint
9339 * @val: the value to 'and'
9341 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9342 * storing the result back in @atomic.
9344 * This call acts as a full compiler and hardware memory barrier.
9346 * Think of this operation as an atomic version of
9347 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9349 * Returns: the value of @atomic before the operation, unsigned
9355 * g_atomic_int_compare_and_exchange:
9356 * @atomic: a pointer to a #gint or #guint
9357 * @oldval: the value to compare with
9358 * @newval: the value to conditionally replace with
9360 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9361 * If @atomic was not equal to @oldval then no change occurs.
9363 * This compare and exchange is done atomically.
9365 * Think of this operation as an atomic version of
9366 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9368 * This call acts as a full compiler and hardware memory barrier.
9370 * Returns: %TRUE if the exchange took place
9376 * g_atomic_int_dec_and_test:
9377 * @atomic: a pointer to a #gint or #guint
9379 * Decrements the value of @atomic by 1.
9381 * Think of this operation as an atomic version of
9382 * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
9384 * This call acts as a full compiler and hardware memory barrier.
9386 * Returns: %TRUE if the resultant value is zero
9392 * g_atomic_int_exchange_and_add:
9393 * @atomic: a pointer to a #gint
9394 * @val: the value to add
9396 * This function existed before g_atomic_int_add() returned the prior
9397 * value of the integer (which it now does). It is retained only for
9398 * compatibility reasons. Don't use this function in new code.
9400 * Returns: the value of @atomic before the add, signed
9402 * Deprecated: 2.30: Use g_atomic_int_add() instead.
9408 * @atomic: a pointer to a #gint or #guint
9410 * Gets the current value of @atomic.
9412 * This call acts as a full compiler and hardware
9413 * memory barrier (before the get).
9415 * Returns: the value of the integer
9422 * @atomic: a pointer to a #gint or #guint
9424 * Increments the value of @atomic by 1.
9426 * Think of this operation as an atomic version of
9427 * <literal>{ *@atomic += 1; }</literal>
9429 * This call acts as a full compiler and hardware memory barrier.
9437 * @atomic: a pointer to a #gint or #guint
9438 * @val: the value to 'or'
9440 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9441 * storing the result back in @atomic.
9443 * Think of this operation as an atomic version of
9444 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9446 * This call acts as a full compiler and hardware memory barrier.
9448 * Returns: the value of @atomic before the operation, unsigned
9455 * @atomic: a pointer to a #gint or #guint
9456 * @newval: a new value to store
9458 * Sets the value of @atomic to @newval.
9460 * This call acts as a full compiler and hardware
9461 * memory barrier (after the set).
9469 * @atomic: a pointer to a #gint or #guint
9470 * @val: the value to 'xor'
9472 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9473 * storing the result back in @atomic.
9475 * Think of this operation as an atomic version of
9476 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9478 * This call acts as a full compiler and hardware memory barrier.
9480 * Returns: the value of @atomic before the operation, unsigned
9486 * g_atomic_pointer_add:
9487 * @atomic: a pointer to a #gpointer-sized value
9488 * @val: the value to add
9490 * Atomically adds @val to the value of @atomic.
9492 * Think of this operation as an atomic version of
9493 * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9495 * This call acts as a full compiler and hardware memory barrier.
9497 * Returns: the value of @atomic before the add, signed
9503 * g_atomic_pointer_and:
9504 * @atomic: a pointer to a #gpointer-sized value
9505 * @val: the value to 'and'
9507 * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9508 * storing the result back in @atomic.
9510 * Think of this operation as an atomic version of
9511 * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9513 * This call acts as a full compiler and hardware memory barrier.
9515 * Returns: the value of @atomic before the operation, unsigned
9521 * g_atomic_pointer_compare_and_exchange:
9522 * @atomic: a pointer to a #gpointer-sized value
9523 * @oldval: the value to compare with
9524 * @newval: the value to conditionally replace with
9526 * Compares @atomic to @oldval and, if equal, sets it to @newval.
9527 * If @atomic was not equal to @oldval then no change occurs.
9529 * This compare and exchange is done atomically.
9531 * Think of this operation as an atomic version of
9532 * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9534 * This call acts as a full compiler and hardware memory barrier.
9536 * Returns: %TRUE if the exchange took place
9542 * g_atomic_pointer_get:
9543 * @atomic: a pointer to a #gpointer-sized value
9545 * Gets the current value of @atomic.
9547 * This call acts as a full compiler and hardware
9548 * memory barrier (before the get).
9550 * Returns: the value of the pointer
9556 * g_atomic_pointer_or:
9557 * @atomic: a pointer to a #gpointer-sized value
9558 * @val: the value to 'or'
9560 * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9561 * storing the result back in @atomic.
9563 * Think of this operation as an atomic version of
9564 * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9566 * This call acts as a full compiler and hardware memory barrier.
9568 * Returns: the value of @atomic before the operation, unsigned
9574 * g_atomic_pointer_set:
9575 * @atomic: a pointer to a #gpointer-sized value
9576 * @newval: a new value to store
9578 * Sets the value of @atomic to @newval.
9580 * This call acts as a full compiler and hardware
9581 * memory barrier (after the set).
9588 * g_atomic_pointer_xor:
9589 * @atomic: a pointer to a #gpointer-sized value
9590 * @val: the value to 'xor'
9592 * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9593 * storing the result back in @atomic.
9595 * Think of this operation as an atomic version of
9596 * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9598 * This call acts as a full compiler and hardware memory barrier.
9600 * Returns: the value of @atomic before the operation, unsigned
9607 * @text: zero-terminated string with base64 text to decode
9608 * @out_len: (out): The length of the decoded data is written here
9610 * Decode a sequence of Base-64 encoded text into binary data. Note
9611 * that the returned binary data is not necessarily zero-terminated,
9612 * so it should not be used as a character string.
9614 * 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().
9620 * g_base64_decode_inplace:
9621 * @text: (inout) (array length=out_len) (element-type guint8): zero-terminated string with base64 text to decode
9622 * @out_len: (inout): The length of the decoded data is written here
9624 * Decode a sequence of Base-64 encoded text into binary data
9625 * by overwriting the input data.
9627 * Returns: (transfer none): The binary data that @text responds. This pointer is the same as the input @text.
9633 * g_base64_decode_step:
9634 * @in: (array length=len) (element-type guint8): binary input data
9635 * @len: max length of @in data to decode
9636 * @out: (out) (array) (element-type guint8): output buffer
9637 * @state: (inout): Saved state between steps, initialize to 0
9638 * @save: (inout): Saved state between steps, initialize to 0
9640 * Incrementally decode a sequence of binary data from its Base-64 stringified
9641 * representation. By calling this function multiple times you can convert
9642 * data in chunks to avoid having to have the full encoded data in memory.
9644 * The output buffer must be large enough to fit all the data that will
9645 * be written to it. Since base64 encodes 3 bytes in 4 chars you need
9646 * at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
9649 * Returns: The number of bytes of output that was written
9656 * @data: (array length=len) (element-type guint8): the binary data to encode
9657 * @len: the length of @data
9659 * Encode a sequence of binary data into its Base-64 stringified
9662 * Returns: (transfer full): a newly allocated, zero-terminated Base-64 encoded string representing @data. The returned string must be freed with g_free().
9668 * g_base64_encode_close:
9669 * @break_lines: whether to break long lines
9670 * @out: (out) (array) (element-type guint8): pointer to destination buffer
9671 * @state: (inout): Saved state from g_base64_encode_step()
9672 * @save: (inout): Saved state from g_base64_encode_step()
9674 * Flush the status from a sequence of calls to g_base64_encode_step().
9676 * The output buffer must be large enough to fit all the data that will
9677 * be written to it. It will need up to 4 bytes, or up to 5 bytes if
9678 * line-breaking is enabled.
9680 * Returns: The number of bytes of output that was written
9686 * g_base64_encode_step:
9687 * @in: (array length=len) (element-type guint8): the binary data to encode
9688 * @len: the length of @in
9689 * @break_lines: whether to break long lines
9690 * @out: (out) (array) (element-type guint8): pointer to destination buffer
9691 * @state: (inout): Saved state between steps, initialize to 0
9692 * @save: (inout): Saved state between steps, initialize to 0
9694 * Incrementally encode a sequence of binary data into its Base-64 stringified
9695 * representation. By calling this function multiple times you can convert
9696 * data in chunks to avoid having to have the full encoded data in memory.
9698 * When all of the data has been converted you must call
9699 * g_base64_encode_close() to flush the saved state.
9701 * The output buffer must be large enough to fit all the data that will
9702 * be written to it. Due to the way base64 encodes you will need
9703 * at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
9704 * non-zero state). If you enable line-breaking you will need at least:
9705 * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
9707 * @break_lines is typically used when putting base64-encoded data in emails.
9708 * It breaks the lines at 72 columns instead of putting all of the text on
9709 * the same line. This avoids problems with long lines in the email system.
9710 * Note however that it breaks the lines with <literal>LF</literal>
9711 * characters, not <literal>CR LF</literal> sequences, so the result cannot
9712 * be passed directly to SMTP or certain other protocols.
9714 * Returns: The number of bytes of output that was written
9721 * @file_name: the name of the file
9723 * Gets the name of the file without any leading directory
9724 * components. It returns a pointer into the given file name
9727 * Returns: the name of the file without any leading directory components
9728 * 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.
9734 * @address: a pointer to an integer
9735 * @lock_bit: a bit value between 0 and 31
9737 * Sets the indicated @lock_bit in @address. If the bit is already
9738 * set, this call will block until g_bit_unlock() unsets the
9739 * corresponding bit.
9741 * Attempting to lock on two different bits within the same integer is
9742 * not supported and will very probably cause deadlocks.
9744 * The value of the bit that is set is (1u << @bit). If @bit is not
9745 * between 0 and 31 then the result is undefined.
9747 * This function accesses @address atomically. All other accesses to
9748 * @address must be atomic in order for this function to work
9757 * @mask: a #gulong containing flags
9758 * @nth_bit: the index of the bit to start the search from
9760 * Find the position of the first bit set in @mask, searching
9761 * from (but not including) @nth_bit upwards. Bits are numbered
9762 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9763 * usually). To start searching from the 0th bit, set @nth_bit to -1.
9765 * Returns: the index of the first bit set which is higher than @nth_bit
9771 * @mask: a #gulong containing flags
9772 * @nth_bit: the index of the bit to start the search from
9774 * Find the position of the first bit set in @mask, searching
9775 * from (but not including) @nth_bit downwards. Bits are numbered
9776 * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9777 * usually). To start searching from the last bit, set @nth_bit to
9778 * -1 or GLIB_SIZEOF_LONG * 8.
9780 * Returns: the index of the first bit set which is lower than @nth_bit
9788 * Gets the number of bits used to hold @number,
9789 * e.g. if @number is 4, 3 bits are needed.
9791 * Returns: the number of bits used to hold @number
9797 * @address: a pointer to an integer
9798 * @lock_bit: a bit value between 0 and 31
9800 * Sets the indicated @lock_bit in @address, returning %TRUE if
9801 * successful. If the bit is already set, returns %FALSE immediately.
9803 * Attempting to lock on two different bits within the same integer is
9806 * The value of the bit that is set is (1u << @bit). If @bit is not
9807 * between 0 and 31 then the result is undefined.
9809 * This function accesses @address atomically. All other accesses to
9810 * @address must be atomic in order for this function to work
9813 * Returns: %TRUE if the lock was acquired
9820 * @address: a pointer to an integer
9821 * @lock_bit: a bit value between 0 and 31
9823 * Clears the indicated @lock_bit in @address. If another thread is
9824 * currently blocked in g_bit_lock() on this same bit then it will be
9827 * This function accesses @address atomically. All other accesses to
9828 * @address must be atomic in order for this function to work
9836 * g_bookmark_file_add_application:
9837 * @bookmark: a #GBookmarkFile
9839 * @name: (allow-none): the name of the application registering the bookmark or %NULL
9840 * @exec: (allow-none): command line to be used to launch the bookmark or %NULL
9842 * Adds the application with @name and @exec to the list of
9843 * applications that have registered a bookmark for @uri into
9846 * Every bookmark inside a #GBookmarkFile must have at least an
9847 * application registered. Each application must provide a name, a
9848 * command line useful for launching the bookmark, the number of times
9849 * the bookmark has been registered by the application and the last
9850 * time the application registered this bookmark.
9852 * If @name is %NULL, the name of the application will be the
9853 * same returned by g_get_application_name(); if @exec is %NULL, the
9854 * command line will be a composition of the program name as
9855 * returned by g_get_prgname() and the "\%u" modifier, which will be
9856 * expanded to the bookmark's URI.
9858 * This function will automatically take care of updating the
9859 * registrations count and timestamping in case an application
9860 * with the same @name had already registered a bookmark for
9861 * @uri inside @bookmark.
9863 * If no bookmark for @uri is found, one is created.
9870 * g_bookmark_file_add_group:
9871 * @bookmark: a #GBookmarkFile
9873 * @group: the group name to be added
9875 * Adds @group to the list of groups to which the bookmark for @uri
9878 * If no bookmark for @uri is found then it is created.
9885 * g_bookmark_file_free:
9886 * @bookmark: a #GBookmarkFile
9888 * Frees a #GBookmarkFile.
9895 * g_bookmark_file_get_added:
9896 * @bookmark: a #GBookmarkFile
9898 * @error: return location for a #GError, or %NULL
9900 * Gets the time the bookmark for @uri was added to @bookmark
9902 * In the event the URI cannot be found, -1 is returned and
9903 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9905 * Returns: a timestamp
9911 * g_bookmark_file_get_app_info:
9912 * @bookmark: a #GBookmarkFile
9914 * @name: an application's name
9915 * @exec: (allow-none) (out): return location for the command line of the application, or %NULL
9916 * @count: (allow-none) (out): return location for the registration count, or %NULL
9917 * @stamp: (allow-none) (out): return location for the last registration time, or %NULL
9918 * @error: return location for a #GError, or %NULL
9920 * Gets the registration informations of @app_name for the bookmark for
9921 * @uri. See g_bookmark_file_set_app_info() for more informations about
9922 * the returned data.
9924 * The string returned in @app_exec must be freed.
9926 * In the event the URI cannot be found, %FALSE is returned and
9927 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
9928 * event that no application with name @app_name has registered a bookmark
9929 * for @uri, %FALSE is returned and error is set to
9930 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
9931 * the command line fails, an error of the #G_SHELL_ERROR domain is
9932 * set and %FALSE is returned.
9934 * Returns: %TRUE on success.
9940 * g_bookmark_file_get_applications:
9941 * @bookmark: a #GBookmarkFile
9943 * @length: (allow-none) (out): return location of the length of the returned list, or %NULL
9944 * @error: return location for a #GError, or %NULL
9946 * Retrieves the names of the applications that have registered the
9947 * bookmark for @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.
9952 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
9958 * g_bookmark_file_get_description:
9959 * @bookmark: a #GBookmarkFile
9961 * @error: return location for a #GError, or %NULL
9963 * Retrieves the description of the bookmark for @uri.
9965 * In the event the URI cannot be found, %NULL is returned and
9966 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9968 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
9974 * g_bookmark_file_get_groups:
9975 * @bookmark: a #GBookmarkFile
9977 * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
9978 * @error: return location for a #GError, or %NULL
9980 * Retrieves the list of group names of the bookmark for @uri.
9982 * In the event the URI cannot be found, %NULL is returned and
9983 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9985 * The returned array is %NULL terminated, so @length may optionally
9988 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of group names. Use g_strfreev() to free it.
9994 * g_bookmark_file_get_icon:
9995 * @bookmark: a #GBookmarkFile
9997 * @href: (allow-none) (out): return location for the icon's location or %NULL
9998 * @mime_type: (allow-none) (out): return location for the icon's MIME type or %NULL
9999 * @error: return location for a #GError or %NULL
10001 * Gets the icon of the bookmark for @uri.
10003 * In the event the URI cannot be found, %FALSE is returned and
10004 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10006 * Returns: %TRUE if the icon for the bookmark for the URI was found. You should free the returned strings.
10012 * g_bookmark_file_get_is_private:
10013 * @bookmark: a #GBookmarkFile
10014 * @uri: a valid URI
10015 * @error: return location for a #GError, or %NULL
10017 * Gets whether the private flag of the bookmark for @uri is set.
10019 * In the event the URI cannot be found, %FALSE is returned and
10020 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
10021 * event that the private flag cannot be found, %FALSE is returned and
10022 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10024 * Returns: %TRUE if the private flag is set, %FALSE otherwise.
10030 * g_bookmark_file_get_mime_type:
10031 * @bookmark: a #GBookmarkFile
10032 * @uri: a valid URI
10033 * @error: return location for a #GError, or %NULL
10035 * Retrieves the MIME type of the resource pointed by @uri.
10037 * In the event the URI cannot be found, %NULL is returned and
10038 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
10039 * event that the MIME type cannot be found, %NULL is returned and
10040 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10042 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
10048 * g_bookmark_file_get_modified:
10049 * @bookmark: a #GBookmarkFile
10050 * @uri: a valid URI
10051 * @error: return location for a #GError, or %NULL
10053 * Gets the time when the bookmark for @uri was last modified.
10055 * In the event the URI cannot be found, -1 is returned and
10056 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10058 * Returns: a timestamp
10064 * g_bookmark_file_get_size:
10065 * @bookmark: a #GBookmarkFile
10067 * Gets the number of bookmarks inside @bookmark.
10069 * Returns: the number of bookmarks
10075 * g_bookmark_file_get_title:
10076 * @bookmark: a #GBookmarkFile
10077 * @uri: (allow-none): a valid URI or %NULL
10078 * @error: return location for a #GError, or %NULL
10080 * Returns the title of the bookmark for @uri.
10082 * If @uri is %NULL, the title of @bookmark is returned.
10084 * In the event the URI cannot be found, %NULL is returned and
10085 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10087 * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
10093 * g_bookmark_file_get_uris:
10094 * @bookmark: a #GBookmarkFile
10095 * @length: (allow-none) (out): return location for the number of returned URIs, or %NULL
10097 * Returns all URIs of the bookmarks in the bookmark file @bookmark.
10098 * The array of returned URIs will be %NULL-terminated, so @length may
10099 * optionally be %NULL.
10101 * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
10107 * g_bookmark_file_get_visited:
10108 * @bookmark: a #GBookmarkFile
10109 * @uri: a valid URI
10110 * @error: return location for a #GError, or %NULL
10112 * Gets the time the bookmark for @uri was last visited.
10114 * In the event the URI cannot be found, -1 is returned and
10115 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10117 * Returns: a timestamp.
10123 * g_bookmark_file_has_application:
10124 * @bookmark: a #GBookmarkFile
10125 * @uri: a valid URI
10126 * @name: the name of the application
10127 * @error: return location for a #GError or %NULL
10129 * Checks whether the bookmark for @uri inside @bookmark has been
10130 * registered by application @name.
10132 * In the event the URI cannot be found, %FALSE is returned and
10133 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10135 * Returns: %TRUE if the application @name was found
10141 * g_bookmark_file_has_group:
10142 * @bookmark: a #GBookmarkFile
10143 * @uri: a valid URI
10144 * @group: the group name to be searched
10145 * @error: return location for a #GError, or %NULL
10147 * Checks whether @group appears in the list of groups to which
10148 * the bookmark for @uri belongs to.
10150 * In the event the URI cannot be found, %FALSE is returned and
10151 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10153 * Returns: %TRUE if @group was found.
10159 * g_bookmark_file_has_item:
10160 * @bookmark: a #GBookmarkFile
10161 * @uri: a valid URI
10163 * Looks whether the desktop bookmark has an item with its URI set to @uri.
10165 * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise
10171 * g_bookmark_file_load_from_data:
10172 * @bookmark: an empty #GBookmarkFile struct
10173 * @data: desktop bookmarks loaded in memory
10174 * @length: the length of @data in bytes
10175 * @error: return location for a #GError, or %NULL
10177 * Loads a bookmark file from memory into an empty #GBookmarkFile
10178 * structure. If the object cannot be created then @error is set to a
10179 * #GBookmarkFileError.
10181 * Returns: %TRUE if a desktop bookmark could be loaded.
10187 * g_bookmark_file_load_from_data_dirs:
10188 * @bookmark: a #GBookmarkFile
10189 * @file: a relative path to a filename to open and parse
10190 * @full_path: (allow-none): return location for a string containing the full path of the file, or %NULL
10191 * @error: return location for a #GError, or %NULL
10193 * This function looks for a desktop bookmark file named @file in the
10194 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
10195 * loads the file into @bookmark and returns the file's full path in
10196 * @full_path. If the file could not be loaded then an %error is
10197 * set to either a #GFileError or #GBookmarkFileError.
10199 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
10205 * g_bookmark_file_load_from_file:
10206 * @bookmark: an empty #GBookmarkFile struct
10207 * @filename: the path of a filename to load, in the GLib file name encoding
10208 * @error: return location for a #GError, or %NULL
10210 * Loads a desktop bookmark file into an empty #GBookmarkFile structure.
10211 * If the file could not be loaded then @error is set to either a #GFileError
10212 * or #GBookmarkFileError.
10214 * Returns: %TRUE if a desktop bookmark file could be loaded
10220 * g_bookmark_file_move_item:
10221 * @bookmark: a #GBookmarkFile
10222 * @old_uri: a valid URI
10223 * @new_uri: (allow-none): a valid URI, or %NULL
10224 * @error: return location for a #GError or %NULL
10226 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any
10227 * existing bookmark for @new_uri will be overwritten. If @new_uri is
10228 * %NULL, then the bookmark is removed.
10230 * In the event the URI cannot be found, %FALSE is returned and
10231 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10233 * Returns: %TRUE if the URI was successfully changed
10239 * g_bookmark_file_new:
10241 * Creates a new empty #GBookmarkFile object.
10243 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
10244 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
10247 * Returns: an empty #GBookmarkFile
10253 * g_bookmark_file_remove_application:
10254 * @bookmark: a #GBookmarkFile
10255 * @uri: a valid URI
10256 * @name: the name of the application
10257 * @error: return location for a #GError or %NULL
10259 * Removes application registered with @name from the list of applications
10260 * that have registered a bookmark for @uri inside @bookmark.
10262 * In the event the URI cannot be found, %FALSE is returned and
10263 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10264 * In the event that no application with name @app_name has registered
10265 * a bookmark for @uri, %FALSE is returned and error is set to
10266 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
10268 * Returns: %TRUE if the application was successfully removed.
10274 * g_bookmark_file_remove_group:
10275 * @bookmark: a #GBookmarkFile
10276 * @uri: a valid URI
10277 * @group: the group name to be removed
10278 * @error: return location for a #GError, or %NULL
10280 * Removes @group from the list of groups to which the bookmark
10281 * for @uri belongs to.
10283 * In the event the URI cannot be found, %FALSE is returned and
10284 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10285 * In the event no group was defined, %FALSE is returned and
10286 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10288 * Returns: %TRUE if @group was successfully removed.
10294 * g_bookmark_file_remove_item:
10295 * @bookmark: a #GBookmarkFile
10296 * @uri: a valid URI
10297 * @error: return location for a #GError, or %NULL
10299 * Removes the bookmark for @uri from the bookmark file @bookmark.
10301 * Returns: %TRUE if the bookmark was removed successfully.
10307 * g_bookmark_file_set_added:
10308 * @bookmark: a #GBookmarkFile
10309 * @uri: a valid URI
10310 * @added: a timestamp or -1 to use the current time
10312 * Sets the time the bookmark for @uri was added into @bookmark.
10314 * If no bookmark for @uri is found then it is created.
10321 * g_bookmark_file_set_app_info:
10322 * @bookmark: a #GBookmarkFile
10323 * @uri: a valid URI
10324 * @name: an application's name
10325 * @exec: an application's command line
10326 * @count: the number of registrations done for this application
10327 * @stamp: the time of the last registration for this application
10328 * @error: return location for a #GError or %NULL
10330 * Sets the meta-data of application @name inside the list of
10331 * applications that have registered a bookmark for @uri inside
10334 * You should rarely use this function; use g_bookmark_file_add_application()
10335 * and g_bookmark_file_remove_application() instead.
10337 * @name can be any UTF-8 encoded string used to identify an
10339 * @exec can have one of these two modifiers: "\%f", which will
10340 * be expanded as the local file name retrieved from the bookmark's
10341 * URI; "\%u", which will be expanded as the bookmark's URI.
10342 * The expansion is done automatically when retrieving the stored
10343 * command line using the g_bookmark_file_get_app_info() function.
10344 * @count is the number of times the application has registered the
10345 * bookmark; if is < 0, the current registration count will be increased
10346 * by one, if is 0, the application with @name will be removed from
10347 * the list of registered applications.
10348 * @stamp is the Unix time of the last registration; if it is -1, the
10349 * current time will be used.
10351 * If you try to remove an application by setting its registration count to
10352 * zero, and no bookmark for @uri is found, %FALSE is returned and
10353 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
10354 * in the event that no application @name has registered a bookmark
10355 * for @uri, %FALSE is returned and error is set to
10356 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
10357 * for @uri is found, one is created.
10359 * Returns: %TRUE if the application's meta-data was successfully changed.
10365 * g_bookmark_file_set_description:
10366 * @bookmark: a #GBookmarkFile
10367 * @uri: (allow-none): a valid URI or %NULL
10368 * @description: a string
10370 * Sets @description as the description of the bookmark for @uri.
10372 * If @uri is %NULL, the description of @bookmark is set.
10374 * If a bookmark for @uri cannot be found then it is created.
10381 * g_bookmark_file_set_groups:
10382 * @bookmark: a #GBookmarkFile
10383 * @uri: an item's URI
10384 * @groups: (allow-none): an array of group names, or %NULL to remove all groups
10385 * @length: number of group name values in @groups
10387 * Sets a list of group names for the item with URI @uri. Each previously
10388 * set group name list is removed.
10390 * If @uri cannot be found then an item for it is created.
10397 * g_bookmark_file_set_icon:
10398 * @bookmark: a #GBookmarkFile
10399 * @uri: a valid URI
10400 * @href: (allow-none): the URI of the icon for the bookmark, or %NULL
10401 * @mime_type: the MIME type of the icon for the bookmark
10403 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
10404 * the currently set icon. @href can either be a full URL for the icon
10405 * file or the icon name following the Icon Naming specification.
10407 * If no bookmark for @uri is found one is created.
10414 * g_bookmark_file_set_is_private:
10415 * @bookmark: a #GBookmarkFile
10416 * @uri: a valid URI
10417 * @is_private: %TRUE if the bookmark should be marked as private
10419 * Sets the private flag of the bookmark for @uri.
10421 * If a bookmark for @uri cannot be found then it is created.
10428 * g_bookmark_file_set_mime_type:
10429 * @bookmark: a #GBookmarkFile
10430 * @uri: a valid URI
10431 * @mime_type: a MIME type
10433 * Sets @mime_type as the MIME type of the bookmark for @uri.
10435 * If a bookmark for @uri cannot be found then it is created.
10442 * g_bookmark_file_set_modified:
10443 * @bookmark: a #GBookmarkFile
10444 * @uri: a valid URI
10445 * @modified: a timestamp or -1 to use the current time
10447 * Sets the last time the bookmark for @uri was last modified.
10449 * If no bookmark for @uri is found then it is created.
10451 * The "modified" time should only be set when the bookmark's meta-data
10452 * was actually changed. Every function of #GBookmarkFile that
10453 * modifies a bookmark also changes the modification time, except for
10454 * g_bookmark_file_set_visited().
10461 * g_bookmark_file_set_title:
10462 * @bookmark: a #GBookmarkFile
10463 * @uri: (allow-none): a valid URI or %NULL
10464 * @title: a UTF-8 encoded string
10466 * Sets @title as the title of the bookmark for @uri inside the
10467 * bookmark file @bookmark.
10469 * If @uri is %NULL, the title of @bookmark is set.
10471 * If a bookmark for @uri cannot be found then it is created.
10478 * g_bookmark_file_set_visited:
10479 * @bookmark: a #GBookmarkFile
10480 * @uri: a valid URI
10481 * @visited: a timestamp or -1 to use the current time
10483 * Sets the time the bookmark for @uri was last visited.
10485 * If no bookmark for @uri is found then it is created.
10487 * The "visited" time should only be set if the bookmark was launched,
10488 * either using the command line retrieved by g_bookmark_file_get_app_info()
10489 * or by the default application for the bookmark's MIME type, retrieved
10490 * using g_bookmark_file_get_mime_type(). Changing the "visited" time
10491 * does not affect the "modified" time.
10498 * g_bookmark_file_to_data:
10499 * @bookmark: a #GBookmarkFile
10500 * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10501 * @error: return location for a #GError, or %NULL
10503 * This function outputs @bookmark as a string.
10505 * Returns: a newly allocated string holding the contents of the #GBookmarkFile
10511 * g_bookmark_file_to_file:
10512 * @bookmark: a #GBookmarkFile
10513 * @filename: path of the output file
10514 * @error: return location for a #GError, or %NULL
10516 * This function outputs @bookmark into a file. The write process is
10517 * guaranteed to be atomic by using g_file_set_contents() internally.
10519 * Returns: %TRUE if the file was successfully written.
10525 * g_build_filename:
10526 * @first_element: the first element in the path
10527 * @...: remaining elements in path, terminated by %NULL
10529 * Creates a filename from a series of elements using the correct
10530 * separator for filenames.
10532 * On Unix, this function behaves identically to <literal>g_build_path
10533 * (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
10535 * On Windows, it takes into account that either the backslash
10536 * (<literal>\</literal> or slash (<literal>/</literal>) can be used
10537 * as separator in filenames, but otherwise behaves as on Unix. When
10538 * file pathname separators need to be inserted, the one that last
10539 * previously occurred in the parameters (reading from left to right)
10542 * No attempt is made to force the resulting filename to be an absolute
10543 * path. If the first element is a relative path, the result will
10544 * be a relative path.
10546 * Returns: a newly-allocated string that must be freed with g_free().
10551 * g_build_filenamev:
10552 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10554 * Behaves exactly like g_build_filename(), but takes the path elements
10555 * as a string array, instead of varargs. This function is mainly
10556 * meant for language bindings.
10558 * Returns: a newly-allocated string that must be freed with g_free().
10565 * @separator: a string used to separator the elements of the path.
10566 * @first_element: the first element in the path
10567 * @...: remaining elements in path, terminated by %NULL
10569 * Creates a path from a series of elements using @separator as the
10570 * separator between elements. At the boundary between two elements,
10571 * any trailing occurrences of separator in the first element, or
10572 * leading occurrences of separator in the second element are removed
10573 * and exactly one copy of the separator is inserted.
10575 * Empty elements are ignored.
10577 * The number of leading copies of the separator on the result is
10578 * the same as the number of leading copies of the separator on
10579 * the first non-empty element.
10581 * The number of trailing copies of the separator on the result is
10582 * the same as the number of trailing copies of the separator on
10583 * the last non-empty element. (Determination of the number of
10584 * trailing copies is done without stripping leading copies, so
10585 * if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
10586 * has 1 trailing copy.)
10588 * However, if there is only a single non-empty element, and there
10589 * are no characters in that element not part of the leading or
10590 * trailing separators, then the result is exactly the original value
10593 * Other than for determination of the number of leading and trailing
10594 * copies of the separator, elements consisting only of copies
10595 * of the separator are ignored.
10597 * Returns: a newly-allocated string that must be freed with g_free().
10603 * @separator: a string used to separator the elements of the path.
10604 * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10606 * Behaves exactly like g_build_path(), but takes the path elements
10607 * as a string array, instead of varargs. This function is mainly
10608 * meant for language bindings.
10610 * Returns: a newly-allocated string that must be freed with g_free().
10616 * g_byte_array_append:
10617 * @array: a #GByteArray.
10618 * @data: the byte data to be added.
10619 * @len: the number of bytes to add.
10621 * Adds the given bytes to the end of the #GByteArray. The array will
10622 * grow in size automatically if necessary.
10624 * Returns: the #GByteArray.
10629 * g_byte_array_free:
10630 * @array: a #GByteArray.
10631 * @free_segment: if %TRUE the actual byte data is freed as well.
10633 * Frees the memory allocated by the #GByteArray. If @free_segment is
10634 * %TRUE it frees the actual byte data. If the reference count of
10635 * @array is greater than one, the #GByteArray wrapper is preserved but
10636 * the size of @array will be set to zero.
10638 * Returns: the element data if @free_segment is %FALSE, otherwise %NULL. The element data should be freed using g_free().
10643 * g_byte_array_free_to_bytes:
10644 * @array: (transfer full): a #GByteArray
10646 * Transfers the data from the #GByteArray into a new immutable #GBytes.
10648 * The #GByteArray is freed unless the reference count of @array is greater
10649 * than one, the #GByteArray wrapper is preserved but the size of @array
10650 * will be set to zero.
10652 * This is identical to using g_bytes_new_take() and g_byte_array_free()
10656 * Returns: (transfer full): a new immutable #GBytes representing same byte data that was in the array
10661 * g_byte_array_new:
10663 * Creates a new #GByteArray with a reference count of 1.
10665 * Returns: (transfer full): the new #GByteArray.
10670 * g_byte_array_new_take:
10671 * @data: (transfer full) (array length=len): byte data for the array
10672 * @len: length of @data
10674 * Create byte array containing the data. The data will be owned by the array
10675 * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
10678 * Returns: (transfer full): a new #GByteArray
10683 * g_byte_array_prepend:
10684 * @array: a #GByteArray.
10685 * @data: the byte data to be added.
10686 * @len: the number of bytes to add.
10688 * Adds the given data to the start of the #GByteArray. The array will
10689 * grow in size automatically if necessary.
10691 * Returns: the #GByteArray.
10696 * g_byte_array_ref:
10697 * @array: A #GByteArray.
10699 * Atomically increments the reference count of @array by one. This
10700 * function is MT-safe and may be called from any thread.
10702 * Returns: The passed in #GByteArray.
10708 * g_byte_array_remove_index:
10709 * @array: a #GByteArray.
10710 * @index_: the index of the byte to remove.
10712 * Removes the byte at the given index from a #GByteArray. The
10713 * following bytes are moved down one place.
10715 * Returns: the #GByteArray.
10720 * g_byte_array_remove_index_fast:
10721 * @array: a #GByteArray.
10722 * @index_: the index of the byte to remove.
10724 * Removes the byte at the given index from a #GByteArray. The last
10725 * element in the array is used to fill in the space, so this function
10726 * does not preserve the order of the #GByteArray. But it is faster
10727 * than g_byte_array_remove_index().
10729 * Returns: the #GByteArray.
10734 * g_byte_array_remove_range:
10735 * @array: a @GByteArray.
10736 * @index_: the index of the first byte to remove.
10737 * @length: the number of bytes to remove.
10739 * Removes the given number of bytes starting at the given index from a
10740 * #GByteArray. The following elements are moved to close the gap.
10742 * Returns: the #GByteArray.
10748 * g_byte_array_set_size:
10749 * @array: a #GByteArray.
10750 * @length: the new size of the #GByteArray.
10752 * Sets the size of the #GByteArray, expanding it if necessary.
10754 * Returns: the #GByteArray.
10759 * g_byte_array_sized_new:
10760 * @reserved_size: number of bytes preallocated.
10762 * Creates a new #GByteArray with @reserved_size bytes preallocated.
10763 * This avoids frequent reallocation, if you are going to add many
10764 * bytes to the array. Note however that the size of the array is still
10767 * Returns: the new #GByteArray.
10772 * g_byte_array_sort:
10773 * @array: a #GByteArray.
10774 * @compare_func: comparison function.
10776 * Sorts a byte array, using @compare_func which should be a
10777 * qsort()-style comparison function (returns less than zero for first
10778 * arg is less than second arg, zero for equal, greater than zero if
10779 * first arg is greater than second arg).
10781 * If two array elements compare equal, their order in the sorted array
10782 * is undefined. If you want equal elements to keep their order (i.e.
10783 * you want a stable sort) you can write a comparison function that,
10784 * if two elements would otherwise compare equal, compares them by
10790 * g_byte_array_sort_with_data:
10791 * @array: a #GByteArray.
10792 * @compare_func: comparison function.
10793 * @user_data: data to pass to @compare_func.
10795 * Like g_byte_array_sort(), but the comparison function takes an extra
10796 * user data argument.
10801 * g_byte_array_unref:
10802 * @array: A #GByteArray.
10804 * Atomically decrements the reference count of @array by one. If the
10805 * reference count drops to 0, all memory allocated by the array is
10806 * released. This function is MT-safe and may be called from any
10815 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10816 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10818 * Compares the two #GBytes values.
10820 * This function can be used to sort GBytes instances in lexographical order.
10822 * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is greater, and zero if bytes2 is equal to bytes1
10829 * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10830 * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10832 * Compares the two #GBytes values being pointed to and returns
10833 * %TRUE if they are equal.
10835 * This function can be passed to g_hash_table_new() as the @key_equal_func
10836 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10838 * Returns: %TRUE if the two keys match.
10844 * g_bytes_get_data:
10845 * @bytes: a #GBytes
10846 * @size: (out) (allow-none): location to return size of byte data
10848 * Get the byte data in the #GBytes. This data should not be modified.
10850 * This function will always return the same pointer for a given #GBytes.
10852 * Returns: (transfer none) (array length=size) (type guint8): a pointer to the byte data
10858 * g_bytes_get_size:
10859 * @bytes: a #GBytes
10861 * Get the size of the byte data in the #GBytes.
10863 * This function will always return the same value for a given #GBytes.
10865 * Returns: the size
10872 * @bytes: (type GLib.Bytes): a pointer to a #GBytes key
10874 * Creates an integer hash code for the byte data in the #GBytes.
10876 * This function can be passed to g_hash_table_new() as the @key_equal_func
10877 * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10879 * Returns: a hash value corresponding to the key.
10886 * @data: (transfer none) (array length=size) (element-type guint8): the data to be used for the bytes
10887 * @size: the size of @data
10889 * Creates a new #GBytes from @data.
10893 * Returns: (transfer full): a new #GBytes
10899 * g_bytes_new_from_bytes:
10900 * @bytes: a #GBytes
10901 * @offset: offset which subsection starts at
10902 * @length: length of subsection
10904 * Creates a #GBytes which is a subsection of another #GBytes. The @offset +
10905 * @length may not be longer than the size of @bytes.
10907 * A reference to @bytes will be held by the newly created #GBytes until
10908 * the byte data is no longer needed.
10910 * Returns: (transfer full): a new #GBytes
10916 * g_bytes_new_static: (skip)
10917 * @data: (transfer full) (array length=size) (element-type guint8): the data to be used for the bytes
10918 * @size: the size of @data
10920 * Creates a new #GBytes from static data.
10922 * @data must be static (ie: never modified or freed).
10924 * Returns: (transfer full): a new #GBytes
10930 * g_bytes_new_take:
10931 * @data: (transfer full) (array length=size) (element-type guint8): the data to be used for the bytes
10932 * @size: the size of @data
10934 * Creates a new #GBytes from @data.
10936 * After this call, @data belongs to the bytes and may no longer be
10937 * modified by the caller. g_free() will be called on @data when the
10938 * bytes is no longer in use. Because of this @data must have been created by
10939 * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
10940 * functions that wrap these calls (such as g_new(), g_strdup(), etc).
10942 * For creating #GBytes with memory from other allocators, see
10943 * g_bytes_new_with_free_func().
10945 * Returns: (transfer full): a new #GBytes
10951 * g_bytes_new_with_free_func:
10952 * @data: (array length=size): the data to be used for the bytes
10953 * @size: the size of @data
10954 * @free_func: the function to call to release the data
10955 * @user_data: data to pass to @free_func
10957 * Creates a #GBytes from @data.
10959 * When the last reference is dropped, @free_func will be called with the
10960 * @user_data argument.
10962 * @data must not be modified after this call is made until @free_func has
10963 * been called to indicate that the bytes is no longer in use.
10965 * Returns: (transfer full): a new #GBytes
10972 * @bytes: a #GBytes
10974 * Increase the reference count on @bytes.
10976 * Returns: the #GBytes
10983 * @bytes: (allow-none): a #GBytes
10985 * Releases a reference on @bytes. This may result in the bytes being
10993 * g_bytes_unref_to_array:
10994 * @bytes: (transfer full): a #GBytes
10996 * Unreferences the bytes, and returns a new mutable #GByteArray containing
10997 * the same byte data.
10999 * As an optimization, the byte data is transferred to the array without copying
11000 * if this was the last reference to bytes and bytes was created with
11001 * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
11002 * other cases the data is copied.
11004 * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
11010 * g_bytes_unref_to_data:
11011 * @bytes: (transfer full): a #GBytes
11012 * @size: location to place the length of the returned data
11014 * Unreferences the bytes, and returns a pointer the same byte data
11017 * As an optimization, the byte data is returned without copying if this was
11018 * the last reference to bytes and bytes was created with g_bytes_new(),
11019 * g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
11022 * Returns: (transfer full): a pointer to the same byte data, which should be freed with g_free()
11029 * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
11031 * A wrapper for the POSIX chdir() function. The function changes the
11032 * current directory of the process to @path.
11034 * See your C library manual for more details about chdir().
11036 * Returns: 0 on success, -1 if an error occurred.
11043 * @checksum: the #GChecksum to copy
11045 * Copies a #GChecksum. If @checksum has been closed, by calling
11046 * g_checksum_get_string() or g_checksum_get_digest(), the copied
11047 * checksum will be closed as well.
11049 * Returns: the copy of the passed #GChecksum. Use g_checksum_free() when finished using it.
11056 * @checksum: a #GChecksum
11058 * Frees the memory allocated for @checksum.
11065 * g_checksum_get_digest: (skip)
11066 * @checksum: a #GChecksum
11067 * @buffer: output buffer
11068 * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
11070 * Gets the digest from @checksum as a raw binary vector and places it
11071 * into @buffer. The size of the digest depends on the type of checksum.
11073 * Once this function has been called, the #GChecksum is closed and can
11074 * no longer be updated with g_checksum_update().
11081 * g_checksum_get_string:
11082 * @checksum: a #GChecksum
11084 * Gets the digest as an hexadecimal string.
11086 * Once this function has been called the #GChecksum can no longer be
11087 * updated with g_checksum_update().
11089 * The hexadecimal characters will be lower case.
11091 * Returns: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed.
11098 * @checksum_type: the desired type of checksum
11100 * Creates a new #GChecksum, using the checksum algorithm @checksum_type.
11101 * If the @checksum_type is not known, %NULL is returned.
11102 * A #GChecksum can be used to compute the checksum, or digest, of an
11103 * arbitrary binary blob, using different hashing algorithms.
11105 * A #GChecksum works by feeding a binary blob through g_checksum_update()
11106 * until there is data to be checked; the digest can then be extracted
11107 * using g_checksum_get_string(), which will return the checksum as a
11108 * hexadecimal string; or g_checksum_get_digest(), which will return a
11109 * vector of raw bytes. Once either g_checksum_get_string() or
11110 * g_checksum_get_digest() have been called on a #GChecksum, the checksum
11111 * will be closed and it won't be possible to call g_checksum_update()
11114 * Returns: (transfer full): the newly created #GChecksum, or %NULL. Use g_checksum_free() to free the memory allocated by it.
11120 * g_checksum_reset:
11121 * @checksum: the #GChecksum to reset
11123 * Resets the state of the @checksum back to its initial state.
11130 * g_checksum_type_get_length:
11131 * @checksum_type: a #GChecksumType
11133 * Gets the length in bytes of digests of type @checksum_type
11135 * Returns: the checksum length, or -1 if @checksum_type is not supported.
11141 * g_checksum_update:
11142 * @checksum: a #GChecksum
11143 * @data: (array length=length) (element-type guint8): buffer used to compute the checksum
11144 * @length: size of the buffer, or -1 if it is a null-terminated string.
11146 * Feeds @data into an existing #GChecksum. The checksum must still be
11147 * open, that is g_checksum_get_string() or g_checksum_get_digest() must
11148 * not have been called on @checksum.
11155 * g_child_watch_add:
11156 * @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).
11157 * @function: function to call
11158 * @data: data to pass to @function
11160 * Sets a function to be called when the child indicated by @pid
11161 * exits, at a default priority, #G_PRIORITY_DEFAULT.
11163 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11164 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11165 * the spawn function for the child watching to work.
11167 * Note that on platforms where #GPid must be explicitly closed
11168 * (see g_spawn_close_pid()) @pid must not be closed while the
11169 * source is still active. Typically, you will want to call
11170 * g_spawn_close_pid() in the callback function for the source.
11172 * GLib supports only a single callback per process id.
11174 * This internally creates a main loop source using
11175 * g_child_watch_source_new() and attaches it to the main loop context
11176 * using g_source_attach(). You can do these steps manually if you
11177 * need greater control.
11179 * Returns: the ID (greater than 0) of the event source.
11185 * g_child_watch_add_full:
11186 * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
11187 * @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).
11188 * @function: function to call
11189 * @data: data to pass to @function
11190 * @notify: (allow-none): function to call when the idle is removed, or %NULL
11192 * Sets a function to be called when the child indicated by @pid
11193 * exits, at the priority @priority.
11195 * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11196 * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11197 * the spawn function for the child watching to work.
11199 * In many programs, you will want to call g_spawn_check_exit_status()
11200 * in the callback to determine whether or not the child exited
11203 * Also, note that on platforms where #GPid must be explicitly closed
11204 * (see g_spawn_close_pid()) @pid must not be closed while the source
11205 * is still active. Typically, you should invoke g_spawn_close_pid()
11206 * in the callback function for the source.
11208 * GLib supports only a single callback per process id.
11210 * This internally creates a main loop source using
11211 * g_child_watch_source_new() and attaches it to the main loop context
11212 * using g_source_attach(). You can do these steps manually if you
11213 * need greater control.
11215 * Returns: the ID (greater than 0) of the event source.
11216 * Rename to: g_child_watch_add
11222 * g_child_watch_source_new:
11223 * @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).
11225 * Creates a new child_watch source.
11227 * The source will not initially be associated with any #GMainContext
11228 * and must be added to one with g_source_attach() before it will be
11231 * Note that child watch sources can only be used in conjunction with
11232 * <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
11235 * Note that on platforms where #GPid must be explicitly closed
11236 * (see g_spawn_close_pid()) @pid must not be closed while the
11237 * source is still active. Typically, you will want to call
11238 * g_spawn_close_pid() in the callback function for the source.
11240 * Note further that using g_child_watch_source_new() is not
11241 * compatible with calling <literal>waitpid</literal> with a
11242 * nonpositive first argument in the application. Calling waitpid()
11243 * for individual pids will still work fine.
11245 * Returns: the newly-created child watch source
11252 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11253 * @mode: as in chmod()
11255 * A wrapper for the POSIX chmod() function. The chmod() function is
11256 * used to set the permissions of a file system object.
11258 * On Windows the file protection mechanism is not at all POSIX-like,
11259 * and the underlying chmod() function in the C library just sets or
11260 * clears the FAT-style READONLY attribute. It does not touch any
11261 * ACL. Software that needs to manage file permissions on Windows
11262 * exactly should use the Win32 API.
11264 * See your C library manual for more details about chmod().
11266 * Returns: zero if the operation succeeded, -1 on error.
11273 * @err: a #GError return location
11275 * If @err is %NULL, does nothing. If @err is non-%NULL,
11276 * calls g_error_free() on *@err and sets *@err to %NULL.
11281 * g_clear_pointer: (skip)
11282 * @pp: a pointer to a variable, struct member etc. holding a pointer
11283 * @destroy: a function to which a gpointer can be passed, to destroy *@pp
11285 * Clears a reference to a variable.
11287 * @pp must not be %NULL.
11289 * If the reference is %NULL then this function does nothing.
11290 * Otherwise, the variable is destroyed using @destroy and the
11291 * pointer is set to %NULL.
11293 * This function is threadsafe and modifies the pointer atomically,
11294 * using memory barriers where needed.
11296 * A macro is also included that allows this function to be used without
11305 * @fd: A file descriptor
11306 * @error: a #GError
11308 * This wraps the close() call; in case of error, %errno will be
11309 * preserved, but the error will also be stored as a #GError in @error.
11311 * Besides using #GError, there is another major reason to prefer this
11312 * function over the call provided by the system; on Unix, it will
11313 * attempt to correctly handle %EINTR, which has platform-specific
11321 * g_compute_checksum_for_bytes:
11322 * @checksum_type: a #GChecksumType
11323 * @data: binary blob to compute the digest of
11325 * Computes the checksum for a binary @data. This is a
11326 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11327 * and g_checksum_free().
11329 * The hexadecimal string returned will be in lower case.
11331 * 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.
11337 * g_compute_checksum_for_data:
11338 * @checksum_type: a #GChecksumType
11339 * @data: (array length=length) (element-type guint8): binary blob to compute the digest of
11340 * @length: length of @data
11342 * Computes the checksum for a binary @data of @length. This is a
11343 * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11344 * and g_checksum_free().
11346 * The hexadecimal string returned will be in lower case.
11348 * 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.
11354 * g_compute_checksum_for_string:
11355 * @checksum_type: a #GChecksumType
11356 * @str: the string to compute the checksum of
11357 * @length: the length of the string, or -1 if the string is null-terminated.
11359 * Computes the checksum of a string.
11361 * The hexadecimal string returned will be in lower case.
11363 * Returns: the checksum as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11369 * g_compute_hmac_for_data:
11370 * @digest_type: a #GChecksumType to use for the HMAC
11371 * @key: (array length=key_len): the key to use in the HMAC
11372 * @key_len: the length of the key
11373 * @data: binary blob to compute the HMAC of
11374 * @length: length of @data
11376 * Computes the HMAC for a binary @data of @length. This is a
11377 * convenience wrapper for g_hmac_new(), g_hmac_get_string()
11378 * and g_hmac_unref().
11380 * The hexadecimal string returned will be in lower case.
11382 * 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.
11388 * g_compute_hmac_for_string:
11389 * @digest_type: a #GChecksumType to use for the HMAC
11390 * @key: (array length=key_len): the key to use in the HMAC
11391 * @key_len: the length of the key
11392 * @str: the string to compute the HMAC for
11393 * @length: the length of the string, or -1 if the string is nul-terminated
11395 * Computes the HMAC for a string.
11397 * The hexadecimal string returned will be in lower case.
11399 * Returns: the HMAC as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11405 * g_cond_broadcast:
11408 * If threads are waiting for @cond, all of them are unblocked.
11409 * If no threads are waiting for @cond, this function has no effect.
11410 * It is good practice to lock the same mutex as the waiting threads
11411 * while calling this function, though not required.
11417 * @cond: an initialised #GCond
11419 * Frees the resources allocated to a #GCond with g_cond_init().
11421 * This function should not be used with a #GCond that has been
11422 * statically allocated.
11424 * Calling g_cond_clear() for a #GCond on which threads are
11425 * blocking leads to undefined behaviour.
11433 * @cond: an uninitialized #GCond
11435 * Initialises a #GCond so that it can be used.
11437 * This function is useful to initialise a #GCond that has been
11438 * allocated as part of a larger structure. It is not necessary to
11439 * initialise a #GCond that has been statically allocated.
11441 * To undo the effect of g_cond_init() when a #GCond is no longer
11442 * needed, use g_cond_clear().
11444 * Calling g_cond_init() on an already-initialised #GCond leads
11445 * to undefined behaviour.
11455 * If threads are waiting for @cond, at least one of them is unblocked.
11456 * If no threads are waiting for @cond, this function has no effect.
11457 * It is good practice to hold the same lock as the waiting thread
11458 * while calling this function, though not required.
11465 * @mutex: a #GMutex that is currently locked
11467 * Atomically releases @mutex and waits until @cond is signalled.
11468 * When this function returns, @mutex is locked again and owned by the
11471 * When using condition variables, it is possible that a spurious wakeup
11472 * may occur (ie: g_cond_wait() returns even though g_cond_signal() was
11473 * not called). It's also possible that a stolen wakeup may occur.
11474 * This is when g_cond_signal() is called, but another thread acquires
11475 * @mutex before this thread and modifies the state of the program in
11476 * such a way that when g_cond_wait() is able to return, the expected
11477 * condition is no longer met.
11479 * For this reason, g_cond_wait() must always be used in a loop. See
11480 * the documentation for #GCond for a complete example.
11485 * g_cond_wait_until:
11487 * @mutex: a #GMutex that is currently locked
11488 * @end_time: the monotonic time to wait until
11490 * Waits until either @cond is signalled or @end_time has passed.
11492 * As with g_cond_wait() it is possible that a spurious or stolen wakeup
11493 * could occur. For that reason, waiting on a condition variable should
11494 * always be in a loop, based on an explicitly-checked predicate.
11496 * %TRUE is returned if the condition variable was signalled (or in the
11497 * case of a spurious wakeup). %FALSE is returned if @end_time has
11500 * The following code shows how to correctly perform a timed wait on a
11501 * condition variable (extended the example presented in the
11502 * documentation for #GCond):
11506 * pop_data_timed (void)
11511 * g_mutex_lock (&data_mutex);
11513 * end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
11514 * while (!current_data)
11515 * if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
11517 * // timeout has passed.
11518 * g_mutex_unlock (&data_mutex);
11522 * // there is data for us
11523 * data = current_data;
11524 * current_data = NULL;
11526 * g_mutex_unlock (&data_mutex);
11532 * Notice that the end time is calculated once, before entering the
11533 * loop and reused. This is the motivation behind the use of absolute
11534 * time on this API -- if a relative time of 5 seconds were passed
11535 * directly to the call and a spurious wakeup occurred, the program would
11536 * have to start over waiting again (which would lead to a total wait
11537 * time of more than 5 seconds).
11539 * Returns: %TRUE on a signal, %FALSE on a timeout
11546 * @str: the string to convert
11547 * @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>.
11548 * @to_codeset: name of character set into which to convert @str
11549 * @from_codeset: character set of @str.
11550 * @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.
11551 * @bytes_written: (out): the number of bytes stored in the output buffer (not including the terminating nul).
11552 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11554 * Converts a string from one character set to another.
11556 * Note that you should use g_iconv() for streaming
11557 * conversions<footnoteref linkend="streaming-state"/>.
11559 * 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.
11564 * g_convert_with_fallback:
11565 * @str: the string to convert
11566 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11567 * @to_codeset: name of character set into which to convert @str
11568 * @from_codeset: character set of @str.
11569 * @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.
11570 * @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.
11571 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11572 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11574 * Converts a string from one character set to another, possibly
11575 * including fallback sequences for characters not representable
11576 * in the output. Note that it is not guaranteed that the specification
11577 * for the fallback sequences in @fallback will be honored. Some
11578 * systems may do an approximate conversion from @from_codeset
11579 * to @to_codeset in their iconv() functions,
11580 * in which case GLib will simply return that approximate conversion.
11582 * Note that you should use g_iconv() for streaming
11583 * conversions<footnoteref linkend="streaming-state"/>.
11585 * 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.
11590 * g_convert_with_iconv:
11591 * @str: the string to convert
11592 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11593 * @converter: conversion descriptor from g_iconv_open()
11594 * @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.
11595 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11596 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11598 * Converts a string from one character set to another.
11600 * Note that you should use g_iconv() for streaming
11601 * conversions<footnote id="streaming-state">
11603 * Despite the fact that @byes_read can return information about partial
11604 * characters, the <literal>g_convert_...</literal> functions
11605 * are not generally suitable for streaming. If the underlying converter
11606 * being used maintains internal state, then this won't be preserved
11607 * across successive calls to g_convert(), g_convert_with_iconv() or
11608 * g_convert_with_fallback(). (An example of this is the GNU C converter
11609 * for CP1255 which does not emit a base character until it knows that
11610 * the next character is not a mark that could combine with the base
11615 * 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.
11621 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11622 * @mode: as in creat()
11624 * A wrapper for the POSIX creat() function. The creat() function is
11625 * used to convert a pathname into a file descriptor, creating a file
11628 * On POSIX systems file descriptors are implemented by the operating
11629 * system. On Windows, it's the C library that implements creat() and
11630 * file descriptors. The actual Windows API for opening files is
11631 * different, see MSDN documentation for CreateFile(). The Win32 API
11632 * uses file handles, which are more randomish integers, not small
11633 * integers like file descriptors.
11635 * Because file descriptors are specific to the C library on Windows,
11636 * the file descriptor returned by this function makes sense only to
11637 * functions in the same C library. Thus if the GLib-using code uses a
11638 * different C library than GLib does, the file descriptor returned by
11639 * this function cannot be passed to C library functions like write()
11642 * See your C library manual for more details about creat().
11644 * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from creat().
11651 * @...: format string, followed by parameters to insert into the format string (as with printf())
11653 * Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
11654 * It's more or less application-defined what constitutes
11655 * a critical vs. a regular warning. You could call
11656 * g_log_set_always_fatal() to make critical warnings exit
11657 * the program, then use g_critical() for fatal errors, for
11660 * You can also make critical warnings fatal at runtime by
11661 * setting the <envar>G_DEBUG</envar> environment variable (see
11662 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
11667 * g_datalist_clear:
11668 * @datalist: a datalist.
11670 * Frees all the data elements of the datalist.
11671 * The data elements' destroy functions are called
11672 * if they have been set.
11677 * g_datalist_foreach:
11678 * @datalist: a datalist.
11679 * @func: the function to call for each data element.
11680 * @user_data: user data to pass to the function.
11682 * Calls the given function for each data element of the datalist. The
11683 * function is called with each data element's #GQuark id and data,
11684 * together with the given @user_data parameter. Note that this
11685 * function is NOT thread-safe. So unless @datalist can be protected
11686 * from any modifications during invocation of this function, it should
11692 * g_datalist_get_data:
11693 * @datalist: a datalist.
11694 * @key: the string identifying a data element.
11696 * Gets a data element, using its string identifier. This is slower than
11697 * g_datalist_id_get_data() because it compares strings.
11699 * Returns: the data element, or %NULL if it is not found.
11704 * g_datalist_get_flags:
11705 * @datalist: pointer to the location that holds a list
11707 * Gets flags values packed in together with the datalist.
11708 * See g_datalist_set_flags().
11710 * Returns: the flags of the datalist
11716 * g_datalist_id_dup_data:
11717 * @datalist: location of a datalist
11718 * @key_id: the #GQuark identifying a data element
11719 * @dup_func: (allow-none): function to duplicate the old value
11720 * @user_data: (allow-none): passed as user_data to @dup_func
11722 * This is a variant of g_datalist_id_get_data() which
11723 * returns a 'duplicate' of the value. @dup_func defines the
11724 * meaning of 'duplicate' in this context, it could e.g.
11725 * take a reference on a ref-counted object.
11727 * If the @key_id is not set in the datalist then @dup_func
11728 * will be called with a %NULL argument.
11730 * Note that @dup_func is called while the datalist is locked, so it
11731 * is not allowed to read or modify the datalist.
11733 * This function can be useful to avoid races when multiple
11734 * threads are using the same datalist and the same key.
11736 * 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.
11742 * g_datalist_id_get_data:
11743 * @datalist: a datalist.
11744 * @key_id: the #GQuark identifying a data element.
11746 * Retrieves the data element corresponding to @key_id.
11748 * Returns: the data element, or %NULL if it is not found.
11753 * g_datalist_id_remove_data:
11755 * @q: the #GQuark identifying the data element.
11757 * Removes an element, using its #GQuark identifier.
11762 * g_datalist_id_remove_no_notify:
11763 * @datalist: a datalist.
11764 * @key_id: the #GQuark identifying a data element.
11766 * Removes an element, without calling its destroy notification
11769 * Returns: the data previously stored at @key_id, or %NULL if none.
11774 * g_datalist_id_replace_data:
11775 * @datalist: location of a datalist
11776 * @key_id: the #GQuark identifying a data element
11777 * @oldval: (allow-none): the old value to compare against
11778 * @newval: (allow-none): the new value to replace it with
11779 * @destroy: (allow-none): destroy notify for the new value
11780 * @old_destroy: (allow-none): destroy notify for the existing value
11782 * Compares the member that is associated with @key_id in
11783 * @datalist to @oldval, and if they are the same, replace
11784 * @oldval with @newval.
11786 * This is like a typical atomic compare-and-exchange
11787 * operation, for a member of @datalist.
11789 * If the previous value was replaced then ownership of the
11790 * old value (@oldval) is passed to the caller, including
11791 * the registred destroy notify for it (passed out in @old_destroy).
11792 * Its up to the caller to free this as he wishes, which may
11793 * or may not include using @old_destroy as sometimes replacement
11794 * should not destroy the object in the normal way.
11796 * Return: %TRUE if the existing value for @key_id was replaced
11797 * by @newval, %FALSE otherwise.
11804 * g_datalist_id_set_data:
11806 * @q: the #GQuark to identify the data element.
11807 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @q.
11809 * Sets the data corresponding to the given #GQuark id. Any previous
11810 * data with the same key is removed, and its destroy function is
11816 * g_datalist_id_set_data_full:
11817 * @datalist: a datalist.
11818 * @key_id: the #GQuark to identify the data element.
11819 * @data: (allow-none): the data element or %NULL to remove any previous element corresponding to @key_id.
11820 * @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.
11822 * Sets the data corresponding to the given #GQuark id, and the
11823 * function to be called when the element is removed from the datalist.
11824 * Any previous data with the same key is removed, and its destroy
11825 * function is called.
11831 * @datalist: a pointer to a pointer to a datalist.
11833 * Resets the datalist to %NULL. It does not free any memory or call
11834 * any destroy functions.
11839 * g_datalist_remove_data:
11841 * @k: the string identifying the data element.
11843 * Removes an element using its string identifier. The data element's
11844 * destroy function is called if it has been set.
11849 * g_datalist_remove_no_notify:
11851 * @k: the string identifying the data element.
11853 * Removes an element, without calling its destroy notifier.
11858 * g_datalist_set_data:
11860 * @k: the string to identify the data element.
11861 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11863 * Sets the data element corresponding to the given string identifier.
11868 * g_datalist_set_data_full:
11870 * @k: the string to identify the data element.
11871 * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11872 * @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.
11874 * Sets the data element corresponding to the given string identifier,
11875 * and the function to be called when the data element is removed.
11880 * g_datalist_set_flags:
11881 * @datalist: pointer to the location that holds a list
11882 * @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.
11884 * Turns on flag values for a data list. This function is used
11885 * to keep a small number of boolean flags in an object with
11886 * a data list without using any additional space. It is
11887 * not generally useful except in circumstances where space
11888 * is very tight. (It is used in the base #GObject type, for
11896 * g_datalist_unset_flags:
11897 * @datalist: pointer to the location that holds a list
11898 * @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.
11900 * Turns off flag values for a data list. See g_datalist_unset_flags()
11907 * g_dataset_destroy:
11908 * @dataset_location: the location identifying the dataset.
11910 * Destroys the dataset, freeing all memory allocated, and calling any
11911 * destroy functions set for data elements.
11916 * g_dataset_foreach:
11917 * @dataset_location: the location identifying the dataset.
11918 * @func: the function to call for each data element.
11919 * @user_data: user data to pass to the function.
11921 * Calls the given function for each data element which is associated
11922 * with the given location. Note that this function is NOT thread-safe.
11923 * So unless @datalist can be protected from any modifications during
11924 * invocation of this function, it should not be called.
11929 * g_dataset_get_data:
11930 * @l: the location identifying the dataset.
11931 * @k: the string identifying the data element.
11933 * Gets the data element corresponding to a string.
11935 * Returns: the data element corresponding to the string, or %NULL if it is not found.
11940 * g_dataset_id_get_data:
11941 * @dataset_location: the location identifying the dataset.
11942 * @key_id: the #GQuark id to identify the data element.
11944 * Gets the data element corresponding to a #GQuark.
11946 * Returns: the data element corresponding to the #GQuark, or %NULL if it is not found.
11951 * g_dataset_id_remove_data:
11952 * @l: the location identifying the dataset.
11953 * @k: the #GQuark id identifying the data element.
11955 * Removes a data element from a dataset. The data element's destroy
11956 * function is called if it has been set.
11961 * g_dataset_id_remove_no_notify:
11962 * @dataset_location: the location identifying the dataset.
11963 * @key_id: the #GQuark ID identifying the data element.
11965 * Removes an element, without calling its destroy notification
11968 * Returns: the data previously stored at @key_id, or %NULL if none.
11973 * g_dataset_id_set_data:
11974 * @l: the location identifying the dataset.
11975 * @k: the #GQuark id to identify the data element.
11976 * @d: the data element.
11978 * Sets the data element associated with the given #GQuark id. Any
11979 * previous data with the same key is removed, and its destroy function
11985 * g_dataset_id_set_data_full:
11986 * @dataset_location: the location identifying the dataset.
11987 * @key_id: the #GQuark id to identify the data element.
11988 * @data: the data element.
11989 * @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.
11991 * Sets the data element associated with the given #GQuark id, and also
11992 * the function to call when the data element is destroyed. Any
11993 * previous data with the same key is removed, and its destroy function
11999 * g_dataset_remove_data:
12000 * @l: the location identifying the dataset.
12001 * @k: the string identifying the data element.
12003 * Removes a data element corresponding to a string. Its destroy
12004 * function is called if it has been set.
12009 * g_dataset_remove_no_notify:
12010 * @l: the location identifying the dataset.
12011 * @k: the string identifying the data element.
12013 * Removes an element, without calling its destroy notifier.
12018 * g_dataset_set_data:
12019 * @l: the location identifying the dataset.
12020 * @k: the string to identify the data element.
12021 * @d: the data element.
12023 * Sets the data corresponding to the given string identifier.
12028 * g_dataset_set_data_full:
12029 * @l: the location identifying the dataset.
12030 * @k: the string to identify the data element.
12031 * @d: the data element.
12032 * @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.
12034 * Sets the data corresponding to the given string identifier, and the
12035 * function to call when the data element is destroyed.
12041 * @date: a #GDate to increment
12042 * @n_days: number of days to move the date forward
12044 * Increments a date some number of days.
12045 * To move forward by weeks, add weeks*7 days.
12046 * The date must be valid.
12051 * g_date_add_months:
12052 * @date: a #GDate to increment
12053 * @n_months: number of months to move forward
12055 * Increments a date by some number of months.
12056 * If the day of the month is greater than 28,
12057 * this routine may change the day of the month
12058 * (because the destination month may not have
12059 * the current day in it). The date must be valid.
12064 * g_date_add_years:
12065 * @date: a #GDate to increment
12066 * @n_years: number of years to move forward
12068 * Increments a date by some number of years.
12069 * If the date is February 29, and the destination
12070 * year is not a leap year, the date will be changed
12071 * to February 28. The date must be valid.
12077 * @date: a #GDate to clamp
12078 * @min_date: minimum accepted value for @date
12079 * @max_date: maximum accepted value for @date
12081 * If @date is prior to @min_date, sets @date equal to @min_date.
12082 * If @date falls after @max_date, sets @date equal to @max_date.
12083 * Otherwise, @date is unchanged.
12084 * Either of @min_date and @max_date may be %NULL.
12085 * All non-%NULL dates must be valid.
12091 * @date: pointer to one or more dates to clear
12092 * @n_dates: number of dates to clear
12094 * Initializes one or more #GDate structs to a sane but invalid
12095 * state. The cleared dates will not represent an existing date, but will
12096 * not contain garbage. Useful to init a date declared on the stack.
12097 * Validity can be tested with g_date_valid().
12103 * @lhs: first date to compare
12104 * @rhs: second date to compare
12106 * qsort()-style comparison function for dates.
12107 * Both dates must be valid.
12109 * Returns: 0 for equal, less than zero if @lhs is less than @rhs, greater than zero if @lhs is greater than @rhs
12114 * g_date_days_between:
12115 * @date1: the first date
12116 * @date2: the second date
12118 * Computes the number of days between two dates.
12119 * If @date2 is prior to @date1, the returned value is negative.
12120 * Both dates must be valid.
12122 * Returns: the number of days between @date1 and @date2
12128 * @date: a #GDate to free
12130 * Frees a #GDate returned from g_date_new().
12136 * @date: a #GDate to extract the day of the month from
12138 * Returns the day of the month. The date must be valid.
12140 * Returns: day of the month
12145 * g_date_get_day_of_year:
12146 * @date: a #GDate to extract day of year from
12148 * Returns the day of the year, where Jan 1 is the first day of the
12149 * year. The date must be valid.
12151 * Returns: day of the year
12156 * g_date_get_days_in_month:
12160 * Returns the number of days in a month, taking leap
12161 * years into account.
12163 * Returns: number of days in @month during the @year
12168 * g_date_get_iso8601_week_of_year:
12169 * @date: a valid #GDate
12171 * Returns the week of the year, where weeks are interpreted according
12174 * Returns: ISO 8601 week number of the year.
12180 * g_date_get_julian:
12181 * @date: a #GDate to extract the Julian day from
12183 * Returns the Julian day or "serial number" of the #GDate. The
12184 * Julian day is simply the number of days since January 1, Year 1; i.e.,
12185 * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
12186 * etc. The date must be valid.
12188 * Returns: Julian day
12193 * g_date_get_monday_week_of_year:
12196 * Returns the week of the year, where weeks are understood to start on
12197 * Monday. If the date is before the first Monday of the year, return
12198 * 0. The date must be valid.
12200 * Returns: week of the year
12205 * g_date_get_monday_weeks_in_year:
12208 * Returns the number of weeks in the year, where weeks
12209 * are taken to start on Monday. Will be 52 or 53. The
12210 * date must be valid. (Years always have 52 7-day periods,
12211 * plus 1 or 2 extra days depending on whether it's a leap
12212 * year. This function is basically telling you how many
12213 * Mondays are in the year, i.e. there are 53 Mondays if
12214 * one of the extra days happens to be a Monday.)
12216 * Returns: number of Mondays in the year
12221 * g_date_get_month:
12222 * @date: a #GDate to get the month from
12224 * Returns the month of the year. The date must be valid.
12226 * Returns: month of the year as a #GDateMonth
12231 * g_date_get_sunday_week_of_year:
12234 * Returns the week of the year during which this date falls, if weeks
12235 * are understood to being on Sunday. The date must be valid. Can return
12236 * 0 if the day is before the first Sunday of the year.
12238 * Returns: week number
12243 * g_date_get_sunday_weeks_in_year:
12244 * @year: year to count weeks in
12246 * Returns the number of weeks in the year, where weeks
12247 * are taken to start on Sunday. Will be 52 or 53. The
12248 * date must be valid. (Years always have 52 7-day periods,
12249 * plus 1 or 2 extra days depending on whether it's a leap
12250 * year. This function is basically telling you how many
12251 * Sundays are in the year, i.e. there are 53 Sundays if
12252 * one of the extra days happens to be a Sunday.)
12254 * Returns: the number of weeks in @year
12259 * g_date_get_weekday:
12262 * Returns the day of the week for a #GDate. The date must be valid.
12264 * Returns: day of the week as a #GDateWeekday.
12272 * Returns the year of a #GDate. The date must be valid.
12274 * Returns: year in which the date falls
12279 * g_date_is_first_of_month:
12280 * @date: a #GDate to check
12282 * Returns %TRUE if the date is on the first of a month.
12283 * The date must be valid.
12285 * Returns: %TRUE if the date is the first of the month
12290 * g_date_is_last_of_month:
12291 * @date: a #GDate to check
12293 * Returns %TRUE if the date is the last day of the month.
12294 * The date must be valid.
12296 * Returns: %TRUE if the date is the last day of the month
12301 * g_date_is_leap_year:
12302 * @year: year to check
12304 * Returns %TRUE if the year is a leap year.
12305 * <footnote><para>For the purposes of this function,
12306 * leap year is every year divisible by 4 unless that year
12307 * is divisible by 100. If it is divisible by 100 it would
12308 * be a leap year only if that year is also divisible
12309 * by 400.</para></footnote>
12311 * Returns: %TRUE if the year is a leap year
12318 * Allocates a #GDate and initializes
12319 * it to a sane state. The new date will
12320 * be cleared (as if you'd called g_date_clear()) but invalid (it won't
12321 * represent an existing day). Free the return value with g_date_free().
12323 * Returns: a newly-allocated #GDate
12329 * @day: day of the month
12330 * @month: month of the year
12333 * Like g_date_new(), but also sets the value of the date. Assuming the
12334 * day-month-year triplet you pass in represents an existing day, the
12335 * returned date will be valid.
12337 * Returns: a newly-allocated #GDate initialized with @day, @month, and @year
12342 * g_date_new_julian:
12343 * @julian_day: days since January 1, Year 1
12345 * Like g_date_new(), but also sets the value of the date. Assuming the
12346 * Julian day number you pass in is valid (greater than 0, less than an
12347 * unreasonably large number), the returned date will be valid.
12349 * Returns: a newly-allocated #GDate initialized with @julian_day
12355 * @date1: the first date
12356 * @date2: the second date
12358 * Checks if @date1 is less than or equal to @date2,
12359 * and swap the values if this is not the case.
12368 * Sets the day of the month for a #GDate. If the resulting
12369 * day-month-year triplet is invalid, the date will be invalid.
12380 * Sets the value of a #GDate from a day, month, and year.
12381 * The day-month-year triplet must be valid; if you aren't
12382 * sure it is, call g_date_valid_dmy() to check before you
12388 * g_date_set_julian:
12390 * @julian_date: Julian day number (days since January 1, Year 1)
12392 * Sets the value of a #GDate from a Julian day number.
12397 * g_date_set_month:
12399 * @month: month to set
12401 * Sets the month of the year for a #GDate. If the resulting
12402 * day-month-year triplet is invalid, the date will be invalid.
12407 * g_date_set_parse:
12408 * @date: a #GDate to fill in
12409 * @str: string to parse
12411 * Parses a user-inputted string @str, and try to figure out what date it
12412 * represents, taking the <link linkend="setlocale">current locale</link>
12413 * into account. If the string is successfully parsed, the date will be
12414 * valid after the call. Otherwise, it will be invalid. You should check
12415 * using g_date_valid() to see whether the parsing succeeded.
12417 * This function is not appropriate for file formats and the like; it
12418 * isn't very precise, and its exact behavior varies with the locale.
12419 * It's intended to be a heuristic routine that guesses what the user
12420 * means by a given string (and it does work pretty well in that
12428 * @time_: #GTime value to set.
12430 * Sets the value of a date from a #GTime value.
12431 * The time to date conversion is done using the user's current timezone.
12433 * Deprecated: 2.10: Use g_date_set_time_t() instead.
12438 * g_date_set_time_t:
12440 * @timet: <type>time_t</type> value to set
12442 * Sets the value of a date to the date corresponding to a time
12443 * specified as a time_t. The time to date conversion is done using
12444 * the user's current timezone.
12446 * To set the value of a date to the current day, you could write:
12448 * g_date_set_time_t (date, time (NULL));
12456 * g_date_set_time_val:
12458 * @timeval: #GTimeVal value to set
12460 * Sets the value of a date from a #GTimeVal value. Note that the
12461 * @tv_usec member is ignored, because #GDate can't make use of the
12462 * additional precision.
12464 * The time to date conversion is done using the user's current timezone.
12473 * @year: year to set
12475 * Sets the year for a #GDate. If the resulting day-month-year
12476 * triplet is invalid, the date will be invalid.
12482 * @s: destination buffer
12483 * @slen: buffer size
12484 * @format: format string
12485 * @date: valid #GDate
12487 * Generates a printed representation of the date, in a
12488 * <link linkend="setlocale">locale</link>-specific way.
12489 * Works just like the platform's C library strftime() function,
12490 * but only accepts date-related formats; time-related formats
12491 * give undefined results. Date must be valid. Unlike strftime()
12492 * (which uses the locale encoding), works on a UTF-8 format
12493 * string and stores a UTF-8 result.
12495 * This function does not provide any conversion specifiers in
12496 * addition to those implemented by the platform's C library.
12497 * For example, don't expect that using g_date_strftime() would
12498 * make the \%F provided by the C99 strftime() work on Windows
12499 * where the C library only complies to C89.
12501 * Returns: number of characters written to the buffer, or 0 the buffer was too small
12506 * g_date_subtract_days:
12507 * @date: a #GDate to decrement
12508 * @n_days: number of days to move
12510 * Moves a date some number of days into the past.
12511 * To move by weeks, just move by weeks*7 days.
12512 * The date must be valid.
12517 * g_date_subtract_months:
12518 * @date: a #GDate to decrement
12519 * @n_months: number of months to move
12521 * Moves a date some number of months into the past.
12522 * If the current day of the month doesn't exist in
12523 * the destination month, the day of the month
12524 * may change. The date must be valid.
12529 * g_date_subtract_years:
12530 * @date: a #GDate to decrement
12531 * @n_years: number of years to move
12533 * Moves a date some number of years into the past.
12534 * If the current day doesn't exist in the destination
12535 * year (i.e. it's February 29 and you move to a non-leap-year)
12536 * then the day is changed to February 29. The date
12543 * @datetime: a #GDateTime
12544 * @timespan: a #GTimeSpan
12546 * Creates a copy of @datetime and adds the specified timespan to the copy.
12548 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12554 * g_date_time_add_days:
12555 * @datetime: a #GDateTime
12556 * @days: the number of days
12558 * Creates a copy of @datetime and adds the specified number of days to the
12561 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12567 * g_date_time_add_full:
12568 * @datetime: a #GDateTime
12569 * @years: the number of years to add
12570 * @months: the number of months to add
12571 * @days: the number of days to add
12572 * @hours: the number of hours to add
12573 * @minutes: the number of minutes to add
12574 * @seconds: the number of seconds to add
12576 * Creates a new #GDateTime adding the specified values to the current date and
12577 * time in @datetime.
12579 * Returns: the newly created #GDateTime that should be freed with g_date_time_unref().
12585 * g_date_time_add_hours:
12586 * @datetime: a #GDateTime
12587 * @hours: the number of hours to add
12589 * Creates a copy of @datetime and adds the specified number of hours
12591 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12597 * g_date_time_add_minutes:
12598 * @datetime: a #GDateTime
12599 * @minutes: the number of minutes to add
12601 * Creates a copy of @datetime adding the specified number of minutes.
12603 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12609 * g_date_time_add_months:
12610 * @datetime: a #GDateTime
12611 * @months: the number of months
12613 * Creates a copy of @datetime and adds the specified number of months to the
12616 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12622 * g_date_time_add_seconds:
12623 * @datetime: a #GDateTime
12624 * @seconds: the number of seconds to add
12626 * Creates a copy of @datetime and adds the specified number of seconds.
12628 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12634 * g_date_time_add_weeks:
12635 * @datetime: a #GDateTime
12636 * @weeks: the number of weeks
12638 * Creates a copy of @datetime and adds the specified number of weeks to the
12641 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12647 * g_date_time_add_years:
12648 * @datetime: a #GDateTime
12649 * @years: the number of years
12651 * Creates a copy of @datetime and adds the specified number of years to the
12654 * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12660 * g_date_time_compare:
12661 * @dt1: first #GDateTime to compare
12662 * @dt2: second #GDateTime to compare
12664 * A comparison function for #GDateTimes that is suitable
12665 * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
12667 * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater than @dt2.
12673 * g_date_time_difference:
12674 * @end: a #GDateTime
12675 * @begin: a #GDateTime
12677 * Calculates the difference in time between @end and @begin. The
12678 * #GTimeSpan that is returned is effectively @end - @begin (ie:
12679 * positive if the first parameter is larger).
12681 * Returns: the difference between the two #GDateTime, as a time span expressed in microseconds.
12687 * g_date_time_equal:
12688 * @dt1: a #GDateTime
12689 * @dt2: a #GDateTime
12691 * Checks to see if @dt1 and @dt2 are equal.
12693 * Equal here means that they represent the same moment after converting
12694 * them to the same time zone.
12696 * Returns: %TRUE if @dt1 and @dt2 are equal
12702 * g_date_time_format:
12703 * @datetime: A #GDateTime
12704 * @format: a valid UTF-8 string, containing the format for the #GDateTime
12706 * Creates a newly allocated string representing the requested @format.
12708 * The format strings understood by this function are a subset of the
12709 * strftime() format language as specified by C99. The \%D, \%U and \%W
12710 * conversions are not supported, nor is the 'E' modifier. The GNU
12711 * extensions \%k, \%l, \%s and \%P are supported, however, as are the
12712 * '0', '_' and '-' modifiers.
12714 * In contrast to strftime(), this function always produces a UTF-8
12715 * string, regardless of the current locale. Note that the rendering of
12716 * many formats is locale-dependent and may not match the strftime()
12719 * The following format specifiers are supported:
12722 * <varlistentry><term>
12723 * <literal>\%a</literal>:
12724 * </term><listitem><simpara>
12725 * the abbreviated weekday name according to the current locale
12726 * </simpara></listitem></varlistentry>
12727 * <varlistentry><term>
12728 * <literal>\%A</literal>:
12729 * </term><listitem><simpara>
12730 * the full weekday name according to the current locale
12731 * </simpara></listitem></varlistentry>
12732 * <varlistentry><term>
12733 * <literal>\%b</literal>:
12734 * </term><listitem><simpara>
12735 * the abbreviated month name according to the current locale
12736 * </simpara></listitem></varlistentry>
12737 * <varlistentry><term>
12738 * <literal>\%B</literal>:
12739 * </term><listitem><simpara>
12740 * the full month name according to the current locale
12741 * </simpara></listitem></varlistentry>
12742 * <varlistentry><term>
12743 * <literal>\%c</literal>:
12744 * </term><listitem><simpara>
12745 * the preferred date and time representation for the current locale
12746 * </simpara></listitem></varlistentry>
12747 * <varlistentry><term>
12748 * <literal>\%C</literal>:
12749 * </term><listitem><simpara>
12750 * The century number (year/100) as a 2-digit integer (00-99)
12751 * </simpara></listitem></varlistentry>
12752 * <varlistentry><term>
12753 * <literal>\%d</literal>:
12754 * </term><listitem><simpara>
12755 * the day of the month as a decimal number (range 01 to 31)
12756 * </simpara></listitem></varlistentry>
12757 * <varlistentry><term>
12758 * <literal>\%e</literal>:
12759 * </term><listitem><simpara>
12760 * the day of the month as a decimal number (range 1 to 31)
12761 * </simpara></listitem></varlistentry>
12762 * <varlistentry><term>
12763 * <literal>\%F</literal>:
12764 * </term><listitem><simpara>
12765 * equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
12767 * </simpara></listitem></varlistentry>
12768 * <varlistentry><term>
12769 * <literal>\%g</literal>:
12770 * </term><listitem><simpara>
12771 * the last two digits of the ISO 8601 week-based year as a decimal
12772 * number (00-99). This works well with \%V and \%u.
12773 * </simpara></listitem></varlistentry>
12774 * <varlistentry><term>
12775 * <literal>\%G</literal>:
12776 * </term><listitem><simpara>
12777 * the ISO 8601 week-based year as a decimal number. This works well
12778 * with \%V and \%u.
12779 * </simpara></listitem></varlistentry>
12780 * <varlistentry><term>
12781 * <literal>\%h</literal>:
12782 * </term><listitem><simpara>
12783 * equivalent to <literal>\%b</literal>
12784 * </simpara></listitem></varlistentry>
12785 * <varlistentry><term>
12786 * <literal>\%H</literal>:
12787 * </term><listitem><simpara>
12788 * the hour as a decimal number using a 24-hour clock (range 00 to
12790 * </simpara></listitem></varlistentry>
12791 * <varlistentry><term>
12792 * <literal>\%I</literal>:
12793 * </term><listitem><simpara>
12794 * the hour as a decimal number using a 12-hour clock (range 01 to
12796 * </simpara></listitem></varlistentry>
12797 * <varlistentry><term>
12798 * <literal>\%j</literal>:
12799 * </term><listitem><simpara>
12800 * the day of the year as a decimal number (range 001 to 366)
12801 * </simpara></listitem></varlistentry>
12802 * <varlistentry><term>
12803 * <literal>\%k</literal>:
12804 * </term><listitem><simpara>
12805 * the hour (24-hour clock) as a decimal number (range 0 to 23);
12806 * single digits are preceded by a blank
12807 * </simpara></listitem></varlistentry>
12808 * <varlistentry><term>
12809 * <literal>\%l</literal>:
12810 * </term><listitem><simpara>
12811 * the hour (12-hour clock) as a decimal number (range 1 to 12);
12812 * single digits are preceded by a blank
12813 * </simpara></listitem></varlistentry>
12814 * <varlistentry><term>
12815 * <literal>\%m</literal>:
12816 * </term><listitem><simpara>
12817 * the month as a decimal number (range 01 to 12)
12818 * </simpara></listitem></varlistentry>
12819 * <varlistentry><term>
12820 * <literal>\%M</literal>:
12821 * </term><listitem><simpara>
12822 * the minute as a decimal number (range 00 to 59)
12823 * </simpara></listitem></varlistentry>
12824 * <varlistentry><term>
12825 * <literal>\%p</literal>:
12826 * </term><listitem><simpara>
12827 * either "AM" or "PM" according to the given time value, or the
12828 * corresponding strings for the current locale. Noon is treated as
12829 * "PM" and midnight as "AM".
12830 * </simpara></listitem></varlistentry>
12831 * <varlistentry><term>
12832 * <literal>\%P</literal>:
12833 * </term><listitem><simpara>
12834 * like \%p but lowercase: "am" or "pm" or a corresponding string for
12835 * the current locale
12836 * </simpara></listitem></varlistentry>
12837 * <varlistentry><term>
12838 * <literal>\%r</literal>:
12839 * </term><listitem><simpara>
12840 * the time in a.m. or p.m. notation
12841 * </simpara></listitem></varlistentry>
12842 * <varlistentry><term>
12843 * <literal>\%R</literal>:
12844 * </term><listitem><simpara>
12845 * the time in 24-hour notation (<literal>\%H:\%M</literal>)
12846 * </simpara></listitem></varlistentry>
12847 * <varlistentry><term>
12848 * <literal>\%s</literal>:
12849 * </term><listitem><simpara>
12850 * the number of seconds since the Epoch, that is, since 1970-01-01
12852 * </simpara></listitem></varlistentry>
12853 * <varlistentry><term>
12854 * <literal>\%S</literal>:
12855 * </term><listitem><simpara>
12856 * the second as a decimal number (range 00 to 60)
12857 * </simpara></listitem></varlistentry>
12858 * <varlistentry><term>
12859 * <literal>\%t</literal>:
12860 * </term><listitem><simpara>
12862 * </simpara></listitem></varlistentry>
12863 * <varlistentry><term>
12864 * <literal>\%T</literal>:
12865 * </term><listitem><simpara>
12866 * the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
12867 * </simpara></listitem></varlistentry>
12868 * <varlistentry><term>
12869 * <literal>\%u</literal>:
12870 * </term><listitem><simpara>
12871 * the ISO 8601 standard day of the week as a decimal, range 1 to 7,
12872 * Monday being 1. This works well with \%G and \%V.
12873 * </simpara></listitem></varlistentry>
12874 * <varlistentry><term>
12875 * <literal>\%V</literal>:
12876 * </term><listitem><simpara>
12877 * the ISO 8601 standard week number of the current year as a decimal
12878 * number, range 01 to 53, where week 1 is the first week that has at
12879 * least 4 days in the new year. See g_date_time_get_week_of_year().
12880 * This works well with \%G and \%u.
12881 * </simpara></listitem></varlistentry>
12882 * <varlistentry><term>
12883 * <literal>\%w</literal>:
12884 * </term><listitem><simpara>
12885 * the day of the week as a decimal, range 0 to 6, Sunday being 0.
12886 * This is not the ISO 8601 standard format -- use \%u instead.
12887 * </simpara></listitem></varlistentry>
12888 * <varlistentry><term>
12889 * <literal>\%x</literal>:
12890 * </term><listitem><simpara>
12891 * the preferred date representation for the current locale without
12893 * </simpara></listitem></varlistentry>
12894 * <varlistentry><term>
12895 * <literal>\%X</literal>:
12896 * </term><listitem><simpara>
12897 * the preferred time representation for the current locale without
12899 * </simpara></listitem></varlistentry>
12900 * <varlistentry><term>
12901 * <literal>\%y</literal>:
12902 * </term><listitem><simpara>
12903 * the year as a decimal number without the century
12904 * </simpara></listitem></varlistentry>
12905 * <varlistentry><term>
12906 * <literal>\%Y</literal>:
12907 * </term><listitem><simpara>
12908 * the year as a decimal number including the century
12909 * </simpara></listitem></varlistentry>
12910 * <varlistentry><term>
12911 * <literal>\%z</literal>:
12912 * </term><listitem><simpara>
12913 * the time zone as an offset from UTC (+hhmm)
12914 * </simpara></listitem></varlistentry>
12915 * <varlistentry><term>
12916 * <literal>\%:z</literal>:
12917 * </term><listitem><simpara>
12918 * the time zone as an offset from UTC (+hh:mm). This is a gnulib strftime extension. Since: 2.38
12919 * </simpara></listitem></varlistentry>
12920 * <varlistentry><term>
12921 * <literal>\%::z</literal>:
12922 * </term><listitem><simpara>
12923 * the time zone as an offset from UTC (+hh:mm:ss). This is a gnulib strftime extension. Since: 2.38
12924 * </simpara></listitem></varlistentry>
12925 * <varlistentry><term>
12926 * <literal>\%:::z</literal>:
12927 * </term><listitem><simpara>
12928 * the time zone as an offset from UTC, with : to necessary precision
12929 * (e.g., -04, +05:30). This is a gnulib strftime extension. Since: 2.38
12930 * </simpara></listitem></varlistentry>
12931 * <varlistentry><term>
12932 * <literal>\%Z</literal>:
12933 * </term><listitem><simpara>
12934 * the time zone or name or abbreviation
12935 * </simpara></listitem></varlistentry>
12936 * <varlistentry><term>
12937 * <literal>\%\%</literal>:
12938 * </term><listitem><simpara>
12939 * a literal <literal>\%</literal> character
12940 * </simpara></listitem></varlistentry>
12943 * Some conversion specifications can be modified by preceding the
12944 * conversion specifier by one or more modifier characters. The
12945 * following modifiers are supported for many of the numeric
12951 * Use alternative numeric symbols, if the current locale
12958 * Pad a numeric result with spaces.
12959 * This overrides the default padding for the specifier.
12965 * Do not pad a numeric result.
12966 * This overrides the default padding for the specifier.
12972 * Pad a numeric result with zeros.
12973 * This overrides the default padding for the specifier.
12978 * 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().
12984 * g_date_time_get_day_of_month:
12985 * @datetime: a #GDateTime
12987 * Retrieves the day of the month represented by @datetime in the gregorian
12990 * Returns: the day of the month
12996 * g_date_time_get_day_of_week:
12997 * @datetime: a #GDateTime
12999 * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
13000 * Monday, 2 is Tuesday... 7 is Sunday).
13002 * Returns: the day of the week
13008 * g_date_time_get_day_of_year:
13009 * @datetime: a #GDateTime
13011 * Retrieves the day of the year represented by @datetime in the Gregorian
13014 * Returns: the day of the year
13020 * g_date_time_get_hour:
13021 * @datetime: a #GDateTime
13023 * Retrieves the hour of the day represented by @datetime
13025 * Returns: the hour of the day
13031 * g_date_time_get_microsecond:
13032 * @datetime: a #GDateTime
13034 * Retrieves the microsecond of the date represented by @datetime
13036 * Returns: the microsecond of the second
13042 * g_date_time_get_minute:
13043 * @datetime: a #GDateTime
13045 * Retrieves the minute of the hour represented by @datetime
13047 * Returns: the minute of the hour
13053 * g_date_time_get_month:
13054 * @datetime: a #GDateTime
13056 * Retrieves the month of the year represented by @datetime in the Gregorian
13059 * Returns: the month represented by @datetime
13065 * g_date_time_get_second:
13066 * @datetime: a #GDateTime
13068 * Retrieves the second of the minute represented by @datetime
13070 * Returns: the second represented by @datetime
13076 * g_date_time_get_seconds:
13077 * @datetime: a #GDateTime
13079 * Retrieves the number of seconds since the start of the last minute,
13080 * including the fractional part.
13082 * Returns: the number of seconds
13088 * g_date_time_get_timezone_abbreviation:
13089 * @datetime: a #GDateTime
13091 * Determines the time zone abbreviation to be used at the time and in
13092 * the time zone of @datetime.
13094 * For example, in Toronto this is currently "EST" during the winter
13095 * months and "EDT" during the summer months when daylight savings
13096 * time is in effect.
13098 * Returns: (transfer none): the time zone abbreviation. The returned string is owned by the #GDateTime and it should not be modified or freed
13104 * g_date_time_get_utc_offset:
13105 * @datetime: a #GDateTime
13107 * Determines the offset to UTC in effect at the time and in the time
13108 * zone of @datetime.
13110 * The offset is the number of microseconds that you add to UTC time to
13111 * arrive at local time for the time zone (ie: negative numbers for time
13112 * zones west of GMT, positive numbers for east).
13114 * If @datetime represents UTC time, then the offset is always zero.
13116 * Returns: the number of microseconds that should be added to UTC to get the local time
13122 * g_date_time_get_week_numbering_year:
13123 * @datetime: a #GDateTime
13125 * Returns the ISO 8601 week-numbering year in which the week containing
13128 * This function, taken together with g_date_time_get_week_of_year() and
13129 * g_date_time_get_day_of_week() can be used to determine the full ISO
13130 * week date on which @datetime falls.
13132 * This is usually equal to the normal Gregorian year (as returned by
13133 * g_date_time_get_year()), except as detailed below:
13135 * For Thursday, the week-numbering year is always equal to the usual
13136 * calendar year. For other days, the number is such that every day
13137 * within a complete week (Monday to Sunday) is contained within the
13138 * same week-numbering year.
13140 * For Monday, Tuesday and Wednesday occurring near the end of the year,
13141 * this may mean that the week-numbering year is one greater than the
13142 * calendar year (so that these days have the same week-numbering year
13143 * as the Thursday occurring early in the next year).
13145 * For Friday, Saturaday and Sunday occurring near the start of the year,
13146 * this may mean that the week-numbering year is one less than the
13147 * calendar year (so that these days have the same week-numbering year
13148 * as the Thursday occurring late in the previous year).
13150 * An equivalent description is that the week-numbering year is equal to
13151 * the calendar year containing the majority of the days in the current
13152 * week (Monday to Sunday).
13154 * Note that January 1 0001 in the proleptic Gregorian calendar is a
13155 * Monday, so this function never returns 0.
13157 * Returns: the ISO 8601 week-numbering year for @datetime
13163 * g_date_time_get_week_of_year:
13164 * @datetime: a #GDateTime
13166 * Returns the ISO 8601 week number for the week containing @datetime.
13167 * The ISO 8601 week number is the same for every day of the week (from
13168 * Moday through Sunday). That can produce some unusual results
13169 * (described below).
13171 * The first week of the year is week 1. This is the week that contains
13172 * the first Thursday of the year. Equivalently, this is the first week
13173 * that has more than 4 of its days falling within the calendar year.
13175 * The value 0 is never returned by this function. Days contained
13176 * within a year but occurring before the first ISO 8601 week of that
13177 * year are considered as being contained in the last week of the
13178 * previous year. Similarly, the final days of a calendar year may be
13179 * considered as being part of the first ISO 8601 week of the next year
13180 * if 4 or more days of that week are contained within the new year.
13182 * Returns: the ISO 8601 week number for @datetime.
13188 * g_date_time_get_year:
13189 * @datetime: A #GDateTime
13191 * Retrieves the year represented by @datetime in the Gregorian calendar.
13193 * Returns: the year represented by @datetime
13199 * g_date_time_get_ymd:
13200 * @datetime: a #GDateTime.
13201 * @year: (out) (allow-none): the return location for the gregorian year, or %NULL.
13202 * @month: (out) (allow-none): the return location for the month of the year, or %NULL.
13203 * @day: (out) (allow-none): the return location for the day of the month, or %NULL.
13205 * Retrieves the Gregorian day, month, and year of a given #GDateTime.
13212 * g_date_time_hash:
13213 * @datetime: a #GDateTime
13215 * Hashes @datetime into a #guint, suitable for use within #GHashTable.
13217 * Returns: a #guint containing the hash
13223 * g_date_time_is_daylight_savings:
13224 * @datetime: a #GDateTime
13226 * Determines if daylight savings time is in effect at the time and in
13227 * the time zone of @datetime.
13229 * Returns: %TRUE if daylight savings time is in effect
13236 * @tz: a #GTimeZone
13237 * @year: the year component of the date
13238 * @month: the month component of the date
13239 * @day: the day component of the date
13240 * @hour: the hour component of the date
13241 * @minute: the minute component of the date
13242 * @seconds: the number of seconds past the minute
13244 * Creates a new #GDateTime corresponding to the given date and time in
13245 * the time zone @tz.
13247 * The @year must be between 1 and 9999, @month between 1 and 12 and @day
13248 * between 1 and 28, 29, 30 or 31 depending on the month and the year.
13250 * @hour must be between 0 and 23 and @minute must be between 0 and 59.
13252 * @seconds must be at least 0.0 and must be strictly less than 60.0.
13253 * It will be rounded down to the nearest microsecond.
13255 * If the given time is not representable in the given time zone (for
13256 * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
13257 * time) then the time will be rounded up to the nearest existing time
13258 * (in this case, 03:00). If this matters to you then you should verify
13259 * the return value for containing the same as the numbers you gave.
13261 * In the case that the given time is ambiguous in the given time zone
13262 * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
13263 * savings time) then the time falling within standard (ie:
13264 * non-daylight) time is taken.
13266 * It not considered a programmer error for the values to this function
13267 * to be out of range, but in the case that they are, the function will
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_from_timeval_local:
13282 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
13285 * The time contained in a #GTimeVal is always stored in the form of
13286 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
13287 * local time offset.
13289 * This call can fail (returning %NULL) if @tv represents a time outside
13290 * of the supported range of #GDateTime.
13292 * You should release the return value by calling g_date_time_unref()
13293 * when you are done with it.
13295 * Returns: a new #GDateTime, or %NULL
13301 * g_date_time_new_from_timeval_utc:
13304 * Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
13306 * The time contained in a #GTimeVal is always stored in the form of
13307 * seconds elapsed since 1970-01-01 00:00:00 UTC.
13309 * This call can fail (returning %NULL) if @tv represents a time outside
13310 * of the supported range of #GDateTime.
13312 * You should release the return value by calling g_date_time_unref()
13313 * when you are done with it.
13315 * Returns: a new #GDateTime, or %NULL
13321 * g_date_time_new_from_unix_local:
13322 * @t: the Unix time
13324 * Creates a #GDateTime corresponding to the given Unix time @t in the
13327 * Unix time is the number of seconds that have elapsed since 1970-01-01
13328 * 00:00:00 UTC, regardless of the local time offset.
13330 * This call can fail (returning %NULL) if @t represents a time outside
13331 * of the supported range of #GDateTime.
13333 * You should release the return value by calling g_date_time_unref()
13334 * when you are done with it.
13336 * Returns: a new #GDateTime, or %NULL
13342 * g_date_time_new_from_unix_utc:
13343 * @t: the Unix time
13345 * Creates a #GDateTime corresponding to the given Unix time @t in UTC.
13347 * Unix time is the number of seconds that have elapsed since 1970-01-01
13350 * This call can fail (returning %NULL) if @t represents a time outside
13351 * of the supported range of #GDateTime.
13353 * You should release the return value by calling g_date_time_unref()
13354 * when you are done with it.
13356 * Returns: a new #GDateTime, or %NULL
13362 * g_date_time_new_local:
13363 * @year: the year component of the date
13364 * @month: the month component of the date
13365 * @day: the day component of the date
13366 * @hour: the hour component of the date
13367 * @minute: the minute component of the date
13368 * @seconds: the number of seconds past the minute
13370 * Creates a new #GDateTime corresponding to the given date and time in
13371 * the local time zone.
13373 * This call is equivalent to calling g_date_time_new() with the time
13374 * zone returned by g_time_zone_new_local().
13376 * Returns: a #GDateTime, or %NULL
13382 * g_date_time_new_now:
13383 * @tz: a #GTimeZone
13385 * Creates a #GDateTime corresponding to this exact instant in the given
13386 * time zone @tz. The time is as accurate as the system allows, to a
13387 * maximum accuracy of 1 microsecond.
13389 * This function will always succeed unless the system clock is set to
13390 * truly insane values (or unless GLib is still being used after the
13393 * You should release the return value by calling g_date_time_unref()
13394 * when you are done with it.
13396 * Returns: a new #GDateTime, or %NULL
13402 * g_date_time_new_now_local:
13404 * Creates a #GDateTime corresponding to this exact instant in the local
13407 * This is equivalent to calling g_date_time_new_now() with the time
13408 * zone returned by g_time_zone_new_local().
13410 * Returns: a new #GDateTime, or %NULL
13416 * g_date_time_new_now_utc:
13418 * Creates a #GDateTime corresponding to this exact instant in UTC.
13420 * This is equivalent to calling g_date_time_new_now() with the time
13421 * zone returned by g_time_zone_new_utc().
13423 * Returns: a new #GDateTime, or %NULL
13429 * g_date_time_new_utc:
13430 * @year: the year component of the date
13431 * @month: the month component of the date
13432 * @day: the day component of the date
13433 * @hour: the hour component of the date
13434 * @minute: the minute component of the date
13435 * @seconds: the number of seconds past the minute
13437 * Creates a new #GDateTime corresponding to the given date and time in
13440 * This call is equivalent to calling g_date_time_new() with the time
13441 * zone returned by g_time_zone_new_utc().
13443 * Returns: a #GDateTime, or %NULL
13450 * @datetime: a #GDateTime
13452 * Atomically increments the reference count of @datetime by one.
13454 * Returns: the #GDateTime with the reference count increased
13460 * g_date_time_to_local:
13461 * @datetime: a #GDateTime
13463 * Creates a new #GDateTime corresponding to the same instant in time as
13464 * @datetime, but in the local time zone.
13466 * This call is equivalent to calling g_date_time_to_timezone() with the
13467 * time zone returned by g_time_zone_new_local().
13469 * Returns: the newly created #GDateTime
13475 * g_date_time_to_timeval:
13476 * @datetime: a #GDateTime
13477 * @tv: a #GTimeVal to modify
13479 * Stores the instant in time that @datetime represents into @tv.
13481 * The time contained in a #GTimeVal is always stored in the form of
13482 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
13483 * zone associated with @datetime.
13485 * On systems where 'long' is 32bit (ie: all 32bit systems and all
13486 * Windows systems), a #GTimeVal is incapable of storing the entire
13487 * range of values that #GDateTime is capable of expressing. On those
13488 * systems, this function returns %FALSE to indicate that the time is
13491 * On systems where 'long' is 64bit, this function never fails.
13493 * Returns: %TRUE if successful, else %FALSE
13499 * g_date_time_to_timezone:
13500 * @datetime: a #GDateTime
13501 * @tz: the new #GTimeZone
13503 * Create a new #GDateTime corresponding to the same instant in time as
13504 * @datetime, but in the time zone @tz.
13506 * This call can fail in the case that the time goes out of bounds. For
13507 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
13508 * Greenwich will fail (due to the year 0 being out of range).
13510 * You should release the return value by calling g_date_time_unref()
13511 * when you are done with it.
13513 * Returns: a new #GDateTime, or %NULL
13519 * g_date_time_to_unix:
13520 * @datetime: a #GDateTime
13522 * Gives the Unix time corresponding to @datetime, rounding down to the
13525 * Unix time is the number of seconds that have elapsed since 1970-01-01
13526 * 00:00:00 UTC, regardless of the time zone associated with @datetime.
13528 * Returns: the Unix time corresponding to @datetime
13534 * g_date_time_to_utc:
13535 * @datetime: a #GDateTime
13537 * Creates a new #GDateTime corresponding to the same instant in time as
13538 * @datetime, but in UTC.
13540 * This call is equivalent to calling g_date_time_to_timezone() with the
13541 * time zone returned by g_time_zone_new_utc().
13543 * Returns: the newly created #GDateTime
13549 * g_date_time_unref:
13550 * @datetime: a #GDateTime
13552 * Atomically decrements the reference count of @datetime by one.
13554 * When the reference count reaches zero, the resources allocated by
13555 * @datetime are freed
13562 * g_date_to_struct_tm:
13563 * @date: a #GDate to set the <structname>struct tm</structname> from
13564 * @tm: <structname>struct tm</structname> to fill
13566 * Fills in the date-related bits of a <structname>struct tm</structname>
13567 * using the @date value. Initializes the non-date parts with something
13568 * sane but meaningless.
13574 * @date: a #GDate to check
13576 * Returns %TRUE if the #GDate represents an existing day. The date must not
13577 * contain garbage; it should have been initialized with g_date_clear()
13578 * if it wasn't allocated by one of the g_date_new() variants.
13580 * Returns: Whether the date is valid
13585 * g_date_valid_day:
13586 * @day: day to check
13588 * Returns %TRUE if the day of the month is valid (a day is valid if it's
13589 * between 1 and 31 inclusive).
13591 * Returns: %TRUE if the day is valid
13596 * g_date_valid_dmy:
13601 * Returns %TRUE if the day-month-year triplet forms a valid, existing day
13602 * in the range of days #GDate understands (Year 1 or later, no more than
13603 * a few thousand years in the future).
13605 * Returns: %TRUE if the date is a valid one
13610 * g_date_valid_julian:
13611 * @julian_date: Julian day to check
13613 * Returns %TRUE if the Julian day is valid. Anything greater than zero
13614 * is basically a valid Julian, though there is a 32-bit limit.
13616 * Returns: %TRUE if the Julian day is valid
13621 * g_date_valid_month:
13624 * Returns %TRUE if the month value is valid. The 12 #GDateMonth
13625 * enumeration values are the only valid months.
13627 * Returns: %TRUE if the month is valid
13632 * g_date_valid_weekday:
13633 * @weekday: weekday
13635 * Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
13636 * values are the only valid weekdays.
13638 * Returns: %TRUE if the weekday is valid
13643 * g_date_valid_year:
13646 * Returns %TRUE if the year is valid. Any year greater than 0 is valid,
13647 * though there is a 16-bit limit to what #GDate will understand.
13649 * Returns: %TRUE if the year is valid
13655 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13656 * @msgid: message to translate
13657 * @category: a locale category
13659 * This is a variant of g_dgettext() that allows specifying a locale
13660 * category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
13661 * more information about how this functions differs from calling
13662 * dcgettext() directly.
13664 * Returns: the translated string for the given locale category
13671 * @...: format string, followed by parameters to insert into the format string (as with printf())
13673 * A convenience function/macro to log a debug message.
13681 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13682 * @msgid: message to translate
13684 * This function is a wrapper of dgettext() which does not translate
13685 * the message if the default domain as set with textdomain() has no
13686 * translations for the current locale.
13688 * The advantage of using this function over dgettext() proper is that
13689 * libraries using this function (like GTK+) will not use translations
13690 * if the application using the library does not have translations for
13691 * the current locale. This results in a consistent English-only
13692 * interface instead of one having partial translations. For this
13693 * feature to work, the call to textdomain() and setlocale() should
13694 * precede any g_dgettext() invocations. For GTK+, it means calling
13695 * textdomain() before gtk_init or its variants.
13697 * This function disables translations if and only if upon its first
13698 * call all the following conditions hold:
13700 * <listitem>@domain is not %NULL</listitem>
13701 * <listitem>textdomain() has been called to set a default text domain</listitem>
13702 * <listitem>there is no translations available for the default text domain
13703 * and the current locale</listitem>
13704 * <listitem>current locale is not "C" or any English locales (those
13705 * starting with "en_")</listitem>
13708 * Note that this behavior may not be desired for example if an application
13709 * has its untranslated messages in a language other than English. In those
13710 * cases the application should call textdomain() after initializing GTK+.
13712 * Applications should normally not use this function directly,
13713 * but use the _() macro for translations.
13715 * Returns: The translated string
13722 * @dir: a #GDir* created by g_dir_open()
13724 * Closes the directory and deallocates all related resources.
13730 * @tmpl: (type filename) (allow-none): Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
13731 * @error: return location for a #GError
13733 * Creates a subdirectory in the preferred directory for temporary
13734 * files (as returned by g_get_tmp_dir()).
13736 * @tmpl should be a string in the GLib file name encoding containing
13737 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
13738 * However, unlike these functions, the template should only be a
13739 * basename, no directory components are allowed. If template is
13740 * %NULL, a default template is used.
13742 * Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
13743 * modified, and might thus be a read-only literal string.
13745 * 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.
13752 * @path: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
13753 * @flags: Currently must be set to 0. Reserved for future use.
13754 * @error: return location for a #GError, or %NULL. If non-%NULL, an error will be set if and only if g_dir_open() fails.
13756 * Opens a directory for reading. The names of the files in the
13757 * directory can then be retrieved using g_dir_read_name(). Note
13758 * that the ordering is not defined.
13760 * 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.
13766 * @dir: a #GDir* created by g_dir_open()
13768 * Retrieves the name of another entry in the directory, or %NULL.
13769 * The order of entries returned from this function is not defined,
13770 * and may vary by file system or other operating-system dependent
13773 * %NULL may also be returned in case of errors. On Unix, you can
13774 * check <literal>errno</literal> to find out if %NULL was returned
13775 * because of an error.
13777 * On Unix, the '.' and '..' entries are omitted, and the returned
13778 * name is in the on-disk encoding.
13780 * On Windows, as is true of all GLib functions which operate on
13781 * filenames, the returned name is in UTF-8.
13783 * 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.
13789 * @dir: a #GDir* created by g_dir_open()
13791 * Resets the given directory. The next call to g_dir_read_name()
13792 * will return the first entry again.
13798 * @v1: (allow-none): a key
13799 * @v2: (allow-none): a key to compare with @v1
13801 * Compares two #gpointer arguments and returns %TRUE if they are equal.
13802 * It can be passed to g_hash_table_new() as the @key_equal_func
13803 * parameter, when using opaque pointers compared by pointer value as keys
13804 * in a #GHashTable.
13806 * This equality function is also appropriate for keys that are integers stored
13807 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13809 * Returns: %TRUE if the two keys match.
13815 * @v: (allow-none): a #gpointer key
13817 * Converts a gpointer to a hash value.
13818 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13819 * when using opaque pointers compared by pointer value as keys in a
13822 * This hash function is also appropriate for keys that are integers stored
13823 * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13825 * Returns: a hash value corresponding to the key.
13831 * @file_name: the name of the file
13833 * Gets the directory components of a file name.
13835 * If the file name has no directory components "." is returned.
13836 * The returned string should be freed when no longer needed.
13838 * Returns: the directory components of the file
13839 * Deprecated: use g_path_get_dirname() instead
13845 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13846 * @msgid: message to translate
13847 * @msgid_plural: plural form of the message
13848 * @n: the quantity for which translation is needed
13850 * This function is a wrapper of dngettext() which does not translate
13851 * the message if the default domain as set with textdomain() has no
13852 * translations for the current locale.
13854 * See g_dgettext() for details of how this differs from dngettext()
13857 * Returns: The translated string
13864 * @v1: a pointer to a #gdouble key
13865 * @v2: a pointer to a #gdouble key to compare with @v1
13867 * Compares the two #gdouble values being pointed to and returns
13868 * %TRUE if they are equal.
13869 * It can be passed to g_hash_table_new() as the @key_equal_func
13870 * parameter, when using non-%NULL pointers to doubles as keys in a
13873 * Returns: %TRUE if the two keys match.
13880 * @v: a pointer to a #gdouble key
13882 * Converts a pointer to a #gdouble to a hash value.
13883 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13884 * It can be passed to g_hash_table_new() as the @hash_func parameter,
13885 * when using non-%NULL pointers to doubles as keys in a #GHashTable.
13887 * Returns: a hash value corresponding to the key.
13894 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13895 * @msgctxtid: a combined message context and message id, separated by a \004 character
13896 * @msgidoffset: the offset of the message id in @msgctxid
13898 * This function is a variant of g_dgettext() which supports
13899 * a disambiguating message context. GNU gettext uses the
13900 * '\004' character to separate the message context and
13901 * message id in @msgctxtid.
13902 * If 0 is passed as @msgidoffset, this function will fall back to
13903 * trying to use the deprecated convention of using "|" as a separation
13906 * This uses g_dgettext() internally. See that functions for differences
13907 * with dgettext() proper.
13909 * Applications should normally not use this function directly,
13910 * but use the C_() macro for translations with context.
13912 * Returns: The translated string
13919 * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13920 * @context: the message context
13921 * @msgid: the message
13923 * This function is a variant of g_dgettext() which supports
13924 * a disambiguating message context. GNU gettext uses the
13925 * '\004' character to separate the message context and
13926 * message id in @msgctxtid.
13928 * This uses g_dgettext() internally. See that functions for differences
13929 * with dgettext() proper.
13931 * This function differs from C_() in that it is not a macro and
13932 * thus you may use non-string-literals as context and msgid arguments.
13934 * Returns: The translated string
13940 * g_environ_getenv:
13941 * @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
13942 * @variable: the environment variable to get, in the GLib file name encoding
13944 * Returns the value of the environment variable @variable in the
13945 * provided list @envp.
13947 * The name and value are in the GLib file name encoding.
13948 * On UNIX, this means the actual bytes which might or might not
13949 * be in some consistent character set and encoding. On Windows,
13950 * it is in UTF-8. On Windows, in case the environment variable's
13951 * value contains references to other environment variables, they
13954 * 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.
13960 * g_environ_setenv:
13961 * @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
13962 * @variable: the environment variable to set, must not contain '='
13963 * @value: the value for to set the variable to
13964 * @overwrite: whether to change the variable if it already exists
13966 * Sets the environment variable @variable in the provided list
13969 * Both the variable's name and value should be in the GLib
13970 * file name encoding. On UNIX, this means that they can be
13971 * arbitrary byte strings. On Windows, they should be in UTF-8.
13973 * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13979 * g_environ_unsetenv:
13980 * @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
13981 * @variable: the environment variable to remove, must not contain '='
13983 * Removes the environment variable @variable from the provided
13984 * environment @envp.
13986 * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13993 * @...: format string, followed by parameters to insert into the format string (as with printf())
13995 * A convenience function/macro to log an error message.
13997 * Error messages are always fatal, resulting in a call to
13998 * abort() to terminate the application. This function will
13999 * result in a core dump; don't use it for errors you expect.
14000 * Using this function indicates a bug in your program, i.e.
14001 * an assertion failure.
14007 * @error: a #GError
14009 * Makes a copy of @error.
14011 * Returns: a new #GError
14017 * @error: a #GError
14019 * Frees a #GError and associated resources.
14025 * @error: (allow-none): a #GError or %NULL
14026 * @domain: an error domain
14027 * @code: an error code
14029 * Returns %TRUE if @error matches @domain and @code, %FALSE
14030 * otherwise. In particular, when @error is %NULL, %FALSE will
14033 * Returns: whether @error has @domain and @code
14039 * @domain: error domain
14040 * @code: error code
14041 * @format: printf()-style format for error message
14042 * @...: parameters for message format
14044 * Creates a new #GError with the given @domain and @code,
14045 * and a message formatted with @format.
14047 * Returns: a new #GError
14052 * g_error_new_literal:
14053 * @domain: error domain
14054 * @code: error code
14055 * @message: error message
14057 * Creates a new #GError; unlike g_error_new(), @message is
14058 * not a printf()-style format string. Use this function if
14059 * @message contains text you don't have control over,
14060 * that could include printf() escape sequences.
14062 * Returns: a new #GError
14067 * g_error_new_valist:
14068 * @domain: error domain
14069 * @code: error code
14070 * @format: printf()-style format for error message
14071 * @args: #va_list of parameters for the message format
14073 * Creates a new #GError with the given @domain and @code,
14074 * and a message formatted with @format.
14076 * Returns: a new #GError
14082 * g_file_error_from_errno:
14083 * @err_no: an "errno" value
14085 * Gets a #GFileError constant based on the passed-in @err_no.
14086 * For example, if you pass in <literal>EEXIST</literal> this function returns
14087 * #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
14088 * assume that all #GFileError values will exist.
14090 * Normally a #GFileError value goes into a #GError returned
14091 * from a function that manipulates files. So you would use
14092 * g_file_error_from_errno() when constructing a #GError.
14094 * Returns: #GFileError corresponding to the given @errno
14099 * g_file_get_contents:
14100 * @filename: (type filename): name of a file to read contents from, in the GLib file name encoding
14101 * @contents: (out) (array length=length) (element-type guint8): location to store an allocated string, use g_free() to free the returned string
14102 * @length: (allow-none): location to store length in bytes of the contents, or %NULL
14103 * @error: return location for a #GError, or %NULL
14105 * Reads an entire file into allocated memory, with good error
14108 * If the call was successful, it returns %TRUE and sets @contents to the file
14109 * contents and @length to the length of the file contents in bytes. The string
14110 * stored in @contents will be nul-terminated, so for text files you can pass
14111 * %NULL for the @length argument. If the call was not successful, it returns
14112 * %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
14113 * codes are those in the #GFileError enumeration. In the error case,
14114 * @contents is set to %NULL and @length is set to zero.
14116 * Returns: %TRUE on success, %FALSE if an error occurred
14122 * @tmpl: (type filename) (allow-none): Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
14123 * @name_used: (out) (type filename): location to store actual name used, or %NULL
14124 * @error: return location for a #GError
14126 * Opens a file for writing in the preferred directory for temporary
14127 * files (as returned by g_get_tmp_dir()).
14129 * @tmpl should be a string in the GLib file name encoding containing
14130 * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14131 * However, unlike these functions, the template should only be a
14132 * basename, no directory components are allowed. If template is
14133 * %NULL, a default template is used.
14135 * Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
14136 * modified, and might thus be a read-only literal string.
14138 * Upon success, and if @name_used is non-%NULL, the actual name used
14139 * is returned in @name_used. This string should be freed with g_free()
14140 * when not needed any longer. The returned name is in the GLib file
14143 * 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.
14148 * g_file_read_link:
14149 * @filename: the symbolic link
14150 * @error: return location for a #GError
14152 * Reads the contents of the symbolic link @filename like the POSIX
14153 * readlink() function. The returned string is in the encoding used
14154 * for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
14156 * Returns: A newly-allocated string with the contents of the symbolic link, or %NULL if an error occurred.
14162 * g_file_set_contents:
14163 * @filename: (type filename): name of a file to write @contents to, in the GLib file name encoding
14164 * @contents: (array length=length) (element-type guint8): string to write to the file
14165 * @length: length of @contents, or -1 if @contents is a nul-terminated string
14166 * @error: return location for a #GError, or %NULL
14168 * Writes all of @contents to a file named @filename, with good error checking.
14169 * If a file called @filename already exists it will be overwritten.
14171 * This write is atomic in the sense that it is first written to a temporary
14172 * file which is then renamed to the final name. Notes:
14175 * On Unix, if @filename already exists hard links to @filename will break.
14176 * Also since the file is recreated, existing permissions, access control
14177 * lists, metadata etc. may be lost. If @filename is a symbolic link,
14178 * the link itself will be replaced, not the linked file.
14181 * On Windows renaming a file will not remove an existing file with the
14182 * new name, so on Windows there is a race condition between the existing
14183 * file being removed and the temporary file being renamed.
14186 * On Windows there is no way to remove a file that is open to some
14187 * process, or mapped into memory. Thus, this function will fail if
14188 * @filename already exists and is open.
14192 * If the call was successful, it returns %TRUE. If the call was not successful,
14193 * it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
14194 * Possible error codes are those in the #GFileError enumeration.
14196 * Note that the name for the temporary file is constructed by appending up
14197 * to 7 characters to @filename.
14199 * Returns: %TRUE on success, %FALSE if an error occurred
14206 * @filename: a filename to test in the GLib file name encoding
14207 * @test: bitfield of #GFileTest flags
14209 * Returns %TRUE if any of the tests in the bitfield @test are
14210 * %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
14211 * G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
14212 * the check whether it's a directory doesn't matter since the existence
14213 * test is %TRUE. With the current set of available tests, there's no point
14214 * passing in more than one test at a time.
14216 * Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
14217 * so for a symbolic link to a regular file g_file_test() will return
14218 * %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
14220 * Note, that for a dangling symbolic link g_file_test() will return
14221 * %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
14223 * You should never use g_file_test() to test whether it is safe
14224 * to perform an operation, because there is always the possibility
14225 * of the condition changing before you actually perform the operation.
14226 * For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
14227 * to know whether it is safe to write to a file without being
14228 * tricked into writing into a different location. It doesn't work!
14230 * /* DON'T DO THIS */
14231 * if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
14233 * fd = g_open (filename, O_WRONLY);
14234 * /* write to fd */
14238 * Another thing to note is that %G_FILE_TEST_EXISTS and
14239 * %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
14240 * system call. This usually doesn't matter, but if your program
14241 * is setuid or setgid it means that these tests will give you
14242 * the answer for the real user ID and group ID, rather than the
14243 * effective user ID and group ID.
14245 * On Windows, there are no symlinks, so testing for
14246 * %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
14247 * %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
14248 * its name indicates that it is executable, checking for well-known
14249 * extensions and those listed in the <envar>PATHEXT</envar> environment variable.
14251 * Returns: whether a test was %TRUE
14256 * g_filename_display_basename:
14257 * @filename: an absolute pathname in the GLib file name encoding
14259 * Returns the display basename for the particular filename, guaranteed
14260 * to be valid UTF-8. The display name might not be identical to the filename,
14261 * for instance there might be problems converting it to UTF-8, and some files
14262 * can be translated in the display.
14264 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14265 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14266 * You can search the result for the UTF-8 encoding of this character (which is
14267 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14270 * You must pass the whole absolute pathname to this functions so that
14271 * translation of well known locations can be done.
14273 * This function is preferred over g_filename_display_name() if you know the
14274 * whole path, as it allows translation.
14276 * Returns: a newly allocated string containing a rendition of the basename of the filename in valid UTF-8
14282 * g_filename_display_name:
14283 * @filename: a pathname hopefully in the GLib file name encoding
14285 * Converts a filename into a valid UTF-8 string. The conversion is
14286 * not necessarily reversible, so you should keep the original around
14287 * and use the return value of this function only for display purposes.
14288 * Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
14289 * even if the filename actually isn't in the GLib file name encoding.
14291 * If GLib cannot make sense of the encoding of @filename, as a last resort it
14292 * replaces unknown characters with U+FFFD, the Unicode replacement character.
14293 * You can search the result for the UTF-8 encoding of this character (which is
14294 * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14297 * If you know the whole pathname of the file you should use
14298 * g_filename_display_basename(), since that allows location-based
14299 * translation of filenames.
14301 * Returns: a newly allocated string containing a rendition of the filename in valid UTF-8
14307 * g_filename_from_uri:
14308 * @uri: a uri describing a filename (escaped, encoded in ASCII).
14309 * @hostname: (out) (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.
14310 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14312 * Converts an escaped ASCII-encoded URI to a local filename in the
14313 * encoding used for filenames.
14315 * Returns: (type filename): a newly-allocated string holding the resulting filename, or %NULL on an error.
14320 * g_filename_from_utf8:
14321 * @utf8string: a UTF-8 encoded string.
14322 * @len: the length of the string, or -1 if the string is nul-terminated.
14323 * @bytes_read: (out) (allow-none): 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.
14324 * @bytes_written: (out): the number of bytes stored in the output buffer (not including the terminating nul).
14325 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14327 * Converts a string from UTF-8 to the encoding GLib uses for
14328 * filenames. Note that on Windows GLib uses UTF-8 for filenames;
14329 * on other platforms, this function indirectly depends on the
14330 * <link linkend="setlocale">current locale</link>.
14332 * Returns: (array length=bytes_written) (element-type guint8) (transfer full): The converted string, or %NULL on an error.
14337 * g_filename_to_uri:
14338 * @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
14339 * @hostname: (allow-none): A UTF-8 encoded hostname, or %NULL for none.
14340 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14342 * Converts an absolute filename to an escaped ASCII-encoded URI, with the path
14343 * component following Section 3.3. of RFC 2396.
14345 * Returns: a newly-allocated string holding the resulting URI, or %NULL on an error.
14350 * g_filename_to_utf8:
14351 * @opsysstring: a string in the encoding for filenames
14352 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
14353 * @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.
14354 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
14355 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14357 * Converts a string which is in the encoding used by GLib for
14358 * filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
14359 * for filenames; on other platforms, this function indirectly depends on
14360 * the <link linkend="setlocale">current locale</link>.
14362 * Returns: The converted string, or %NULL on an error.
14367 * g_find_program_in_path:
14368 * @program: a program name in the GLib file name encoding
14370 * Locates the first executable named @program in the user's path, in the
14371 * same way that execvp() would locate it. Returns an allocated string
14372 * with the absolute path name, or %NULL if the program is not found in
14373 * the path. If @program is already an absolute path, returns a copy of
14374 * @program if @program exists and is executable, and %NULL otherwise.
14376 * On Windows, if @program does not have a file type suffix, tries
14377 * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
14378 * the <envar>PATHEXT</envar> environment variable.
14380 * On Windows, it looks for the file in the same way as CreateProcess()
14381 * would. This means first in the directory where the executing
14382 * program was loaded from, then in the current directory, then in the
14383 * Windows 32-bit system directory, then in the Windows directory, and
14384 * finally in the directories in the <envar>PATH</envar> environment
14385 * variable. If the program is found, the return value contains the
14386 * full name including the type suffix.
14388 * Returns: a newly-allocated string with the absolute path, or %NULL
14394 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14395 * @mode: a string describing the mode in which the file should be opened
14397 * A wrapper for the stdio fopen() function. The fopen() function
14398 * opens a file and associates a new stream with it.
14400 * Because file descriptors are specific to the C library on Windows,
14401 * and a file descriptor is partof the <type>FILE</type> struct, the
14402 * <type>FILE</type> pointer returned by this function makes sense
14403 * only to functions in the same C library. Thus if the GLib-using
14404 * code uses a different C library than GLib does, the
14405 * <type>FILE</type> pointer returned by this function cannot be
14406 * passed to C library functions like fprintf() or fread().
14408 * See your C library manual for more details about fopen().
14410 * Returns: A <type>FILE</type> pointer if the file was successfully opened, or %NULL if an error occurred
14417 * @size: a size in bytes
14419 * Formats a size (for example the size of a file) into a human readable
14420 * string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
14421 * and are displayed rounded to the nearest tenth. E.g. the file size
14422 * 3292528 bytes will be converted into the string "3.2 MB".
14424 * The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
14426 * This string should be freed with g_free() when not needed any longer.
14428 * See g_format_size_full() for more options about how the size might be
14431 * Returns: a newly-allocated formatted string containing a human readable file size
14437 * g_format_size_for_display:
14438 * @size: a size in bytes
14440 * Formats a size (for example the size of a file) into a human
14441 * readable string. Sizes are rounded to the nearest size prefix
14442 * (KB, MB, GB) and are displayed rounded to the nearest tenth.
14443 * E.g. the file size 3292528 bytes will be converted into the
14446 * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
14448 * This string should be freed with g_free() when not needed any longer.
14450 * Returns: a newly-allocated formatted string containing a human readable file size
14452 * Deprecated: 2.30: This function is broken due to its use of SI suffixes to denote IEC units. Use g_format_size() instead.
14457 * g_format_size_full:
14458 * @size: a size in bytes
14459 * @flags: #GFormatSizeFlags to modify the output
14463 * This function is similar to g_format_size() but allows for flags
14464 * that modify the output. See #GFormatSizeFlags.
14466 * Returns: a newly-allocated formatted string containing a human readable file size
14473 * @file: the stream to write to.
14474 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
14475 * @...: the arguments to insert in the output.
14477 * An implementation of the standard fprintf() function which supports
14478 * positional parameters, as specified in the Single Unix Specification.
14480 * Returns: the number of bytes printed.
14487 * @mem: the memory to free
14489 * Frees the memory pointed to by @mem.
14490 * If @mem is %NULL it simply returns.
14496 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14497 * @mode: a string describing the mode in which the file should be opened
14498 * @stream: (allow-none): an existing stream which will be reused, or %NULL
14500 * A wrapper for the POSIX freopen() function. The freopen() function
14501 * opens a file and associates it with an existing stream.
14503 * See your C library manual for more details about freopen().
14505 * Returns: A <literal>FILE</literal> pointer if the file was successfully opened, or %NULL if an error occurred.
14511 * g_get_application_name:
14513 * Gets a human-readable name for the application, as set by
14514 * g_set_application_name(). This name should be localized if
14515 * possible, and is intended for display to the user. Contrast with
14516 * g_get_prgname(), which gets a non-localized name. If
14517 * g_set_application_name() has not been called, returns the result of
14518 * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
14521 * Returns: human-readable application name. may return %NULL
14528 * @charset: return location for character set name
14530 * Obtains the character set for the <link linkend="setlocale">current
14531 * locale</link>; you might use this character set as an argument to
14532 * g_convert(), to convert from the current locale's encoding to some
14533 * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
14534 * are nice shortcuts, though.)
14536 * On Windows the character set returned by this function is the
14537 * so-called system default ANSI code-page. That is the character set
14538 * used by the "narrow" versions of C library and Win32 functions that
14539 * handle file names. It might be different from the character set
14540 * used by the C library's current locale.
14542 * The return value is %TRUE if the locale's encoding is UTF-8, in that
14543 * case you can perhaps avoid calling g_convert().
14545 * The string returned in @charset is not allocated, and should not be
14548 * Returns: %TRUE if the returned charset is UTF-8
14555 * Gets the character set for the current locale.
14557 * Returns: a newly allocated string containing the name of the character set. This string must be freed with g_free().
14562 * g_get_current_dir:
14564 * Gets the current directory.
14566 * The returned string should be freed when no longer needed.
14567 * The encoding of the returned string is system defined.
14568 * On Windows, it is always UTF-8.
14570 * Returns: the current directory
14575 * g_get_current_time:
14576 * @result: #GTimeVal structure in which to store current time.
14578 * Equivalent to the UNIX gettimeofday() function, but portable.
14580 * You may find g_get_real_time() to be more convenient.
14587 * Gets the list of environment variables for the current process.
14589 * The list is %NULL terminated and each item in the list is of the
14590 * form 'NAME=VALUE'.
14592 * This is equivalent to direct access to the 'environ' global variable,
14595 * The return value is freshly allocated and it should be freed with
14596 * g_strfreev() when it is no longer needed.
14598 * Returns: (array zero-terminated=1) (transfer full): the list of environment variables
14604 * g_get_filename_charsets:
14605 * @charsets: return location for the %NULL-terminated list of encoding names
14607 * Determines the preferred character sets used for filenames.
14608 * The first character set from the @charsets is the filename encoding, the
14609 * subsequent character sets are used when trying to generate a displayable
14610 * representation of a filename, see g_filename_display_name().
14612 * On Unix, the character sets are determined by consulting the
14613 * environment variables <envar>G_FILENAME_ENCODING</envar> and
14614 * <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
14615 * used in the GLib API is always UTF-8 and said environment variables
14618 * <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
14619 * of character set names. The special token "@locale" is taken to
14620 * mean the character set for the <link linkend="setlocale">current
14621 * locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
14622 * <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
14623 * locale is taken as the filename encoding. If neither environment variable
14624 * is set, UTF-8 is taken as the filename encoding, but the character
14625 * set of the current locale is also put in the list of encodings.
14627 * The returned @charsets belong to GLib and must not be freed.
14629 * Note that on Unix, regardless of the locale character set or
14630 * <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
14631 * on a system might be in any random encoding or just gibberish.
14633 * Returns: %TRUE if the filename encoding is UTF-8.
14641 * Gets the current user's home directory.
14643 * As with most UNIX tools, this function will return the value of the
14644 * <envar>HOME</envar> environment variable if it is set to an existing
14645 * absolute path name, falling back to the <filename>passwd</filename>
14646 * file in the case that it is unset.
14648 * If the path given in <envar>HOME</envar> is non-absolute, does not
14649 * exist, or is not a directory, the result is undefined.
14652 * Before version 2.36 this function would ignore the
14653 * <envar>HOME</envar> environment variable, taking the value from the
14654 * <filename>passwd</filename> database instead. This was changed to
14655 * increase the compatibility of GLib with other programs (and the XDG
14656 * basedir specification) and to increase testability of programs
14657 * based on GLib (by making it easier to run them from test
14660 * If your program has a strong requirement for either the new or the
14661 * old behaviour (and if you don't wish to increase your GLib
14662 * dependency to ensure that the new behaviour is in effect) then you
14663 * should either directly check the <envar>HOME</envar> environment
14664 * variable yourself or unset it before calling any functions in GLib.
14667 * Returns: the current user's home directory
14674 * Return a name for the machine.
14676 * The returned name is not necessarily a fully-qualified domain name,
14677 * or even present in DNS or some other name service at all. It need
14678 * not even be unique on your local network or site, but usually it
14679 * is. Callers should not rely on the return value having any specific
14680 * properties like uniqueness for security purposes. Even if the name
14681 * of the machine is changed while an application is running, the
14682 * return value from this function does not change. The returned
14683 * string is owned by GLib and should not be modified or freed. If no
14684 * name can be determined, a default fixed string "localhost" is
14687 * Returns: the host name of the machine.
14693 * g_get_language_names:
14695 * Computes a list of applicable locale names, which can be used to
14696 * e.g. construct locale-dependent filenames or search paths. The returned
14697 * list is sorted from most desirable to least desirable and always contains
14698 * the default locale "C".
14700 * For example, if LANGUAGE=de:en_US, then the returned list is
14701 * "de", "en_US", "en", "C".
14703 * This function consults the environment variables <envar>LANGUAGE</envar>,
14704 * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
14705 * to find the list of locales specified by the user.
14707 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14713 * g_get_locale_variants:
14714 * @locale: a locale identifier
14716 * Returns a list of derived variants of @locale, which can be used to
14717 * e.g. construct locale-dependent filenames or search paths. The returned
14718 * list is sorted from most desirable to least desirable.
14719 * This function handles territory, charset and extra locale modifiers.
14721 * For example, if @locale is "fr_BE", then the returned list
14722 * is "fr_BE", "fr".
14724 * If you need the list of variants for the <emphasis>current locale</emphasis>,
14725 * use g_get_language_names().
14727 * 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().
14733 * g_get_monotonic_time:
14735 * Queries the system monotonic time, if available.
14737 * On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
14738 * is a very shallow wrapper for that. Otherwise, we make a best effort
14739 * that probably involves returning the wall clock time (with at least
14740 * microsecond accuracy, subject to the limitations of the OS kernel).
14742 * It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
14743 * not count time spent while the machine is suspended.
14745 * On Windows, "limitations of the OS kernel" is a rather substantial
14746 * statement. Depending on the configuration of the system, the wall
14747 * clock time is updated as infrequently as 64 times a second (which
14748 * is approximately every 16ms). Also, on XP (but not on Vista or later)
14749 * the monotonic clock is locally monotonic, but may differ in exact
14750 * value between processes due to timer wrap handling.
14752 * Returns: the monotonic time, in microseconds
14758 * g_get_num_processors:
14760 * Determine the approximate number of threads that the system will
14761 * schedule simultaneously for this process. This is intended to be
14762 * used as a parameter to g_thread_pool_new() for CPU bound tasks and
14765 * Returns: Number of schedulable threads, always greater than 0
14773 * Gets the name of the program. This name should <emphasis>not</emphasis>
14774 * be localized, contrast with g_get_application_name().
14775 * (If you are using GDK or GTK+ the program name is set in gdk_init(),
14776 * which is called by gtk_init(). The program name is found by taking
14777 * the last component of <literal>argv[0]</literal>.)
14779 * Returns: the name of the program. The returned string belongs to GLib and must not be modified or freed.
14786 * Gets the real name of the user. This usually comes from the user's entry
14787 * in the <filename>passwd</filename> file. The encoding of the returned
14788 * string is system-defined. (On Windows, it is, however, always UTF-8.)
14789 * If the real user name cannot be determined, the string "Unknown" is
14792 * Returns: the user's real name.
14799 * Queries the system wall-clock time.
14801 * This call is functionally equivalent to g_get_current_time() except
14802 * that the return value is often more convenient than dealing with a
14805 * You should only use this call if you are actually interested in the real
14806 * wall-clock time. g_get_monotonic_time() is probably more useful for
14807 * measuring intervals.
14809 * Returns: the number of microseconds since January 1, 1970 UTC.
14815 * g_get_system_config_dirs:
14817 * Returns an ordered list of base directories in which to access
14818 * system-wide configuration information.
14820 * On UNIX platforms this is determined using the mechanisms described in
14821 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14822 * XDG Base Directory Specification</ulink>.
14823 * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
14825 * On Windows is the directory that contains application data for all users.
14826 * A typical path is C:\Documents and Settings\All Users\Application Data.
14827 * This folder is used for application data that is not user specific.
14828 * For example, an application can store a spell-check dictionary, a database
14829 * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
14830 * This information will not roam and is available to anyone using the computer.
14832 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14838 * g_get_system_data_dirs:
14840 * Returns an ordered list of base directories in which to access
14841 * system-wide application data.
14843 * On UNIX platforms this is determined using the mechanisms described in
14844 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14845 * XDG Base Directory Specification</ulink>
14846 * In this case the list of directories retrieved will be XDG_DATA_DIRS.
14848 * On Windows the first elements in the list are the Application Data
14849 * and Documents folders for All Users. (These can be determined only
14850 * on Windows 2000 or later and are not present in the list on other
14851 * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
14852 * CSIDL_COMMON_DOCUMENTS.
14854 * Then follows the "share" subfolder in the installation folder for
14855 * the package containing the DLL that calls this function, if it can
14858 * Finally the list contains the "share" subfolder in the installation
14859 * folder for GLib, and in the installation folder for the package the
14860 * application's .exe file belongs to.
14862 * The installation folders above are determined by looking up the
14863 * folder where the module (DLL or EXE) in question is located. If the
14864 * folder's name is "bin", its parent is used, otherwise the folder
14867 * Note that on Windows the returned list can vary depending on where
14868 * this function is called.
14870 * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14878 * Gets the directory to use for temporary files.
14880 * On UNIX, this is taken from the <envar>TMPDIR</envar> environment
14881 * variable. If the variable is not set, <literal>P_tmpdir</literal> is
14882 * used, as defined by the system C library. Failing that, a hard-coded
14883 * default of "/tmp" is returned.
14885 * On Windows, the <envar>TEMP</envar> environment variable is used,
14886 * with the root directory of the Windows installation (eg: "C:\") used
14889 * The encoding of the returned string is system-defined. On Windows, it
14890 * is always UTF-8. The return value is never %NULL or the empty string.
14892 * Returns: the directory to use for temporary files.
14897 * g_get_user_cache_dir:
14899 * Returns a base directory in which to store non-essential, cached
14900 * data specific to particular user.
14902 * On UNIX platforms this is determined using the mechanisms described in
14903 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14904 * XDG Base Directory Specification</ulink>.
14905 * In this case the directory retrieved will be XDG_CACHE_HOME.
14907 * On Windows is the directory that serves as a common repository for
14908 * temporary Internet files. A typical path is
14909 * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
14910 * See documentation for CSIDL_INTERNET_CACHE.
14912 * Returns: a string owned by GLib that must not be modified or freed.
14918 * g_get_user_config_dir:
14920 * Returns a base directory in which to store user-specific application
14921 * configuration information such as user preferences and settings.
14923 * On UNIX platforms this is determined using the mechanisms described in
14924 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14925 * XDG Base Directory Specification</ulink>.
14926 * In this case the directory retrieved will be XDG_CONFIG_HOME.
14928 * On Windows this is the folder to use for local (as opposed to
14929 * roaming) application data. See documentation for
14930 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14931 * what g_get_user_data_dir() returns.
14933 * Returns: a string owned by GLib that must not be modified or freed.
14939 * g_get_user_data_dir:
14941 * Returns a base directory in which to access application data such
14942 * as icons that is customized for a particular user.
14944 * On UNIX platforms this is determined using the mechanisms described in
14945 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14946 * XDG Base Directory Specification</ulink>.
14947 * In this case the directory retrieved will be XDG_DATA_HOME.
14949 * On Windows this is the folder to use for local (as opposed to
14950 * roaming) application data. See documentation for
14951 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14952 * what g_get_user_config_dir() returns.
14954 * Returns: a string owned by GLib that must not be modified or freed.
14962 * Gets the user name of the current user. The encoding of the returned
14963 * string is system-defined. On UNIX, it might be the preferred file name
14964 * encoding, or something else, and there is no guarantee that it is even
14965 * consistent on a machine. On Windows, it is always UTF-8.
14967 * Returns: the user name of the current user.
14972 * g_get_user_runtime_dir:
14974 * Returns a directory that is unique to the current user on the local
14977 * On UNIX platforms this is determined using the mechanisms described in
14978 * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14979 * XDG Base Directory Specification</ulink>. This is the directory
14980 * specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
14981 * In the case that this variable is not set, GLib will issue a warning
14982 * message to stderr and return the value of g_get_user_cache_dir().
14984 * On Windows this is the folder to use for local (as opposed to
14985 * roaming) application data. See documentation for
14986 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14987 * what g_get_user_config_dir() returns.
14989 * Returns: a string owned by GLib that must not be modified or freed.
14995 * g_get_user_special_dir:
14996 * @directory: the logical id of special directory
14998 * Returns the full path of a special directory using its logical id.
15000 * On Unix this is done using the XDG special user directories.
15001 * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
15002 * falls back to <filename>$HOME/Desktop</filename> when XDG special
15003 * user directories have not been set up.
15005 * Depending on the platform, the user might be able to change the path
15006 * of the special directory without requiring the session to restart; GLib
15007 * will not reflect any change once the special directories are loaded.
15009 * 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.
15016 * @variable: the environment variable to get, in the GLib file name encoding
15018 * Returns the value of an environment variable.
15020 * The name and value are in the GLib file name encoding. On UNIX,
15021 * this means the actual bytes which might or might not be in some
15022 * consistent character set and encoding. On Windows, it is in UTF-8.
15023 * On Windows, in case the environment variable's value contains
15024 * references to other environment variables, they are expanded.
15026 * 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().
15031 * g_hash_table_add:
15032 * @hash_table: a #GHashTable
15033 * @key: a key to insert
15035 * This is a convenience function for using a #GHashTable as a set. It
15036 * is equivalent to calling g_hash_table_replace() with @key as both the
15037 * key and the value.
15039 * When a hash table only ever contains keys that have themselves as the
15040 * corresponding value it is able to be stored more efficiently. See
15041 * the discussion in the section description.
15048 * g_hash_table_contains:
15049 * @hash_table: a #GHashTable
15050 * @key: a key to check
15052 * Checks if @key is in @hash_table.
15059 * g_hash_table_destroy:
15060 * @hash_table: a #GHashTable
15062 * Destroys all keys and values in the #GHashTable and decrements its
15063 * reference count by 1. If keys and/or values are dynamically allocated,
15064 * you should either free them first or create the #GHashTable with destroy
15065 * notifiers using g_hash_table_new_full(). In the latter case the destroy
15066 * functions you supplied will be called on all keys and values during the
15067 * destruction phase.
15072 * g_hash_table_find:
15073 * @hash_table: a #GHashTable
15074 * @predicate: function to test the key/value pairs for a certain property
15075 * @user_data: user data to pass to the function
15077 * Calls the given function for key/value pairs in the #GHashTable
15078 * until @predicate returns %TRUE. The function is passed the key
15079 * and value of each pair, and the given @user_data parameter. The
15080 * hash table may not be modified while iterating over it (you can't
15081 * add/remove items).
15083 * Note, that hash tables are really only optimized for forward
15084 * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
15085 * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
15086 * once per every entry in a hash table) should probably be reworked
15087 * to use additional or different data structures for reverse lookups
15088 * (keep in mind that an O(n) find/foreach operation issued for all n
15089 * values in a hash table ends up needing O(n*n) operations).
15091 * 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.
15097 * g_hash_table_foreach:
15098 * @hash_table: a #GHashTable
15099 * @func: the function to call for each key/value pair
15100 * @user_data: user data to pass to the function
15102 * Calls the given function for each of the key/value pairs in the
15103 * #GHashTable. The function is passed the key and value of each
15104 * pair, and the given @user_data parameter. The hash table may not
15105 * be modified while iterating over it (you can't add/remove
15106 * items). To remove all items matching a predicate, use
15107 * g_hash_table_foreach_remove().
15109 * See g_hash_table_find() for performance caveats for linear
15110 * order searches in contrast to g_hash_table_lookup().
15115 * g_hash_table_foreach_remove:
15116 * @hash_table: a #GHashTable
15117 * @func: the function to call for each key/value pair
15118 * @user_data: user data to pass to the function
15120 * Calls the given function for each key/value pair in the
15121 * #GHashTable. If the function returns %TRUE, then the key/value
15122 * pair is removed from the #GHashTable. If you supplied key or
15123 * value destroy functions when creating the #GHashTable, they are
15124 * used to free the memory allocated for the removed keys and values.
15126 * See #GHashTableIter for an alternative way to loop over the
15127 * key/value pairs in the hash table.
15129 * Returns: the number of key/value pairs removed
15134 * g_hash_table_foreach_steal:
15135 * @hash_table: a #GHashTable
15136 * @func: the function to call for each key/value pair
15137 * @user_data: user data to pass to the function
15139 * Calls the given function for each key/value pair in the
15140 * #GHashTable. If the function returns %TRUE, then the key/value
15141 * pair is removed from the #GHashTable, but no key or value
15142 * destroy functions are called.
15144 * See #GHashTableIter for an alternative way to loop over the
15145 * key/value pairs in the hash table.
15147 * Returns: the number of key/value pairs removed.
15152 * g_hash_table_freeze:
15153 * @hash_table: a #GHashTable
15155 * This function is deprecated and will be removed in the next major
15156 * release of GLib. It does nothing.
15161 * g_hash_table_get_keys:
15162 * @hash_table: a #GHashTable
15164 * Retrieves every key inside @hash_table. The returned data is valid
15165 * until changes to the hash release those keys.
15167 * 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.
15173 * g_hash_table_get_values:
15174 * @hash_table: a #GHashTable
15176 * Retrieves every value inside @hash_table. The returned data
15177 * is valid until @hash_table is modified.
15179 * 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.
15185 * g_hash_table_insert:
15186 * @hash_table: a #GHashTable
15187 * @key: a key to insert
15188 * @value: the value to associate with the key
15190 * Inserts a new key and value into a #GHashTable.
15192 * If the key already exists in the #GHashTable its current
15193 * value is replaced with the new value. If you supplied a
15194 * @value_destroy_func when creating the #GHashTable, the old
15195 * value is freed using that function. If you supplied a
15196 * @key_destroy_func when creating the #GHashTable, the passed
15197 * key is freed using that function.
15202 * g_hash_table_iter_get_hash_table:
15203 * @iter: an initialized #GHashTableIter
15205 * Returns the #GHashTable associated with @iter.
15207 * Returns: the #GHashTable associated with @iter.
15213 * g_hash_table_iter_init:
15214 * @iter: an uninitialized #GHashTableIter
15215 * @hash_table: a #GHashTable
15217 * Initializes a key/value pair iterator and associates it with
15218 * @hash_table. Modifying the hash table after calling this function
15219 * invalidates the returned iterator.
15221 * GHashTableIter iter;
15222 * gpointer key, value;
15224 * g_hash_table_iter_init (&iter, hash_table);
15225 * while (g_hash_table_iter_next (&iter, &key, &value))
15227 * /* do something with key and value */
15236 * g_hash_table_iter_next:
15237 * @iter: an initialized #GHashTableIter
15238 * @key: (allow-none): a location to store the key, or %NULL
15239 * @value: (allow-none): a location to store the value, or %NULL
15241 * Advances @iter and retrieves the key and/or value that are now
15242 * pointed to as a result of this advancement. If %FALSE is returned,
15243 * @key and @value are not set, and the iterator becomes invalid.
15245 * Returns: %FALSE if the end of the #GHashTable has been reached.
15251 * g_hash_table_iter_remove:
15252 * @iter: an initialized #GHashTableIter
15254 * Removes the key/value pair currently pointed to by the iterator
15255 * from its associated #GHashTable. Can only be called after
15256 * g_hash_table_iter_next() returned %TRUE, and cannot be called
15257 * more than once for the same key/value pair.
15259 * If the #GHashTable was created using g_hash_table_new_full(),
15260 * the key and value are freed using the supplied destroy functions,
15261 * otherwise you have to make sure that any dynamically allocated
15262 * values are freed yourself.
15269 * g_hash_table_iter_replace:
15270 * @iter: an initialized #GHashTableIter
15271 * @value: the value to replace with
15273 * Replaces the value currently pointed to by the iterator
15274 * from its associated #GHashTable. Can only be called after
15275 * g_hash_table_iter_next() returned %TRUE.
15277 * If you supplied a @value_destroy_func when creating the
15278 * #GHashTable, the old value is freed using that function.
15285 * g_hash_table_iter_steal:
15286 * @iter: an initialized #GHashTableIter
15288 * Removes the key/value pair currently pointed to by the
15289 * iterator from its associated #GHashTable, without calling
15290 * the key and value destroy functions. Can only be called
15291 * after g_hash_table_iter_next() returned %TRUE, and cannot
15292 * be called more than once for the same key/value pair.
15299 * g_hash_table_lookup:
15300 * @hash_table: a #GHashTable
15301 * @key: the key to look up
15303 * Looks up a key in a #GHashTable. Note that this function cannot
15304 * distinguish between a key that is not present and one which is present
15305 * and has the value %NULL. If you need this distinction, use
15306 * g_hash_table_lookup_extended().
15308 * Returns: (allow-none): the associated value, or %NULL if the key is not found
15313 * g_hash_table_lookup_extended:
15314 * @hash_table: a #GHashTable
15315 * @lookup_key: the key to look up
15316 * @orig_key: (allow-none): return location for the original key, or %NULL
15317 * @value: (allow-none): return location for the value associated with the key, or %NULL
15319 * Looks up a key in the #GHashTable, returning the original key and the
15320 * associated value and a #gboolean which is %TRUE if the key was found. This
15321 * is useful if you need to free the memory allocated for the original key,
15322 * for example before calling g_hash_table_remove().
15324 * You can actually pass %NULL for @lookup_key to test
15325 * whether the %NULL key exists, provided the hash and equal functions
15326 * of @hash_table are %NULL-safe.
15328 * Returns: %TRUE if the key was found in the #GHashTable
15333 * g_hash_table_new:
15334 * @hash_func: a function to create a hash value from a key
15335 * @key_equal_func: a function to check two keys for equality
15337 * Creates a new #GHashTable with a reference count of 1.
15339 * Hash values returned by @hash_func are used to determine where keys
15340 * are stored within the #GHashTable data structure. The g_direct_hash(),
15341 * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
15342 * functions are provided for some common types of keys.
15343 * If @hash_func is %NULL, g_direct_hash() is used.
15345 * @key_equal_func is used when looking up keys in the #GHashTable.
15346 * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
15347 * and g_str_equal() functions are provided for the most common types
15348 * of keys. If @key_equal_func is %NULL, keys are compared directly in
15349 * a similar fashion to g_direct_equal(), but without the overhead of
15352 * Returns: a new #GHashTable
15357 * g_hash_table_new_full:
15358 * @hash_func: a function to create a hash value from a key
15359 * @key_equal_func: a function to check two keys for equality
15360 * @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.
15361 * @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.
15363 * Creates a new #GHashTable like g_hash_table_new() with a reference
15364 * count of 1 and allows to specify functions to free the memory
15365 * allocated for the key and value that get called when removing the
15366 * entry from the #GHashTable.
15368 * Returns: a new #GHashTable
15373 * g_hash_table_ref:
15374 * @hash_table: a valid #GHashTable
15376 * Atomically increments the reference count of @hash_table by one.
15377 * This function is MT-safe and may be called from any thread.
15379 * Returns: the passed in #GHashTable
15385 * g_hash_table_remove:
15386 * @hash_table: a #GHashTable
15387 * @key: the key to remove
15389 * Removes a key and its associated value from a #GHashTable.
15391 * If the #GHashTable was created using g_hash_table_new_full(), the
15392 * key and value are freed using the supplied destroy functions, otherwise
15393 * you have to make sure that any dynamically allocated values are freed
15396 * Returns: %TRUE if the key was found and removed from the #GHashTable
15401 * g_hash_table_remove_all:
15402 * @hash_table: a #GHashTable
15404 * Removes all keys and their associated values from a #GHashTable.
15406 * If the #GHashTable was created using g_hash_table_new_full(),
15407 * the keys and values are freed using the supplied destroy functions,
15408 * otherwise you have to make sure that any dynamically allocated
15409 * values are freed yourself.
15416 * g_hash_table_replace:
15417 * @hash_table: a #GHashTable
15418 * @key: a key to insert
15419 * @value: the value to associate with the key
15421 * Inserts a new key and value into a #GHashTable similar to
15422 * g_hash_table_insert(). The difference is that if the key
15423 * already exists in the #GHashTable, it gets replaced by the
15424 * new key. If you supplied a @value_destroy_func when creating
15425 * the #GHashTable, the old value is freed using that function.
15426 * If you supplied a @key_destroy_func when creating the
15427 * #GHashTable, the old key is freed using that function.
15432 * g_hash_table_size:
15433 * @hash_table: a #GHashTable
15435 * Returns the number of elements contained in the #GHashTable.
15437 * Returns: the number of key/value pairs in the #GHashTable.
15442 * g_hash_table_steal:
15443 * @hash_table: a #GHashTable
15444 * @key: the key to remove
15446 * Removes a key and its associated value from a #GHashTable without
15447 * calling the key and value destroy functions.
15449 * Returns: %TRUE if the key was found and removed from the #GHashTable
15454 * g_hash_table_steal_all:
15455 * @hash_table: a #GHashTable
15457 * Removes all keys and their associated values from a #GHashTable
15458 * without calling the key and value destroy functions.
15465 * g_hash_table_thaw:
15466 * @hash_table: a #GHashTable
15468 * This function is deprecated and will be removed in the next major
15469 * release of GLib. It does nothing.
15474 * g_hash_table_unref:
15475 * @hash_table: a valid #GHashTable
15477 * Atomically decrements the reference count of @hash_table by one.
15478 * If the reference count drops to 0, all keys and values will be
15479 * destroyed, and all memory allocated by the hash table is released.
15480 * This function is MT-safe and may be called from any thread.
15488 * @hmac: the #GHmac to copy
15490 * Copies a #GHmac. If @hmac has been closed, by calling
15491 * g_hmac_get_string() or g_hmac_get_digest(), the copied
15492 * HMAC will be closed as well.
15494 * Returns: the copy of the passed #GHmac. Use g_hmac_unref() when finished using it.
15500 * g_hmac_get_digest:
15502 * @buffer: output buffer
15503 * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
15505 * Gets the digest from @checksum as a raw binary array and places it
15506 * into @buffer. The size of the digest depends on the type of checksum.
15508 * Once this function has been called, the #GHmac is closed and can
15509 * no longer be updated with g_checksum_update().
15516 * g_hmac_get_string:
15519 * Gets the HMAC as an hexadecimal string.
15521 * Once this function has been called the #GHmac can no longer be
15522 * updated with g_hmac_update().
15524 * The hexadecimal characters will be lower case.
15526 * Returns: the hexadecimal representation of the HMAC. The returned string is owned by the HMAC and should not be modified or freed.
15533 * @digest_type: the desired type of digest
15534 * @key: (array length=key_len): the key for the HMAC
15535 * @key_len: the length of the keys
15537 * Creates a new #GHmac, using the digest algorithm @digest_type.
15538 * If the @digest_type is not known, %NULL is returned.
15539 * A #GHmac can be used to compute the HMAC of a key and an
15540 * arbitrary binary blob, using different hashing algorithms.
15542 * A #GHmac works by feeding a binary blob through g_hmac_update()
15543 * until the data is complete; the digest can then be extracted
15544 * using g_hmac_get_string(), which will return the checksum as a
15545 * hexadecimal string; or g_hmac_get_digest(), which will return a
15546 * array of raw bytes. Once either g_hmac_get_string() or
15547 * g_hmac_get_digest() have been called on a #GHmac, the HMAC
15548 * will be closed and it won't be possible to call g_hmac_update()
15551 * Returns: the newly created #GHmac, or %NULL. Use g_hmac_unref() to free the memory allocated by it.
15558 * @hmac: a valid #GHmac
15560 * Atomically increments the reference count of @hmac by one.
15562 * This function is MT-safe and may be called from any thread.
15564 * Returns: the passed in #GHmac.
15573 * Atomically decrements the reference count of @hmac by one.
15575 * If the reference count drops to 0, all keys and values will be
15576 * destroyed, and all memory allocated by the hash table is released.
15577 * This function is MT-safe and may be called from any thread.
15578 * Frees the memory allocated for @hmac.
15587 * @data: (array length=length): buffer used to compute the checksum
15588 * @length: size of the buffer, or -1 if it is a nul-terminated string
15590 * Feeds @data into an existing #GHmac.
15592 * The HMAC must still be open, that is g_hmac_get_string() or
15593 * g_hmac_get_digest() must not have been called on @hmac.
15601 * @hook_list: a #GHookList
15603 * Allocates space for a #GHook and initializes it.
15605 * Returns: a new #GHook
15611 * @hook_list: a #GHookList
15612 * @hook: the #GHook to add to the end of @hook_list
15614 * Appends a #GHook onto the end of a #GHookList.
15619 * g_hook_compare_ids:
15620 * @new_hook: a #GHook
15621 * @sibling: a #GHook to compare with @new_hook
15623 * Compares the ids of two #GHook elements, returning a negative value
15624 * if the second id is greater than the first.
15626 * Returns: a value <= 0 if the id of @sibling is >= the id of @new_hook
15632 * @hook_list: a #GHookList
15633 * @hook_id: a hook ID
15635 * Destroys a #GHook, given its ID.
15637 * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed
15642 * g_hook_destroy_link:
15643 * @hook_list: a #GHookList
15644 * @hook: the #GHook to remove
15646 * Removes one #GHook from a #GHookList, marking it
15647 * inactive and calling g_hook_unref() on it.
15653 * @hook_list: a #GHookList
15654 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15655 * @func: the function to call for each #GHook, which should return %TRUE when the #GHook has been found
15656 * @data: the data to pass to @func
15658 * Finds a #GHook in a #GHookList using the given function to
15659 * test for a match.
15661 * Returns: the found #GHook or %NULL if no matching #GHook is found
15666 * g_hook_find_data:
15667 * @hook_list: a #GHookList
15668 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15669 * @data: the data to find
15671 * Finds a #GHook in a #GHookList with the given data.
15673 * Returns: the #GHook with the given @data or %NULL if no matching #GHook is found
15678 * g_hook_find_func:
15679 * @hook_list: a #GHookList
15680 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15681 * @func: the function to find
15683 * Finds a #GHook in a #GHookList with the given function.
15685 * Returns: the #GHook with the given @func or %NULL if no matching #GHook is found
15690 * g_hook_find_func_data:
15691 * @hook_list: a #GHookList
15692 * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15693 * @func: the function to find
15694 * @data: the data to find
15696 * Finds a #GHook in a #GHookList with the given function and data.
15698 * Returns: the #GHook with the given @func and @data or %NULL if no matching #GHook is found
15703 * g_hook_first_valid:
15704 * @hook_list: a #GHookList
15705 * @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
15707 * Returns the first #GHook in a #GHookList which has not been destroyed.
15708 * The reference count for the #GHook is incremented, so you must call
15709 * g_hook_unref() to restore it when no longer needed. (Or call
15710 * g_hook_next_valid() if you are stepping through the #GHookList.)
15712 * Returns: the first valid #GHook, or %NULL if none are valid
15718 * @hook_list: a #GHookList
15719 * @hook: the #GHook to free
15721 * Calls the #GHookList @finalize_hook function if it exists,
15722 * and frees the memory allocated for the #GHook.
15728 * @hook_list: a #GHookList
15729 * @hook_id: a hook id
15731 * Returns the #GHook with the given id, or %NULL if it is not found.
15733 * Returns: the #GHook with the given id, or %NULL if it is not found
15738 * g_hook_insert_before:
15739 * @hook_list: a #GHookList
15740 * @sibling: the #GHook to insert the new #GHook before
15741 * @hook: the #GHook to insert
15743 * Inserts a #GHook into a #GHookList, before a given #GHook.
15748 * g_hook_insert_sorted:
15749 * @hook_list: a #GHookList
15750 * @hook: the #GHook to insert
15751 * @func: the comparison function used to sort the #GHook elements
15753 * Inserts a #GHook into a #GHookList, sorted by the given function.
15758 * g_hook_list_clear:
15759 * @hook_list: a #GHookList
15761 * Removes all the #GHook elements from a #GHookList.
15766 * g_hook_list_init:
15767 * @hook_list: a #GHookList
15768 * @hook_size: the size of each element in the #GHookList, typically <literal>sizeof (GHook)</literal>
15770 * Initializes a #GHookList.
15771 * This must be called before the #GHookList is used.
15776 * g_hook_list_invoke:
15777 * @hook_list: a #GHookList
15778 * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15780 * Calls all of the #GHook functions in a #GHookList.
15785 * g_hook_list_invoke_check:
15786 * @hook_list: a #GHookList
15787 * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15789 * Calls all of the #GHook functions in a #GHookList.
15790 * Any function which returns %FALSE is removed from the #GHookList.
15795 * g_hook_list_marshal:
15796 * @hook_list: a #GHookList
15797 * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15798 * @marshaller: the function to call for each #GHook
15799 * @marshal_data: data to pass to @marshaller
15801 * Calls a function on each valid #GHook.
15806 * g_hook_list_marshal_check:
15807 * @hook_list: a #GHookList
15808 * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15809 * @marshaller: the function to call for each #GHook
15810 * @marshal_data: data to pass to @marshaller
15812 * Calls a function on each valid #GHook and destroys it if the
15813 * function returns %FALSE.
15818 * g_hook_next_valid:
15819 * @hook_list: a #GHookList
15820 * @hook: the current #GHook
15821 * @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
15823 * Returns the next #GHook in a #GHookList which has not been destroyed.
15824 * The reference count for the #GHook is incremented, so you must call
15825 * g_hook_unref() to restore it when no longer needed. (Or continue to call
15826 * g_hook_next_valid() until %NULL is returned.)
15828 * Returns: the next valid #GHook, or %NULL if none are valid
15834 * @hook_list: a #GHookList
15835 * @hook: the #GHook to add to the start of @hook_list
15837 * Prepends a #GHook on the start of a #GHookList.
15843 * @hook_list: a #GHookList
15844 * @hook: the #GHook to increment the reference count of
15846 * Increments the reference count for a #GHook.
15848 * Returns: the @hook that was passed in (since 2.6)
15854 * @hook_list: a #GHookList
15855 * @hook: the #GHook to unref
15857 * Decrements the reference count of a #GHook.
15858 * If the reference count falls to 0, the #GHook is removed
15859 * from the #GHookList and g_hook_free() is called to free it.
15864 * g_hostname_is_ascii_encoded:
15865 * @hostname: a hostname
15867 * Tests if @hostname contains segments with an ASCII-compatible
15868 * encoding of an Internationalized Domain Name. If this returns
15869 * %TRUE, you should decode the hostname with g_hostname_to_unicode()
15870 * before displaying it to the user.
15872 * Note that a hostname might contain a mix of encoded and unencoded
15873 * segments, and so it is possible for g_hostname_is_non_ascii() and
15874 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15876 * Returns: %TRUE if @hostname contains any ASCII-encoded segments.
15882 * g_hostname_is_ip_address:
15883 * @hostname: a hostname (or IP address in string form)
15885 * Tests if @hostname is the string form of an IPv4 or IPv6 address.
15886 * (Eg, "192.168.0.1".)
15888 * Returns: %TRUE if @hostname is an IP address
15894 * g_hostname_is_non_ascii:
15895 * @hostname: a hostname
15897 * Tests if @hostname contains Unicode characters. If this returns
15898 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
15899 * before using it in non-IDN-aware contexts.
15901 * Note that a hostname might contain a mix of encoded and unencoded
15902 * segments, and so it is possible for g_hostname_is_non_ascii() and
15903 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15905 * Returns: %TRUE if @hostname contains any non-ASCII characters
15911 * g_hostname_to_ascii:
15912 * @hostname: a valid UTF-8 or ASCII hostname
15914 * Converts @hostname to its canonical ASCII form; an ASCII-only
15915 * string containing no uppercase letters and not ending with a
15918 * Returns: an ASCII hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15924 * g_hostname_to_unicode:
15925 * @hostname: a valid UTF-8 or ASCII hostname
15927 * Converts @hostname to its canonical presentation form; a UTF-8
15928 * string in Unicode normalization form C, containing no uppercase
15929 * letters, no forbidden characters, and no ASCII-encoded segments,
15930 * and not ending with a trailing dot.
15932 * Of course if @hostname is not an internationalized hostname, then
15933 * the canonical presentation form will be entirely ASCII.
15935 * Returns: a UTF-8 hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15942 * @val: a 32-bit integer value in host byte order
15944 * Converts a 32-bit integer value from host to network byte order.
15946 * Returns: @val converted to network byte order
15952 * @val: a 16-bit integer value in host byte order
15954 * Converts a 16-bit integer value from host to network byte order.
15956 * Returns: @val converted to network byte order
15962 * @converter: conversion descriptor from g_iconv_open()
15963 * @inbuf: bytes to convert
15964 * @inbytes_left: inout parameter, bytes remaining to convert in @inbuf
15965 * @outbuf: converted output bytes
15966 * @outbytes_left: inout parameter, bytes available to fill in @outbuf
15968 * Same as the standard UNIX routine iconv(), but
15969 * may be implemented via libiconv on UNIX flavors that lack
15970 * a native implementation.
15972 * GLib provides g_convert() and g_locale_to_utf8() which are likely
15973 * more convenient than the raw iconv wrappers.
15975 * Returns: count of non-reversible conversions, or -1 on error
15981 * @converter: a conversion descriptor from g_iconv_open()
15983 * Same as the standard UNIX routine iconv_close(), but
15984 * may be implemented via libiconv on UNIX flavors that lack
15985 * a native implementation. Should be called to clean up
15986 * the conversion descriptor from g_iconv_open() when
15987 * you are done converting things.
15989 * GLib provides g_convert() and g_locale_to_utf8() which are likely
15990 * more convenient than the raw iconv wrappers.
15992 * Returns: -1 on error, 0 on success
15998 * @to_codeset: destination codeset
15999 * @from_codeset: source codeset
16001 * Same as the standard UNIX routine iconv_open(), but
16002 * may be implemented via libiconv on UNIX flavors that lack
16003 * a native implementation.
16005 * GLib provides g_convert() and g_locale_to_utf8() which are likely
16006 * more convenient than the raw iconv wrappers.
16008 * Returns: a "conversion descriptor", or (GIConv)-1 if opening the converter failed.
16014 * @function: function to call
16015 * @data: data to pass to @function.
16017 * Adds a function to be called whenever there are no higher priority
16018 * events pending to the default main loop. The function is given the
16019 * default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
16020 * returns %FALSE it is automatically removed from the list of event
16021 * sources and will not be called again.
16023 * This internally creates a main loop source using g_idle_source_new()
16024 * and attaches it to the main loop context using g_source_attach().
16025 * You can do these steps manually if you need greater control.
16027 * Returns: the ID (greater than 0) of the event source.
16033 * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
16034 * @function: function to call
16035 * @data: data to pass to @function
16036 * @notify: (allow-none): function to call when the idle is removed, or %NULL
16038 * Adds a function to be called whenever there are no higher priority
16039 * events pending. If the function returns %FALSE it is automatically
16040 * removed from the list of event sources and will not be called again.
16042 * This internally creates a main loop source using g_idle_source_new()
16043 * and attaches it to the main loop context using g_source_attach().
16044 * You can do these steps manually if you need greater control.
16046 * Returns: the ID (greater than 0) of the event source.
16047 * Rename to: g_idle_add
16052 * g_idle_remove_by_data:
16053 * @data: the data for the idle source's callback.
16055 * Removes the idle function with the given data.
16057 * Returns: %TRUE if an idle source was found and removed.
16062 * g_idle_source_new:
16064 * Creates a new idle source.
16066 * The source will not initially be associated with any #GMainContext
16067 * and must be added to one with g_source_attach() before it will be
16068 * executed. Note that the default priority for idle sources is
16069 * %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
16070 * have a default priority of %G_PRIORITY_DEFAULT.
16072 * Returns: the newly-created idle source
16078 * @v1: a pointer to a #gint64 key
16079 * @v2: a pointer to a #gint64 key to compare with @v1
16081 * Compares the two #gint64 values being pointed to and returns
16082 * %TRUE if they are equal.
16083 * It can be passed to g_hash_table_new() as the @key_equal_func
16084 * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
16087 * Returns: %TRUE if the two keys match.
16094 * @v: a pointer to a #gint64 key
16096 * Converts a pointer to a #gint64 to a hash value.
16098 * It can be passed to g_hash_table_new() as the @hash_func parameter,
16099 * when using non-%NULL pointers to 64-bit integer values as keys in a
16102 * Returns: a hash value corresponding to the key.
16109 * @v1: a pointer to a #gint key
16110 * @v2: a pointer to a #gint key to compare with @v1
16112 * Compares the two #gint values being pointed to and returns
16113 * %TRUE if they are equal.
16114 * It can be passed to g_hash_table_new() as the @key_equal_func
16115 * parameter, when using non-%NULL pointers to integers as keys in a
16118 * Note that this function acts on pointers to #gint, not on #gint directly:
16119 * if your hash table's keys are of the form
16120 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
16122 * Returns: %TRUE if the two keys match.
16128 * @v: a pointer to a #gint key
16130 * Converts a pointer to a #gint to a hash value.
16131 * It can be passed to g_hash_table_new() as the @hash_func parameter,
16132 * when using non-%NULL pointers to integer values as keys in a #GHashTable.
16134 * Note that this function acts on pointers to #gint, not on #gint directly:
16135 * if your hash table's keys are of the form
16136 * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
16138 * Returns: a hash value corresponding to the key.
16143 * g_intern_static_string:
16144 * @string: (allow-none): a static string
16146 * Returns a canonical representation for @string. Interned strings
16147 * can be compared for equality by comparing the pointers, instead of
16148 * using strcmp(). g_intern_static_string() does not copy the string,
16149 * therefore @string must not be freed or modified.
16151 * Returns: a canonical representation for the string
16158 * @string: (allow-none): a string
16160 * Returns a canonical representation for @string. Interned strings
16161 * can be compared for equality by comparing the pointers, instead of
16164 * Returns: a canonical representation for the string
16171 * @channel: a #GIOChannel
16172 * @condition: the condition to watch for
16173 * @func: the function to call when the condition is satisfied
16174 * @user_data: user data to pass to @func
16176 * Adds the #GIOChannel into the default main loop context
16177 * with the default priority.
16179 * Returns: the event source id
16184 * g_io_add_watch_full:
16185 * @channel: a #GIOChannel
16186 * @priority: the priority of the #GIOChannel source
16187 * @condition: the condition to watch for
16188 * @func: the function to call when the condition is satisfied
16189 * @user_data: user data to pass to @func
16190 * @notify: the function to call when the source is removed
16192 * Adds the #GIOChannel into the default main loop context
16193 * with the given priority.
16195 * This internally creates a main loop source using g_io_create_watch()
16196 * and attaches it to the main loop context with g_source_attach().
16197 * You can do these steps manually if you need greater control.
16199 * Returns: the event source id
16200 * Rename to: g_io_add_watch
16205 * g_io_channel_close:
16206 * @channel: A #GIOChannel
16208 * Close an IO channel. Any pending data to be written will be
16209 * flushed, ignoring errors. The channel will not be freed until the
16210 * last reference is dropped using g_io_channel_unref().
16212 * Deprecated: 2.2: Use g_io_channel_shutdown() instead.
16217 * g_io_channel_error_from_errno:
16218 * @en: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
16220 * Converts an <literal>errno</literal> error number to a #GIOChannelError.
16222 * Returns: a #GIOChannelError error number, e.g. %G_IO_CHANNEL_ERROR_INVAL.
16227 * g_io_channel_error_quark:
16229 * Returns: the quark used as %G_IO_CHANNEL_ERROR
16234 * g_io_channel_flush:
16235 * @channel: a #GIOChannel
16236 * @error: location to store an error of type #GIOChannelError
16238 * Flushes the write buffer for the GIOChannel.
16240 * Returns: the status of the operation: One of #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or #G_IO_STATUS_ERROR.
16245 * g_io_channel_get_buffer_condition:
16246 * @channel: A #GIOChannel
16248 * This function returns a #GIOCondition depending on whether there
16249 * is data to be read/space to write data in the internal buffers in
16250 * the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
16252 * Returns: A #GIOCondition
16257 * g_io_channel_get_buffer_size:
16258 * @channel: a #GIOChannel
16260 * Gets the buffer size.
16262 * Returns: the size of the buffer.
16267 * g_io_channel_get_buffered:
16268 * @channel: a #GIOChannel
16270 * Returns whether @channel is buffered.
16272 * Returns: %TRUE if the @channel is buffered.
16277 * g_io_channel_get_close_on_unref:
16278 * @channel: a #GIOChannel.
16280 * Returns whether the file/socket/whatever associated with @channel
16281 * will be closed when @channel receives its final unref and is
16282 * destroyed. The default value of this is %TRUE for channels created
16283 * by g_io_channel_new_file (), and %FALSE for all other channels.
16285 * Returns: Whether the channel will be closed on the final unref of the GIOChannel data structure.
16290 * g_io_channel_get_encoding:
16291 * @channel: a #GIOChannel
16293 * Gets the encoding for the input/output of the channel.
16294 * The internal encoding is always UTF-8. The encoding %NULL
16295 * makes the channel safe for binary data.
16297 * Returns: A string containing the encoding, this string is owned by GLib and must not be freed.
16302 * g_io_channel_get_flags:
16303 * @channel: a #GIOChannel
16305 * Gets the current flags for a #GIOChannel, including read-only
16306 * flags such as %G_IO_FLAG_IS_READABLE.
16308 * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
16309 * are cached for internal use by the channel when it is created.
16310 * If they should change at some later point (e.g. partial shutdown
16311 * of a socket with the UNIX shutdown() function), the user
16312 * should immediately call g_io_channel_get_flags() to update
16313 * the internal values of these flags.
16315 * Returns: the flags which are set on the channel
16320 * g_io_channel_get_line_term:
16321 * @channel: a #GIOChannel
16322 * @length: a location to return the length of the line terminator
16324 * This returns the string that #GIOChannel uses to determine
16325 * where in the file a line break occurs. A value of %NULL
16326 * indicates autodetection.
16328 * Returns: The line termination string. This value is owned by GLib and must not be freed.
16333 * g_io_channel_init:
16334 * @channel: a #GIOChannel
16336 * Initializes a #GIOChannel struct.
16338 * This is called by each of the above functions when creating a
16339 * #GIOChannel, and so is not often needed by the application
16340 * programmer (unless you are creating a new type of #GIOChannel).
16345 * g_io_channel_new_file:
16346 * @filename: A string containing the name of a file
16347 * @mode: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
16348 * @error: A location to return an error of type %G_FILE_ERROR
16350 * Open a file @filename as a #GIOChannel using mode @mode. This
16351 * channel will be closed when the last reference to it is dropped,
16352 * so there is no need to call g_io_channel_close() (though doing
16353 * so will not cause problems, as long as no attempt is made to
16354 * access the channel after it is closed).
16356 * Returns: A #GIOChannel on success, %NULL on failure.
16361 * g_io_channel_read:
16362 * @channel: a #GIOChannel
16363 * @buf: a buffer to read the data into (which should be at least count bytes long)
16364 * @count: the number of bytes to read from the #GIOChannel
16365 * @bytes_read: returns the number of bytes actually read
16367 * Reads data from a #GIOChannel.
16369 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16370 * Deprecated: 2.2: Use g_io_channel_read_chars() instead.
16375 * g_io_channel_read_chars:
16376 * @channel: a #GIOChannel
16377 * @buf: (out caller-allocates) (array length=count) (element-type guint8): a buffer to read data into
16378 * @count: (in): 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.
16379 * @bytes_read: (allow-none) (out): 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.
16380 * @error: a location to return an error of type #GConvertError or #GIOChannelError.
16382 * Replacement for g_io_channel_read() with the new API.
16384 * Returns: the status of the operation.
16389 * g_io_channel_read_line:
16390 * @channel: a #GIOChannel
16391 * @str_return: (out): 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.
16392 * @length: (allow-none) (out): location to store length of the read data, or %NULL
16393 * @terminator_pos: (allow-none) (out): location to store position of line terminator, or %NULL
16394 * @error: A location to return an error of type #GConvertError or #GIOChannelError
16396 * Reads a line, including the terminating character(s),
16397 * from a #GIOChannel into a newly-allocated string.
16398 * @str_return will contain allocated memory if the return
16399 * is %G_IO_STATUS_NORMAL.
16401 * Returns: the status of the operation.
16406 * g_io_channel_read_line_string:
16407 * @channel: a #GIOChannel
16408 * @buffer: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
16409 * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
16410 * @error: a location to store an error of type #GConvertError or #GIOChannelError
16412 * Reads a line from a #GIOChannel, using a #GString as a buffer.
16414 * Returns: the status of the operation.
16419 * g_io_channel_read_to_end:
16420 * @channel: a #GIOChannel
16421 * @str_return: (out) (array length=length) (element-type guint8): 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.
16422 * @length: (out): location to store length of the data
16423 * @error: location to return an error of type #GConvertError or #GIOChannelError
16425 * Reads all the remaining data from the file.
16427 * Returns: %G_IO_STATUS_NORMAL on success. This function never returns %G_IO_STATUS_EOF.
16432 * g_io_channel_read_unichar:
16433 * @channel: a #GIOChannel
16434 * @thechar: (out): a location to return a character
16435 * @error: a location to return an error of type #GConvertError or #GIOChannelError
16437 * Reads a Unicode character from @channel.
16438 * This function cannot be called on a channel with %NULL encoding.
16440 * Returns: a #GIOStatus
16445 * g_io_channel_ref:
16446 * @channel: a #GIOChannel
16448 * Increments the reference count of a #GIOChannel.
16450 * Returns: the @channel that was passed in (since 2.6)
16455 * g_io_channel_seek:
16456 * @channel: a #GIOChannel
16457 * @offset: an offset, in bytes, which is added to the position specified by @type
16458 * @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)
16460 * Sets the current position in the #GIOChannel, similar to the standard
16461 * library function fseek().
16463 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16464 * Deprecated: 2.2: Use g_io_channel_seek_position() instead.
16469 * g_io_channel_seek_position:
16470 * @channel: a #GIOChannel
16471 * @offset: The offset in bytes from the position specified by @type
16472 * @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.
16473 * @error: A location to return an error of type #GIOChannelError
16475 * Replacement for g_io_channel_seek() with the new API.
16477 * Returns: the status of the operation.
16482 * g_io_channel_set_buffer_size:
16483 * @channel: a #GIOChannel
16484 * @size: the size of the buffer, or 0 to let GLib pick a good size
16486 * Sets the buffer size.
16491 * g_io_channel_set_buffered:
16492 * @channel: a #GIOChannel
16493 * @buffered: whether to set the channel buffered or unbuffered
16495 * The buffering state can only be set if the channel's encoding
16496 * is %NULL. For any other encoding, the channel must be buffered.
16498 * A buffered channel can only be set unbuffered if the channel's
16499 * internal buffers have been flushed. Newly created channels or
16500 * channels which have returned %G_IO_STATUS_EOF
16501 * not require such a flush. For write-only channels, a call to
16502 * g_io_channel_flush () is sufficient. For all other channels,
16503 * the buffers may be flushed by a call to g_io_channel_seek_position ().
16504 * This includes the possibility of seeking with seek type %G_SEEK_CUR
16505 * and an offset of zero. Note that this means that socket-based
16506 * channels cannot be set unbuffered once they have had data
16509 * On unbuffered channels, it is safe to mix read and write
16510 * calls from the new and old APIs, if this is necessary for
16511 * maintaining old code.
16513 * The default state of the channel is buffered.
16518 * g_io_channel_set_close_on_unref:
16519 * @channel: a #GIOChannel
16520 * @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.
16522 * Setting this flag to %TRUE for a channel you have already closed
16523 * can cause problems.
16528 * g_io_channel_set_encoding:
16529 * @channel: a #GIOChannel
16530 * @encoding: (allow-none): the encoding type
16531 * @error: location to store an error of type #GConvertError
16533 * Sets the encoding for the input/output of the channel.
16534 * The internal encoding is always UTF-8. The default encoding
16535 * for the external file is UTF-8.
16537 * The encoding %NULL is safe to use with binary data.
16539 * The encoding can only be set if one of the following conditions
16543 * The channel was just created, and has not been written to or read
16545 * </para></listitem>
16547 * The channel is write-only.
16548 * </para></listitem>
16550 * The channel is a file, and the file pointer was just
16551 * repositioned by a call to g_io_channel_seek_position().
16552 * (This flushes all the internal buffers.)
16553 * </para></listitem>
16555 * The current encoding is %NULL or UTF-8.
16556 * </para></listitem>
16558 * One of the (new API) read functions has just returned %G_IO_STATUS_EOF
16559 * (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
16560 * </para></listitem>
16562 * One of the functions g_io_channel_read_chars() or
16563 * g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
16564 * %G_IO_STATUS_ERROR. This may be useful in the case of
16565 * %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
16566 * Returning one of these statuses from g_io_channel_read_line(),
16567 * g_io_channel_read_line_string(), or g_io_channel_read_to_end()
16568 * does <emphasis>not</emphasis> guarantee that the encoding can
16570 * </para></listitem>
16572 * Channels which do not meet one of the above conditions cannot call
16573 * g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
16574 * they are "seekable", cannot call g_io_channel_write_chars() after
16575 * calling one of the API "read" functions.
16577 * Returns: %G_IO_STATUS_NORMAL if the encoding was successfully set.
16582 * g_io_channel_set_flags:
16583 * @channel: a #GIOChannel
16584 * @flags: the flags to set on the IO channel
16585 * @error: A location to return an error of type #GIOChannelError
16587 * Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
16589 * Returns: the status of the operation.
16594 * g_io_channel_set_line_term:
16595 * @channel: a #GIOChannel
16596 * @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.
16597 * @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.
16599 * This sets the string that #GIOChannel uses to determine
16600 * where in the file a line break occurs.
16605 * g_io_channel_shutdown:
16606 * @channel: a #GIOChannel
16607 * @flush: if %TRUE, flush pending
16608 * @err: location to store a #GIOChannelError
16610 * Close an IO channel. Any pending data to be written will be
16611 * flushed if @flush is %TRUE. The channel will not be freed until the
16612 * last reference is dropped using g_io_channel_unref().
16614 * Returns: the status of the operation.
16619 * g_io_channel_unix_get_fd:
16620 * @channel: a #GIOChannel, created with g_io_channel_unix_new().
16622 * Returns the file descriptor of the #GIOChannel.
16624 * On Windows this function returns the file descriptor or socket of
16627 * Returns: the file descriptor of the #GIOChannel.
16632 * g_io_channel_unix_new:
16633 * @fd: a file descriptor.
16635 * Creates a new #GIOChannel given a file descriptor. On UNIX systems
16636 * this works for plain files, pipes, and sockets.
16638 * The returned #GIOChannel has a reference count of 1.
16640 * The default encoding for #GIOChannel is UTF-8. If your application
16641 * is reading output from a command using via pipe, you may need to set
16642 * the encoding to the encoding of the current locale (see
16643 * g_get_charset()) with the g_io_channel_set_encoding() function.
16645 * If you want to read raw binary data without interpretation, then
16646 * call the g_io_channel_set_encoding() function with %NULL for the
16647 * encoding argument.
16649 * This function is available in GLib on Windows, too, but you should
16650 * avoid using it on Windows. The domain of file descriptors and
16651 * sockets overlap. There is no way for GLib to know which one you mean
16652 * in case the argument you pass to this function happens to be both a
16653 * valid file descriptor and socket. If that happens a warning is
16654 * issued, and GLib assumes that it is the file descriptor you mean.
16656 * Returns: a new #GIOChannel.
16661 * g_io_channel_unref:
16662 * @channel: a #GIOChannel
16664 * Decrements the reference count of a #GIOChannel.
16669 * g_io_channel_win32_new_fd:
16670 * @fd: a C library file descriptor.
16672 * Creates a new #GIOChannel given a file descriptor on Windows. This
16673 * works for file descriptors from the C runtime.
16675 * This function works for file descriptors as returned by the open(),
16676 * creat(), pipe() and fileno() calls in the Microsoft C runtime. In
16677 * order to meaningfully use this function your code should use the
16678 * same C runtime as GLib uses, which is msvcrt.dll. Note that in
16679 * current Microsoft compilers it is near impossible to convince it to
16680 * build code that would use msvcrt.dll. The last Microsoft compiler
16681 * version that supported using msvcrt.dll as the C runtime was version
16682 * 6. The GNU compiler and toolchain for Windows, also known as Mingw,
16683 * fully supports msvcrt.dll.
16685 * If you have created a #GIOChannel for a file descriptor and started
16686 * watching (polling) it, you shouldn't call read() on the file
16687 * descriptor. This is because adding polling for a file descriptor is
16688 * implemented in GLib on Windows by starting a thread that sits
16689 * blocked in a read() from the file descriptor most of the time. All
16690 * reads from the file descriptor should be done by this internal GLib
16691 * thread. Your code should call only g_io_channel_read().
16693 * This function is available only in GLib on Windows.
16695 * Returns: a new #GIOChannel.
16700 * g_io_channel_win32_new_messages:
16701 * @hwnd: a window handle.
16703 * Creates a new #GIOChannel given a window handle on Windows.
16705 * This function creates a #GIOChannel that can be used to poll for
16706 * Windows messages for the window in question.
16708 * Returns: a new #GIOChannel.
16713 * g_io_channel_win32_new_socket:
16714 * @socket: a Winsock socket
16716 * Creates a new #GIOChannel given a socket on Windows.
16718 * This function works for sockets created by Winsock. It's available
16719 * only in GLib on Windows.
16721 * Polling a #GSource created to watch a channel for a socket puts the
16722 * socket in non-blocking mode. This is a side-effect of the
16723 * implementation and unavoidable.
16725 * Returns: a new #GIOChannel
16730 * g_io_channel_write:
16731 * @channel: a #GIOChannel
16732 * @buf: the buffer containing the data to write
16733 * @count: the number of bytes to write
16734 * @bytes_written: the number of bytes actually written
16736 * Writes data to a #GIOChannel.
16738 * Returns: %G_IO_ERROR_NONE if the operation was successful.
16739 * Deprecated: 2.2: Use g_io_channel_write_chars() instead.
16744 * g_io_channel_write_chars:
16745 * @channel: a #GIOChannel
16746 * @buf: (array) (element-type guint8): a buffer to write data from
16747 * @count: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
16748 * @bytes_written: (out): 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.
16749 * @error: a location to return an error of type #GConvertError or #GIOChannelError
16751 * Replacement for g_io_channel_write() with the new API.
16753 * On seekable channels with encodings other than %NULL or UTF-8, generic
16754 * mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
16755 * may only be made on a channel from which data has been read in the
16756 * cases described in the documentation for g_io_channel_set_encoding ().
16758 * Returns: the status of the operation.
16763 * g_io_channel_write_unichar:
16764 * @channel: a #GIOChannel
16765 * @thechar: a character
16766 * @error: location to return an error of type #GConvertError or #GIOChannelError
16768 * Writes a Unicode character to @channel.
16769 * This function cannot be called on a channel with %NULL encoding.
16771 * Returns: a #GIOStatus
16776 * g_io_create_watch:
16777 * @channel: a #GIOChannel to watch
16778 * @condition: conditions to watch for
16780 * Creates a #GSource that's dispatched when @condition is met for the
16781 * given @channel. For example, if condition is #G_IO_IN, the source will
16782 * be dispatched when there's data available for reading.
16784 * g_io_add_watch() is a simpler interface to this same functionality, for
16785 * the case where you want to add the source to the default main loop context
16786 * at the default priority.
16788 * On Windows, polling a #GSource created to watch a channel for a socket
16789 * puts the socket in non-blocking mode. This is a side-effect of the
16790 * implementation and unavoidable.
16792 * Returns: a new #GSource
16797 * g_key_file_free: (skip)
16798 * @key_file: a #GKeyFile
16800 * Clears all keys and groups from @key_file, and decreases the
16801 * reference count by 1. If the reference count reaches zero,
16802 * frees the key file and all its allocated memory.
16809 * g_key_file_get_boolean:
16810 * @key_file: a #GKeyFile
16811 * @group_name: a group name
16813 * @error: return location for a #GError
16815 * Returns the value associated with @key under @group_name as a
16818 * If @key cannot be found then %FALSE is returned and @error is set
16819 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
16820 * associated with @key cannot be interpreted as a boolean then %FALSE
16821 * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16823 * Returns: the value associated with the key as a boolean, or %FALSE if the key was not found or could not be parsed.
16829 * g_key_file_get_boolean_list:
16830 * @key_file: a #GKeyFile
16831 * @group_name: a group name
16833 * @length: (out): the number of booleans returned
16834 * @error: return location for a #GError
16836 * Returns the values associated with @key under @group_name as
16839 * If @key cannot be found then %NULL is returned and @error is set to
16840 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16841 * with @key cannot be interpreted as booleans then %NULL is returned
16842 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16844 * 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.
16850 * g_key_file_get_comment:
16851 * @key_file: a #GKeyFile
16852 * @group_name: (allow-none): a group name, or %NULL
16854 * @error: return location for a #GError
16856 * Retrieves a comment above @key from @group_name.
16857 * If @key is %NULL then @comment will be read from above
16858 * @group_name. If both @key and @group_name are %NULL, then
16859 * @comment will be read from above the first group in the file.
16861 * Returns: a comment that should be freed with g_free()
16867 * g_key_file_get_double:
16868 * @key_file: a #GKeyFile
16869 * @group_name: a group name
16871 * @error: return location for a #GError
16873 * Returns the value associated with @key under @group_name as a
16874 * double. If @group_name is %NULL, the start_group is used.
16876 * If @key cannot be found then 0.0 is returned and @error is set to
16877 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16878 * with @key cannot be interpreted as a double then 0.0 is returned
16879 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16881 * Returns: the value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.
16887 * g_key_file_get_double_list:
16888 * @key_file: a #GKeyFile
16889 * @group_name: a group name
16891 * @length: (out): the number of doubles returned
16892 * @error: return location for a #GError
16894 * Returns the values associated with @key under @group_name as
16897 * If @key cannot be found then %NULL is returned and @error is set to
16898 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16899 * with @key cannot be interpreted as doubles then %NULL is returned
16900 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16902 * 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.
16908 * g_key_file_get_groups:
16909 * @key_file: a #GKeyFile
16910 * @length: (out) (allow-none): return location for the number of returned groups, or %NULL
16912 * Returns all groups in the key file loaded with @key_file.
16913 * The array of returned groups will be %NULL-terminated, so
16914 * @length may optionally be %NULL.
16916 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16922 * g_key_file_get_int64:
16923 * @key_file: a non-%NULL #GKeyFile
16924 * @group_name: a non-%NULL group name
16925 * @key: a non-%NULL key
16926 * @error: return location for a #GError
16928 * Returns the value associated with @key under @group_name as a signed
16929 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
16930 * 64-bit results without truncation.
16932 * 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.
16938 * g_key_file_get_integer:
16939 * @key_file: a #GKeyFile
16940 * @group_name: a group name
16942 * @error: return location for a #GError
16944 * Returns the value associated with @key under @group_name as an
16947 * If @key cannot be found then 0 is returned and @error is set to
16948 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16949 * with @key cannot be interpreted as an integer then 0 is returned
16950 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16952 * Returns: the value associated with the key as an integer, or 0 if the key was not found or could not be parsed.
16958 * g_key_file_get_integer_list:
16959 * @key_file: a #GKeyFile
16960 * @group_name: a group name
16962 * @length: (out): the number of integers returned
16963 * @error: return location for a #GError
16965 * Returns the values associated with @key under @group_name as
16968 * If @key cannot be found then %NULL is returned and @error is set to
16969 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16970 * with @key cannot be interpreted as integers then %NULL is returned
16971 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16973 * 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.
16979 * g_key_file_get_keys:
16980 * @key_file: a #GKeyFile
16981 * @group_name: a group name
16982 * @length: (out) (allow-none): return location for the number of keys returned, or %NULL
16983 * @error: return location for a #GError, or %NULL
16985 * Returns all keys for the group name @group_name. The array of
16986 * returned keys will be %NULL-terminated, so @length may
16987 * optionally be %NULL. In the event that the @group_name cannot
16988 * be found, %NULL is returned and @error is set to
16989 * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16991 * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16997 * g_key_file_get_locale_string:
16998 * @key_file: a #GKeyFile
16999 * @group_name: a group name
17001 * @locale: (allow-none): a locale identifier or %NULL
17002 * @error: return location for a #GError, or %NULL
17004 * Returns the value associated with @key under @group_name
17005 * translated in the given @locale if available. If @locale is
17006 * %NULL then the current locale is assumed.
17008 * If @key cannot be found then %NULL is returned and @error is set
17009 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
17010 * with @key cannot be interpreted or no suitable translation can
17011 * be found then the untranslated value is returned.
17013 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17019 * g_key_file_get_locale_string_list:
17020 * @key_file: a #GKeyFile
17021 * @group_name: a group name
17023 * @locale: (allow-none): a locale identifier or %NULL
17024 * @length: (out) (allow-none): return location for the number of returned strings or %NULL
17025 * @error: return location for a #GError or %NULL
17027 * Returns the values associated with @key under @group_name
17028 * translated in the given @locale if available. If @locale is
17029 * %NULL then the current locale is assumed.
17031 * If @key cannot be found then %NULL is returned and @error is set
17032 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
17033 * with @key cannot be interpreted or no suitable translations
17034 * can be found then the untranslated values are returned. The
17035 * returned array is %NULL-terminated, so @length may optionally
17038 * Returns: (array zero-terminated=1 length=length) (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().
17044 * g_key_file_get_start_group:
17045 * @key_file: a #GKeyFile
17047 * Returns the name of the start group of the file.
17049 * Returns: The start group of the key file.
17055 * g_key_file_get_string:
17056 * @key_file: a #GKeyFile
17057 * @group_name: a group name
17059 * @error: return location for a #GError, or %NULL
17061 * Returns the string value associated with @key under @group_name.
17062 * Unlike g_key_file_get_value(), this function handles escape sequences
17065 * In the event the key cannot be found, %NULL is returned and
17066 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17067 * event that the @group_name cannot be found, %NULL is returned
17068 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17070 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17076 * g_key_file_get_string_list:
17077 * @key_file: a #GKeyFile
17078 * @group_name: a group name
17080 * @length: (out) (allow-none): return location for the number of returned strings, or %NULL
17081 * @error: return location for a #GError, or %NULL
17083 * Returns the values associated with @key under @group_name.
17085 * In the event the key cannot be found, %NULL is returned and
17086 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17087 * event that the @group_name cannot be found, %NULL is returned
17088 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17090 * Returns: (array zero-terminated=1 length=length) (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().
17096 * g_key_file_get_uint64:
17097 * @key_file: a non-%NULL #GKeyFile
17098 * @group_name: a non-%NULL group name
17099 * @key: a non-%NULL key
17100 * @error: return location for a #GError
17102 * Returns the value associated with @key under @group_name as an unsigned
17103 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17104 * large positive results without truncation.
17106 * 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.
17112 * g_key_file_get_value:
17113 * @key_file: a #GKeyFile
17114 * @group_name: a group name
17116 * @error: return location for a #GError, or %NULL
17118 * Returns the raw value associated with @key under @group_name.
17119 * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
17121 * In the event the key cannot be found, %NULL is returned and
17122 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
17123 * event that the @group_name cannot be found, %NULL is returned
17124 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17126 * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17132 * g_key_file_has_group:
17133 * @key_file: a #GKeyFile
17134 * @group_name: a group name
17136 * Looks whether the key file has the group @group_name.
17138 * Returns: %TRUE if @group_name is a part of @key_file, %FALSE otherwise.
17144 * g_key_file_has_key: (skip)
17145 * @key_file: a #GKeyFile
17146 * @group_name: a group name
17148 * @error: return location for a #GError
17150 * Looks whether the key file has the key @key in the group
17153 * <note>This function does not follow the rules for #GError strictly;
17154 * the return value both carries meaning and signals an error. To use
17155 * this function, you must pass a #GError pointer in @error, and check
17156 * whether it is not %NULL to see if an error occurred.</note>
17158 * Language bindings should use g_key_file_get_value() to test whether
17159 * or not a key exists.
17161 * Returns: %TRUE if @key is a part of @group_name, %FALSE otherwise.
17167 * g_key_file_load_from_data:
17168 * @key_file: an empty #GKeyFile struct
17169 * @data: key file loaded in memory
17170 * @length: the length of @data in bytes (or -1 if data is nul-terminated)
17171 * @flags: flags from #GKeyFileFlags
17172 * @error: return location for a #GError, or %NULL
17174 * Loads a key file from memory into an empty #GKeyFile structure.
17175 * If the object cannot be created then %error is set to a #GKeyFileError.
17177 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17183 * g_key_file_load_from_data_dirs:
17184 * @key_file: an empty #GKeyFile struct
17185 * @file: (type filename): a relative path to a filename to open and parse
17186 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17187 * @flags: flags from #GKeyFileFlags
17188 * @error: return location for a #GError, or %NULL
17190 * This function looks for a key file named @file in the paths
17191 * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
17192 * loads the file into @key_file and returns the file's full path in
17193 * @full_path. If the file could not be loaded then an %error is
17194 * set to either a #GFileError or #GKeyFileError.
17196 * Returns: %TRUE if a key file could be loaded, %FALSE othewise
17202 * g_key_file_load_from_dirs:
17203 * @key_file: an empty #GKeyFile struct
17204 * @file: (type filename): a relative path to a filename to open and parse
17205 * @search_dirs: (array zero-terminated=1) (element-type filename): %NULL-terminated array of directories to search
17206 * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17207 * @flags: flags from #GKeyFileFlags
17208 * @error: return location for a #GError, or %NULL
17210 * This function looks for a key file named @file in the paths
17211 * specified in @search_dirs, loads the file into @key_file and
17212 * returns the file's full path in @full_path. If the file could not
17213 * be loaded then an %error is set to either a #GFileError or
17216 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17222 * g_key_file_load_from_file:
17223 * @key_file: an empty #GKeyFile struct
17224 * @file: (type filename): the path of a filename to load, in the GLib filename encoding
17225 * @flags: flags from #GKeyFileFlags
17226 * @error: return location for a #GError, or %NULL
17228 * Loads a key file into an empty #GKeyFile structure.
17229 * If the file could not be loaded then @error is set to
17230 * either a #GFileError or #GKeyFileError.
17232 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17240 * Creates a new empty #GKeyFile object. Use
17241 * g_key_file_load_from_file(), g_key_file_load_from_data(),
17242 * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
17243 * read an existing key file.
17245 * Returns: (transfer full): an empty #GKeyFile.
17251 * g_key_file_ref: (skip)
17252 * @key_file: a #GKeyFile
17254 * Increases the reference count of @key_file.
17256 * Returns: the same @key_file.
17262 * g_key_file_remove_comment:
17263 * @key_file: a #GKeyFile
17264 * @group_name: (allow-none): a group name, or %NULL
17265 * @key: (allow-none): a key
17266 * @error: return location for a #GError
17268 * Removes a comment above @key from @group_name.
17269 * If @key is %NULL then @comment will be removed above @group_name.
17270 * If both @key and @group_name are %NULL, then @comment will
17271 * be removed above the first group in the file.
17273 * Returns: %TRUE if the comment was removed, %FALSE otherwise
17279 * g_key_file_remove_group:
17280 * @key_file: a #GKeyFile
17281 * @group_name: a group name
17282 * @error: return location for a #GError or %NULL
17284 * Removes the specified group, @group_name,
17285 * from the key file.
17287 * Returns: %TRUE if the group was removed, %FALSE otherwise
17293 * g_key_file_remove_key:
17294 * @key_file: a #GKeyFile
17295 * @group_name: a group name
17296 * @key: a key name to remove
17297 * @error: return location for a #GError or %NULL
17299 * Removes @key in @group_name from the key file.
17301 * Returns: %TRUE if the key was removed, %FALSE otherwise
17307 * g_key_file_set_boolean:
17308 * @key_file: a #GKeyFile
17309 * @group_name: a group name
17311 * @value: %TRUE or %FALSE
17313 * Associates a new boolean value with @key under @group_name.
17314 * If @key cannot be found then it is created.
17321 * g_key_file_set_boolean_list:
17322 * @key_file: a #GKeyFile
17323 * @group_name: a group name
17325 * @list: (array length=length): an array of boolean values
17326 * @length: length of @list
17328 * Associates a list of boolean values with @key under @group_name.
17329 * If @key cannot be found then it is created.
17330 * If @group_name is %NULL, the start_group is used.
17337 * g_key_file_set_comment:
17338 * @key_file: a #GKeyFile
17339 * @group_name: (allow-none): a group name, or %NULL
17340 * @key: (allow-none): a key
17341 * @comment: a comment
17342 * @error: return location for a #GError
17344 * Places a comment above @key from @group_name.
17345 * If @key is %NULL then @comment will be written above @group_name.
17346 * If both @key and @group_name are %NULL, then @comment will be
17347 * written above the first group in the file.
17349 * Returns: %TRUE if the comment was written, %FALSE otherwise
17355 * g_key_file_set_double:
17356 * @key_file: a #GKeyFile
17357 * @group_name: a group name
17359 * @value: an double value
17361 * Associates a new double value with @key under @group_name.
17362 * If @key cannot be found then it is created.
17369 * g_key_file_set_double_list:
17370 * @key_file: a #GKeyFile
17371 * @group_name: a group name
17373 * @list: (array length=length): an array of double values
17374 * @length: number of double values in @list
17376 * Associates a list of double values with @key under
17377 * @group_name. If @key cannot be found then it is created.
17384 * g_key_file_set_int64:
17385 * @key_file: a #GKeyFile
17386 * @group_name: a group name
17388 * @value: an integer value
17390 * Associates a new integer value with @key under @group_name.
17391 * If @key cannot be found then it is created.
17398 * g_key_file_set_integer:
17399 * @key_file: a #GKeyFile
17400 * @group_name: a group name
17402 * @value: an integer value
17404 * Associates a new integer value with @key under @group_name.
17405 * If @key cannot be found then it is created.
17412 * g_key_file_set_integer_list:
17413 * @key_file: a #GKeyFile
17414 * @group_name: a group name
17416 * @list: (array length=length): an array of integer values
17417 * @length: number of integer values in @list
17419 * Associates a list of integer values with @key under @group_name.
17420 * If @key cannot be found then it is created.
17427 * g_key_file_set_list_separator:
17428 * @key_file: a #GKeyFile
17429 * @separator: the separator
17431 * Sets the character which is used to separate
17432 * values in lists. Typically ';' or ',' are used
17433 * as separators. The default list separator is ';'.
17440 * g_key_file_set_locale_string:
17441 * @key_file: a #GKeyFile
17442 * @group_name: a group name
17444 * @locale: a locale identifier
17445 * @string: a string
17447 * Associates a string value for @key and @locale under @group_name.
17448 * If the translation for @key cannot be found then it is created.
17455 * g_key_file_set_locale_string_list:
17456 * @key_file: a #GKeyFile
17457 * @group_name: a group name
17459 * @locale: a locale identifier
17460 * @list: (array zero-terminated=1 length=length): a %NULL-terminated array of locale string values
17461 * @length: the length of @list
17463 * Associates a list of string values for @key and @locale under
17464 * @group_name. If the translation for @key cannot be found then
17472 * g_key_file_set_string:
17473 * @key_file: a #GKeyFile
17474 * @group_name: a group name
17476 * @string: a string
17478 * Associates a new string value with @key under @group_name.
17479 * If @key cannot be found then it is created.
17480 * If @group_name cannot be found then it is created.
17481 * Unlike g_key_file_set_value(), this function handles characters
17482 * that need escaping, such as newlines.
17489 * g_key_file_set_string_list:
17490 * @key_file: a #GKeyFile
17491 * @group_name: a group name
17493 * @list: (array zero-terminated=1 length=length) (element-type utf8): an array of string values
17494 * @length: number of string values in @list
17496 * Associates a list of string values for @key under @group_name.
17497 * If @key cannot be found then it is created.
17498 * If @group_name cannot be found then it is created.
17505 * g_key_file_set_uint64:
17506 * @key_file: a #GKeyFile
17507 * @group_name: a group name
17509 * @value: an integer value
17511 * Associates a new integer value with @key under @group_name.
17512 * If @key cannot be found then it is created.
17519 * g_key_file_set_value:
17520 * @key_file: a #GKeyFile
17521 * @group_name: a group name
17525 * Associates a new value with @key under @group_name.
17527 * If @key cannot be found then it is created. If @group_name cannot
17528 * be found then it is created. To set an UTF-8 string which may contain
17529 * characters that need escaping (such as newlines or spaces), use
17530 * g_key_file_set_string().
17537 * g_key_file_to_data:
17538 * @key_file: a #GKeyFile
17539 * @length: (out) (allow-none): return location for the length of the returned string, or %NULL
17540 * @error: return location for a #GError, or %NULL
17542 * This function outputs @key_file as a string.
17544 * Note that this function never reports an error,
17545 * so it is safe to pass %NULL as @error.
17547 * Returns: a newly allocated string holding the contents of the #GKeyFile
17553 * g_key_file_unref:
17554 * @key_file: a #GKeyFile
17556 * Decreases the reference count of @key_file by 1. If the reference count
17557 * reaches zero, frees the key file and all its allocated memory.
17566 * Allocates space for one #GList element. It is called by
17567 * g_list_append(), g_list_prepend(), g_list_insert() and
17568 * g_list_insert_sorted() and so is rarely used on its own.
17570 * Returns: a pointer to the newly-allocated #GList element.
17576 * @list: a pointer to a #GList
17577 * @data: the data for the new element
17579 * Adds a new element on to the end of the list.
17582 * The return value is the new start of the list, which
17583 * may have changed, so make sure you store the new value.
17587 * Note that g_list_append() has to traverse the entire list
17588 * to find the end, which is inefficient when adding multiple
17589 * elements. A common idiom to avoid the inefficiency is to prepend
17590 * the elements and reverse the list when all elements have been added.
17594 * /* Notice that these are initialized to the empty list. */
17595 * GList *list = NULL, *number_list = NULL;
17597 * /* This is a list of strings. */
17598 * list = g_list_append (list, "first");
17599 * list = g_list_append (list, "second");
17601 * /* This is a list of integers. */
17602 * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
17603 * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
17606 * Returns: the new start of the #GList
17613 * @list2: the #GList to add to the end of the first #GList
17615 * Adds the second #GList onto the end of the first #GList.
17616 * Note that the elements of the second #GList are not copied.
17617 * They are used directly.
17619 * Returns: the start of the new #GList
17630 * Note that this is a "shallow" copy. If the list elements
17631 * consist of pointers to data, the pointers are copied but
17632 * the actual data is not. See g_list_copy_deep() if you need
17633 * to copy the data as well.
17636 * Returns: a copy of @list
17641 * g_list_copy_deep:
17643 * @func: a copy function used to copy every element in the list
17644 * @user_data: user data passed to the copy function @func, or #NULL
17646 * Makes a full (deep) copy of a #GList.
17648 * In contrast with g_list_copy(), this function uses @func to make a copy of
17649 * each list element, in addition to copying the list container itself.
17651 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
17652 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
17655 * For instance, if @list holds a list of GObjects, you can do:
17657 * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
17660 * And, to entirely free the new list, you could do:
17662 * g_list_free_full (another_list, g_object_unref);
17665 * Returns: a full copy of @list, use #g_list_free_full to free it
17671 * g_list_delete_link:
17673 * @link_: node to delete from @list
17675 * Removes the node link_ from the list and frees it.
17676 * Compare this to g_list_remove_link() which removes the node
17677 * without freeing it.
17679 * Returns: the new head of @list
17686 * @data: the element data to find
17688 * Finds the element in a #GList which
17689 * contains the given data.
17691 * Returns: the found #GList element, or %NULL if it is not found
17696 * g_list_find_custom:
17698 * @data: user data passed to the function
17699 * @func: the function to call for each element. It should return 0 when the desired element is found
17701 * Finds an element in a #GList, using a supplied function to
17702 * find the desired element. It iterates over the list, calling
17703 * the given function which should return 0 when the desired
17704 * element is found. The function takes two #gconstpointer arguments,
17705 * the #GList element's data as the first argument and the
17708 * Returns: the found #GList element, or %NULL if it is not found
17716 * Gets the first element in a #GList.
17718 * Returns: the first element in the #GList, or %NULL if the #GList has no elements
17725 * @func: the function to call with each element's data
17726 * @user_data: user data to pass to the function
17728 * Calls a function for each element of a #GList.
17736 * Frees all of the memory used by a #GList.
17737 * The freed elements are returned to the slice allocator.
17740 * If list elements contain dynamically-allocated memory,
17741 * you should either use g_list_free_full() or free them manually
17750 * Another name for g_list_free_1().
17756 * @list: a #GList element
17758 * Frees one #GList element.
17759 * It is usually used after g_list_remove_link().
17764 * g_list_free_full:
17765 * @list: a pointer to a #GList
17766 * @free_func: the function to be called to free each element's data
17768 * Convenience method, which frees all the memory used by a #GList, and
17769 * calls the specified destroy function on every element's data.
17778 * @data: the data to find
17780 * Gets the position of the element containing
17781 * the given data (starting from 0).
17783 * Returns: the index of the element containing the data, or -1 if the data is not found
17789 * @list: a pointer to a #GList
17790 * @data: the data for the new element
17791 * @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.
17793 * Inserts a new element into the list at the given position.
17795 * Returns: the new start of the #GList
17800 * g_list_insert_before:
17801 * @list: a pointer to a #GList
17802 * @sibling: the list element before which the new element is inserted or %NULL to insert at the end of the list
17803 * @data: the data for the new element
17805 * Inserts a new element into the list before the given position.
17807 * Returns: the new start of the #GList
17812 * g_list_insert_sorted:
17813 * @list: a pointer to a #GList
17814 * @data: the data for the new element
17815 * @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.
17817 * Inserts a new element into the list, using the given comparison
17818 * function to determine its position.
17820 * Returns: the new start of the #GList
17825 * g_list_insert_sorted_with_data:
17826 * @list: a pointer to a #GList
17827 * @data: the data for the new element
17828 * @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.
17829 * @user_data: user data to pass to comparison function.
17831 * Inserts a new element into the list, using the given comparison
17832 * function to determine its position.
17834 * Returns: the new start of the #GList
17843 * Gets the last element in a #GList.
17845 * Returns: the last element in the #GList, or %NULL if the #GList has no elements
17853 * Gets the number of elements in a #GList.
17856 * This function iterates over the whole list to
17857 * count its elements.
17860 * Returns: the number of elements in the #GList
17866 * @list: an element in a #GList.
17868 * A convenience macro to get the next element in a #GList.
17870 * Returns: the next element, or %NULL if there are no more elements.
17877 * @n: the position of the element, counting from 0
17879 * Gets the element at the given position in a #GList.
17881 * Returns: the element, or %NULL if the position is off the end of the #GList
17888 * @n: the position of the element
17890 * Gets the data of the element at the given position.
17892 * Returns: the element's data, or %NULL if the position is off the end of the #GList
17899 * @n: the position of the element, counting from 0
17901 * Gets the element @n places before @list.
17903 * Returns: the element, or %NULL if the position is off the end of the #GList
17910 * @llink: an element in the #GList
17912 * Gets the position of the given element
17913 * in the #GList (starting from 0).
17915 * Returns: the position of the element in the #GList, or -1 if the element is not found
17921 * @list: a pointer to a #GList
17922 * @data: the data for the new element
17924 * Adds a new element on to the start of the list.
17927 * The return value is the new start of the list, which
17928 * may have changed, so make sure you store the new value.
17932 * /* Notice that it is initialized to the empty list. */
17933 * GList *list = NULL;
17934 * list = g_list_prepend (list, "last");
17935 * list = g_list_prepend (list, "first");
17938 * Returns: the new start of the #GList
17944 * @list: an element in a #GList.
17946 * A convenience macro to get the previous element in a #GList.
17948 * Returns: the previous element, or %NULL if there are no previous elements.
17955 * @data: the data of the element to remove
17957 * Removes an element from a #GList.
17958 * If two elements contain the same data, only the first is removed.
17959 * If none of the elements contain the data, the #GList is unchanged.
17961 * Returns: the new start of the #GList
17966 * g_list_remove_all:
17968 * @data: data to remove
17970 * Removes all list nodes with data equal to @data.
17971 * Returns the new head of the list. Contrast with
17972 * g_list_remove() which removes only the first node
17973 * matching the given data.
17975 * Returns: new head of @list
17980 * g_list_remove_link:
17982 * @llink: an element in the #GList
17984 * Removes an element from a #GList, without freeing the element.
17985 * The removed element's prev and next links are set to %NULL, so
17986 * that it becomes a self-contained list with one element.
17988 * Returns: the new start of the #GList, without the element
17996 * Reverses a #GList.
17997 * It simply switches the next and prev pointers of each element.
17999 * Returns: the start of the reversed #GList
18006 * @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.
18008 * Sorts a #GList using the given comparison function. The algorithm
18009 * used is a stable sort.
18011 * Returns: the start of the sorted #GList
18016 * g_list_sort_with_data:
18018 * @compare_func: comparison function
18019 * @user_data: user data to pass to comparison function
18021 * Like g_list_sort(), but the comparison function accepts
18022 * a user data argument.
18024 * Returns: the new head of @list
18031 * Gets the names of all variables set in the environment.
18033 * Programs that want to be portable to Windows should typically use
18034 * this function and g_getenv() instead of using the environ array
18035 * from the C library directly. On Windows, the strings in the environ
18036 * array are in system codepage encoding, while in most of the typical
18037 * use cases for environment variables in GLib-using programs you want
18038 * the UTF-8 encoding that this function and g_getenv() provide.
18040 * Returns: (array zero-terminated=1) (transfer full): a %NULL-terminated list of strings which must be freed with g_strfreev().
18046 * g_locale_from_utf8:
18047 * @utf8string: a UTF-8 encoded string
18048 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18049 * @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.
18050 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
18051 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
18053 * Converts a string from UTF-8 to the encoding used for strings by
18054 * the C runtime (usually the same as that used by the operating
18055 * system) in the <link linkend="setlocale">current locale</link>. On
18056 * Windows this means the system codepage.
18058 * Returns: The converted string, or %NULL on an error.
18063 * g_locale_to_utf8:
18064 * @opsysstring: a string in the encoding of the current locale. On Windows this means the system codepage.
18065 * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18066 * @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.
18067 * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
18068 * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
18070 * Converts a string which is in the encoding used for strings by
18071 * the C runtime (usually the same as that used by the operating
18072 * system) in the <link linkend="setlocale">current locale</link> into a
18075 * Returns: The converted string, or %NULL on an error.
18081 * @log_domain: the log domain, usually #G_LOG_DOMAIN
18082 * @log_level: the log level, either from #GLogLevelFlags or a user-defined level
18083 * @format: the message format. See the printf() documentation
18084 * @...: the parameters to insert into the format string
18086 * Logs an error or debugging message.
18088 * If the log level has been set as fatal, the abort()
18089 * function is called to terminate the program.
18094 * g_log_default_handler:
18095 * @log_domain: the log domain of the message
18096 * @log_level: the level of the message
18097 * @message: the message
18098 * @unused_data: data passed from g_log() which is unused
18100 * The default log handler set up by GLib; g_log_set_default_handler()
18101 * allows to install an alternate default log handler.
18102 * This is used if no log handler has been set for the particular log
18103 * domain and log level combination. It outputs the message to stderr
18104 * or stdout and if the log level is fatal it calls abort().
18106 * The behavior of this log handler can be influenced by a number of
18107 * environment variables:
18110 * <term><envar>G_MESSAGES_PREFIXED</envar></term>
18112 * A :-separated list of log levels for which messages should
18113 * be prefixed by the program name and PID of the aplication.
18117 * <term><envar>G_MESSAGES_DEBUG</envar></term>
18119 * A space-separated list of log domains for which debug and
18120 * informational messages are printed. By default these
18121 * messages are not printed.
18126 * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
18127 * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
18133 * g_log_remove_handler:
18134 * @log_domain: the log domain
18135 * @handler_id: the id of the handler, which was returned in g_log_set_handler()
18137 * Removes the log handler.
18142 * g_log_set_always_fatal:
18143 * @fatal_mask: the mask containing bits set for each level of error which is to be fatal
18145 * Sets the message levels which are always fatal, in any log domain.
18146 * When a message with any of these levels is logged the program terminates.
18147 * You can only set the levels defined by GLib to be fatal.
18148 * %G_LOG_LEVEL_ERROR is always fatal.
18150 * You can also make some message levels fatal at runtime by setting
18151 * the <envar>G_DEBUG</envar> environment variable (see
18152 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
18154 * Returns: the old fatal mask
18159 * g_log_set_default_handler:
18160 * @log_func: the log handler function
18161 * @user_data: data passed to the log handler
18163 * Installs a default log handler which is used if no
18164 * log handler has been set for the particular log domain
18165 * and log level combination. By default, GLib uses
18166 * g_log_default_handler() as default log handler.
18168 * Returns: the previous default log handler
18174 * g_log_set_fatal_mask:
18175 * @log_domain: the log domain
18176 * @fatal_mask: the new fatal mask
18178 * Sets the log levels which are fatal in the given domain.
18179 * %G_LOG_LEVEL_ERROR is always fatal.
18181 * Returns: the old fatal mask for the log domain
18186 * g_log_set_handler:
18187 * @log_domain: (allow-none): the log domain, or %NULL for the default "" application domain
18188 * @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.
18189 * @log_func: the log handler function
18190 * @user_data: data passed to the log handler
18192 * Sets the log handler for a domain and a set of log levels.
18193 * To handle fatal and recursive messages the @log_levels parameter
18194 * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
18197 * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
18198 * you want to set a handler for this log level you must combine it with
18199 * #G_LOG_FLAG_FATAL.
18202 * <title>Adding a log handler for all warning messages in the default
18203 * (application) domain</title>
18205 * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
18206 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18207 * </programlisting>
18211 * <title>Adding a log handler for all critical messages from GTK+</title>
18213 * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
18214 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18215 * </programlisting>
18219 * <title>Adding a log handler for <emphasis>all</emphasis> messages from
18222 * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
18223 * | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18224 * </programlisting>
18227 * Returns: the id of the new handler
18233 * @log_domain: the log domain
18234 * @log_level: the log level
18235 * @format: the message format. See the printf() documentation
18236 * @args: the parameters to insert into the format string
18238 * Logs an error or debugging message.
18240 * If the log level has been set as fatal, the abort()
18241 * function is called to terminate the program.
18247 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
18248 * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
18250 * A wrapper for the POSIX lstat() function. The lstat() function is
18251 * like stat() except that in the case of symbolic links, it returns
18252 * information about the symbolic link itself and not the file that it
18253 * refers to. If the system does not support symbolic links g_lstat()
18254 * is identical to g_stat().
18256 * See your C library manual for more details about lstat().
18258 * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
18264 * g_main_context_acquire:
18265 * @context: a #GMainContext
18267 * Tries to become the owner of the specified context.
18268 * If some other thread is the owner of the context,
18269 * returns %FALSE immediately. Ownership is properly
18270 * recursive: the owner can require ownership again
18271 * and will release ownership when g_main_context_release()
18272 * is called as many times as g_main_context_acquire().
18274 * You must be the owner of a context before you
18275 * can call g_main_context_prepare(), g_main_context_query(),
18276 * g_main_context_check(), g_main_context_dispatch().
18278 * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18283 * g_main_context_add_poll:
18284 * @context: (allow-none): a #GMainContext (or %NULL for the default context)
18285 * @fd: a #GPollFD structure holding information about a file descriptor to watch.
18286 * @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.
18288 * Adds a file descriptor to the set of file descriptors polled for
18289 * this context. This will very seldom be used directly. Instead
18290 * a typical event source will use g_source_add_unix_fd() instead.
18295 * g_main_context_check:
18296 * @context: a #GMainContext
18297 * @max_priority: the maximum numerical priority of sources to check
18298 * @fds: (array length=n_fds): array of #GPollFD's that was passed to the last call to g_main_context_query()
18299 * @n_fds: return value of g_main_context_query()
18301 * Passes the results of polling back to the main loop.
18303 * Returns: %TRUE if some sources are ready to be dispatched.
18308 * g_main_context_default:
18310 * Returns the global default main context. This is the main context
18311 * used for main loop functions when a main loop is not explicitly
18312 * specified, and corresponds to the "main" main loop. See also
18313 * g_main_context_get_thread_default().
18315 * Returns: (transfer none): the global default main context.
18320 * g_main_context_dispatch:
18321 * @context: a #GMainContext
18323 * Dispatches all pending sources.
18328 * g_main_context_find_source_by_funcs_user_data:
18329 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
18330 * @funcs: the @source_funcs passed to g_source_new().
18331 * @user_data: the user data from the callback.
18333 * Finds a source with the given source functions and user data. If
18334 * multiple sources exist with the same source function and user data,
18335 * the first one found will be returned.
18337 * Returns: (transfer none): the source, if one was found, otherwise %NULL
18342 * g_main_context_find_source_by_id:
18343 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18344 * @source_id: the source ID, as returned by g_source_get_id().
18346 * Finds a #GSource given a pair of context and ID.
18348 * Returns: (transfer none): the #GSource if found, otherwise, %NULL
18353 * g_main_context_find_source_by_user_data:
18354 * @context: a #GMainContext
18355 * @user_data: the user_data for the callback.
18357 * Finds a source with the given user data for the callback. If
18358 * multiple sources exist with the same user data, the first
18359 * one found will be returned.
18361 * Returns: (transfer none): the source, if one was found, otherwise %NULL
18366 * g_main_context_get_poll_func:
18367 * @context: a #GMainContext
18369 * Gets the poll function set by g_main_context_set_poll_func().
18371 * Returns: the poll function
18376 * g_main_context_get_thread_default:
18378 * Gets the thread-default #GMainContext for this thread. Asynchronous
18379 * operations that want to be able to be run in contexts other than
18380 * the default one should call this method or
18381 * g_main_context_ref_thread_default() to get a #GMainContext to add
18382 * their #GSource<!-- -->s to. (Note that even in single-threaded
18383 * programs applications may sometimes want to temporarily push a
18384 * non-default context, so it is not safe to assume that this will
18385 * always return %NULL if you are running in the default thread.)
18387 * If you need to hold a reference on the context, use
18388 * g_main_context_ref_thread_default() instead.
18390 * Returns: (transfer none): the thread-default #GMainContext, or %NULL if the thread-default context is the global default context.
18396 * g_main_context_invoke:
18397 * @context: (allow-none): a #GMainContext, or %NULL
18398 * @function: function to call
18399 * @data: data to pass to @function
18401 * Invokes a function in such a way that @context is owned during the
18402 * invocation of @function.
18404 * If @context is %NULL then the global default main context — as
18405 * returned by g_main_context_default() — is used.
18407 * If @context is owned by the current thread, @function is called
18408 * directly. Otherwise, if @context is the thread-default main context
18409 * of the current thread and g_main_context_acquire() succeeds, then
18410 * @function is called and g_main_context_release() is called
18413 * In any other case, an idle source is created to call @function and
18414 * that source is attached to @context (presumably to be run in another
18415 * thread). The idle source is attached with #G_PRIORITY_DEFAULT
18416 * priority. If you want a different priority, use
18417 * g_main_context_invoke_full().
18419 * Note that, as with normal idle functions, @function should probably
18420 * return %FALSE. If it returns %TRUE, it will be continuously run in a
18421 * loop (and may prevent this call from returning).
18428 * g_main_context_invoke_full:
18429 * @context: (allow-none): a #GMainContext, or %NULL
18430 * @priority: the priority at which to run @function
18431 * @function: function to call
18432 * @data: data to pass to @function
18433 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
18435 * Invokes a function in such a way that @context is owned during the
18436 * invocation of @function.
18438 * This function is the same as g_main_context_invoke() except that it
18439 * lets you specify the priority incase @function ends up being
18440 * scheduled as an idle and also lets you give a #GDestroyNotify for @data.
18442 * @notify should not assume that it is called from any particular
18443 * thread or with any particular context acquired.
18450 * g_main_context_is_owner:
18451 * @context: a #GMainContext
18453 * Determines whether this thread holds the (recursive)
18454 * ownership of this #GMainContext. This is useful to
18455 * know before waiting on another thread that may be
18456 * blocking to get ownership of @context.
18458 * Returns: %TRUE if current thread is owner of @context.
18464 * g_main_context_iteration:
18465 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18466 * @may_block: whether the call may block.
18468 * Runs a single iteration for the given main loop. This involves
18469 * checking to see if any event sources are ready to be processed,
18470 * then if no events sources are ready and @may_block is %TRUE, waiting
18471 * for a source to become ready, then dispatching the highest priority
18472 * events sources that are ready. Otherwise, if @may_block is %FALSE
18473 * sources are not waited to become ready, only those highest priority
18474 * events sources will be dispatched (if any), that are ready at this
18475 * given moment without further waiting.
18477 * Note that even when @may_block is %TRUE, it is still possible for
18478 * g_main_context_iteration() to return %FALSE, since the wait may
18479 * be interrupted for other reasons than an event source becoming ready.
18481 * Returns: %TRUE if events were dispatched.
18486 * g_main_context_new:
18488 * Creates a new #GMainContext structure.
18490 * Returns: the new #GMainContext
18495 * g_main_context_pending:
18496 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18498 * Checks if any sources have pending events for the given context.
18500 * Returns: %TRUE if events are pending.
18505 * g_main_context_pop_thread_default:
18506 * @context: (allow-none): a #GMainContext object, or %NULL
18508 * Pops @context off the thread-default context stack (verifying that
18509 * it was on the top of the stack).
18516 * g_main_context_prepare:
18517 * @context: a #GMainContext
18518 * @priority: location to store priority of highest priority source already ready.
18520 * Prepares to poll sources within a main loop. The resulting information
18521 * for polling is determined by calling g_main_context_query ().
18523 * Returns: %TRUE if some source is ready to be dispatched prior to polling.
18528 * g_main_context_push_thread_default:
18529 * @context: (allow-none): a #GMainContext, or %NULL for the global default context
18531 * Acquires @context and sets it as the thread-default context for the
18532 * current thread. This will cause certain asynchronous operations
18533 * (such as most <link linkend="gio">gio</link>-based I/O) which are
18534 * started in this thread to run under @context and deliver their
18535 * results to its main loop, rather than running under the global
18536 * default context in the main thread. Note that calling this function
18537 * changes the context returned by
18538 * g_main_context_get_thread_default(), <emphasis>not</emphasis> the
18539 * one returned by g_main_context_default(), so it does not affect the
18540 * context used by functions like g_idle_add().
18542 * Normally you would call this function shortly after creating a new
18543 * thread, passing it a #GMainContext which will be run by a
18544 * #GMainLoop in that thread, to set a new default context for all
18545 * async operations in that thread. (In this case, you don't need to
18546 * ever call g_main_context_pop_thread_default().) In some cases
18547 * however, you may want to schedule a single operation in a
18548 * non-default context, or temporarily use a non-default context in
18549 * the main thread. In that case, you can wrap the call to the
18550 * asynchronous operation inside a
18551 * g_main_context_push_thread_default() /
18552 * g_main_context_pop_thread_default() pair, but it is up to you to
18553 * ensure that no other asynchronous operations accidentally get
18554 * started while the non-default context is active.
18556 * Beware that libraries that predate this function may not correctly
18557 * handle being used from a thread with a thread-default context. Eg,
18558 * see g_file_supports_thread_contexts().
18565 * g_main_context_query:
18566 * @context: a #GMainContext
18567 * @max_priority: maximum priority source to check
18568 * @timeout_: (out): location to store timeout to be used in polling
18569 * @fds: (out caller-allocates) (array length=n_fds): location to store #GPollFD records that need to be polled.
18570 * @n_fds: length of @fds.
18572 * Determines information necessary to poll this main loop.
18574 * 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.
18579 * g_main_context_ref:
18580 * @context: a #GMainContext
18582 * Increases the reference count on a #GMainContext object by one.
18584 * Returns: the @context that was passed in (since 2.6)
18589 * g_main_context_ref_thread_default:
18591 * Gets the thread-default #GMainContext for this thread, as with
18592 * g_main_context_get_thread_default(), but also adds a reference to
18593 * it with g_main_context_ref(). In addition, unlike
18594 * g_main_context_get_thread_default(), if the thread-default context
18595 * is the global default context, this will return that #GMainContext
18596 * (with a ref added to it) rather than returning %NULL.
18598 * Returns: (transfer full): the thread-default #GMainContext. Unref with g_main_context_unref() when you are done with it.
18604 * g_main_context_release:
18605 * @context: a #GMainContext
18607 * Releases ownership of a context previously acquired by this thread
18608 * with g_main_context_acquire(). If the context was acquired multiple
18609 * times, the ownership will be released only when g_main_context_release()
18610 * is called as many times as it was acquired.
18615 * g_main_context_remove_poll:
18616 * @context: a #GMainContext
18617 * @fd: a #GPollFD descriptor previously added with g_main_context_add_poll()
18619 * Removes file descriptor from the set of file descriptors to be
18620 * polled for a particular context.
18625 * g_main_context_set_poll_func:
18626 * @context: a #GMainContext
18627 * @func: the function to call to poll all file descriptors
18629 * Sets the function to use to handle polling of file descriptors. It
18630 * will be used instead of the poll() system call
18631 * (or GLib's replacement function, which is used where
18632 * poll() isn't available).
18634 * This function could possibly be used to integrate the GLib event
18635 * loop with an external event loop.
18640 * g_main_context_unref:
18641 * @context: a #GMainContext
18643 * Decreases the reference count on a #GMainContext object by one. If
18644 * the result is zero, free the context and free all associated memory.
18649 * g_main_context_wait:
18650 * @context: a #GMainContext
18651 * @cond: a condition variable
18652 * @mutex: a mutex, currently held
18654 * Tries to become the owner of the specified context,
18655 * as with g_main_context_acquire(). But if another thread
18656 * is the owner, atomically drop @mutex and wait on @cond until
18657 * that owner releases ownership or until @cond is signaled, then
18658 * try again (once) to become the owner.
18660 * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18665 * g_main_context_wakeup:
18666 * @context: a #GMainContext
18668 * If @context is currently blocking in g_main_context_iteration()
18669 * waiting for a source to become ready, cause it to stop blocking
18670 * and return. Otherwise, cause the next invocation of
18671 * g_main_context_iteration() to return without blocking.
18673 * This API is useful for low-level control over #GMainContext; for
18674 * example, integrating it with main loop implementations such as
18677 * Another related use for this function is when implementing a main
18678 * loop with a termination condition, computed from multiple threads:
18681 * #define NUM_TASKS 10
18682 * static volatile gint tasks_remaining = NUM_TASKS;
18685 * while (g_atomic_int_get (&tasks_remaining) != 0)
18686 * g_main_context_iteration (NULL, TRUE);
18689 * Then in a thread:
18693 * if (g_atomic_int_dec_and_test (&tasks_remaining))
18694 * g_main_context_wakeup (NULL);
18700 * g_main_current_source:
18702 * Returns the currently firing source for this thread.
18704 * Returns: (transfer none): The currently firing source or %NULL.
18712 * Returns the depth of the stack of calls to
18713 * g_main_context_dispatch() on any #GMainContext in the current thread.
18714 * That is, when called from the toplevel, it gives 0. When
18715 * called from within a callback from g_main_context_iteration()
18716 * (or g_main_loop_run(), etc.) it returns 1. When called from within
18717 * a callback to a recursive call to g_main_context_iteration(),
18718 * it returns 2. And so forth.
18720 * This function is useful in a situation like the following:
18721 * Imagine an extremely simple "garbage collected" system.
18724 * static GList *free_list;
18727 * allocate_memory (gsize size)
18729 * gpointer result = g_malloc (size);
18730 * free_list = g_list_prepend (free_list, result);
18735 * free_allocated_memory (void)
18738 * for (l = free_list; l; l = l->next);
18739 * g_free (l->data);
18740 * g_list_free (free_list);
18741 * free_list = NULL;
18748 * g_main_context_iteration (NULL, TRUE);
18749 * free_allocated_memory();
18753 * This works from an application, however, if you want to do the same
18754 * thing from a library, it gets more difficult, since you no longer
18755 * control the main loop. You might think you can simply use an idle
18756 * function to make the call to free_allocated_memory(), but that
18757 * doesn't work, since the idle function could be called from a
18758 * recursive callback. This can be fixed by using g_main_depth()
18762 * allocate_memory (gsize size)
18764 * FreeListBlock *block = g_new (FreeListBlock, 1);
18765 * block->mem = g_malloc (size);
18766 * block->depth = g_main_depth ();
18767 * free_list = g_list_prepend (free_list, block);
18768 * return block->mem;
18772 * free_allocated_memory (void)
18776 * int depth = g_main_depth ();
18777 * for (l = free_list; l; );
18779 * GList *next = l->next;
18780 * FreeListBlock *block = l->data;
18781 * if (block->depth > depth)
18783 * g_free (block->mem);
18785 * free_list = g_list_delete_link (free_list, l);
18793 * There is a temptation to use g_main_depth() to solve
18794 * problems with reentrancy. For instance, while waiting for data
18795 * to be received from the network in response to a menu item,
18796 * the menu item might be selected again. It might seem that
18797 * one could make the menu item's callback return immediately
18798 * and do nothing if g_main_depth() returns a value greater than 1.
18799 * However, this should be avoided since the user then sees selecting
18800 * the menu item do nothing. Furthermore, you'll find yourself adding
18801 * these checks all over your code, since there are doubtless many,
18802 * many things that the user could do. Instead, you can use the
18803 * following techniques:
18808 * Use gtk_widget_set_sensitive() or modal dialogs to prevent
18809 * the user from interacting with elements while the main
18810 * loop is recursing.
18815 * Avoid main loop recursion in situations where you can't handle
18816 * arbitrary callbacks. Instead, structure your code so that you
18817 * simply return to the main loop and then get called again when
18818 * there is more work to do.
18823 * Returns: The main loop recursion level in the current thread
18828 * g_main_loop_get_context:
18829 * @loop: a #GMainLoop.
18831 * Returns the #GMainContext of @loop.
18833 * Returns: (transfer none): the #GMainContext of @loop
18838 * g_main_loop_is_running:
18839 * @loop: a #GMainLoop.
18841 * Checks to see if the main loop is currently being run via g_main_loop_run().
18843 * Returns: %TRUE if the mainloop is currently being run.
18849 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
18850 * @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.
18852 * Creates a new #GMainLoop structure.
18854 * Returns: a new #GMainLoop.
18859 * g_main_loop_quit:
18860 * @loop: a #GMainLoop
18862 * Stops a #GMainLoop from running. Any calls to g_main_loop_run()
18863 * for the loop will return.
18865 * Note that sources that have already been dispatched when
18866 * g_main_loop_quit() is called will still be executed.
18872 * @loop: a #GMainLoop
18874 * Increases the reference count on a #GMainLoop object by one.
18882 * @loop: a #GMainLoop
18884 * Runs a main loop until g_main_loop_quit() is called on the loop.
18885 * If this is called for the thread of the loop's #GMainContext,
18886 * it will process events from the loop, otherwise it will
18892 * g_main_loop_unref:
18893 * @loop: a #GMainLoop
18895 * Decreases the reference count on a #GMainLoop object by one. If
18896 * the result is zero, free the loop and free all associated memory.
18902 * @n_bytes: the number of bytes to allocate
18904 * Allocates @n_bytes bytes of memory.
18905 * If @n_bytes is 0 it returns %NULL.
18907 * Returns: a pointer to the allocated memory
18913 * @n_bytes: the number of bytes to allocate
18915 * Allocates @n_bytes bytes of memory, initialized to 0's.
18916 * If @n_bytes is 0 it returns %NULL.
18918 * Returns: a pointer to the allocated memory
18924 * @n_blocks: the number of blocks to allocate
18925 * @n_block_bytes: the size of each block in bytes
18927 * This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
18928 * but care is taken to detect possible overflow during multiplication.
18931 * Returns: a pointer to the allocated memory
18937 * @n_blocks: the number of blocks to allocate
18938 * @n_block_bytes: the size of each block in bytes
18940 * This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
18941 * but care is taken to detect possible overflow during multiplication.
18944 * Returns: a pointer to the allocated memory
18949 * g_mapped_file_free:
18950 * @file: a #GMappedFile
18952 * This call existed before #GMappedFile had refcounting and is currently
18953 * exactly the same as g_mapped_file_unref().
18956 * Deprecated: 2.22: Use g_mapped_file_unref() instead.
18961 * g_mapped_file_get_bytes:
18962 * @file: a #GMappedFile
18964 * Creates a new #GBytes which references the data mapped from @file.
18965 * The mapped contents of the file must not be modified after creating this
18966 * bytes object, because a #GBytes should be immutable.
18968 * Returns: (transfer full): A newly allocated #GBytes referencing data from @file
18974 * g_mapped_file_get_contents:
18975 * @file: a #GMappedFile
18977 * Returns the contents of a #GMappedFile.
18979 * Note that the contents may not be zero-terminated,
18980 * even if the #GMappedFile is backed by a text file.
18982 * If the file is empty then %NULL is returned.
18984 * Returns: the contents of @file, or %NULL.
18990 * g_mapped_file_get_length:
18991 * @file: a #GMappedFile
18993 * Returns the length of the contents of a #GMappedFile.
18995 * Returns: the length of the contents of @file.
19001 * g_mapped_file_new:
19002 * @filename: The path of the file to load, in the GLib filename encoding
19003 * @writable: whether the mapping should be writable
19004 * @error: return location for a #GError, or %NULL
19006 * Maps a file into memory. On UNIX, this is using the mmap() function.
19008 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19009 * it is an error to modify the mapped buffer. Modifications to the buffer
19010 * are not visible to other processes mapping the same file, and are not
19011 * written back to the file.
19013 * Note that modifications of the underlying file might affect the contents
19014 * of the #GMappedFile. Therefore, mapping should only be used if the file
19015 * will not be modified, or if all modifications of the file are done
19016 * atomically (e.g. using g_file_set_contents()).
19018 * If @filename is the name of an empty, regular file, the function
19019 * will successfully return an empty #GMappedFile. In other cases of
19020 * size 0 (e.g. device files such as /dev/null), @error will be set
19021 * to the #GFileError value #G_FILE_ERROR_INVAL.
19023 * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
19029 * g_mapped_file_new_from_fd:
19030 * @fd: The file descriptor of the file to load
19031 * @writable: whether the mapping should be writable
19032 * @error: return location for a #GError, or %NULL
19034 * Maps a file into memory. On UNIX, this is using the mmap() function.
19036 * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19037 * it is an error to modify the mapped buffer. Modifications to the buffer
19038 * are not visible to other processes mapping the same file, and are not
19039 * written back to the file.
19041 * Note that modifications of the underlying file might affect the contents
19042 * of the #GMappedFile. Therefore, mapping should only be used if the file
19043 * will not be modified, or if all modifications of the file are done
19044 * atomically (e.g. using g_file_set_contents()).
19046 * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
19052 * g_mapped_file_ref:
19053 * @file: a #GMappedFile
19055 * Increments the reference count of @file by one. It is safe to call
19056 * this function from any thread.
19058 * Returns: the passed in #GMappedFile.
19064 * g_mapped_file_unref:
19065 * @file: a #GMappedFile
19067 * Decrements the reference count of @file by one. If the reference count
19068 * drops to 0, unmaps the buffer of @file and frees it.
19070 * It is safe to call this function from any thread.
19077 * g_markup_collect_attributes:
19078 * @element_name: the current tag name
19079 * @attribute_names: the attribute names
19080 * @attribute_values: the attribute values
19081 * @error: a pointer to a #GError or %NULL
19082 * @first_type: the #GMarkupCollectType of the first attribute
19083 * @first_attr: the name of the first attribute
19084 * @...: 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
19086 * Collects the attributes of the element from the data passed to the
19087 * #GMarkupParser start_element function, dealing with common error
19088 * conditions and supporting boolean values.
19090 * This utility function is not required to write a parser but can save
19093 * The @element_name, @attribute_names, @attribute_values and @error
19094 * parameters passed to the start_element callback should be passed
19095 * unmodified to this function.
19097 * Following these arguments is a list of "supported" attributes to collect.
19098 * It is an error to specify multiple attributes with the same name. If any
19099 * attribute not in the list appears in the @attribute_names array then an
19100 * unknown attribute error will result.
19102 * The #GMarkupCollectType field allows specifying the type of collection
19103 * to perform and if a given attribute must appear or is optional.
19105 * The attribute name is simply the name of the attribute to collect.
19107 * The pointer should be of the appropriate type (see the descriptions
19108 * under #GMarkupCollectType) and may be %NULL in case a particular
19109 * attribute is to be allowed but ignored.
19111 * This function deals with issuing errors for missing attributes
19112 * (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19113 * (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19114 * attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19115 * as parse errors for boolean-valued attributes (again of type
19116 * %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19117 * will be returned and @error will be set as appropriate.
19119 * Returns: %TRUE if successful
19125 * g_markup_escape_text:
19126 * @text: some valid UTF-8 text
19127 * @length: length of @text in bytes, or -1 if the text is nul-terminated
19129 * Escapes text so that the markup parser will parse it verbatim.
19130 * Less than, greater than, ampersand, etc. are replaced with the
19131 * corresponding entities. This function would typically be used
19132 * when writing out a file to be parsed with the markup parser.
19134 * Note that this function doesn't protect whitespace and line endings
19135 * from being processed according to the XML rules for normalization
19136 * of line endings and attribute values.
19138 * Note also that this function will produce character references in
19139 * the range of &#x1; ... &#x1f; for all control sequences
19140 * except for tabstop, newline and carriage return. The character
19141 * references in this range are not valid XML 1.0, but they are
19142 * valid XML 1.1 and will be accepted by the GMarkup parser.
19144 * Returns: a newly allocated string with the escaped text
19149 * g_markup_parse_context_end_parse:
19150 * @context: a #GMarkupParseContext
19151 * @error: return location for a #GError
19153 * Signals to the #GMarkupParseContext that all data has been
19154 * fed into the parse context with g_markup_parse_context_parse().
19156 * This function reports an error if the document isn't complete,
19157 * for example if elements are still open.
19159 * Returns: %TRUE on success, %FALSE if an error was set
19164 * g_markup_parse_context_free:
19165 * @context: a #GMarkupParseContext
19167 * Frees a #GMarkupParseContext.
19169 * This function can't be called from inside one of the
19170 * #GMarkupParser functions or while a subparser is pushed.
19175 * g_markup_parse_context_get_element:
19176 * @context: a #GMarkupParseContext
19178 * Retrieves the name of the currently open element.
19180 * If called from the start_element or end_element handlers this will
19181 * give the element_name as passed to those functions. For the parent
19182 * elements, see g_markup_parse_context_get_element_stack().
19184 * Returns: the name of the currently open element, or %NULL
19190 * g_markup_parse_context_get_element_stack:
19191 * @context: a #GMarkupParseContext
19193 * Retrieves the element stack from the internal state of the parser.
19195 * The returned #GSList is a list of strings where the first item is
19196 * the currently open tag (as would be returned by
19197 * g_markup_parse_context_get_element()) and the next item is its
19198 * immediate parent.
19200 * This function is intended to be used in the start_element and
19201 * end_element handlers where g_markup_parse_context_get_element()
19202 * would merely return the name of the element that is being
19205 * Returns: the element stack, which must not be modified
19211 * g_markup_parse_context_get_position:
19212 * @context: a #GMarkupParseContext
19213 * @line_number: (allow-none): return location for a line number, or %NULL
19214 * @char_number: (allow-none): return location for a char-on-line number, or %NULL
19216 * Retrieves the current line number and the number of the character on
19217 * that line. Intended for use in error messages; there are no strict
19218 * semantics for what constitutes the "current" line number other than
19219 * "the best number we could come up with for error messages."
19224 * g_markup_parse_context_get_user_data:
19225 * @context: a #GMarkupParseContext
19227 * Returns the user_data associated with @context.
19229 * This will either be the user_data that was provided to
19230 * g_markup_parse_context_new() or to the most recent call
19231 * of g_markup_parse_context_push().
19233 * 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.
19239 * g_markup_parse_context_new:
19240 * @parser: a #GMarkupParser
19241 * @flags: one or more #GMarkupParseFlags
19242 * @user_data: user data to pass to #GMarkupParser functions
19243 * @user_data_dnotify: user data destroy notifier called when the parse context is freed
19245 * Creates a new parse context. A parse context is used to parse
19246 * marked-up documents. You can feed any number of documents into
19247 * a context, as long as no errors occur; once an error occurs,
19248 * the parse context can't continue to parse text (you have to
19249 * free it and create a new parse context).
19251 * Returns: a new #GMarkupParseContext
19256 * g_markup_parse_context_parse:
19257 * @context: a #GMarkupParseContext
19258 * @text: chunk of text to parse
19259 * @text_len: length of @text in bytes
19260 * @error: return location for a #GError
19262 * Feed some data to the #GMarkupParseContext.
19264 * The data need not be valid UTF-8; an error will be signaled if
19265 * it's invalid. The data need not be an entire document; you can
19266 * feed a document into the parser incrementally, via multiple calls
19267 * to this function. Typically, as you receive data from a network
19268 * connection or file, you feed each received chunk of data into this
19269 * function, aborting the process if an error occurs. Once an error
19270 * is reported, no further data may be fed to the #GMarkupParseContext;
19271 * all errors are fatal.
19273 * Returns: %FALSE if an error occurred, %TRUE on success
19278 * g_markup_parse_context_pop:
19279 * @context: a #GMarkupParseContext
19281 * Completes the process of a temporary sub-parser redirection.
19283 * This function exists to collect the user_data allocated by a
19284 * matching call to g_markup_parse_context_push(). It must be called
19285 * in the end_element handler corresponding to the start_element
19286 * handler during which g_markup_parse_context_push() was called.
19287 * You must not call this function from the error callback -- the
19288 * @user_data is provided directly to the callback in that case.
19290 * This function is not intended to be directly called by users
19291 * interested in invoking subparsers. Instead, it is intended to
19292 * be used by the subparsers themselves to implement a higher-level
19295 * Returns: the user data passed to g_markup_parse_context_push()
19301 * g_markup_parse_context_push:
19302 * @context: a #GMarkupParseContext
19303 * @parser: a #GMarkupParser
19304 * @user_data: user data to pass to #GMarkupParser functions
19306 * Temporarily redirects markup data to a sub-parser.
19308 * This function may only be called from the start_element handler of
19309 * a #GMarkupParser. It must be matched with a corresponding call to
19310 * g_markup_parse_context_pop() in the matching end_element handler
19311 * (except in the case that the parser aborts due to an error).
19313 * All tags, text and other data between the matching tags is
19314 * redirected to the subparser given by @parser. @user_data is used
19315 * as the user_data for that parser. @user_data is also passed to the
19316 * error callback in the event that an error occurs. This includes
19317 * errors that occur in subparsers of the subparser.
19319 * The end tag matching the start tag for which this call was made is
19320 * handled by the previous parser (which is given its own user_data)
19321 * which is why g_markup_parse_context_pop() is provided to allow "one
19322 * last access" to the @user_data provided to this function. In the
19323 * case of error, the @user_data provided here is passed directly to
19324 * the error callback of the subparser and g_markup_parse_context_pop()
19325 * should not be called. In either case, if @user_data was allocated
19326 * then it ought to be freed from both of these locations.
19328 * This function is not intended to be directly called by users
19329 * interested in invoking subparsers. Instead, it is intended to be
19330 * used by the subparsers themselves to implement a higher-level
19333 * As an example, see the following implementation of a simple
19334 * parser that counts the number of tags encountered.
19343 * counter_start_element (GMarkupParseContext *context,
19344 * const gchar *element_name,
19345 * const gchar **attribute_names,
19346 * const gchar **attribute_values,
19347 * gpointer user_data,
19350 * CounterData *data = user_data;
19352 * data->tag_count++;
19356 * counter_error (GMarkupParseContext *context,
19358 * gpointer user_data)
19360 * CounterData *data = user_data;
19362 * g_slice_free (CounterData, data);
19365 * static GMarkupParser counter_subparser =
19367 * counter_start_element,
19375 * In order to allow this parser to be easily used as a subparser, the
19376 * following interface is provided:
19380 * start_counting (GMarkupParseContext *context)
19382 * CounterData *data = g_slice_new (CounterData);
19384 * data->tag_count = 0;
19385 * g_markup_parse_context_push (context, &counter_subparser, data);
19389 * end_counting (GMarkupParseContext *context)
19391 * CounterData *data = g_markup_parse_context_pop (context);
19394 * result = data->tag_count;
19395 * g_slice_free (CounterData, data);
19401 * The subparser would then be used as follows:
19404 * static void start_element (context, element_name, ...)
19406 * if (strcmp (element_name, "count-these") == 0)
19407 * start_counting (context);
19409 * /* else, handle other tags... */
19412 * static void end_element (context, element_name, ...)
19414 * if (strcmp (element_name, "count-these") == 0)
19415 * g_print ("Counted %d tags\n", end_counting (context));
19417 * /* else, handle other tags... */
19426 * g_markup_parse_context_ref:
19427 * @context: a #GMarkupParseContext
19429 * Increases the reference count of @context.
19431 * Returns: the same @context
19437 * g_markup_parse_context_unref:
19438 * @context: a #GMarkupParseContext
19440 * Decreases the reference count of @context. When its reference count
19441 * drops to 0, it is freed.
19448 * g_markup_printf_escaped:
19449 * @format: printf() style format string
19450 * @...: the arguments to insert in the format string
19452 * Formats arguments according to @format, escaping
19453 * all string and character arguments in the fashion
19454 * of g_markup_escape_text(). This is useful when you
19455 * want to insert literal strings into XML-style markup
19456 * output, without having to worry that the strings
19457 * might themselves contain markup.
19460 * const char *store = "Fortnum & Mason";
19461 * const char *item = "Tea";
19464 * output = g_markup_printf_escaped ("<purchase>"
19465 * "<store>%s</store>"
19466 * "<item>%s</item>"
19467 * "</purchase>",
19471 * Returns: newly allocated result from formatting operation. Free with g_free().
19477 * g_markup_vprintf_escaped:
19478 * @format: printf() style format string
19479 * @args: variable argument list, similar to vprintf()
19481 * Formats the data in @args according to @format, escaping
19482 * all string and character arguments in the fashion
19483 * of g_markup_escape_text(). See g_markup_printf_escaped().
19485 * Returns: newly allocated result from formatting operation. Free with g_free().
19491 * g_match_info_expand_references:
19492 * @match_info: (allow-none): a #GMatchInfo or %NULL
19493 * @string_to_expand: the string to expand
19494 * @error: location to store the error occurring, or %NULL to ignore errors
19496 * Returns a new string containing the text in @string_to_expand with
19497 * references and escape sequences expanded. References refer to the last
19498 * match done with @string against @regex and have the same syntax used by
19499 * g_regex_replace().
19501 * The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
19502 * passed to g_regex_new().
19504 * The backreferences are extracted from the string passed to the match
19505 * function, so you cannot call this function after freeing the string.
19507 * @match_info may be %NULL in which case @string_to_expand must not
19508 * contain references. For instance "foo\n" does not refer to an actual
19509 * pattern and '\n' merely will be replaced with \n character,
19510 * while to expand "\0" (whole match) one needs the result of a match.
19511 * Use g_regex_check_replacement() to find out whether @string_to_expand
19512 * contains references.
19514 * Returns: (allow-none): the expanded string, or %NULL if an error occurred
19520 * g_match_info_fetch:
19521 * @match_info: #GMatchInfo structure
19522 * @match_num: number of the sub expression
19524 * Retrieves the text matching the @match_num<!-- -->'th capturing
19525 * parentheses. 0 is the full text of the match, 1 is the first paren
19526 * set, 2 the second, and so on.
19528 * If @match_num is a valid sub pattern but it didn't match anything
19529 * (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
19530 * string is returned.
19532 * If the match was obtained using the DFA algorithm, that is using
19533 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19534 * string is not that of a set of parentheses but that of a matched
19535 * substring. Substrings are matched in reverse order of length, so
19536 * 0 is the longest match.
19538 * The string is fetched from the string passed to the match function,
19539 * so you cannot call this function after freeing the string.
19541 * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19547 * g_match_info_fetch_all:
19548 * @match_info: a #GMatchInfo structure
19550 * Bundles up pointers to each of the matching substrings from a match
19551 * and stores them in an array of gchar pointers. The first element in
19552 * the returned array is the match number 0, i.e. the entire matched
19555 * If a sub pattern didn't match anything (e.g. sub pattern 1, matching
19556 * "b" against "(a)?b") then an empty string is inserted.
19558 * If the last match was obtained using the DFA algorithm, that is using
19559 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19560 * strings are not that matched by sets of parentheses but that of the
19561 * matched substring. Substrings are matched in reverse order of length,
19562 * so the first one is the longest match.
19564 * The strings are fetched from the string passed to the match function,
19565 * so you cannot call this function after freeing the string.
19567 * 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
19573 * g_match_info_fetch_named:
19574 * @match_info: #GMatchInfo structure
19575 * @name: name of the subexpression
19577 * Retrieves the text matching the capturing parentheses named @name.
19579 * If @name is a valid sub pattern name but it didn't match anything
19580 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
19581 * then an empty string is returned.
19583 * The string is fetched from the string passed to the match function,
19584 * so you cannot call this function after freeing the string.
19586 * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19592 * g_match_info_fetch_named_pos:
19593 * @match_info: #GMatchInfo structure
19594 * @name: name of the subexpression
19595 * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19596 * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19598 * Retrieves the position in bytes of the capturing parentheses named @name.
19600 * If @name is a valid sub pattern name but it didn't match anything
19601 * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
19602 * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
19604 * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged.
19610 * g_match_info_fetch_pos:
19611 * @match_info: #GMatchInfo structure
19612 * @match_num: number of the sub expression
19613 * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19614 * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19616 * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
19617 * parentheses. 0 is the full text of the match, 1 is the first
19618 * paren set, 2 the second, and so on.
19620 * If @match_num is a valid sub pattern but it didn't match anything
19621 * (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
19622 * and @end_pos are set to -1 and %TRUE is returned.
19624 * If the match was obtained using the DFA algorithm, that is using
19625 * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19626 * position is not that of a set of parentheses but that of a matched
19627 * substring. Substrings are matched in reverse order of length, so
19628 * 0 is the longest match.
19630 * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged
19636 * g_match_info_free:
19637 * @match_info: (allow-none): a #GMatchInfo, or %NULL
19639 * If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
19647 * g_match_info_get_match_count:
19648 * @match_info: a #GMatchInfo structure
19650 * Retrieves the number of matched substrings (including substring 0,
19651 * that is the whole matched text), so 1 is returned if the pattern
19652 * has no substrings in it and 0 is returned if the match failed.
19654 * If the last match was obtained using the DFA algorithm, that is
19655 * using g_regex_match_all() or g_regex_match_all_full(), the retrieved
19656 * count is not that of the number of capturing parentheses but that of
19657 * the number of matched substrings.
19659 * Returns: Number of matched substrings, or -1 if an error occurred
19665 * g_match_info_get_regex:
19666 * @match_info: a #GMatchInfo
19668 * Returns #GRegex object used in @match_info. It belongs to Glib
19669 * and must not be freed. Use g_regex_ref() if you need to keep it
19670 * after you free @match_info object.
19672 * Returns: #GRegex object used in @match_info
19678 * g_match_info_get_string:
19679 * @match_info: a #GMatchInfo
19681 * Returns the string searched with @match_info. This is the
19682 * string passed to g_regex_match() or g_regex_replace() so
19683 * you may not free it before calling this function.
19685 * Returns: the string searched with @match_info
19691 * g_match_info_is_partial_match:
19692 * @match_info: a #GMatchInfo structure
19694 * Usually if the string passed to g_regex_match*() matches as far as
19695 * it goes, but is too short to match the entire pattern, %FALSE is
19696 * returned. There are circumstances where it might be helpful to
19697 * distinguish this case from other cases in which there is no match.
19699 * Consider, for example, an application where a human is required to
19700 * type in data for a field with specific formatting requirements. An
19701 * example might be a date in the form ddmmmyy, defined by the pattern
19702 * "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
19703 * If the application sees the user’s keystrokes one by one, and can
19704 * check that what has been typed so far is potentially valid, it is
19705 * able to raise an error as soon as a mistake is made.
19707 * GRegex supports the concept of partial matching by means of the
19708 * #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD flags.
19709 * When they are used, the return code for
19710 * g_regex_match() or g_regex_match_full() is, as usual, %TRUE
19711 * for a complete match, %FALSE otherwise. But, when these functions
19712 * return %FALSE, you can check if the match was partial calling
19713 * g_match_info_is_partial_match().
19715 * The difference between #G_REGEX_MATCH_PARTIAL_SOFT and
19716 * #G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
19717 * with #G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
19718 * possible complete match, while with #G_REGEX_MATCH_PARTIAL_HARD matching
19719 * stops at the partial match.
19720 * When both #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD
19721 * are set, the latter takes precedence.
19723 * There were formerly some restrictions on the pattern for partial matching.
19724 * The restrictions no longer apply.
19726 * See <ulink>man:pcrepartial</ulink> for more information on partial matching.
19728 * Returns: %TRUE if the match was partial, %FALSE otherwise
19734 * g_match_info_matches:
19735 * @match_info: a #GMatchInfo structure
19737 * Returns whether the previous match operation succeeded.
19739 * Returns: %TRUE if the previous match operation succeeded, %FALSE otherwise
19745 * g_match_info_next:
19746 * @match_info: a #GMatchInfo structure
19747 * @error: location to store the error occurring, or %NULL to ignore errors
19749 * Scans for the next match using the same parameters of the previous
19750 * call to g_regex_match_full() or g_regex_match() that returned
19753 * The match is done on the string passed to the match function, so you
19754 * cannot free it before calling this function.
19756 * Returns: %TRUE is the string matched, %FALSE otherwise
19762 * g_match_info_ref:
19763 * @match_info: a #GMatchInfo
19765 * Increases reference count of @match_info by 1.
19767 * Returns: @match_info
19773 * g_match_info_unref:
19774 * @match_info: a #GMatchInfo
19776 * Decreases reference count of @match_info by 1. When reference count drops
19777 * to zero, it frees all the memory associated with the match_info structure.
19784 * g_mem_gc_friendly:
19786 * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
19787 * includes the key <literal>gc-friendly</literal>.
19792 * g_mem_is_system_malloc:
19794 * Checks whether the allocator used by g_malloc() is the system's
19795 * malloc implementation. If it returns %TRUE memory allocated with
19796 * malloc() can be used interchangeable with memory allocated using g_malloc().
19797 * This function is useful for avoiding an extra copy of allocated memory returned
19798 * by a non-GLib-based API.
19800 * A different allocator can be set using g_mem_set_vtable().
19802 * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
19809 * Outputs a summary of memory usage.
19811 * It outputs the frequency of allocations of different sizes,
19812 * the total number of bytes which have been allocated,
19813 * the total number of bytes which have been freed,
19814 * and the difference between the previous two values, i.e. the number of bytes
19817 * Note that this function will not output anything unless you have
19818 * previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
19823 * g_mem_set_vtable:
19824 * @vtable: table of memory allocation routines.
19826 * Sets the #GMemVTable to use for memory allocation. You can use this to provide
19827 * custom memory allocation routines. <emphasis>This function must be called
19828 * before using any other GLib functions.</emphasis> The @vtable only needs to
19829 * provide malloc(), realloc(), and free() functions; GLib can provide default
19830 * implementations of the others. The malloc() and realloc() implementations
19831 * should return %NULL on failure, GLib will handle error-checking for you.
19832 * @vtable is copied, so need not persist after this function has been called.
19838 * @mem: the memory to copy.
19839 * @byte_size: the number of bytes to copy.
19841 * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
19842 * from @mem. If @mem is %NULL it returns %NULL.
19844 * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem is %NULL.
19850 * @dest: the destination address to copy the bytes to.
19851 * @src: the source address to copy the bytes from.
19852 * @len: the number of bytes to copy.
19854 * Copies a block of memory @len bytes long, from @src to @dest.
19855 * The source and destination areas may overlap.
19857 * In order to use this function, you must include
19858 * <filename>string.h</filename> yourself, because this macro will
19859 * typically simply resolve to memmove() and GLib does not include
19860 * <filename>string.h</filename> for you.
19866 * @...: format string, followed by parameters to insert into the format string (as with printf())
19868 * A convenience function/macro to log a normal message.
19874 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
19875 * @mode: permissions to use for the newly created directory
19877 * A wrapper for the POSIX mkdir() function. The mkdir() function
19878 * attempts to create a directory with the given name and permissions.
19879 * The mode argument is ignored on Windows.
19881 * See your C library manual for more details about mkdir().
19883 * Returns: 0 if the directory was successfully created, -1 if an error occurred
19889 * g_mkdir_with_parents:
19890 * @pathname: a pathname in the GLib file name encoding
19891 * @mode: permissions to use for newly created directories
19893 * Create a directory if it doesn't already exist. Create intermediate
19894 * parent directories as needed, too.
19896 * Returns: 0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set.
19903 * @tmpl: (type filename): template directory name
19905 * Creates a temporary directory. See the mkdtemp() documentation
19906 * on most UNIX-like systems.
19908 * The parameter is a string that should follow the rules for
19909 * mkdtemp() templates, i.e. contain the string "XXXXXX".
19910 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19911 * sequence does not have to occur at the very end of the template
19912 * and you can pass a @mode and additional @flags. The X string will
19913 * be modified to form the name of a directory that didn't exist.
19914 * The string should be in the GLib file name encoding. Most importantly,
19915 * on Windows it should be in UTF-8.
19917 * 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.
19924 * @tmpl: (type filename): template directory name
19925 * @mode: permissions to create the temporary directory with
19927 * Creates a temporary directory. See the mkdtemp() documentation
19928 * on most UNIX-like systems.
19930 * The parameter is a string that should follow the rules for
19931 * mkdtemp() templates, i.e. contain the string "XXXXXX".
19932 * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19933 * sequence does not have to occur at the very end of the template
19934 * and you can pass a @mode. The X string will be modified to form
19935 * the name of a directory that didn't exist. The string should be
19936 * in the GLib file name encoding. Most importantly, on Windows it
19937 * should be in UTF-8.
19939 * 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.
19946 * @tmpl: (type filename): template filename
19948 * Opens a temporary file. See the mkstemp() documentation
19949 * on most UNIX-like systems.
19951 * The parameter is a string that should follow the rules for
19952 * mkstemp() templates, i.e. contain the string "XXXXXX".
19953 * g_mkstemp() is slightly more flexible than mkstemp() in that the
19954 * sequence does not have to occur at the very end of the template.
19955 * The X string will be modified to form the name of a file that
19956 * didn't exist. The string should be in the GLib file name encoding.
19957 * Most importantly, on Windows it should be in UTF-8.
19959 * 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.
19965 * @tmpl: (type filename): template filename
19966 * @flags: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
19967 * @mode: permissions to create the temporary file with
19969 * Opens a temporary file. See the mkstemp() documentation
19970 * on most UNIX-like systems.
19972 * The parameter is a string that should follow the rules for
19973 * mkstemp() templates, i.e. contain the string "XXXXXX".
19974 * g_mkstemp_full() is slightly more flexible than mkstemp()
19975 * in that the sequence does not have to occur at the very end of the
19976 * template and you can pass a @mode and additional @flags. The X
19977 * string will be modified to form the name of a file that didn't exist.
19978 * The string should be in the GLib file name encoding. Most importantly,
19979 * on Windows it should be in UTF-8.
19981 * 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.
19988 * @mutex: an initialized #GMutex
19990 * Frees the resources allocated to a mutex with g_mutex_init().
19992 * This function should not be used with a #GMutex that has been
19993 * statically allocated.
19995 * Calling g_mutex_clear() on a locked mutex leads to undefined
20004 * @mutex: an uninitialized #GMutex
20006 * Initializes a #GMutex so that it can be used.
20008 * This function is useful to initialize a mutex that has been
20009 * allocated on the stack, or as part of a larger structure.
20010 * It is not necessary to initialize a mutex that has been
20011 * statically allocated.
20021 * b = g_new (Blob, 1);
20022 * g_mutex_init (&b->m);
20025 * To undo the effect of g_mutex_init() when a mutex is no longer
20026 * needed, use g_mutex_clear().
20028 * Calling g_mutex_init() on an already initialized #GMutex leads
20029 * to undefined behaviour.
20037 * @mutex: a #GMutex
20039 * Locks @mutex. If @mutex is already locked by another thread, the
20040 * current thread will block until @mutex is unlocked by the other
20043 * <note>#GMutex is neither guaranteed to be recursive nor to be
20044 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
20045 * already been locked by the same thread results in undefined behaviour
20046 * (including but not limited to deadlocks).</note>
20052 * @mutex: a #GMutex
20054 * Tries to lock @mutex. If @mutex is already locked by another thread,
20055 * it immediately returns %FALSE. Otherwise it locks @mutex and returns
20058 * <note>#GMutex is neither guaranteed to be recursive nor to be
20059 * non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
20060 * already been locked by the same thread results in undefined behaviour
20061 * (including but not limited to deadlocks or arbitrary return values).
20064 * Returns: %TRUE if @mutex could be locked
20070 * @mutex: a #GMutex
20072 * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
20073 * call for @mutex, it will become unblocked and can lock @mutex itself.
20075 * Calling g_mutex_unlock() on a mutex that is not locked by the
20076 * current thread leads to undefined behaviour.
20081 * g_node_child_index:
20083 * @data: the data to find
20085 * Gets the position of the first child of a #GNode
20086 * which contains the given data.
20088 * Returns: the index of the child of @node which contains @data, or -1 if the data is not found
20093 * g_node_child_position:
20095 * @child: a child of @node
20097 * Gets the position of a #GNode with respect to its siblings.
20098 * @child must be a child of @node. The first child is numbered 0,
20099 * the second 1, and so on.
20101 * Returns: the position of @child with respect to its siblings
20106 * g_node_children_foreach:
20108 * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20109 * @func: the function to call for each visited node
20110 * @data: user data to pass to the function
20112 * Calls a function for each of the children of a #GNode.
20113 * Note that it doesn't descend beneath the child nodes.
20121 * Recursively copies a #GNode (but does not deep-copy the data inside the
20122 * nodes, see g_node_copy_deep() if you need that).
20124 * Returns: a new #GNode containing the same data pointers
20129 * g_node_copy_deep:
20131 * @copy_func: the function which is called to copy the data inside each node, or %NULL to use the original data.
20132 * @data: data to pass to @copy_func
20134 * Recursively copies a #GNode and its data.
20136 * Returns: a new #GNode containing copies of the data in @node.
20145 * Gets the depth of a #GNode.
20147 * If @node is %NULL the depth is 0. The root node has a depth of 1.
20148 * For the children of the root node the depth is 2. And so on.
20150 * Returns: the depth of the #GNode
20156 * @root: the root of the tree/subtree to destroy
20158 * Removes @root and its children from the tree, freeing any memory
20165 * @root: the root #GNode of the tree to search
20166 * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
20167 * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20168 * @data: the data to find
20170 * Finds a #GNode in a tree.
20172 * Returns: the found #GNode, or %NULL if the data is not found
20177 * g_node_find_child:
20179 * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20180 * @data: the data to find
20182 * Finds the first child of a #GNode with the given data.
20184 * Returns: the found child #GNode, or %NULL if the data is not found
20189 * g_node_first_sibling:
20192 * Gets the first sibling of a #GNode.
20193 * This could possibly be the node itself.
20195 * Returns: the first sibling of @node
20203 * Gets the root of a tree.
20205 * Returns: the root of the tree
20211 * @parent: the #GNode to place @node under
20212 * @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
20213 * @node: the #GNode to insert
20215 * Inserts a #GNode beneath the parent at the given position.
20217 * Returns: the inserted #GNode
20222 * g_node_insert_after:
20223 * @parent: the #GNode to place @node under
20224 * @sibling: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
20225 * @node: the #GNode to insert
20227 * Inserts a #GNode beneath the parent after the given sibling.
20229 * Returns: the inserted #GNode
20234 * g_node_insert_before:
20235 * @parent: the #GNode to place @node under
20236 * @sibling: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
20237 * @node: the #GNode to insert
20239 * Inserts a #GNode beneath the parent before the given sibling.
20241 * Returns: the inserted #GNode
20246 * g_node_is_ancestor:
20248 * @descendant: a #GNode
20250 * Returns %TRUE if @node is an ancestor of @descendant.
20251 * This is true if node is the parent of @descendant,
20252 * or if node is the grandparent of @descendant etc.
20254 * Returns: %TRUE if @node is an ancestor of @descendant
20259 * g_node_last_child:
20260 * @node: a #GNode (must not be %NULL)
20262 * Gets the last child of a #GNode.
20264 * Returns: the last child of @node, or %NULL if @node has no children
20269 * g_node_last_sibling:
20272 * Gets the last sibling of a #GNode.
20273 * This could possibly be the node itself.
20275 * Returns: the last sibling of @node
20280 * g_node_max_height:
20283 * Gets the maximum height of all branches beneath a #GNode.
20284 * This is the maximum distance from the #GNode to all leaf nodes.
20286 * If @root is %NULL, 0 is returned. If @root has no children,
20287 * 1 is returned. If @root has children, 2 is returned. And so on.
20289 * Returns: the maximum height of the tree beneath @root
20294 * g_node_n_children:
20297 * Gets the number of children of a #GNode.
20299 * Returns: the number of children of @node
20306 * @flags: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20308 * Gets the number of nodes in a tree.
20310 * Returns: the number of nodes in the tree
20316 * @data: the data of the new node
20318 * Creates a new #GNode containing the given data.
20319 * Used to create the first node in a tree.
20321 * Returns: a new #GNode
20326 * g_node_nth_child:
20328 * @n: the index of the desired child
20330 * Gets a child of a #GNode, using the given index.
20331 * The first child is at index 0. If the index is
20332 * too big, %NULL is returned.
20334 * Returns: the child of @node at index @n
20340 * @parent: the #GNode to place the new #GNode under
20341 * @node: the #GNode to insert
20343 * Inserts a #GNode as the first child of the given parent.
20345 * Returns: the inserted #GNode
20350 * g_node_reverse_children:
20353 * Reverses the order of the children of a #GNode.
20354 * (It doesn't change the order of the grandchildren.)
20360 * @root: the root #GNode of the tree to traverse
20361 * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
20362 * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20363 * @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.
20364 * @func: the function to call for each visited #GNode
20365 * @data: user data to pass to the function
20367 * Traverses a tree starting at the given root #GNode.
20368 * It calls the given function for each node visited.
20369 * The traversal can be halted at any point by returning %TRUE from @func.
20375 * @node: the #GNode to unlink, which becomes the root of a new tree
20377 * Unlinks a #GNode from a tree, resulting in two separate trees.
20383 * @val: a 32-bit integer value in network byte order
20385 * Converts a 32-bit integer value from network to host byte order.
20387 * Returns: @val converted to host byte order.
20393 * @val: a 16-bit integer value in network byte order
20395 * Converts a 16-bit integer value from network to host byte order.
20397 * Returns: @val converted to host byte order
20402 * g_nullify_pointer:
20403 * @nullify_location: the memory address of the pointer.
20405 * Set the pointer at the specified location to %NULL.
20410 * g_on_error_query:
20411 * @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)
20413 * Prompts the user with
20414 * <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
20415 * This function is intended to be used for debugging use only.
20416 * The following example shows how it can be used together with
20417 * the g_log() functions.
20420 * #include <glib.h>
20423 * log_handler (const gchar *log_domain,
20424 * GLogLevelFlags log_level,
20425 * const gchar *message,
20426 * gpointer user_data)
20428 * g_log_default_handler (log_domain, log_level, message, user_data);
20430 * g_on_error_query (MY_PROGRAM_NAME);
20434 * main (int argc, char *argv[])
20436 * g_log_set_handler (MY_LOG_DOMAIN,
20437 * G_LOG_LEVEL_WARNING |
20438 * G_LOG_LEVEL_ERROR |
20439 * G_LOG_LEVEL_CRITICAL,
20442 * /* ... */
20445 * If [E]xit is selected, the application terminates with a call
20446 * to <literal>_exit(0)</literal>.
20448 * If [S]tack trace is selected, g_on_error_stack_trace() is called.
20449 * This invokes <command>gdb</command>, which attaches to the current
20450 * process and shows a stack trace. The prompt is then shown again.
20452 * If [P]roceed is selected, the function returns.
20454 * This function may cause different actions on non-UNIX platforms.
20459 * g_on_error_stack_trace:
20460 * @prg_name: the program name, needed by <command>gdb</command> for the [S]tack trace option.
20462 * Invokes <command>gdb</command>, which attaches to the current
20463 * process and shows a stack trace. Called by g_on_error_query()
20464 * when the [S]tack trace option is selected. You can get the current
20465 * process's "program name" with g_get_prgname(), assuming that you
20466 * have called gtk_init() or gdk_init().
20468 * This function may cause different actions on non-UNIX platforms.
20474 * @once: a #GOnce structure
20475 * @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().
20476 * @arg: data to be passed to @func
20478 * The first call to this routine by a process with a given #GOnce
20479 * struct calls @func with the given argument. Thereafter, subsequent
20480 * calls to g_once() with the same #GOnce struct do not call @func
20481 * again, but return the stored result of the first call. On return
20482 * from g_once(), the status of @once will be %G_ONCE_STATUS_READY.
20484 * For example, a mutex or a thread-specific data key must be created
20485 * exactly once. In a threaded environment, calling g_once() ensures
20486 * that the initialization is serialized across multiple threads.
20488 * Calling g_once() recursively on the same #GOnce struct in
20489 * @func will lead to a deadlock.
20493 * get_debug_flags (void)
20495 * static GOnce my_once = G_ONCE_INIT;
20497 * g_once (&my_once, parse_debug_flags, NULL);
20499 * return my_once.retval;
20508 * g_once_init_enter:
20509 * @location: location of a static initializable variable containing 0
20511 * Function to be called when starting a critical initialization
20512 * section. The argument @location must point to a static
20513 * 0-initialized variable that will be set to a value other than 0 at
20514 * the end of the initialization section. In combination with
20515 * g_once_init_leave() and the unique address @value_location, it can
20516 * be ensured that an initialization section will be executed only once
20517 * during a program's life time, and that concurrent threads are
20518 * blocked until initialization completed. To be used in constructs
20522 * static gsize initialization_value = 0;
20524 * if (g_once_init_enter (&initialization_value))
20526 * gsize setup_value = 42; /** initialization code here **/
20528 * g_once_init_leave (&initialization_value, setup_value);
20531 * /** use initialization_value here **/
20534 * Returns: %TRUE if the initialization section should be entered, %FALSE and blocks otherwise
20540 * g_once_init_leave:
20541 * @location: location of a static initializable variable containing 0
20542 * @result: new non-0 value for *@value_location
20544 * Counterpart to g_once_init_enter(). Expects a location of a static
20545 * 0-initialized initialization variable, and an initialization value
20546 * other than 0. Sets the variable to the initialization value, and
20547 * releases concurrent threads blocking in g_once_init_enter() on this
20548 * initialization variable.
20556 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
20557 * @flags: as in open()
20558 * @mode: as in open()
20560 * A wrapper for the POSIX open() function. The open() function is
20561 * used to convert a pathname into a file descriptor.
20563 * On POSIX systems file descriptors are implemented by the operating
20564 * system. On Windows, it's the C library that implements open() and
20565 * file descriptors. The actual Win32 API for opening files is quite
20566 * different, see MSDN documentation for CreateFile(). The Win32 API
20567 * uses file handles, which are more randomish integers, not small
20568 * integers like file descriptors.
20570 * Because file descriptors are specific to the C library on Windows,
20571 * the file descriptor returned by this function makes sense only to
20572 * functions in the same C library. Thus if the GLib-using code uses a
20573 * different C library than GLib does, the file descriptor returned by
20574 * this function cannot be passed to C library functions like write()
20577 * See your C library manual for more details about open().
20579 * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from open().
20585 * g_option_context_add_group:
20586 * @context: a #GOptionContext
20587 * @group: the group to add
20589 * Adds a #GOptionGroup to the @context, so that parsing with @context
20590 * will recognize the options in the group. Note that the group will
20591 * be freed together with the context when g_option_context_free() is
20592 * called, so you must not free the group yourself after adding it
20600 * g_option_context_add_main_entries:
20601 * @context: a #GOptionContext
20602 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20603 * @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
20605 * A convenience function which creates a main group if it doesn't
20606 * exist, adds the @entries to it and sets the translation domain.
20613 * g_option_context_free:
20614 * @context: a #GOptionContext
20616 * Frees context and all the groups which have been
20619 * Please note that parsed arguments need to be freed separately (see
20627 * g_option_context_get_description:
20628 * @context: a #GOptionContext
20630 * Returns the description. See g_option_context_set_description().
20632 * Returns: the description
20638 * g_option_context_get_help:
20639 * @context: a #GOptionContext
20640 * @main_help: if %TRUE, only include the main group
20641 * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
20643 * Returns a formatted, translated help text for the given context.
20644 * To obtain the text produced by <option>--help</option>, call
20645 * <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
20646 * To obtain the text produced by <option>--help-all</option>, call
20647 * <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
20648 * To obtain the help text for an option group, call
20649 * <literal>g_option_context_get_help (context, FALSE, group)</literal>.
20651 * Returns: A newly allocated string containing the help text
20657 * g_option_context_get_help_enabled:
20658 * @context: a #GOptionContext
20660 * Returns whether automatic <option>--help</option> generation
20661 * is turned on for @context. See g_option_context_set_help_enabled().
20663 * Returns: %TRUE if automatic help generation is turned on.
20669 * g_option_context_get_ignore_unknown_options:
20670 * @context: a #GOptionContext
20672 * Returns whether unknown options are ignored or not. See
20673 * g_option_context_set_ignore_unknown_options().
20675 * Returns: %TRUE if unknown options are ignored.
20681 * g_option_context_get_main_group:
20682 * @context: a #GOptionContext
20684 * Returns a pointer to the main group of @context.
20686 * 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.
20692 * g_option_context_get_summary:
20693 * @context: a #GOptionContext
20695 * Returns the summary. See g_option_context_set_summary().
20697 * Returns: the summary
20703 * g_option_context_new:
20704 * @parameter_string: (allow-none): a string which is displayed in the first line of <option>--help</option> output, after the usage summary <literal><replaceable>programname</replaceable> [OPTION...]</literal>
20706 * Creates a new option context.
20708 * The @parameter_string can serve multiple purposes. It can be used
20709 * to add descriptions for "rest" arguments, which are not parsed by
20710 * the #GOptionContext, typically something like "FILES" or
20711 * "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
20712 * collecting "rest" arguments, GLib handles this automatically by
20713 * using the @arg_description of the corresponding #GOptionEntry in
20714 * the usage summary.
20716 * Another usage is to give a short summary of the program
20717 * functionality, like " - frob the strings", which will be displayed
20718 * in the same line as the usage. For a longer description of the
20719 * program functionality that should be displayed as a paragraph
20720 * below the usage line, use g_option_context_set_summary().
20722 * Note that the @parameter_string is translated using the
20723 * function set with g_option_context_set_translate_func(), so
20724 * it should normally be passed untranslated.
20726 * Returns: a newly created #GOptionContext, which must be freed with g_option_context_free() after use.
20732 * g_option_context_parse:
20733 * @context: a #GOptionContext
20734 * @argc: (inout) (allow-none): a pointer to the number of command line arguments
20735 * @argv: (inout) (array length=argc) (allow-none): a pointer to the array of command line arguments
20736 * @error: a return location for errors
20738 * Parses the command line arguments, recognizing options
20739 * which have been added to @context. A side-effect of
20740 * calling this function is that g_set_prgname() will be
20743 * If the parsing is successful, any parsed arguments are
20744 * removed from the array and @argc and @argv are updated
20745 * accordingly. A '--' option is stripped from @argv
20746 * unless there are unparsed options before and after it,
20747 * or some of the options after it start with '-'. In case
20748 * of an error, @argc and @argv are left unmodified.
20750 * If automatic <option>--help</option> support is enabled
20751 * (see g_option_context_set_help_enabled()), and the
20752 * @argv array contains one of the recognized help options,
20753 * this function will produce help output to stdout and
20754 * call <literal>exit (0)</literal>.
20756 * Note that function depends on the
20757 * <link linkend="setlocale">current locale</link> for
20758 * automatic character set conversion of string and filename
20761 * Returns: %TRUE if the parsing was successful, %FALSE if an error occurred
20767 * g_option_context_set_description:
20768 * @context: a #GOptionContext
20769 * @description: (allow-none): a string to be shown in <option>--help</option> output after the list of options, or %NULL
20771 * Adds a string to be displayed in <option>--help</option> output
20772 * after the list of options. This text often includes a bug reporting
20775 * Note that the summary is translated (see
20776 * g_option_context_set_translate_func()).
20783 * g_option_context_set_help_enabled:
20784 * @context: a #GOptionContext
20785 * @help_enabled: %TRUE to enable <option>--help</option>, %FALSE to disable it
20787 * Enables or disables automatic generation of <option>--help</option>
20788 * output. By default, g_option_context_parse() recognizes
20789 * <option>--help</option>, <option>-h</option>,
20790 * <option>-?</option>, <option>--help-all</option>
20791 * and <option>--help-</option><replaceable>groupname</replaceable> and creates
20792 * suitable output to stdout.
20799 * g_option_context_set_ignore_unknown_options:
20800 * @context: a #GOptionContext
20801 * @ignore_unknown: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
20803 * Sets whether to ignore unknown options or not. If an argument is
20804 * ignored, it is left in the @argv array after parsing. By default,
20805 * g_option_context_parse() treats unknown options as error.
20807 * This setting does not affect non-option arguments (i.e. arguments
20808 * which don't start with a dash). But note that GOption cannot reliably
20809 * determine whether a non-option belongs to a preceding unknown option.
20816 * g_option_context_set_main_group:
20817 * @context: a #GOptionContext
20818 * @group: the group to set as main group
20820 * Sets a #GOptionGroup as main group of the @context.
20821 * This has the same effect as calling g_option_context_add_group(),
20822 * the only difference is that the options in the main group are
20823 * treated differently when generating <option>--help</option> output.
20830 * g_option_context_set_summary:
20831 * @context: a #GOptionContext
20832 * @summary: (allow-none): a string to be shown in <option>--help</option> output before the list of options, or %NULL
20834 * Adds a string to be displayed in <option>--help</option> output
20835 * before the list of options. This is typically a summary of the
20836 * program functionality.
20838 * Note that the summary is translated (see
20839 * g_option_context_set_translate_func() and
20840 * g_option_context_set_translation_domain()).
20847 * g_option_context_set_translate_func:
20848 * @context: a #GOptionContext
20849 * @func: (allow-none): the #GTranslateFunc, or %NULL
20850 * @data: (allow-none): user data to pass to @func, or %NULL
20851 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20853 * Sets the function which is used to translate the contexts
20854 * user-visible strings, for <option>--help</option> output.
20855 * If @func is %NULL, strings are not translated.
20857 * Note that option groups have their own translation functions,
20858 * this function only affects the @parameter_string (see g_option_context_new()),
20859 * the summary (see g_option_context_set_summary()) and the description
20860 * (see g_option_context_set_description()).
20862 * If you are using gettext(), you only need to set the translation
20863 * domain, see g_option_context_set_translation_domain().
20870 * g_option_context_set_translation_domain:
20871 * @context: a #GOptionContext
20872 * @domain: the domain to use
20874 * A convenience function to use gettext() for translating
20875 * user-visible strings.
20882 * g_option_group_add_entries:
20883 * @group: a #GOptionGroup
20884 * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20886 * Adds the options specified in @entries to @group.
20893 * g_option_group_free:
20894 * @group: a #GOptionGroup
20896 * Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
20897 * free groups which have been added to a #GOptionContext.
20904 * g_option_group_new:
20905 * @name: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
20906 * @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
20907 * @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
20908 * @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
20909 * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
20911 * Creates a new #GOptionGroup.
20913 * Returns: a newly created option group. It should be added to a #GOptionContext or freed with g_option_group_free().
20919 * g_option_group_set_error_hook:
20920 * @group: a #GOptionGroup
20921 * @error_func: a function to call when an error occurs
20923 * Associates a function with @group which will be called
20924 * from g_option_context_parse() when an error occurs.
20926 * Note that the user data to be passed to @error_func can be
20927 * specified when constructing the group with g_option_group_new().
20934 * g_option_group_set_parse_hooks:
20935 * @group: a #GOptionGroup
20936 * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
20937 * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
20939 * Associates two functions with @group which will be called
20940 * from g_option_context_parse() before the first option is parsed
20941 * and after the last option has been parsed, respectively.
20943 * Note that the user data to be passed to @pre_parse_func and
20944 * @post_parse_func can be specified when constructing the group
20945 * with g_option_group_new().
20952 * g_option_group_set_translate_func:
20953 * @group: a #GOptionGroup
20954 * @func: (allow-none): the #GTranslateFunc, or %NULL
20955 * @data: (allow-none): user data to pass to @func, or %NULL
20956 * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20958 * Sets the function which is used to translate user-visible
20959 * strings, for <option>--help</option> output. Different
20960 * groups can use different #GTranslateFunc<!-- -->s. If @func
20961 * is %NULL, strings are not translated.
20963 * If you are using gettext(), you only need to set the translation
20964 * domain, see g_option_group_set_translation_domain().
20971 * g_option_group_set_translation_domain:
20972 * @group: a #GOptionGroup
20973 * @domain: the domain to use
20975 * A convenience function to use gettext() for translating
20976 * user-visible strings.
20983 * g_parse_debug_string:
20984 * @string: (allow-none): a list of debug options separated by colons, spaces, or commas, or %NULL.
20985 * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate strings with bit flags.
20986 * @nkeys: the number of #GDebugKey<!-- -->s in the array.
20988 * Parses a string containing debugging options
20989 * into a %guint containing bit flags. This is used
20990 * within GDK and GTK+ to parse the debug options passed on the
20991 * command line or through environment variables.
20993 * If @string is equal to <code>"all"</code>, all flags are set. Any flags
20994 * specified along with <code>"all"</code> in @string are inverted; thus,
20995 * <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
20996 * except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
20998 * If @string is equal to <code>"help"</code>, all the available keys in @keys
20999 * are printed out to standard error.
21001 * Returns: the combined set of bit flags.
21006 * g_path_get_basename:
21007 * @file_name: the name of the file
21009 * Gets the last component of the filename.
21011 * If @file_name ends with a directory separator it gets the component
21012 * before the last slash. If @file_name consists only of directory
21013 * separators (and on Windows, possibly a drive letter), a single
21014 * separator is returned. If @file_name is empty, it gets ".".
21016 * Returns: a newly allocated string containing the last component of the filename
21021 * g_path_get_dirname:
21022 * @file_name: the name of the file
21024 * Gets the directory components of a file name.
21026 * If the file name has no directory components "." is returned.
21027 * The returned string should be freed when no longer needed.
21029 * Returns: the directory components of the file
21034 * g_path_is_absolute:
21035 * @file_name: a file name
21037 * Returns %TRUE if the given @file_name is an absolute file name.
21038 * Note that this is a somewhat vague concept on Windows.
21040 * On POSIX systems, an absolute file name is well-defined. It always
21041 * starts from the single root directory. For example "/usr/local".
21043 * On Windows, the concepts of current drive and drive-specific
21044 * current directory introduce vagueness. This function interprets as
21045 * an absolute file name one that either begins with a directory
21046 * separator such as "\Users\tml" or begins with the root on a drive,
21047 * for example "C:\Windows". The first case also includes UNC paths
21048 * such as "\\myserver\docs\foo". In all cases, either slashes or
21049 * backslashes are accepted.
21051 * Note that a file name relative to the current drive root does not
21052 * truly specify a file uniquely over time and across processes, as
21053 * the current drive is a per-process value and can be changed.
21055 * File names relative the current directory on some specific drive,
21056 * such as "D:foo/bar", are not interpreted as absolute by this
21057 * function, but they obviously are not relative to the normal current
21058 * directory as returned by getcwd() or g_get_current_dir()
21059 * either. Such paths should be avoided, or need to be handled using
21060 * Windows-specific code.
21062 * Returns: %TRUE if @file_name is absolute
21067 * g_path_skip_root:
21068 * @file_name: a file name
21070 * Returns a pointer into @file_name after the root component,
21071 * i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
21072 * is not an absolute path it returns %NULL.
21074 * Returns: a pointer into @file_name after the root component
21080 * @pspec: a #GPatternSpec
21081 * @string_length: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
21082 * @string: the UTF-8 encoded string to match
21083 * @string_reversed: (allow-none): the reverse of @string or %NULL
21085 * Matches a string against a compiled pattern. Passing the correct
21086 * length of the string given is mandatory. The reversed string can be
21087 * omitted by passing %NULL, this is more efficient if the reversed
21088 * version of the string to be matched is not at hand, as
21089 * g_pattern_match() will only construct it if the compiled pattern
21090 * requires reverse matches.
21092 * Note that, if the user code will (possibly) match a string against a
21093 * multitude of patterns containing wildcards, chances are high that
21094 * some patterns will require a reversed string. In this case, it's
21095 * more efficient to provide the reversed string to avoid multiple
21096 * constructions thereof in the various calls to g_pattern_match().
21098 * Note also that the reverse of a UTF-8 encoded string can in general
21099 * <emphasis>not</emphasis> be obtained by g_strreverse(). This works
21100 * only if the string doesn't contain any multibyte characters. GLib
21101 * offers the g_utf8_strreverse() function to reverse UTF-8 encoded
21104 * Returns: %TRUE if @string matches @pspec
21109 * g_pattern_match_simple:
21110 * @pattern: the UTF-8 encoded pattern
21111 * @string: the UTF-8 encoded string to match
21113 * Matches a string against a pattern given as a string. If this
21114 * function is to be called in a loop, it's more efficient to compile
21115 * the pattern once with g_pattern_spec_new() and call
21116 * g_pattern_match_string() repeatedly.
21118 * Returns: %TRUE if @string matches @pspec
21123 * g_pattern_match_string:
21124 * @pspec: a #GPatternSpec
21125 * @string: the UTF-8 encoded string to match
21127 * Matches a string against a compiled pattern. If the string is to be
21128 * matched against more than one pattern, consider using
21129 * g_pattern_match() instead while supplying the reversed string.
21131 * Returns: %TRUE if @string matches @pspec
21136 * g_pattern_spec_equal:
21137 * @pspec1: a #GPatternSpec
21138 * @pspec2: another #GPatternSpec
21140 * Compares two compiled pattern specs and returns whether they will
21141 * match the same set of strings.
21143 * Returns: Whether the compiled patterns are equal
21148 * g_pattern_spec_free:
21149 * @pspec: a #GPatternSpec
21151 * Frees the memory allocated for the #GPatternSpec.
21156 * g_pattern_spec_new:
21157 * @pattern: a zero-terminated UTF-8 encoded string
21159 * Compiles a pattern to a #GPatternSpec.
21161 * Returns: a newly-allocated #GPatternSpec
21166 * g_pointer_bit_lock:
21167 * @address: a pointer to a #gpointer-sized value
21168 * @lock_bit: a bit value between 0 and 31
21170 * This is equivalent to g_bit_lock, but working on pointers (or other
21171 * pointer-sized values).
21173 * For portability reasons, you may only lock on the bottom 32 bits of
21181 * g_pointer_bit_trylock:
21182 * @address: a pointer to a #gpointer-sized value
21183 * @lock_bit: a bit value between 0 and 31
21185 * This is equivalent to g_bit_trylock, but working on pointers (or
21186 * other pointer-sized values).
21188 * For portability reasons, you may only lock on the bottom 32 bits of
21191 * Returns: %TRUE if the lock was acquired
21197 * g_pointer_bit_unlock:
21198 * @address: a pointer to a #gpointer-sized value
21199 * @lock_bit: a bit value between 0 and 31
21201 * This is equivalent to g_bit_unlock, but working on pointers (or other
21202 * pointer-sized values).
21204 * For portability reasons, you may only lock on the bottom 32 bits of
21213 * @fds: file descriptors to poll
21214 * @nfds: the number of file descriptors in @fds
21215 * @timeout: amount of time to wait, in milliseconds, or -1 to wait forever
21217 * Polls @fds, as with the poll() system call, but portably. (On
21218 * systems that don't have poll(), it is emulated using select().)
21219 * This is used internally by #GMainContext, but it can be called
21220 * directly if you need to block until a file descriptor is ready, but
21221 * don't want to run the full main loop.
21223 * Each element of @fds is a #GPollFD describing a single file
21224 * descriptor to poll. The %fd field indicates the file descriptor,
21225 * and the %events field indicates the events to poll for. On return,
21226 * the %revents fields will be filled with the events that actually
21229 * On POSIX systems, the file descriptors in @fds can be any sort of
21230 * file descriptor, but the situation is much more complicated on
21231 * Windows. If you need to use g_poll() in code that has to run on
21232 * Windows, the easiest solution is to construct all of your
21233 * #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
21235 * 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.
21242 * @err: (allow-none): a return location for a #GError, or %NULL
21243 * @format: printf()-style format string
21244 * @...: arguments to @format
21246 * Formats a string according to @format and
21247 * prefix it to an existing error message. If
21248 * @err is %NULL (ie: no error variable) then do
21251 * If *@err is %NULL (ie: an error variable is
21252 * present but there is no error condition) then
21253 * also do nothing. Whether or not it makes
21254 * sense to take advantage of this feature is up
21263 * @format: the message format. See the printf() documentation
21264 * @...: the parameters to insert into the format string
21266 * Outputs a formatted message via the print handler.
21267 * The default print handler simply outputs the message to stdout.
21269 * g_print() should not be used from within libraries for debugging
21270 * messages, since it may be redirected by applications to special
21271 * purpose message windows or even files. Instead, libraries should
21272 * use g_log(), or the convenience functions g_message(), g_warning()
21279 * @format: the message format. See the printf() documentation
21280 * @...: the parameters to insert into the format string
21282 * Outputs a formatted message via the error message handler.
21283 * The default handler simply outputs the message to stderr.
21285 * g_printerr() should not be used from within libraries.
21286 * Instead g_log() should be used, or the convenience functions
21287 * g_message(), g_warning() and g_error().
21293 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21294 * @...: the arguments to insert in the output.
21296 * An implementation of the standard printf() function which supports
21297 * positional parameters, as specified in the Single Unix Specification.
21299 * Returns: the number of bytes printed.
21305 * g_printf_string_upper_bound:
21306 * @format: the format string. See the printf() documentation
21307 * @args: the parameters to be inserted into the format string
21309 * Calculates the maximum space needed to store the output
21310 * of the sprintf() function.
21312 * Returns: the maximum space needed to store the formatted string
21318 * @key: a #GPrivate
21320 * Returns the current value of the thread local variable @key.
21322 * If the value has not yet been set in this thread, %NULL is returned.
21323 * Values are never copied between threads (when a new thread is
21324 * created, for example).
21326 * Returns: the thread-local value
21331 * g_private_replace:
21332 * @key: a #GPrivate
21333 * @value: the new value
21335 * Sets the thread local variable @key to have the value @value in the
21338 * This function differs from g_private_set() in the following way: if
21339 * the previous value was non-%NULL then the #GDestroyNotify handler for
21340 * @key is run on it.
21348 * @key: a #GPrivate
21349 * @value: the new value
21351 * Sets the thread local variable @key to have the value @value in the
21354 * This function differs from g_private_replace() in the following way:
21355 * the #GDestroyNotify for @key is not called on the old value.
21360 * g_propagate_error:
21361 * @dest: error return location
21362 * @src: error to move into the return location
21364 * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
21365 * The error variable @dest points to must be %NULL.
21370 * g_propagate_prefixed_error:
21371 * @dest: error return location
21372 * @src: error to move into the return location
21373 * @format: printf()-style format string
21374 * @...: arguments to @format
21376 * If @dest is %NULL, free @src; otherwise,
21377 * moves @src into *@dest. *@dest must be %NULL.
21378 * After the move, add a prefix as with
21379 * g_prefix_error().
21387 * @array: a #GPtrArray.
21388 * @data: the pointer to add.
21390 * Adds a pointer to the end of the pointer array. The array will grow
21391 * in size automatically if necessary.
21396 * g_ptr_array_foreach:
21397 * @array: a #GPtrArray
21398 * @func: the function to call for each array element
21399 * @user_data: user data to pass to the function
21401 * Calls a function for each element of a #GPtrArray.
21408 * g_ptr_array_free:
21409 * @array: a #GPtrArray.
21410 * @free_seg: if %TRUE the actual pointer array is freed as well.
21412 * Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
21413 * it frees the memory block holding the elements as well. Pass %FALSE
21414 * if you want to free the #GPtrArray wrapper but preserve the
21415 * underlying array for use elsewhere. If the reference count of @array
21416 * is greater than one, the #GPtrArray wrapper is preserved but the
21417 * size of @array will be set to zero.
21419 * <note><para>If array contents point to dynamically-allocated
21420 * memory, they should be freed separately if @free_seg is %TRUE and no
21421 * #GDestroyNotify function has been set for @array.</para></note>
21423 * Returns: the pointer array if @free_seg is %FALSE, otherwise %NULL. The pointer array should be freed using g_free().
21428 * g_ptr_array_index:
21429 * @array: a #GPtrArray.
21430 * @index_: the index of the pointer to return.
21432 * Returns the pointer at the given index of the pointer array.
21434 * Returns: the pointer at the given index.
21441 * Creates a new #GPtrArray with a reference count of 1.
21443 * Returns: the new #GPtrArray.
21448 * g_ptr_array_new_full:
21449 * @reserved_size: number of pointers preallocated.
21450 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21452 * Creates a new #GPtrArray with @reserved_size pointers preallocated
21453 * and a reference count of 1. This avoids frequent reallocation, if
21454 * you are going to add many pointers to the array. Note however that
21455 * the size of the array is still 0. It also set @element_free_func
21456 * for freeing each element when the array is destroyed either via
21457 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21458 * set to %TRUE or when removing elements.
21460 * Returns: A new #GPtrArray.
21466 * g_ptr_array_new_with_free_func:
21467 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21469 * Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
21470 * for freeing each element when the array is destroyed either via
21471 * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21472 * set to %TRUE or when removing elements.
21474 * Returns: A new #GPtrArray.
21481 * @array: a #GPtrArray
21483 * Atomically increments the reference count of @array by one.
21484 * This function is thread-safe and may be called from any thread.
21486 * Returns: The passed in #GPtrArray
21492 * g_ptr_array_remove:
21493 * @array: a #GPtrArray.
21494 * @data: the pointer to remove.
21496 * Removes the first occurrence of the given pointer from the pointer
21497 * array. The following elements are moved down one place. If @array
21498 * has a non-%NULL #GDestroyNotify function it is called for the
21501 * It returns %TRUE if the pointer was removed, or %FALSE if the
21502 * pointer was not found.
21504 * Returns: %TRUE if the pointer is removed. %FALSE if the pointer is not found in the array.
21509 * g_ptr_array_remove_fast:
21510 * @array: a #GPtrArray.
21511 * @data: the pointer to remove.
21513 * Removes the first occurrence of the given pointer from the pointer
21514 * array. The last element in the array is used to fill in the space,
21515 * so this function does not preserve the order of the array. But it is
21516 * faster than g_ptr_array_remove(). If @array has a non-%NULL
21517 * #GDestroyNotify function it is called for the removed element.
21519 * It returns %TRUE if the pointer was removed, or %FALSE if the
21520 * pointer was not found.
21522 * Returns: %TRUE if the pointer was found in the array.
21527 * g_ptr_array_remove_index:
21528 * @array: a #GPtrArray.
21529 * @index_: the index of the pointer to remove.
21531 * Removes the pointer at the given index from the pointer array. The
21532 * following elements are moved down one place. If @array has a
21533 * non-%NULL #GDestroyNotify function it is called for the removed
21536 * Returns: the pointer which was removed.
21541 * g_ptr_array_remove_index_fast:
21542 * @array: a #GPtrArray.
21543 * @index_: the index of the pointer to remove.
21545 * Removes the pointer at the given index from the pointer array. The
21546 * last element in the array is used to fill in the space, so this
21547 * function does not preserve the order of the array. But it is faster
21548 * than g_ptr_array_remove_index(). If @array has a non-%NULL
21549 * #GDestroyNotify function it is called for the removed element.
21551 * Returns: the pointer which was removed.
21556 * g_ptr_array_remove_range:
21557 * @array: a @GPtrArray.
21558 * @index_: the index of the first pointer to remove.
21559 * @length: the number of pointers to remove.
21561 * Removes the given number of pointers starting at the given index
21562 * from a #GPtrArray. The following elements are moved to close the
21563 * gap. If @array has a non-%NULL #GDestroyNotify function it is called
21564 * for the removed elements.
21571 * g_ptr_array_set_free_func:
21572 * @array: A #GPtrArray.
21573 * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21575 * Sets a function for freeing each element when @array is destroyed
21576 * either via g_ptr_array_unref(), when g_ptr_array_free() is called
21577 * with @free_segment set to %TRUE or when removing elements.
21584 * g_ptr_array_set_size:
21585 * @array: a #GPtrArray.
21586 * @length: the new length of the pointer array.
21588 * Sets the size of the array. When making the array larger,
21589 * newly-added elements will be set to %NULL. When making it smaller,
21590 * if @array has a non-%NULL #GDestroyNotify function then it will be
21591 * called for the removed elements.
21596 * g_ptr_array_sized_new:
21597 * @reserved_size: number of pointers preallocated.
21599 * Creates a new #GPtrArray with @reserved_size pointers preallocated
21600 * and a reference count of 1. This avoids frequent reallocation, if
21601 * you are going to add many pointers to the array. Note however that
21602 * the size of the array is still 0.
21604 * Returns: the new #GPtrArray.
21609 * g_ptr_array_sort:
21610 * @array: a #GPtrArray.
21611 * @compare_func: comparison function.
21613 * Sorts the array, using @compare_func which should be a qsort()-style
21614 * comparison function (returns less than zero for first arg is less
21615 * than second arg, zero for equal, greater than zero if irst arg is
21616 * greater than second arg).
21618 * <note><para>The comparison function for g_ptr_array_sort() doesn't
21619 * take the pointers from the array as arguments, it takes pointers to
21620 * the pointers in the array.</para></note>
21622 * This is guaranteed to be a stable sort since version 2.32.
21627 * g_ptr_array_sort_with_data:
21628 * @array: a #GPtrArray.
21629 * @compare_func: comparison function.
21630 * @user_data: data to pass to @compare_func.
21632 * Like g_ptr_array_sort(), but the comparison function has an extra
21633 * user data argument.
21635 * <note><para>The comparison function for g_ptr_array_sort_with_data()
21636 * doesn't take the pointers from the array as arguments, it takes
21637 * pointers to the pointers in the array.</para></note>
21639 * This is guaranteed to be a stable sort since version 2.32.
21644 * g_ptr_array_unref:
21645 * @array: A #GPtrArray.
21647 * Atomically decrements the reference count of @array by one. If the
21648 * reference count drops to 0, the effect is the same as calling
21649 * g_ptr_array_free() with @free_segment set to %TRUE. This function
21650 * is MT-safe and may be called from any thread.
21657 * g_qsort_with_data:
21658 * @pbase: start of array to sort
21659 * @total_elems: elements in the array
21660 * @size: size of each element
21661 * @compare_func: function to compare elements
21662 * @user_data: data to pass to @compare_func
21664 * This is just like the standard C qsort() function, but
21665 * the comparison routine accepts a user data argument.
21667 * This is guaranteed to be a stable sort since version 2.32.
21672 * g_quark_from_static_string:
21673 * @string: (allow-none): a string.
21675 * Gets the #GQuark identifying the given (static) string. If the
21676 * string does not currently have an associated #GQuark, a new #GQuark
21677 * is created, linked to the given string.
21679 * Note that this function is identical to g_quark_from_string() except
21680 * that if a new #GQuark is created the string itself is used rather
21681 * than a copy. This saves memory, but can only be used if the string
21682 * will <emphasis>always</emphasis> exist. It can be used with
21683 * statically allocated strings in the main program, but not with
21684 * statically allocated memory in dynamically loaded modules, if you
21685 * expect to ever unload the module again (e.g. do not use this
21686 * function in GTK+ theme engines).
21688 * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21693 * g_quark_from_string:
21694 * @string: (allow-none): a string.
21696 * Gets the #GQuark identifying the given string. If the string does
21697 * not currently have an associated #GQuark, a new #GQuark is created,
21698 * using a copy of the string.
21700 * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21705 * g_quark_to_string:
21706 * @quark: a #GQuark.
21708 * Gets the string associated with the given #GQuark.
21710 * Returns: the string associated with the #GQuark
21715 * g_quark_try_string:
21716 * @string: (allow-none): a string.
21718 * Gets the #GQuark associated with the given string, or 0 if string is
21719 * %NULL or it has no associated #GQuark.
21721 * If you want the GQuark to be created if it doesn't already exist,
21722 * use g_quark_from_string() or g_quark_from_static_string().
21724 * Returns: the #GQuark associated with the string, or 0 if @string is %NULL or there is no #GQuark associated with it.
21730 * @queue: a #GQueue
21732 * Removes all the elements in @queue. If queue elements contain
21733 * dynamically-allocated memory, they should be freed first.
21741 * @queue: a #GQueue
21743 * Copies a @queue. Note that is a shallow copy. If the elements in the
21744 * queue consist of pointers to data, the pointers are copied, but the
21745 * actual data is not.
21747 * Returns: A copy of @queue
21753 * g_queue_delete_link:
21754 * @queue: a #GQueue
21755 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
21757 * Removes @link_ from @queue and frees it.
21759 * @link_ must be part of @queue.
21767 * @queue: a #GQueue
21768 * @data: data to find
21770 * Finds the first link in @queue which contains @data.
21772 * Returns: The first link in @queue which contains @data.
21778 * g_queue_find_custom:
21779 * @queue: a #GQueue
21780 * @data: user data passed to @func
21781 * @func: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
21783 * Finds an element in a #GQueue, using a supplied function to find the
21784 * desired element. It iterates over the queue, calling the given function
21785 * which should return 0 when the desired element is found. The function
21786 * takes two gconstpointer arguments, the #GQueue element's data as the
21787 * first argument and the given user data as the second argument.
21789 * Returns: The found link, or %NULL if it wasn't found
21796 * @queue: a #GQueue
21797 * @func: the function to call for each element's data
21798 * @user_data: user data to pass to @func
21800 * Calls @func for each element in the queue passing @user_data to the
21809 * @queue: a #GQueue.
21811 * Frees the memory allocated for the #GQueue. Only call this function if
21812 * @queue was created with g_queue_new(). If queue elements contain
21813 * dynamically-allocated memory, they should be freed first.
21816 * If queue elements contain dynamically-allocated memory,
21817 * you should either use g_queue_free_full() or free them manually
21824 * g_queue_free_full:
21825 * @queue: a pointer to a #GQueue
21826 * @free_func: the function to be called to free each element's data
21828 * Convenience method, which frees all the memory used by a #GQueue, and
21829 * calls the specified destroy function on every element's data.
21836 * g_queue_get_length:
21837 * @queue: a #GQueue
21839 * Returns the number of items in @queue.
21841 * Returns: The number of items in @queue.
21848 * @queue: a #GQueue
21849 * @data: the data to find.
21851 * Returns the position of the first element in @queue which contains @data.
21853 * Returns: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
21860 * @queue: an uninitialized #GQueue
21862 * A statically-allocated #GQueue must be initialized with this function
21863 * before it can be used. Alternatively you can initialize it with
21864 * #G_QUEUE_INIT. It is not necessary to initialize queues created with
21872 * g_queue_insert_after:
21873 * @queue: a #GQueue
21874 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21875 * @data: the data to insert
21877 * Inserts @data into @queue after @sibling
21879 * @sibling must be part of @queue
21886 * g_queue_insert_before:
21887 * @queue: a #GQueue
21888 * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21889 * @data: the data to insert
21891 * Inserts @data into @queue before @sibling.
21893 * @sibling must be part of @queue.
21900 * g_queue_insert_sorted:
21901 * @queue: a #GQueue
21902 * @data: the data to insert
21903 * @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.
21904 * @user_data: user data passed to @func.
21906 * Inserts @data into @queue using @func to determine the new position.
21913 * g_queue_is_empty:
21914 * @queue: a #GQueue.
21916 * Returns %TRUE if the queue is empty.
21918 * Returns: %TRUE if the queue is empty.
21923 * g_queue_link_index:
21924 * @queue: a #GQueue
21925 * @link_: A #GList link
21927 * Returns the position of @link_ in @queue.
21929 * Returns: The position of @link_, or -1 if the link is not part of @queue
21937 * Creates a new #GQueue.
21939 * Returns: a new #GQueue.
21944 * g_queue_peek_head:
21945 * @queue: a #GQueue.
21947 * Returns the first element of the queue.
21949 * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
21954 * g_queue_peek_head_link:
21955 * @queue: a #GQueue
21957 * Returns the first link in @queue
21959 * Returns: the first link in @queue, or %NULL if @queue is empty
21965 * g_queue_peek_nth:
21966 * @queue: a #GQueue
21967 * @n: the position of the element.
21969 * Returns the @n'th element of @queue.
21971 * Returns: The data for the @n'th element of @queue, or %NULL if @n is off the end of @queue.
21977 * g_queue_peek_nth_link:
21978 * @queue: a #GQueue
21979 * @n: the position of the link
21981 * Returns the link at the given position
21983 * Returns: The link at the @n'th position, or %NULL if @n is off the end of the list
21989 * g_queue_peek_tail:
21990 * @queue: a #GQueue.
21992 * Returns the last element of the queue.
21994 * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
21999 * g_queue_peek_tail_link:
22000 * @queue: a #GQueue
22002 * Returns the last link @queue.
22004 * Returns: the last link in @queue, or %NULL if @queue is empty
22010 * g_queue_pop_head:
22011 * @queue: a #GQueue.
22013 * Removes the first element of the queue.
22015 * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
22020 * g_queue_pop_head_link:
22021 * @queue: a #GQueue.
22023 * Removes the first element of the queue.
22025 * Returns: the #GList element at the head of the queue, or %NULL if the queue is empty.
22031 * @queue: a #GQueue
22032 * @n: the position of the element.
22034 * Removes the @n'th element of @queue.
22036 * Returns: the element's data, or %NULL if @n is off the end of @queue.
22042 * g_queue_pop_nth_link:
22043 * @queue: a #GQueue
22044 * @n: the link's position
22046 * Removes and returns the link at the given position.
22048 * Returns: The @n'th link, or %NULL if @n is off the end of @queue.
22054 * g_queue_pop_tail:
22055 * @queue: a #GQueue.
22057 * Removes the last element of the queue.
22059 * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
22064 * g_queue_pop_tail_link:
22065 * @queue: a #GQueue.
22067 * Removes the last element of the queue.
22069 * Returns: the #GList element at the tail of the queue, or %NULL if the queue is empty.
22074 * g_queue_push_head:
22075 * @queue: a #GQueue.
22076 * @data: the data for the new element.
22078 * Adds a new element at the head of the queue.
22083 * g_queue_push_head_link:
22084 * @queue: a #GQueue.
22085 * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
22087 * Adds a new element at the head of the queue.
22092 * g_queue_push_nth:
22093 * @queue: a #GQueue
22094 * @data: the data for the new element
22095 * @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.
22097 * Inserts a new element into @queue at the given position
22104 * g_queue_push_nth_link:
22105 * @queue: a #GQueue
22106 * @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.
22107 * @link_: the link to add to @queue
22109 * Inserts @link into @queue at the given position.
22116 * g_queue_push_tail:
22117 * @queue: a #GQueue.
22118 * @data: the data for the new element.
22120 * Adds a new element at the tail of the queue.
22125 * g_queue_push_tail_link:
22126 * @queue: a #GQueue.
22127 * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
22129 * Adds a new element at the tail of the queue.
22135 * @queue: a #GQueue
22136 * @data: data to remove.
22138 * Removes the first element in @queue that contains @data.
22140 * Returns: %TRUE if @data was found and removed from @queue
22146 * g_queue_remove_all:
22147 * @queue: a #GQueue
22148 * @data: data to remove
22150 * Remove all elements whose data equals @data from @queue.
22152 * Returns: the number of elements removed from @queue
22159 * @queue: a #GQueue
22161 * Reverses the order of the items in @queue.
22169 * @queue: a #GQueue
22170 * @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.
22171 * @user_data: user data passed to @compare_func
22173 * Sorts @queue using @compare_func.
22181 * @queue: a #GQueue
22182 * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
22184 * Unlinks @link_ so that it will no longer be part of @queue. The link is
22187 * @link_ must be part of @queue,
22195 * @rand_: a #GRand.
22197 * Returns a random #gboolean from @rand_. This corresponds to a
22198 * unbiased coin toss.
22200 * Returns: a random #gboolean.
22206 * @rand_: a #GRand.
22208 * Copies a #GRand into a new one with the same exact state as before.
22209 * This way you can take a snapshot of the random number generator for
22212 * Returns: the new #GRand.
22219 * @rand_: a #GRand.
22221 * Returns the next random #gdouble from @rand_ equally distributed over
22222 * the range [0..1).
22224 * Returns: A random number.
22229 * g_rand_double_range:
22230 * @rand_: a #GRand.
22231 * @begin: lower closed bound of the interval.
22232 * @end: upper open bound of the interval.
22234 * Returns the next random #gdouble from @rand_ equally distributed over
22235 * the range [@begin..@end).
22237 * Returns: A random number.
22243 * @rand_: a #GRand.
22245 * Frees the memory allocated for the #GRand.
22251 * @rand_: a #GRand.
22253 * Returns the next random #guint32 from @rand_ equally distributed over
22254 * the range [0..2^32-1].
22256 * Returns: A random number.
22261 * g_rand_int_range:
22262 * @rand_: a #GRand.
22263 * @begin: lower closed bound of the interval.
22264 * @end: upper open bound of the interval.
22266 * Returns the next random #gint32 from @rand_ equally distributed over
22267 * the range [@begin..@end-1].
22269 * Returns: A random number.
22276 * Creates a new random number generator initialized with a seed taken
22277 * either from <filename>/dev/urandom</filename> (if existing) or from
22278 * the current time (as a fallback).
22280 * Returns: the new #GRand.
22285 * g_rand_new_with_seed:
22286 * @seed: a value to initialize the random number generator.
22288 * Creates a new random number generator initialized with @seed.
22290 * Returns: the new #GRand.
22295 * g_rand_new_with_seed_array:
22296 * @seed: an array of seeds to initialize the random number generator.
22297 * @seed_length: an array of seeds to initialize the random number generator.
22299 * Creates a new random number generator initialized with @seed.
22301 * Returns: the new #GRand.
22308 * @rand_: a #GRand.
22309 * @seed: a value to reinitialize the random number generator.
22311 * Sets the seed for the random number generator #GRand to @seed.
22316 * g_rand_set_seed_array:
22317 * @rand_: a #GRand.
22318 * @seed: array to initialize with
22319 * @seed_length: length of array
22321 * Initializes the random number generator by an array of
22322 * longs. Array can be of arbitrary size, though only the
22323 * first 624 values are taken. This function is useful
22324 * if you have many low entropy seeds, or if you require more then
22325 * 32bits of actual entropy for your application.
22332 * g_random_boolean:
22334 * Returns a random #gboolean. This corresponds to a unbiased coin toss.
22336 * Returns: a random #gboolean.
22343 * Returns a random #gdouble equally distributed over the range [0..1).
22345 * Returns: A random number.
22350 * g_random_double_range:
22351 * @begin: lower closed bound of the interval.
22352 * @end: upper open bound of the interval.
22354 * Returns a random #gdouble equally distributed over the range [@begin..@end).
22356 * Returns: A random number.
22363 * Return a random #guint32 equally distributed over the range
22366 * Returns: A random number.
22371 * g_random_int_range:
22372 * @begin: lower closed bound of the interval.
22373 * @end: upper open bound of the interval.
22375 * Returns a random #gint32 equally distributed over the range
22376 * [@begin..@end-1].
22378 * Returns: A random number.
22383 * g_random_set_seed:
22384 * @seed: a value to reinitialize the global random number generator.
22386 * Sets the seed for the global random number generator, which is used
22387 * by the <function>g_random_*</function> functions, to @seed.
22393 * @mem: the memory to reallocate
22394 * @n_bytes: new size of the memory in bytes
22396 * Reallocates the memory pointed to by @mem, so that it now has space for
22397 * @n_bytes bytes of memory. It returns the new address of the memory, which may
22398 * have been moved. @mem may be %NULL, in which case it's considered to
22399 * have zero-length. @n_bytes may be 0, in which case %NULL will be returned
22400 * and @mem will be freed unless it is %NULL.
22402 * Returns: the new address of the allocated memory
22408 * @mem: the memory to reallocate
22409 * @n_blocks: the number of blocks to allocate
22410 * @n_block_bytes: the size of each block in bytes
22412 * This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22413 * but care is taken to detect possible overflow during multiplication.
22416 * Returns: the new address of the allocated memory
22421 * g_rec_mutex_clear:
22422 * @rec_mutex: an initialized #GRecMutex
22424 * Frees the resources allocated to a recursive mutex with
22425 * g_rec_mutex_init().
22427 * This function should not be used with a #GRecMutex that has been
22428 * statically allocated.
22430 * Calling g_rec_mutex_clear() on a locked recursive mutex leads
22431 * to undefined behaviour.
22438 * g_rec_mutex_init:
22439 * @rec_mutex: an uninitialized #GRecMutex
22441 * Initializes a #GRecMutex so that it can be used.
22443 * This function is useful to initialize a recursive mutex
22444 * that has been allocated on the stack, or as part of a larger
22447 * It is not necessary to initialise a recursive mutex that has been
22448 * statically allocated.
22458 * b = g_new (Blob, 1);
22459 * g_rec_mutex_init (&b->m);
22462 * Calling g_rec_mutex_init() on an already initialized #GRecMutex
22463 * leads to undefined behaviour.
22465 * To undo the effect of g_rec_mutex_init() when a recursive mutex
22466 * is no longer needed, use g_rec_mutex_clear().
22473 * g_rec_mutex_lock:
22474 * @rec_mutex: a #GRecMutex
22476 * Locks @rec_mutex. If @rec_mutex is already locked by another
22477 * thread, the current thread will block until @rec_mutex is
22478 * unlocked by the other thread. If @rec_mutex is already locked
22479 * by the current thread, the 'lock count' of @rec_mutex is increased.
22480 * The mutex will only become available again when it is unlocked
22481 * as many times as it has been locked.
22488 * g_rec_mutex_trylock:
22489 * @rec_mutex: a #GRecMutex
22491 * Tries to lock @rec_mutex. If @rec_mutex is already locked
22492 * by another thread, it immediately returns %FALSE. Otherwise
22493 * it locks @rec_mutex and returns %TRUE.
22495 * Returns: %TRUE if @rec_mutex could be locked
22501 * g_rec_mutex_unlock:
22502 * @rec_mutex: a #GRecMutex
22504 * Unlocks @rec_mutex. If another thread is blocked in a
22505 * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
22506 * and can lock @rec_mutex itself.
22508 * Calling g_rec_mutex_unlock() on a recursive mutex that is not
22509 * locked by the current thread leads to undefined behaviour.
22516 * g_regex_check_replacement:
22517 * @replacement: the replacement string
22518 * @has_references: (out) (allow-none): location to store information about references in @replacement or %NULL
22519 * @error: location to store error
22521 * Checks whether @replacement is a valid replacement string
22522 * (see g_regex_replace()), i.e. that all escape sequences in
22525 * If @has_references is not %NULL then @replacement is checked
22526 * for pattern references. For instance, replacement text 'foo\n'
22527 * does not contain references and may be evaluated without information
22528 * about actual match, but '\0\1' (whole match followed by first
22529 * subpattern) requires valid #GMatchInfo object.
22531 * Returns: whether @replacement is a valid replacement string
22537 * g_regex_escape_nul:
22538 * @string: the string to escape
22539 * @length: the length of @string
22541 * Escapes the nul characters in @string to "\x00". It can be used
22542 * to compile a regex with embedded nul characters.
22544 * For completeness, @length can be -1 for a nul-terminated string.
22545 * In this case the output string will be of course equal to @string.
22547 * Returns: a newly-allocated escaped string
22553 * g_regex_escape_string:
22554 * @string: (array length=length): the string to escape
22555 * @length: the length of @string, or -1 if @string is nul-terminated
22557 * Escapes the special characters used for regular expressions
22558 * in @string, for instance "a.b*c" becomes "a\.b\*c". This
22559 * function is useful to dynamically generate regular expressions.
22561 * @string can contain nul characters that are replaced with "\0",
22562 * in this case remember to specify the correct length of @string
22565 * Returns: a newly-allocated escaped string
22571 * g_regex_get_capture_count:
22572 * @regex: a #GRegex
22574 * Returns the number of capturing subpatterns in the pattern.
22576 * Returns: the number of capturing subpatterns
22582 * g_regex_get_compile_flags:
22583 * @regex: a #GRegex
22585 * Returns the compile options that @regex was created with.
22587 * Returns: flags from #GRegexCompileFlags
22593 * g_regex_get_has_cr_or_lf:
22594 * @regex: a #GRegex structure
22596 * Checks whether the pattern contains explicit CR or LF references.
22598 * Returns: %TRUE if the pattern contains explicit CR or LF references
22604 * g_regex_get_match_flags:
22605 * @regex: a #GRegex
22607 * Returns the match options that @regex was created with.
22609 * Returns: flags from #GRegexMatchFlags
22615 * g_regex_get_max_backref:
22616 * @regex: a #GRegex
22618 * Returns the number of the highest back reference
22619 * in the pattern, or 0 if the pattern does not contain
22622 * Returns: the number of the highest back reference
22628 * g_regex_get_max_lookbehind:
22629 * @regex: a #GRegex structure
22631 * Gets the number of characters in the longest lookbehind assertion in the
22632 * pattern. This information is useful when doing multi-segment matching using
22633 * the partial matching facilities.
22635 * Returns: the number of characters in the longest lookbehind assertion.
22641 * g_regex_get_pattern:
22642 * @regex: a #GRegex structure
22644 * Gets the pattern string associated with @regex, i.e. a copy of
22645 * the string passed to g_regex_new().
22647 * Returns: the pattern of @regex
22653 * g_regex_get_string_number:
22654 * @regex: #GRegex structure
22655 * @name: name of the subexpression
22657 * Retrieves the number of the subexpression named @name.
22659 * Returns: The number of the subexpression or -1 if @name does not exists
22666 * @regex: a #GRegex structure from g_regex_new()
22667 * @string: the string to scan for matches
22668 * @match_options: match options
22669 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22671 * Scans for a match in string for the pattern in @regex.
22672 * The @match_options are combined with the match options specified
22673 * when the @regex structure was created, letting you have more
22674 * flexibility in reusing #GRegex structures.
22676 * A #GMatchInfo structure, used to get information on the match,
22677 * is stored in @match_info if not %NULL. Note that if @match_info
22678 * is not %NULL then it is created even if the function returns %FALSE,
22679 * i.e. you must free it regardless if regular expression actually matched.
22681 * To retrieve all the non-overlapping matches of the pattern in
22682 * string you can use g_match_info_next().
22686 * print_uppercase_words (const gchar *string)
22688 * /* Print all uppercase-only words. */
22690 * GMatchInfo *match_info;
22692 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22693 * g_regex_match (regex, string, 0, &match_info);
22694 * while (g_match_info_matches (match_info))
22696 * gchar *word = g_match_info_fetch (match_info, 0);
22697 * g_print ("Found: %s\n", word);
22699 * g_match_info_next (match_info, NULL);
22701 * g_match_info_free (match_info);
22702 * g_regex_unref (regex);
22706 * @string is not copied and is used in #GMatchInfo internally. If
22707 * you use any #GMatchInfo method (except g_match_info_free()) after
22708 * freeing or modifying @string then the behaviour is undefined.
22710 * Returns: %TRUE is the string matched, %FALSE otherwise
22716 * g_regex_match_all:
22717 * @regex: a #GRegex structure from g_regex_new()
22718 * @string: the string to scan for matches
22719 * @match_options: match options
22720 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22722 * Using the standard algorithm for regular expression matching only
22723 * the longest match in the string is retrieved. This function uses
22724 * a different algorithm so it can retrieve all the possible matches.
22725 * For more documentation see g_regex_match_all_full().
22727 * A #GMatchInfo structure, used to get information on the match, is
22728 * stored in @match_info if not %NULL. Note that if @match_info is
22729 * not %NULL then it is created even if the function returns %FALSE,
22730 * i.e. you must free it regardless if regular expression actually
22733 * @string is not copied and is used in #GMatchInfo internally. If
22734 * you use any #GMatchInfo method (except g_match_info_free()) after
22735 * freeing or modifying @string then the behaviour is undefined.
22737 * Returns: %TRUE is the string matched, %FALSE otherwise
22743 * g_regex_match_all_full:
22744 * @regex: a #GRegex structure from g_regex_new()
22745 * @string: (array length=string_len): the string to scan for matches
22746 * @string_len: the length of @string, or -1 if @string is nul-terminated
22747 * @start_position: starting index of the string to match
22748 * @match_options: match options
22749 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22750 * @error: location to store the error occurring, or %NULL to ignore errors
22752 * Using the standard algorithm for regular expression matching only
22753 * the longest match in the string is retrieved, it is not possible
22754 * to obtain all the available matches. For instance matching
22755 * "<a> <b> <c>" against the pattern "<.*>"
22756 * you get "<a> <b> <c>".
22758 * This function uses a different algorithm (called DFA, i.e. deterministic
22759 * finite automaton), so it can retrieve all the possible matches, all
22760 * starting at the same point in the string. For instance matching
22761 * "<a> <b> <c>" against the pattern "<.*>"
22762 * you would obtain three matches: "<a> <b> <c>",
22763 * "<a> <b>" and "<a>".
22765 * The number of matched strings is retrieved using
22766 * g_match_info_get_match_count(). To obtain the matched strings and
22767 * their position you can use, respectively, g_match_info_fetch() and
22768 * g_match_info_fetch_pos(). Note that the strings are returned in
22769 * reverse order of length; that is, the longest matching string is
22772 * Note that the DFA algorithm is slower than the standard one and it
22773 * is not able to capture substrings, so backreferences do not work.
22775 * Setting @start_position differs from just passing over a shortened
22776 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22777 * that begins with any kind of lookbehind assertion, such as "\b".
22779 * A #GMatchInfo structure, used to get information on the match, is
22780 * stored in @match_info if not %NULL. Note that if @match_info is
22781 * not %NULL then it is created even if the function returns %FALSE,
22782 * i.e. you must free it regardless if regular expression actually
22785 * @string is not copied and is used in #GMatchInfo internally. If
22786 * you use any #GMatchInfo method (except g_match_info_free()) after
22787 * freeing or modifying @string then the behaviour is undefined.
22789 * Returns: %TRUE is the string matched, %FALSE otherwise
22795 * g_regex_match_full:
22796 * @regex: a #GRegex structure from g_regex_new()
22797 * @string: (array length=string_len): the string to scan for matches
22798 * @string_len: the length of @string, or -1 if @string is nul-terminated
22799 * @start_position: starting index of the string to match
22800 * @match_options: match options
22801 * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22802 * @error: location to store the error occurring, or %NULL to ignore errors
22804 * Scans for a match in string for the pattern in @regex.
22805 * The @match_options are combined with the match options specified
22806 * when the @regex structure was created, letting you have more
22807 * flexibility in reusing #GRegex structures.
22809 * Setting @start_position differs from just passing over a shortened
22810 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22811 * that begins with any kind of lookbehind assertion, such as "\b".
22813 * A #GMatchInfo structure, used to get information on the match, is
22814 * stored in @match_info if not %NULL. Note that if @match_info is
22815 * not %NULL then it is created even if the function returns %FALSE,
22816 * i.e. you must free it regardless if regular expression actually
22819 * @string is not copied and is used in #GMatchInfo internally. If
22820 * you use any #GMatchInfo method (except g_match_info_free()) after
22821 * freeing or modifying @string then the behaviour is undefined.
22823 * To retrieve all the non-overlapping matches of the pattern in
22824 * string you can use g_match_info_next().
22828 * print_uppercase_words (const gchar *string)
22830 * /* Print all uppercase-only words. */
22832 * GMatchInfo *match_info;
22833 * GError *error = NULL;
22835 * regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22836 * g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
22837 * while (g_match_info_matches (match_info))
22839 * gchar *word = g_match_info_fetch (match_info, 0);
22840 * g_print ("Found: %s\n", word);
22842 * g_match_info_next (match_info, &error);
22844 * g_match_info_free (match_info);
22845 * g_regex_unref (regex);
22846 * if (error != NULL)
22848 * g_printerr ("Error while matching: %s\n", error->message);
22849 * g_error_free (error);
22854 * Returns: %TRUE is the string matched, %FALSE otherwise
22860 * g_regex_match_simple:
22861 * @pattern: the regular expression
22862 * @string: the string to scan for matches
22863 * @compile_options: compile options for the regular expression, or 0
22864 * @match_options: match options, or 0
22866 * Scans for a match in @string for @pattern.
22868 * This function is equivalent to g_regex_match() but it does not
22869 * require to compile the pattern with g_regex_new(), avoiding some
22870 * lines of code when you need just to do a match without extracting
22871 * substrings, capture counts, and so on.
22873 * If this function is to be called on the same @pattern more than
22874 * once, it's more efficient to compile the pattern once with
22875 * g_regex_new() and then use g_regex_match().
22877 * Returns: %TRUE if the string matched, %FALSE otherwise
22884 * @pattern: the regular expression
22885 * @compile_options: compile options for the regular expression, or 0
22886 * @match_options: match options for the regular expression, or 0
22887 * @error: return location for a #GError
22889 * Compiles the regular expression to an internal form, and does
22890 * the initial setup of the #GRegex structure.
22892 * Returns: a #GRegex structure. Call g_regex_unref() when you are done with it
22899 * @regex: a #GRegex
22901 * Increases reference count of @regex by 1.
22910 * @regex: a #GRegex structure
22911 * @string: (array length=string_len): the string to perform matches against
22912 * @string_len: the length of @string, or -1 if @string is nul-terminated
22913 * @start_position: starting index of the string to match
22914 * @replacement: text to replace each match with
22915 * @match_options: options for the match
22916 * @error: location to store the error occurring, or %NULL to ignore errors
22918 * Replaces all occurrences of the pattern in @regex with the
22919 * replacement text. Backreferences of the form '\number' or
22920 * '\g<number>' in the replacement text are interpolated by the
22921 * number-th captured subexpression of the match, '\g<name>' refers
22922 * to the captured subexpression with the given name. '\0' refers to the
22923 * complete match, but '\0' followed by a number is the octal representation
22924 * of a character. To include a literal '\' in the replacement, write '\\'.
22925 * There are also escapes that changes the case of the following text:
22928 * <varlistentry><term>\l</term>
22930 * <para>Convert to lower case the next character</para>
22933 * <varlistentry><term>\u</term>
22935 * <para>Convert to upper case the next character</para>
22938 * <varlistentry><term>\L</term>
22940 * <para>Convert to lower case till \E</para>
22943 * <varlistentry><term>\U</term>
22945 * <para>Convert to upper case till \E</para>
22948 * <varlistentry><term>\E</term>
22950 * <para>End case modification</para>
22955 * If you do not need to use backreferences use g_regex_replace_literal().
22957 * The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
22958 * passed to g_regex_new(). If you want to use not UTF-8 encoded stings
22959 * you can use g_regex_replace_literal().
22961 * Setting @start_position differs from just passing over a shortened
22962 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
22963 * begins with any kind of lookbehind assertion, such as "\b".
22965 * Returns: a newly allocated string containing the replacements
22971 * g_regex_replace_eval:
22972 * @regex: a #GRegex structure from g_regex_new()
22973 * @string: (array length=string_len): string to perform matches against
22974 * @string_len: the length of @string, or -1 if @string is nul-terminated
22975 * @start_position: starting index of the string to match
22976 * @match_options: options for the match
22977 * @eval: a function to call for each match
22978 * @user_data: user data to pass to the function
22979 * @error: location to store the error occurring, or %NULL to ignore errors
22981 * Replaces occurrences of the pattern in regex with the output of
22982 * @eval for that occurrence.
22984 * Setting @start_position differs from just passing over a shortened
22985 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22986 * that begins with any kind of lookbehind assertion, such as "\b".
22988 * The following example uses g_regex_replace_eval() to replace multiple
22992 * eval_cb (const GMatchInfo *info,
22999 * match = g_match_info_fetch (info, 0);
23000 * r = g_hash_table_lookup ((GHashTable *)data, match);
23001 * g_string_append (res, r);
23007 * /* ... */
23013 * h = g_hash_table_new (g_str_hash, g_str_equal);
23015 * g_hash_table_insert (h, "1", "ONE");
23016 * g_hash_table_insert (h, "2", "TWO");
23017 * g_hash_table_insert (h, "3", "THREE");
23018 * g_hash_table_insert (h, "4", "FOUR");
23020 * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
23021 * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
23022 * g_hash_table_destroy (h);
23024 * /* ... */
23027 * Returns: a newly allocated string containing the replacements
23033 * g_regex_replace_literal:
23034 * @regex: a #GRegex structure
23035 * @string: (array length=string_len): the string to perform matches against
23036 * @string_len: the length of @string, or -1 if @string is nul-terminated
23037 * @start_position: starting index of the string to match
23038 * @replacement: text to replace each match with
23039 * @match_options: options for the match
23040 * @error: location to store the error occurring, or %NULL to ignore errors
23042 * Replaces all occurrences of the pattern in @regex with the
23043 * replacement text. @replacement is replaced literally, to
23044 * include backreferences use g_regex_replace().
23046 * Setting @start_position differs from just passing over a
23047 * shortened string and setting #G_REGEX_MATCH_NOTBOL in the
23048 * case of a pattern that begins with any kind of lookbehind
23049 * assertion, such as "\b".
23051 * Returns: a newly allocated string containing the replacements
23058 * @regex: a #GRegex structure
23059 * @string: the string to split with the pattern
23060 * @match_options: match time option flags
23062 * Breaks the string on the pattern, and returns an array of the tokens.
23063 * If the pattern contains capturing parentheses, then the text for each
23064 * of the substrings will also be returned. If the pattern does not match
23065 * anywhere in the string, then the whole string is returned as the first
23068 * As a special case, the result of splitting the empty string "" is an
23069 * empty vector, not a vector containing a single string. The reason for
23070 * this special case is that being able to represent a empty vector is
23071 * typically more useful than consistent handling of empty elements. If
23072 * you do need to represent empty elements, you'll need to check for the
23073 * empty string before calling this function.
23075 * A pattern that can match empty strings splits @string into separate
23076 * characters wherever it matches the empty string between characters.
23077 * For example splitting "ab c" using as a separator "\s*", you will get
23078 * "a", "b" and "c".
23080 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
23086 * g_regex_split_full:
23087 * @regex: a #GRegex structure
23088 * @string: (array length=string_len): the string to split with the pattern
23089 * @string_len: the length of @string, or -1 if @string is nul-terminated
23090 * @start_position: starting index of the string to match
23091 * @match_options: match time option flags
23092 * @max_tokens: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
23093 * @error: return location for a #GError
23095 * Breaks the string on the pattern, and returns an array of the tokens.
23096 * If the pattern contains capturing parentheses, then the text for each
23097 * of the substrings will also be returned. If the pattern does not match
23098 * anywhere in the string, then the whole string is returned as the first
23101 * As a special case, the result of splitting the empty string "" is an
23102 * empty vector, not a vector containing a single string. The reason for
23103 * this special case is that being able to represent a empty vector is
23104 * typically more useful than consistent handling of empty elements. If
23105 * you do need to represent empty elements, you'll need to check for the
23106 * empty string before calling this function.
23108 * A pattern that can match empty strings splits @string into separate
23109 * characters wherever it matches the empty string between characters.
23110 * For example splitting "ab c" using as a separator "\s*", you will get
23111 * "a", "b" and "c".
23113 * Setting @start_position differs from just passing over a shortened
23114 * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23115 * that begins with any kind of lookbehind assertion, such as "\b".
23117 * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
23123 * g_regex_split_simple:
23124 * @pattern: the regular expression
23125 * @string: the string to scan for matches
23126 * @compile_options: compile options for the regular expression, or 0
23127 * @match_options: match options, or 0
23129 * Breaks the string on the pattern, and returns an array of
23130 * the tokens. If the pattern contains capturing parentheses,
23131 * then the text for each of the substrings will also be returned.
23132 * If the pattern does not match anywhere in the string, then the
23133 * whole string is returned as the first token.
23135 * This function is equivalent to g_regex_split() but it does
23136 * not require to compile the pattern with g_regex_new(), avoiding
23137 * some lines of code when you need just to do a split without
23138 * extracting substrings, capture counts, and so on.
23140 * If this function is to be called on the same @pattern more than
23141 * once, it's more efficient to compile the pattern once with
23142 * g_regex_new() and then use g_regex_split().
23144 * As a special case, the result of splitting the empty string ""
23145 * is an empty vector, not a vector containing a single string.
23146 * The reason for this special case is that being able to represent
23147 * a empty vector is typically more useful than consistent handling
23148 * of empty elements. If you do need to represent empty elements,
23149 * you'll need to check for the empty string before calling this
23152 * A pattern that can match empty strings splits @string into
23153 * separate characters wherever it matches the empty string between
23154 * characters. For example splitting "ab c" using as a separator
23155 * "\s*", you will get "a", "b" and "c".
23157 * Returns: (transfer full): a %NULL-terminated array of strings. Free it using g_strfreev()
23164 * @regex: a #GRegex
23166 * Decreases reference count of @regex by 1. When reference count drops
23167 * to zero, it frees all the memory associated with the regex structure.
23174 * g_reload_user_special_dirs_cache:
23176 * Resets the cache used for g_get_user_special_dir(), so
23177 * that the latest on-disk version is used. Call this only
23178 * if you just changed the data on disk yourself.
23180 * Due to threadsafety issues this may cause leaking of strings
23181 * that were previously returned from g_get_user_special_dir()
23182 * that can't be freed. We ensure to only leak the data for
23183 * the directories that actually changed value though.
23191 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23193 * A wrapper for the POSIX remove() function. The remove() function
23194 * deletes a name from the filesystem.
23196 * See your C library manual for more details about how remove() works
23197 * on your system. On Unix, remove() removes also directories, as it
23198 * calls unlink() for files and rmdir() for directories. On Windows,
23199 * although remove() in the C library only works for files, this
23200 * function tries first remove() and then if that fails rmdir(), and
23201 * thus works for both files and directories. Note however, that on
23202 * Windows, it is in general not possible to remove a file that is
23203 * open to some process, or mapped into memory.
23205 * If this function fails on Windows you can't infer too much from the
23206 * errno value. rmdir() is tried regardless of what caused remove() to
23207 * fail. Any errno value set by remove() will be overwritten by that
23210 * Returns: 0 if the file was successfully removed, -1 if an error occurred
23217 * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23218 * @newfilename: a pathname in the GLib file name encoding
23220 * A wrapper for the POSIX rename() function. The rename() function
23221 * renames a file, moving it between directories if required.
23223 * See your C library manual for more details about how rename() works
23224 * on your system. It is not possible in general on Windows to rename
23225 * a file that is open to some process.
23227 * Returns: 0 if the renaming succeeded, -1 if an error occurred
23234 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23236 * A wrapper for the POSIX rmdir() function. The rmdir() function
23237 * deletes a directory from the filesystem.
23239 * See your C library manual for more details about how rmdir() works
23242 * Returns: 0 if the directory was successfully removed, -1 if an error occurred
23249 * @rw_lock: an initialized #GRWLock
23251 * Frees the resources allocated to a lock with g_rw_lock_init().
23253 * This function should not be used with a #GRWLock that has been
23254 * statically allocated.
23256 * Calling g_rw_lock_clear() when any thread holds the lock
23257 * leads to undefined behaviour.
23265 * @rw_lock: an uninitialized #GRWLock
23267 * Initializes a #GRWLock so that it can be used.
23269 * This function is useful to initialize a lock that has been
23270 * allocated on the stack, or as part of a larger structure. It is not
23271 * necessary to initialise a reader-writer lock that has been statically
23282 * b = g_new (Blob, 1);
23283 * g_rw_lock_init (&b->l);
23286 * To undo the effect of g_rw_lock_init() when a lock is no longer
23287 * needed, use g_rw_lock_clear().
23289 * Calling g_rw_lock_init() on an already initialized #GRWLock leads
23290 * to undefined behaviour.
23297 * g_rw_lock_reader_lock:
23298 * @rw_lock: a #GRWLock
23300 * Obtain a read lock on @rw_lock. If another thread currently holds
23301 * the write lock on @rw_lock or blocks waiting for it, the current
23302 * thread will block. Read locks can be taken recursively.
23304 * It is implementation-defined how many threads are allowed to
23305 * hold read locks on the same lock simultaneously.
23312 * g_rw_lock_reader_trylock:
23313 * @rw_lock: a #GRWLock
23315 * Tries to obtain a read lock on @rw_lock and returns %TRUE if
23316 * the read lock was successfully obtained. Otherwise it
23319 * Returns: %TRUE if @rw_lock could be locked
23325 * g_rw_lock_reader_unlock:
23326 * @rw_lock: a #GRWLock
23328 * Release a read lock on @rw_lock.
23330 * Calling g_rw_lock_reader_unlock() on a lock that is not held
23331 * by the current thread leads to undefined behaviour.
23338 * g_rw_lock_writer_lock:
23339 * @rw_lock: a #GRWLock
23341 * Obtain a write lock on @rw_lock. If any thread already holds
23342 * a read or write lock on @rw_lock, the current thread will block
23343 * until all other threads have dropped their locks on @rw_lock.
23350 * g_rw_lock_writer_trylock:
23351 * @rw_lock: a #GRWLock
23353 * Tries to obtain a write lock on @rw_lock. If any other thread holds
23354 * a read or write lock on @rw_lock, it immediately returns %FALSE.
23355 * Otherwise it locks @rw_lock and returns %TRUE.
23357 * Returns: %TRUE if @rw_lock could be locked
23363 * g_rw_lock_writer_unlock:
23364 * @rw_lock: a #GRWLock
23366 * Release a write lock on @rw_lock.
23368 * Calling g_rw_lock_writer_unlock() on a lock that is not held
23369 * by the current thread leads to undefined behaviour.
23376 * g_scanner_add_symbol:
23377 * @scanner: a #GScanner
23378 * @symbol: the symbol to add
23379 * @value: the value of the symbol
23381 * Adds a symbol to the default scope.
23383 * Deprecated: 2.2: Use g_scanner_scope_add_symbol() instead.
23388 * g_scanner_cur_line:
23389 * @scanner: a #GScanner
23391 * Returns the current line in the input stream (counting
23392 * from 1). This is the line of the last token parsed via
23393 * g_scanner_get_next_token().
23395 * Returns: the current line
23400 * g_scanner_cur_position:
23401 * @scanner: a #GScanner
23403 * Returns the current position in the current line (counting
23404 * from 0). This is the position of the last token parsed via
23405 * g_scanner_get_next_token().
23407 * Returns: the current position on the line
23412 * g_scanner_cur_token:
23413 * @scanner: a #GScanner
23415 * Gets the current token type. This is simply the @token
23416 * field in the #GScanner structure.
23418 * Returns: the current token type
23423 * g_scanner_cur_value:
23424 * @scanner: a #GScanner
23426 * Gets the current token value. This is simply the @value
23427 * field in the #GScanner structure.
23429 * Returns: the current token value
23434 * g_scanner_destroy:
23435 * @scanner: a #GScanner
23437 * Frees all memory used by the #GScanner.
23443 * @scanner: a #GScanner
23445 * Returns %TRUE if the scanner has reached the end of
23446 * the file or text buffer.
23448 * Returns: %TRUE if the scanner has reached the end of the file or text buffer
23454 * @scanner: a #GScanner
23455 * @format: the message format. See the printf() documentation
23456 * @...: the parameters to insert into the format string
23458 * Outputs an error message, via the #GScanner message handler.
23463 * g_scanner_foreach_symbol:
23464 * @scanner: a #GScanner
23465 * @func: the function to call with each symbol
23466 * @data: data to pass to the function
23468 * Calls a function for each symbol in the default scope.
23470 * Deprecated: 2.2: Use g_scanner_scope_foreach_symbol() instead.
23475 * g_scanner_freeze_symbol_table:
23476 * @scanner: a #GScanner
23478 * There is no reason to use this macro, since it does nothing.
23480 * Deprecated: 2.2: This macro does nothing.
23485 * g_scanner_get_next_token:
23486 * @scanner: a #GScanner
23488 * Parses the next token just like g_scanner_peek_next_token()
23489 * and also removes it from the input stream. The token data is
23490 * placed in the @token, @value, @line, and @position fields of
23491 * the #GScanner structure.
23493 * Returns: the type of the token
23498 * g_scanner_input_file:
23499 * @scanner: a #GScanner
23500 * @input_fd: a file descriptor
23502 * Prepares to scan a file.
23507 * g_scanner_input_text:
23508 * @scanner: a #GScanner
23509 * @text: the text buffer to scan
23510 * @text_len: the length of the text buffer
23512 * Prepares to scan a text buffer.
23517 * g_scanner_lookup_symbol:
23518 * @scanner: a #GScanner
23519 * @symbol: the symbol to look up
23521 * Looks up a symbol in the current scope and return its value.
23522 * If the symbol is not bound in the current scope, %NULL is
23525 * Returns: the value of @symbol in the current scope, or %NULL if @symbol is not bound in the current scope
23531 * @config_templ: the initial scanner settings
23533 * Creates a new #GScanner.
23535 * The @config_templ structure specifies the initial settings
23536 * of the scanner, which are copied into the #GScanner
23537 * @config field. If you pass %NULL then the default settings
23540 * Returns: the new #GScanner
23545 * g_scanner_peek_next_token:
23546 * @scanner: a #GScanner
23548 * Parses the next token, without removing it from the input stream.
23549 * The token data is placed in the @next_token, @next_value, @next_line,
23550 * and @next_position fields of the #GScanner structure.
23552 * Note that, while the token is not removed from the input stream
23553 * (i.e. the next call to g_scanner_get_next_token() will return the
23554 * same token), it will not be reevaluated. This can lead to surprising
23555 * results when changing scope or the scanner configuration after peeking
23556 * the next token. Getting the next token after switching the scope or
23557 * configuration will return whatever was peeked before, regardless of
23558 * any symbols that may have been added or removed in the new scope.
23560 * Returns: the type of the token
23565 * g_scanner_remove_symbol:
23566 * @scanner: a #GScanner
23567 * @symbol: the symbol to remove
23569 * Removes a symbol from the default scope.
23571 * Deprecated: 2.2: Use g_scanner_scope_remove_symbol() instead.
23576 * g_scanner_scope_add_symbol:
23577 * @scanner: a #GScanner
23578 * @scope_id: the scope id
23579 * @symbol: the symbol to add
23580 * @value: the value of the symbol
23582 * Adds a symbol to the given scope.
23587 * g_scanner_scope_foreach_symbol:
23588 * @scanner: a #GScanner
23589 * @scope_id: the scope id
23590 * @func: the function to call for each symbol/value pair
23591 * @user_data: user data to pass to the function
23593 * Calls the given function for each of the symbol/value pairs
23594 * in the given scope of the #GScanner. The function is passed
23595 * the symbol and value of each pair, and the given @user_data
23601 * g_scanner_scope_lookup_symbol:
23602 * @scanner: a #GScanner
23603 * @scope_id: the scope id
23604 * @symbol: the symbol to look up
23606 * Looks up a symbol in a scope and return its value. If the
23607 * symbol is not bound in the scope, %NULL is returned.
23609 * Returns: the value of @symbol in the given scope, or %NULL if @symbol is not bound in the given scope.
23614 * g_scanner_scope_remove_symbol:
23615 * @scanner: a #GScanner
23616 * @scope_id: the scope id
23617 * @symbol: the symbol to remove
23619 * Removes a symbol from a scope.
23624 * g_scanner_set_scope:
23625 * @scanner: a #GScanner
23626 * @scope_id: the new scope id
23628 * Sets the current scope.
23630 * Returns: the old scope id
23635 * g_scanner_sync_file_offset:
23636 * @scanner: a #GScanner
23638 * Rewinds the filedescriptor to the current buffer position
23639 * and blows the file read ahead buffer. This is useful for
23640 * third party uses of the scanners filedescriptor, which hooks
23641 * onto the current scanning position.
23646 * g_scanner_thaw_symbol_table:
23647 * @scanner: a #GScanner
23649 * There is no reason to use this macro, since it does nothing.
23651 * Deprecated: 2.2: This macro does nothing.
23656 * g_scanner_unexp_token:
23657 * @scanner: a #GScanner
23658 * @expected_token: the expected token
23659 * @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.
23660 * @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.
23661 * @symbol_name: the name of the symbol, if the scanner's current token is a symbol.
23662 * @message: a message string to output at the end of the warning/error, or %NULL.
23663 * @is_error: if %TRUE it is output as an error. If %FALSE it is output as a warning.
23665 * Outputs a message through the scanner's msg_handler,
23666 * resulting from an unexpected token in the input stream.
23667 * Note that you should not call g_scanner_peek_next_token()
23668 * followed by g_scanner_unexp_token() without an intermediate
23669 * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
23670 * evaluates the scanner's current token (not the peeked token)
23671 * to construct part of the message.
23677 * @scanner: a #GScanner
23678 * @format: the message format. See the printf() documentation
23679 * @...: the parameters to insert into the format string
23681 * Outputs a warning message, via the #GScanner message handler.
23686 * g_sequence_append:
23687 * @seq: a #GSequence
23688 * @data: the data for the new item
23690 * Adds a new item to the end of @seq.
23692 * Returns: an iterator pointing to the new item
23698 * g_sequence_foreach:
23699 * @seq: a #GSequence
23700 * @func: the function to call for each item in @seq
23701 * @user_data: user data passed to @func
23703 * Calls @func for each item in the sequence passing @user_data
23711 * g_sequence_foreach_range:
23712 * @begin: a #GSequenceIter
23713 * @end: a #GSequenceIter
23715 * @user_data: user data passed to @func
23717 * Calls @func for each item in the range (@begin, @end) passing
23718 * @user_data to the function.
23726 * @seq: a #GSequence
23728 * Frees the memory allocated for @seq. If @seq has a data destroy
23729 * function associated with it, that function is called on all items in
23738 * @iter: a #GSequenceIter
23740 * Returns the data that @iter points to.
23742 * Returns: the data that @iter points to
23748 * g_sequence_get_begin_iter:
23749 * @seq: a #GSequence
23751 * Returns the begin iterator for @seq.
23753 * Returns: the begin iterator for @seq.
23759 * g_sequence_get_end_iter:
23760 * @seq: a #GSequence
23762 * Returns the end iterator for @seg
23764 * Returns: the end iterator for @seq
23770 * g_sequence_get_iter_at_pos:
23771 * @seq: a #GSequence
23772 * @pos: a position in @seq, or -1 for the end.
23774 * Returns the iterator at position @pos. If @pos is negative or larger
23775 * than the number of items in @seq, the end iterator is returned.
23777 * Returns: The #GSequenceIter at position @pos
23783 * g_sequence_get_length:
23784 * @seq: a #GSequence
23786 * Returns the length of @seq
23788 * Returns: the length of @seq
23794 * g_sequence_insert_before:
23795 * @iter: a #GSequenceIter
23796 * @data: the data for the new item
23798 * Inserts a new item just before the item pointed to by @iter.
23800 * Returns: an iterator pointing to the new item
23806 * g_sequence_insert_sorted:
23807 * @seq: a #GSequence
23808 * @data: the data to insert
23809 * @cmp_func: the function used to compare items in the sequence
23810 * @cmp_data: user data passed to @cmp_func.
23812 * Inserts @data into @sequence using @func to determine the new
23813 * position. The sequence must already be sorted according to @cmp_func;
23814 * otherwise the new position of @data is undefined.
23816 * @cmp_func is called with two items of the @seq and @user_data.
23817 * It should return 0 if the items are equal, a negative value
23818 * if the first item comes before the second, and a positive value
23819 * if the second item comes before the first.
23821 * Returns: a #GSequenceIter pointing to the new item.
23827 * g_sequence_insert_sorted_iter:
23828 * @seq: a #GSequence
23829 * @data: data for the new item
23830 * @iter_cmp: the function used to compare iterators in the sequence
23831 * @cmp_data: user data passed to @cmp_func
23833 * Like g_sequence_insert_sorted(), but uses
23834 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
23835 * the compare function.
23837 * @iter_cmp is called with two iterators pointing into @seq.
23838 * It should return 0 if the iterators are equal, a negative
23839 * value if the first iterator comes before the second, and a
23840 * positive value if the second iterator comes before the first.
23842 * It is called with two iterators pointing into @seq. It should
23843 * return 0 if the iterators are equal, a negative value if the
23844 * first iterator comes before the second, and a positive value
23845 * if the second iterator comes before the first.
23847 * Returns: a #GSequenceIter pointing to the new item
23853 * g_sequence_iter_compare:
23854 * @a: a #GSequenceIter
23855 * @b: a #GSequenceIter
23857 * Returns a negative number if @a comes before @b, 0 if they are equal,
23858 * and a positive number if @a comes after @b.
23860 * The @a and @b iterators must point into the same sequence.
23862 * Returns: A negative number if @a comes before @b, 0 if they are equal, and a positive number if @a comes after @b.
23868 * g_sequence_iter_get_position:
23869 * @iter: a #GSequenceIter
23871 * Returns the position of @iter
23873 * Returns: the position of @iter
23879 * g_sequence_iter_get_sequence:
23880 * @iter: a #GSequenceIter
23882 * Returns the #GSequence that @iter points into.
23884 * Returns: the #GSequence that @iter points into.
23890 * g_sequence_iter_is_begin:
23891 * @iter: a #GSequenceIter
23893 * Returns whether @iter is the begin iterator
23895 * Returns: whether @iter is the begin iterator
23901 * g_sequence_iter_is_end:
23902 * @iter: a #GSequenceIter
23904 * Returns whether @iter is the end iterator
23906 * Returns: Whether @iter is the end iterator.
23912 * g_sequence_iter_move:
23913 * @iter: a #GSequenceIter
23914 * @delta: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
23916 * Returns the #GSequenceIter which is @delta positions away from @iter.
23917 * If @iter is closer than -@delta positions to the beginning of the sequence,
23918 * the begin iterator is returned. If @iter is closer than @delta positions
23919 * to the end of the sequence, the end iterator is returned.
23921 * Returns: a #GSequenceIter which is @delta positions away from @iter.
23927 * g_sequence_iter_next:
23928 * @iter: a #GSequenceIter
23930 * Returns an iterator pointing to the next position after @iter. If
23931 * @iter is the end iterator, the end iterator is returned.
23933 * Returns: a #GSequenceIter pointing to the next position after @iter.
23939 * g_sequence_iter_prev:
23940 * @iter: a #GSequenceIter
23942 * Returns an iterator pointing to the previous position before @iter. If
23943 * @iter is the begin iterator, the begin iterator is returned.
23945 * Returns: a #GSequenceIter pointing to the previous position before @iter.
23951 * g_sequence_lookup:
23952 * @seq: a #GSequence
23953 * @data: data to lookup
23954 * @cmp_func: the function used to compare items in the sequence
23955 * @cmp_data: user data passed to @cmp_func.
23957 * Returns an iterator pointing to the position of the first item found
23958 * equal to @data according to @cmp_func and @cmp_data. If more than one
23959 * item is equal, it is not guaranteed that it is the first which is
23960 * returned. In that case, you can use g_sequence_iter_next() and
23961 * g_sequence_iter_prev() to get others.
23963 * @cmp_func is called with two items of the @seq and @user_data.
23964 * It should return 0 if the items are equal, a negative value if
23965 * the first item comes before the second, and a positive value if
23966 * the second item comes before the first.
23969 * This function will fail if the data contained in the sequence is
23970 * unsorted. Use g_sequence_insert_sorted() or
23971 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23972 * you want to add a large amount of data, call g_sequence_sort() after
23973 * doing unsorted insertions.
23976 * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data, or %NULL if no such item exists.
23982 * g_sequence_lookup_iter:
23983 * @seq: a #GSequence
23984 * @data: data to lookup
23985 * @iter_cmp: the function used to compare iterators in the sequence
23986 * @cmp_data: user data passed to @iter_cmp
23988 * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
23989 * instead of a #GCompareDataFunc as the compare function.
23991 * @iter_cmp is called with two iterators pointing into @seq.
23992 * It should return 0 if the iterators are equal, a negative value
23993 * if the first iterator comes before the second, and a positive
23994 * value if the second iterator comes before the first.
23997 * This function will fail if the data contained in the sequence is
23998 * unsorted. Use g_sequence_insert_sorted() or
23999 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24000 * you want to add a large amount of data, call g_sequence_sort() after
24001 * doing unsorted insertions.
24004 * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data, or %NULL if no such item exists.
24011 * @src: a #GSequenceIter pointing to the item to move
24012 * @dest: a #GSequenceIter pointing to the position to which the item is moved.
24014 * Moves the item pointed to by @src to the position indicated by @dest.
24015 * After calling this function @dest will point to the position immediately
24016 * after @src. It is allowed for @src and @dest to point into different
24024 * g_sequence_move_range:
24025 * @dest: a #GSequenceIter
24026 * @begin: a #GSequenceIter
24027 * @end: a #GSequenceIter
24029 * Inserts the (@begin, @end) range at the destination pointed to by ptr.
24030 * The @begin and @end iters must point into the same sequence. It is
24031 * allowed for @dest to point to a different sequence than the one pointed
24032 * into by @begin and @end.
24034 * If @dest is NULL, the range indicated by @begin and @end is
24035 * removed from the sequence. If @dest iter points to a place within
24036 * the (@begin, @end) range, the range does not move.
24044 * @data_destroy: (allow-none): a #GDestroyNotify function, or %NULL
24046 * Creates a new GSequence. The @data_destroy function, if non-%NULL will
24047 * be called on all items when the sequence is destroyed and on items that
24048 * are removed from the sequence.
24050 * Returns: a new #GSequence
24056 * g_sequence_prepend:
24057 * @seq: a #GSequence
24058 * @data: the data for the new item
24060 * Adds a new item to the front of @seq
24062 * Returns: an iterator pointing to the new item
24068 * g_sequence_range_get_midpoint:
24069 * @begin: a #GSequenceIter
24070 * @end: a #GSequenceIter
24072 * Finds an iterator somewhere in the range (@begin, @end). This
24073 * iterator will be close to the middle of the range, but is not
24074 * guaranteed to be <emphasis>exactly</emphasis> in the middle.
24076 * The @begin and @end iterators must both point to the same sequence and
24077 * @begin must come before or be equal to @end in the sequence.
24079 * Returns: A #GSequenceIter pointing somewhere in the (@begin, @end) range.
24085 * g_sequence_remove:
24086 * @iter: a #GSequenceIter
24088 * Removes the item pointed to by @iter. It is an error to pass the
24089 * end iterator to this function.
24091 * If the sequence has a data destroy function associated with it, this
24092 * function is called on the data for the removed item.
24099 * g_sequence_remove_range:
24100 * @begin: a #GSequenceIter
24101 * @end: a #GSequenceIter
24103 * Removes all items in the (@begin, @end) range.
24105 * If the sequence has a data destroy function associated with it, this
24106 * function is called on the data for the removed items.
24113 * g_sequence_search:
24114 * @seq: a #GSequence
24115 * @data: data for the new item
24116 * @cmp_func: the function used to compare items in the sequence
24117 * @cmp_data: user data passed to @cmp_func.
24119 * Returns an iterator pointing to the position where @data would
24120 * be inserted according to @cmp_func and @cmp_data.
24122 * @cmp_func is called with two items of the @seq and @user_data.
24123 * It should return 0 if the items are equal, a negative value if
24124 * the first item comes before the second, and a positive value if
24125 * the second item comes before the first.
24127 * If you are simply searching for an existing element of the sequence,
24128 * consider using g_sequence_lookup().
24131 * This function will fail if the data contained in the sequence is
24132 * unsorted. Use g_sequence_insert_sorted() or
24133 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24134 * you want to add a large amount of data, call g_sequence_sort() after
24135 * doing unsorted insertions.
24138 * Returns: an #GSequenceIter pointing to the position where @data would have been inserted according to @cmp_func and @cmp_data.
24144 * g_sequence_search_iter:
24145 * @seq: a #GSequence
24146 * @data: data for the new item
24147 * @iter_cmp: the function used to compare iterators in the sequence
24148 * @cmp_data: user data passed to @iter_cmp
24150 * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
24151 * instead of a #GCompareDataFunc as the compare function.
24153 * @iter_cmp is called with two iterators pointing into @seq.
24154 * It should return 0 if the iterators are equal, a negative value
24155 * if the first iterator comes before the second, and a positive
24156 * value if the second iterator comes before the first.
24158 * If you are simply searching for an existing element of the sequence,
24159 * consider using g_sequence_lookup_iter().
24162 * This function will fail if the data contained in the sequence is
24163 * unsorted. Use g_sequence_insert_sorted() or
24164 * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24165 * you want to add a large amount of data, call g_sequence_sort() after
24166 * doing unsorted insertions.
24169 * Returns: a #GSequenceIter pointing to the position in @seq where @data would have been inserted according to @iter_cmp and @cmp_data.
24176 * @iter: a #GSequenceIter
24177 * @data: new data for the item
24179 * Changes the data for the item pointed to by @iter to be @data. If
24180 * the sequence has a data destroy function associated with it, that
24181 * function is called on the existing data that @iter pointed to.
24189 * @seq: a #GSequence
24190 * @cmp_func: the function used to sort the sequence
24191 * @cmp_data: user data passed to @cmp_func
24193 * Sorts @seq using @cmp_func.
24195 * @cmp_func is passed two items of @seq and should
24196 * return 0 if they are equal, a negative value if the
24197 * first comes before the second, and a positive value
24198 * if the second comes before the first.
24205 * g_sequence_sort_changed:
24206 * @iter: A #GSequenceIter
24207 * @cmp_func: the function used to compare items in the sequence
24208 * @cmp_data: user data passed to @cmp_func.
24210 * Moves the data pointed to a new position as indicated by @cmp_func. This
24211 * function should be called for items in a sequence already sorted according
24212 * to @cmp_func whenever some aspect of an item changes so that @cmp_func
24213 * may return different values for that item.
24215 * @cmp_func is called with two items of the @seq and @user_data.
24216 * It should return 0 if the items are equal, a negative value if
24217 * the first item comes before the second, and a positive value if
24218 * the second item comes before the first.
24225 * g_sequence_sort_changed_iter:
24226 * @iter: a #GSequenceIter
24227 * @iter_cmp: the function used to compare iterators in the sequence
24228 * @cmp_data: user data passed to @cmp_func
24230 * Like g_sequence_sort_changed(), but uses
24231 * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
24232 * the compare function.
24234 * @iter_cmp is called with two iterators pointing into @seq. It should
24235 * return 0 if the iterators are equal, a negative value if the first
24236 * iterator comes before the second, and a positive value if the second
24237 * iterator comes before the first.
24244 * g_sequence_sort_iter:
24245 * @seq: a #GSequence
24246 * @cmp_func: the function used to compare iterators in the sequence
24247 * @cmp_data: user data passed to @cmp_func
24249 * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
24250 * of a GCompareDataFunc as the compare function
24252 * @cmp_func is called with two iterators pointing into @seq. It should
24253 * return 0 if the iterators are equal, a negative value if the first
24254 * iterator comes before the second, and a positive value if the second
24255 * iterator comes before the first.
24263 * @a: a #GSequenceIter
24264 * @b: a #GSequenceIter
24266 * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
24267 * to point into difference sequences.
24274 * g_set_application_name:
24275 * @application_name: localized name of the application
24277 * Sets a human-readable name for the application. This name should be
24278 * localized if possible, and is intended for display to the user.
24279 * Contrast with g_set_prgname(), which sets a non-localized name.
24280 * g_set_prgname() will be called automatically by gtk_init(),
24281 * but g_set_application_name() will not.
24283 * Note that for thread safety reasons, this function can only
24286 * The application name will be used in contexts such as error messages,
24287 * or when displaying an application's name in the task list.
24295 * @err: (allow-none): a return location for a #GError, or %NULL
24296 * @domain: error domain
24297 * @code: error code
24298 * @format: printf()-style format
24299 * @...: args for @format
24301 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24302 * must be %NULL. A new #GError is created and assigned to *@err.
24307 * g_set_error_literal:
24308 * @err: (allow-none): a return location for a #GError, or %NULL
24309 * @domain: error domain
24310 * @code: error code
24311 * @message: error message
24313 * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24314 * must be %NULL. A new #GError is created and assigned to *@err.
24315 * Unlike g_set_error(), @message is not a printf()-style format string.
24316 * Use this function if @message contains text you don't have control over,
24317 * that could include printf() escape sequences.
24325 * @prgname: the name of the program.
24327 * Sets the name of the program. This name should <emphasis>not</emphasis>
24328 * be localized, contrast with g_set_application_name(). Note that for
24329 * thread-safety reasons this function can only be called once.
24334 * g_set_print_handler:
24335 * @func: the new print handler
24337 * Sets the print handler.
24339 * Any messages passed to g_print() will be output via
24340 * the new handler. The default handler simply outputs
24341 * the message to stdout. By providing your own handler
24342 * you can redirect the output, to a GTK+ widget or a
24343 * log file for example.
24345 * Returns: the old print handler
24350 * g_set_printerr_handler:
24351 * @func: the new error message handler
24353 * Sets the handler for printing error messages.
24355 * Any messages passed to g_printerr() will be output via
24356 * the new handler. The default handler simply outputs the
24357 * message to stderr. By providing your own handler you can
24358 * redirect the output, to a GTK+ widget or a log file for
24361 * Returns: the old error message handler
24367 * @variable: the environment variable to set, must not contain '='.
24368 * @value: the value for to set the variable to.
24369 * @overwrite: whether to change the variable if it already exists.
24371 * Sets an environment variable. Both the variable's name and value
24372 * should be in the GLib file name encoding. On UNIX, this means that
24373 * they can be arbitrary byte strings. On Windows, they should be in
24376 * Note that on some systems, when variables are overwritten, the memory
24377 * used for the previous variables and its value isn't reclaimed.
24380 * Environment variable handling in UNIX is not thread-safe, and your
24381 * program may crash if one thread calls g_setenv() while another
24382 * thread is calling getenv(). (And note that many functions, such as
24383 * gettext(), call getenv() internally.) This function is only safe to
24384 * use at the very start of your program, before creating any other
24385 * threads (or creating objects that create worker threads of their
24388 * If you need to set up the environment for a child process, you can
24389 * use g_get_environ() to get an environment array, modify that with
24390 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
24391 * array directly to execvpe(), g_spawn_async(), or the like.
24392 * </para></warning>
24394 * Returns: %FALSE if the environment variable couldn't be set.
24400 * g_shell_parse_argv:
24401 * @command_line: command line to parse
24402 * @argcp: (out): return location for number of args
24403 * @argvp: (out) (array length=argcp zero-terminated=1): return location for array of args
24404 * @error: return location for error
24406 * Parses a command line into an argument vector, in much the same way
24407 * the shell would, but without many of the expansions the shell would
24408 * perform (variable expansion, globs, operators, filename expansion,
24409 * etc. are not supported). The results are defined to be the same as
24410 * those you would get from a UNIX98 /bin/sh, as long as the input
24411 * contains none of the unsupported shell expansions. If the input
24412 * does contain such expansions, they are passed through
24413 * literally. Possible errors are those from the #G_SHELL_ERROR
24414 * domain. Free the returned vector with g_strfreev().
24416 * Returns: %TRUE on success, %FALSE if error set
24422 * @unquoted_string: a literal string
24424 * Quotes a string so that the shell (/bin/sh) will interpret the
24425 * quoted string to mean @unquoted_string. If you pass a filename to
24426 * the shell, for example, you should first quote it with this
24427 * function. The return value must be freed with g_free(). The
24428 * quoting style used is undefined (single or double quotes may be
24431 * Returns: quoted string
24437 * @quoted_string: shell-quoted string
24438 * @error: error return location or NULL
24440 * Unquotes a string as the shell (/bin/sh) would. Only handles
24441 * quotes; if a string contains file globs, arithmetic operators,
24442 * variables, backticks, redirections, or other special-to-the-shell
24443 * features, the result will be different from the result a real shell
24444 * would produce (the variables, backticks, etc. will be passed
24445 * through literally instead of being expanded). This function is
24446 * guaranteed to succeed if applied to the result of
24447 * g_shell_quote(). If it fails, it returns %NULL and sets the
24448 * error. The @quoted_string need not actually contain quoted or
24449 * escaped text; g_shell_unquote() simply goes through the string and
24450 * unquotes/unescapes anything that the shell would. Both single and
24451 * double quotes are handled, as are escapes including escaped
24452 * newlines. The return value must be freed with g_free(). Possible
24453 * errors are in the #G_SHELL_ERROR domain.
24455 * Shell quoting rules are a bit strange. Single quotes preserve the
24456 * literal string exactly. escape sequences are not allowed; not even
24457 * \' - if you want a ' in the quoted text, you have to do something
24458 * like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
24459 * be escaped with backslash. Otherwise double quotes preserve things
24462 * Returns: an unquoted string
24468 * @block_size: the number of bytes to allocate
24470 * Allocates a block of memory from the slice allocator.
24471 * The block adress handed out can be expected to be aligned
24472 * to at least <literal>1 * sizeof (void*)</literal>,
24473 * though in general slices are 2 * sizeof (void*) bytes aligned,
24474 * if a malloc() fallback implementation is used instead,
24475 * the alignment may be reduced in a libc dependent fashion.
24476 * Note that the underlying slice allocation mechanism can
24477 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24478 * environment variable.
24480 * Returns: a pointer to the allocated memory block
24487 * @block_size: the number of bytes to allocate
24489 * Allocates a block of memory via g_slice_alloc() and initializes
24490 * the returned memory to 0. Note that the underlying slice allocation
24491 * mechanism can be changed with the
24492 * <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24493 * environment variable.
24495 * Returns: a pointer to the allocated block
24502 * @block_size: the number of bytes to allocate
24503 * @mem_block: the memory to copy
24505 * Allocates a block of memory from the slice allocator
24506 * and copies @block_size bytes into it from @mem_block.
24508 * Returns: a pointer to the allocated memory block
24515 * @type: the type to duplicate, typically a structure name
24516 * @mem: the memory to copy into the allocated block
24518 * A convenience macro to duplicate a block of memory using
24519 * the slice allocator.
24521 * It calls g_slice_copy() with <literal>sizeof (@type)</literal>
24522 * and casts the returned pointer to a pointer of the given type,
24523 * avoiding a type cast in the source code.
24524 * Note that the underlying slice allocation mechanism can
24525 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24526 * environment variable.
24528 * Returns: a pointer to the allocated block, cast to a pointer to @type
24535 * @type: the type of the block to free, typically a structure name
24536 * @mem: a pointer to the block to free
24538 * A convenience macro to free a block of memory that has
24539 * been allocated from the slice allocator.
24541 * It calls g_slice_free1() using <literal>sizeof (type)</literal>
24542 * as the block size.
24543 * Note that the exact release behaviour can be changed with the
24544 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24545 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24546 * related debugging options.
24554 * @block_size: the size of the block
24555 * @mem_block: a pointer to the block to free
24557 * Frees a block of memory.
24559 * The memory must have been allocated via g_slice_alloc() or
24560 * g_slice_alloc0() and the @block_size has to match the size
24561 * specified upon allocation. Note that the exact release behaviour
24562 * can be changed with the
24563 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24564 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24565 * related debugging options.
24572 * g_slice_free_chain:
24573 * @type: the type of the @mem_chain blocks
24574 * @mem_chain: a pointer to the first block of the chain
24575 * @next: the field name of the next pointer in @type
24577 * Frees a linked list of memory blocks of structure type @type.
24578 * The memory blocks must be equal-sized, allocated via
24579 * g_slice_alloc() or g_slice_alloc0() and linked together by
24580 * a @next pointer (similar to #GSList). The name of the
24581 * @next field in @type is passed as third argument.
24582 * Note that the exact release behaviour can be changed with the
24583 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24584 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24585 * related debugging options.
24592 * g_slice_free_chain_with_offset:
24593 * @block_size: the size of the blocks
24594 * @mem_chain: a pointer to the first block of the chain
24595 * @next_offset: the offset of the @next field in the blocks
24597 * Frees a linked list of memory blocks of structure type @type.
24599 * The memory blocks must be equal-sized, allocated via
24600 * g_slice_alloc() or g_slice_alloc0() and linked together by a
24601 * @next pointer (similar to #GSList). The offset of the @next
24602 * field in each block is passed as third argument.
24603 * Note that the exact release behaviour can be changed with the
24604 * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24605 * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24606 * related debugging options.
24614 * @type: the type to allocate, typically a structure name
24616 * A convenience macro to allocate a block of memory from the
24619 * It calls g_slice_alloc() with <literal>sizeof (@type)</literal>
24620 * and casts the returned pointer to a pointer of the given type,
24621 * avoiding a type cast in the source code.
24622 * Note that the underlying slice allocation mechanism can
24623 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24624 * environment variable.
24626 * Returns: a pointer to the allocated block, cast to a pointer to @type
24633 * @type: the type to allocate, typically a structure name
24635 * A convenience macro to allocate a block of memory from the
24636 * slice allocator and set the memory to 0.
24638 * It calls g_slice_alloc0() with <literal>sizeof (@type)</literal>
24639 * and casts the returned pointer to a pointer of the given type,
24640 * avoiding a type cast in the source code.
24641 * Note that the underlying slice allocation mechanism can
24642 * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24643 * environment variable.
24652 * Allocates space for one #GSList element. It is called by the
24653 * g_slist_append(), g_slist_prepend(), g_slist_insert() and
24654 * g_slist_insert_sorted() functions and so is rarely used on its own.
24656 * Returns: a pointer to the newly-allocated #GSList element.
24663 * @data: the data for the new element
24665 * Adds a new element on to the end of the list.
24668 * The return value is the new start of the list, which may
24669 * have changed, so make sure you store the new value.
24673 * Note that g_slist_append() has to traverse the entire list
24674 * to find the end, which is inefficient when adding multiple
24675 * elements. A common idiom to avoid the inefficiency is to prepend
24676 * the elements and reverse the list when all elements have been added.
24680 * /* Notice that these are initialized to the empty list. */
24681 * GSList *list = NULL, *number_list = NULL;
24683 * /* This is a list of strings. */
24684 * list = g_slist_append (list, "first");
24685 * list = g_slist_append (list, "second");
24687 * /* This is a list of integers. */
24688 * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
24689 * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
24692 * Returns: the new start of the #GSList
24698 * @list1: a #GSList
24699 * @list2: the #GSList to add to the end of the first #GSList
24701 * Adds the second #GSList onto the end of the first #GSList.
24702 * Note that the elements of the second #GSList are not copied.
24703 * They are used directly.
24705 * Returns: the start of the new #GSList
24713 * Copies a #GSList.
24716 * Note that this is a "shallow" copy. If the list elements
24717 * consist of pointers to data, the pointers are copied but
24718 * the actual data isn't. See g_slist_copy_deep() if you need
24719 * to copy the data as well.
24722 * Returns: a copy of @list
24727 * g_slist_copy_deep:
24729 * @func: a copy function used to copy every element in the list
24730 * @user_data: user data passed to the copy function @func, or #NULL
24732 * Makes a full (deep) copy of a #GSList.
24734 * In contrast with g_slist_copy(), this function uses @func to make a copy of
24735 * each list element, in addition to copying the list container itself.
24737 * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
24738 * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
24741 * For instance, if @list holds a list of GObjects, you can do:
24743 * another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
24746 * And, to entirely free the new list, you could do:
24748 * g_slist_free_full (another_list, g_object_unref);
24751 * Returns: a full copy of @list, use #g_slist_free_full to free it
24757 * g_slist_delete_link:
24759 * @link_: node to delete
24761 * Removes the node link_ from the list and frees it.
24762 * Compare this to g_slist_remove_link() which removes the node
24763 * without freeing it.
24765 * <note>Removing arbitrary nodes from a singly-linked list
24766 * requires time that is proportional to the length of the list
24767 * (ie. O(n)). If you find yourself using g_slist_delete_link()
24768 * frequently, you should consider a different data structure, such
24769 * as the doubly-linked #GList.</note>
24771 * Returns: the new head of @list
24778 * @data: the element data to find
24780 * Finds the element in a #GSList which
24781 * contains the given data.
24783 * Returns: the found #GSList element, or %NULL if it is not found
24788 * g_slist_find_custom:
24790 * @data: user data passed to the function
24791 * @func: the function to call for each element. It should return 0 when the desired element is found
24793 * Finds an element in a #GSList, using a supplied function to
24794 * find the desired element. It iterates over the list, calling
24795 * the given function which should return 0 when the desired
24796 * element is found. The function takes two #gconstpointer arguments,
24797 * the #GSList element's data as the first argument and the
24800 * Returns: the found #GSList element, or %NULL if it is not found
24807 * @func: the function to call with each element's data
24808 * @user_data: user data to pass to the function
24810 * Calls a function for each element of a #GSList.
24818 * Frees all of the memory used by a #GSList.
24819 * The freed elements are returned to the slice allocator.
24822 * If list elements contain dynamically-allocated memory,
24823 * you should either use g_slist_free_full() or free them manually
24832 * A macro which does the same as g_slist_free_1().
24840 * @list: a #GSList element
24842 * Frees one #GSList element.
24843 * It is usually used after g_slist_remove_link().
24848 * g_slist_free_full:
24849 * @list: a pointer to a #GSList
24850 * @free_func: the function to be called to free each element's data
24852 * Convenience method, which frees all the memory used by a #GSList, and
24853 * calls the specified destroy function on every element's data.
24862 * @data: the data to find
24864 * Gets the position of the element containing
24865 * the given data (starting from 0).
24867 * Returns: the index of the element containing the data, or -1 if the data is not found
24874 * @data: the data for the new element
24875 * @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.
24877 * Inserts a new element into the list at the given position.
24879 * Returns: the new start of the #GSList
24884 * g_slist_insert_before:
24885 * @slist: a #GSList
24886 * @sibling: node to insert @data before
24887 * @data: data to put in the newly-inserted node
24889 * Inserts a node before @sibling containing @data.
24891 * Returns: the new head of the list.
24896 * g_slist_insert_sorted:
24898 * @data: the data for the new element
24899 * @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.
24901 * Inserts a new element into the list, using the given
24902 * comparison function to determine its position.
24904 * Returns: the new start of the #GSList
24909 * g_slist_insert_sorted_with_data:
24911 * @data: the data for the new element
24912 * @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.
24913 * @user_data: data to pass to comparison function
24915 * Inserts a new element into the list, using the given
24916 * comparison function to determine its position.
24918 * Returns: the new start of the #GSList
24927 * Gets the last element in a #GSList.
24930 * This function iterates over the whole list.
24933 * Returns: the last element in the #GSList, or %NULL if the #GSList has no elements
24941 * Gets the number of elements in a #GSList.
24944 * This function iterates over the whole list to
24945 * count its elements.
24948 * Returns: the number of elements in the #GSList
24954 * @slist: an element in a #GSList.
24956 * A convenience macro to get the next element in a #GSList.
24958 * Returns: the next element, or %NULL if there are no more elements.
24965 * @n: the position of the element, counting from 0
24967 * Gets the element at the given position in a #GSList.
24969 * Returns: the element, or %NULL if the position is off the end of the #GSList
24974 * g_slist_nth_data:
24976 * @n: the position of the element
24978 * Gets the data of the element at the given position.
24980 * Returns: the element's data, or %NULL if the position is off the end of the #GSList
24985 * g_slist_position:
24987 * @llink: an element in the #GSList
24989 * Gets the position of the given element
24990 * in the #GSList (starting from 0).
24992 * Returns: the position of the element in the #GSList, or -1 if the element is not found
24999 * @data: the data for the new element
25001 * Adds a new element on to the start of the list.
25004 * The return value is the new start of the list, which
25005 * may have changed, so make sure you store the new value.
25009 * /* Notice that it is initialized to the empty list. */
25010 * GSList *list = NULL;
25011 * list = g_slist_prepend (list, "last");
25012 * list = g_slist_prepend (list, "first");
25015 * Returns: the new start of the #GSList
25022 * @data: the data of the element to remove
25024 * Removes an element from a #GSList.
25025 * If two elements contain the same data, only the first is removed.
25026 * If none of the elements contain the data, the #GSList is unchanged.
25028 * Returns: the new start of the #GSList
25033 * g_slist_remove_all:
25035 * @data: data to remove
25037 * Removes all list nodes with data equal to @data.
25038 * Returns the new head of the list. Contrast with
25039 * g_slist_remove() which removes only the first node
25040 * matching the given data.
25042 * Returns: new head of @list
25047 * g_slist_remove_link:
25049 * @link_: an element in the #GSList
25051 * Removes an element from a #GSList, without
25052 * freeing the element. The removed element's next
25053 * link is set to %NULL, so that it becomes a
25054 * self-contained list with one element.
25056 * <note>Removing arbitrary nodes from a singly-linked list
25057 * requires time that is proportional to the length of the list
25058 * (ie. O(n)). If you find yourself using g_slist_remove_link()
25059 * frequently, you should consider a different data structure, such
25060 * as the doubly-linked #GList.</note>
25062 * Returns: the new start of the #GSList, without the element
25070 * Reverses a #GSList.
25072 * Returns: the start of the reversed #GSList
25079 * @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.
25081 * Sorts a #GSList using the given comparison function.
25083 * Returns: the start of the sorted #GSList
25088 * g_slist_sort_with_data:
25090 * @compare_func: comparison function
25091 * @user_data: data to pass to comparison function
25093 * Like g_slist_sort(), but the sort function accepts a user data argument.
25095 * Returns: new head of the list
25101 * @string: the buffer to hold the output.
25102 * @n: the maximum number of bytes to produce (including the terminating nul character).
25103 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
25104 * @...: the arguments to insert in the output.
25106 * A safer form of the standard sprintf() function. The output is guaranteed
25107 * to not exceed @n characters (including the terminating nul character), so
25108 * it is easy to ensure that a buffer overflow cannot occur.
25110 * See also g_strdup_printf().
25112 * In versions of GLib prior to 1.2.3, this function may return -1 if the
25113 * output was truncated, and the truncated string may not be nul-terminated.
25114 * In versions prior to 1.3.12, this function returns the length of the output
25117 * The return value of g_snprintf() conforms to the snprintf()
25118 * function as standardized in ISO C99. Note that this is different from
25119 * traditional snprintf(), which returns the length of the output string.
25121 * The format string may contain positional parameters, as specified in
25122 * the Single Unix Specification.
25124 * Returns: the number of bytes which would be produced if the buffer was large enough.
25129 * g_source_add_child_source:
25130 * @source: a #GSource
25131 * @child_source: a second #GSource that @source should "poll"
25133 * Adds @child_source to @source as a "polled" source; when @source is
25134 * added to a #GMainContext, @child_source will be automatically added
25135 * with the same priority, when @child_source is triggered, it will
25136 * cause @source to dispatch (in addition to calling its own
25137 * callback), and when @source is destroyed, it will destroy
25138 * @child_source as well. (@source will also still be dispatched if
25139 * its own prepare/check functions indicate that it is ready.)
25141 * If you don't need @child_source to do anything on its own when it
25142 * triggers, you can call g_source_set_dummy_callback() on it to set a
25143 * callback that does nothing (except return %TRUE if appropriate).
25145 * @source will hold a reference on @child_source while @child_source
25146 * is attached to it.
25153 * g_source_add_poll:
25154 * @source: a #GSource
25155 * @fd: a #GPollFD structure holding information about a file descriptor to watch.
25157 * Adds a file descriptor to the set of file descriptors polled for
25158 * this source. This is usually combined with g_source_new() to add an
25159 * event source. The event source's check function will typically test
25160 * the @revents field in the #GPollFD struct and return %TRUE if events need
25163 * Using this API forces the linear scanning of event sources on each
25164 * main loop iteration. Newly-written event sources should try to use
25165 * g_source_add_unix_fd() instead of this API.
25170 * g_source_add_unix_fd:
25171 * @source: a #GSource
25172 * @fd: the fd to monitor
25173 * @events: an event mask
25175 * Monitors @fd for the IO events in @events.
25177 * The tag returned by this function can be used to remove or modify the
25178 * monitoring of the fd using g_source_remove_unix_fd() or
25179 * g_source_modify_unix_fd().
25181 * It is not necessary to remove the fd before destroying the source; it
25182 * will be cleaned up automatically.
25184 * As the name suggests, this function is not available on Windows.
25186 * Returns: an opaque tag
25193 * @source: a #GSource
25194 * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
25196 * Adds a #GSource to a @context so that it will be executed within
25197 * that context. Remove it by calling g_source_destroy().
25199 * Returns: the ID (greater than 0) for the source within the #GMainContext.
25204 * g_source_destroy:
25205 * @source: a #GSource
25207 * Removes a source from its #GMainContext, if any, and mark it as
25208 * destroyed. The source cannot be subsequently added to another
25214 * g_source_get_can_recurse:
25215 * @source: a #GSource
25217 * Checks whether a source is allowed to be called recursively.
25218 * see g_source_set_can_recurse().
25220 * Returns: whether recursion is allowed.
25225 * g_source_get_context:
25226 * @source: a #GSource
25228 * Gets the #GMainContext with which the source is associated.
25230 * You can call this on a source that has been destroyed, provided
25231 * that the #GMainContext it was attached to still exists (in which
25232 * case it will return that #GMainContext). In particular, you can
25233 * always call this function on the source returned from
25234 * g_main_current_source(). But calling this function on a source
25235 * whose #GMainContext has been destroyed is an error.
25237 * 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.
25242 * g_source_get_current_time:
25243 * @source: a #GSource
25244 * @timeval: #GTimeVal structure in which to store current time.
25246 * This function ignores @source and is otherwise the same as
25247 * g_get_current_time().
25249 * Deprecated: 2.28: use g_source_get_time() instead
25255 * @source: a #GSource
25257 * Returns the numeric ID for a particular source. The ID of a source
25258 * is a positive integer which is unique within a particular main loop
25259 * context. The reverse
25260 * mapping from ID to source is done by g_main_context_find_source_by_id().
25262 * Returns: the ID (greater than 0) for the source
25267 * g_source_get_name:
25268 * @source: a #GSource
25270 * Gets a name for the source, used in debugging and profiling.
25271 * The name may be #NULL if it has never been set with
25272 * g_source_set_name().
25274 * Returns: the name of the source
25280 * g_source_get_priority:
25281 * @source: a #GSource
25283 * Gets the priority of a source.
25285 * Returns: the priority of the source
25290 * g_source_get_ready_time:
25291 * @source: a #GSource
25293 * Gets the "ready time" of @source, as set by
25294 * g_source_set_ready_time().
25296 * Any time before the current monotonic time (including 0) is an
25297 * indication that the source will fire immediately.
25299 * Returns: the monotonic ready time, -1 for "never"
25304 * g_source_get_time:
25305 * @source: a #GSource
25307 * Gets the time to be used when checking this source. The advantage of
25308 * calling this function over calling g_get_monotonic_time() directly is
25309 * that when checking multiple sources, GLib can cache a single value
25310 * instead of having to repeatedly get the system monotonic time.
25312 * The time here is the system monotonic time, if available, or some
25313 * other reasonable alternative otherwise. See g_get_monotonic_time().
25315 * Returns: the monotonic time in microseconds
25321 * g_source_is_destroyed:
25322 * @source: a #GSource
25324 * Returns whether @source has been destroyed.
25326 * This is important when you operate upon your objects
25327 * from within idle handlers, but may have freed the object
25328 * before the dispatch of your idle handler.
25332 * idle_callback (gpointer data)
25334 * SomeWidget *self = data;
25336 * GDK_THREADS_ENTER (<!-- -->);
25337 * /<!-- -->* do stuff with self *<!-- -->/
25338 * self->idle_id = 0;
25339 * GDK_THREADS_LEAVE (<!-- -->);
25341 * return G_SOURCE_REMOVE;
25345 * some_widget_do_stuff_later (SomeWidget *self)
25347 * self->idle_id = g_idle_add (idle_callback, self);
25351 * some_widget_finalize (GObject *object)
25353 * SomeWidget *self = SOME_WIDGET (object);
25355 * if (self->idle_id)
25356 * g_source_remove (self->idle_id);
25358 * G_OBJECT_CLASS (parent_class)->finalize (object);
25362 * This will fail in a multi-threaded application if the
25363 * widget is destroyed before the idle handler fires due
25364 * to the use after free in the callback. A solution, to
25365 * this particular problem, is to check to if the source
25366 * has already been destroy within the callback.
25370 * idle_callback (gpointer data)
25372 * SomeWidget *self = data;
25374 * GDK_THREADS_ENTER ();
25375 * if (!g_source_is_destroyed (g_main_current_source ()))
25377 * /<!-- -->* do stuff with self *<!-- -->/
25379 * GDK_THREADS_LEAVE ();
25385 * Returns: %TRUE if the source has been destroyed
25391 * g_source_modify_unix_fd:
25392 * @source: a #GSource
25393 * @tag: the tag from g_source_add_unix_fd()
25394 * @new_events: the new event mask to watch
25396 * Updates the event mask to watch for the fd identified by @tag.
25398 * @tag is the tag returned from g_source_add_unix_fd().
25400 * If you want to remove a fd, don't set its event mask to zero.
25401 * Instead, call g_source_remove_unix_fd().
25403 * As the name suggests, this function is not available on Windows.
25411 * @source_funcs: structure containing functions that implement the sources behavior.
25412 * @struct_size: size of the #GSource structure to create.
25414 * Creates a new #GSource structure. The size is specified to
25415 * allow creating structures derived from #GSource that contain
25416 * additional data. The size passed in must be at least
25417 * <literal>sizeof (GSource)</literal>.
25419 * The source will not initially be associated with any #GMainContext
25420 * and must be added to one with g_source_attach() before it will be
25423 * Returns: the newly-created #GSource.
25428 * g_source_query_unix_fd:
25429 * @source: a #GSource
25430 * @tag: the tag from g_source_add_unix_fd()
25432 * Queries the events reported for the fd corresponding to @tag on
25433 * @source during the last poll.
25435 * The return value of this function is only defined when the function
25436 * is called from the check or dispatch functions for @source.
25438 * As the name suggests, this function is not available on Windows.
25440 * Returns: the conditions reported on the fd
25447 * @source: a #GSource
25449 * Increases the reference count on a source by one.
25457 * @tag: the ID of the source to remove.
25459 * Removes the source with the given id from the default main context.
25461 * a #GSource is given by g_source_get_id(), or will be returned by the
25462 * functions g_source_attach(), g_idle_add(), g_idle_add_full(),
25463 * g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
25464 * g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
25466 * See also g_source_destroy(). You must use g_source_destroy() for sources
25467 * added to a non-default main context.
25469 * Returns: %TRUE if the source was found and removed.
25474 * g_source_remove_by_funcs_user_data:
25475 * @funcs: The @source_funcs passed to g_source_new()
25476 * @user_data: the user data for the callback
25478 * Removes a source from the default main loop context given the
25479 * source functions and user data. If multiple sources exist with the
25480 * same source functions and user data, only one will be destroyed.
25482 * Returns: %TRUE if a source was found and removed.
25487 * g_source_remove_by_user_data:
25488 * @user_data: the user_data for the callback.
25490 * Removes a source from the default main loop context given the user
25491 * data for the callback. If multiple sources exist with the same user
25492 * data, only one will be destroyed.
25494 * Returns: %TRUE if a source was found and removed.
25499 * g_source_remove_child_source:
25500 * @source: a #GSource
25501 * @child_source: a #GSource previously passed to g_source_add_child_source().
25503 * Detaches @child_source from @source and destroys it.
25510 * g_source_remove_poll:
25511 * @source: a #GSource
25512 * @fd: a #GPollFD structure previously passed to g_source_add_poll().
25514 * Removes a file descriptor from the set of file descriptors polled for
25520 * g_source_remove_unix_fd:
25521 * @source: a #GSource
25522 * @tag: the tag from g_source_add_unix_fd()
25524 * Reverses the effect of a previous call to g_source_add_unix_fd().
25526 * You only need to call this if you want to remove an fd from being
25527 * watched while keeping the same source around. In the normal case you
25528 * will just want to destroy the source.
25530 * As the name suggests, this function is not available on Windows.
25537 * g_source_set_callback:
25538 * @source: the source
25539 * @func: a callback function
25540 * @data: the data to pass to callback function
25541 * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
25543 * Sets the callback function for a source. The callback for a source is
25544 * called from the source's dispatch function.
25546 * The exact type of @func depends on the type of source; ie. you
25547 * should not count on @func being called with @data as its first
25550 * Typically, you won't use this function. Instead use functions specific
25551 * to the type of source you are using.
25556 * g_source_set_callback_indirect:
25557 * @source: the source
25558 * @callback_data: pointer to callback data "object"
25559 * @callback_funcs: functions for reference counting @callback_data and getting the callback and data
25561 * Sets the callback function storing the data as a refcounted callback
25562 * "object". This is used internally. Note that calling
25563 * g_source_set_callback_indirect() assumes
25564 * an initial reference count on @callback_data, and thus
25565 * @callback_funcs->unref will eventually be called once more
25566 * than @callback_funcs->ref.
25571 * g_source_set_can_recurse:
25572 * @source: a #GSource
25573 * @can_recurse: whether recursion is allowed for this source
25575 * Sets whether a source can be called recursively. If @can_recurse is
25576 * %TRUE, then while the source is being dispatched then this source
25577 * will be processed normally. Otherwise, all processing of this
25578 * source is blocked until the dispatch function returns.
25583 * g_source_set_funcs:
25584 * @source: a #GSource
25585 * @funcs: the new #GSourceFuncs
25587 * Sets the source functions (can be used to override
25588 * default implementations) of an unattached source.
25595 * g_source_set_name:
25596 * @source: a #GSource
25597 * @name: debug name for the source
25599 * Sets a name for the source, used in debugging and profiling.
25600 * The name defaults to #NULL.
25602 * The source name should describe in a human-readable way
25603 * what the source does. For example, "X11 event queue"
25604 * or "GTK+ repaint idle handler" or whatever it is.
25606 * It is permitted to call this function multiple times, but is not
25607 * recommended due to the potential performance impact. For example,
25608 * one could change the name in the "check" function of a #GSourceFuncs
25609 * to include details like the event type in the source name.
25616 * g_source_set_name_by_id:
25617 * @tag: a #GSource ID
25618 * @name: debug name for the source
25620 * Sets the name of a source using its ID.
25622 * This is a convenience utility to set source names from the return
25623 * value of g_idle_add(), g_timeout_add(), etc.
25630 * g_source_set_priority:
25631 * @source: a #GSource
25632 * @priority: the new priority.
25634 * Sets the priority of a source. While the main loop is being run, a
25635 * source will be dispatched if it is ready to be dispatched and no
25636 * sources at a higher (numerically smaller) priority are ready to be
25642 * g_source_set_ready_time:
25643 * @source: a #GSource
25644 * @ready_time: the monotonic time at which the source will be ready, 0 for "immediately", -1 for "never"
25646 * Sets a #GSource to be dispatched when the given monotonic time is
25647 * reached (or passed). If the monotonic time is in the past (as it
25648 * always will be if @ready_time is 0) then the source will be
25649 * dispatched immediately.
25651 * If @ready_time is -1 then the source is never woken up on the basis
25652 * of the passage of time.
25654 * Dispatching the source does not reset the ready time. You should do
25655 * so yourself, from the source dispatch function.
25657 * Note that if you have a pair of sources where the ready time of one
25658 * suggests that it will be delivered first but the priority for the
25659 * other suggests that it would be delivered first, and the ready time
25660 * for both sources is reached during the same main context iteration
25661 * then the order of dispatch is undefined.
25669 * @source: a #GSource
25671 * Decreases the reference count of a source by one. If the
25672 * resulting reference count is zero the source and associated
25673 * memory will be destroyed.
25678 * g_spaced_primes_closest:
25681 * Gets the smallest prime number from a built-in array of primes which
25682 * is larger than @num. This is used within GLib to calculate the optimum
25683 * size of a #GHashTable.
25685 * The built-in array of primes ranges from 11 to 13845163 such that
25686 * each prime is approximately 1.5-2 times the previous prime.
25688 * Returns: the smallest prime number from a built-in array of primes which is larger than @num
25694 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
25695 * @argv: (array zero-terminated=1): child's argument vector
25696 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
25697 * @flags: flags from #GSpawnFlags
25698 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25699 * @user_data: (closure): user data for @child_setup
25700 * @child_pid: (out) (allow-none): return location for child process reference, or %NULL
25701 * @error: return location for error
25703 * See g_spawn_async_with_pipes() for a full description; this function
25704 * simply calls the g_spawn_async_with_pipes() without any pipes.
25706 * You should call g_spawn_close_pid() on the returned child process
25707 * reference when you don't need it any more.
25710 * If you are writing a GTK+ application, and the program you
25711 * are spawning is a graphical application, too, then you may
25712 * want to use gdk_spawn_on_screen() instead to ensure that
25713 * the spawned program opens its windows on the right screen.
25716 * <note><para> Note that the returned @child_pid on Windows is a
25717 * handle to the child process and not its identifier. Process handles
25718 * and process identifiers are different concepts on Windows.
25721 * Returns: %TRUE on success, %FALSE if error is set
25726 * g_spawn_async_with_pipes:
25727 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
25728 * @argv: (array zero-terminated=1): child's argument vector, in the GLib file name encoding
25729 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's, in the GLib file name encoding
25730 * @flags: flags from #GSpawnFlags
25731 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25732 * @user_data: (closure): user data for @child_setup
25733 * @child_pid: (out) (allow-none): return location for child process ID, or %NULL
25734 * @standard_input: (out) (allow-none): return location for file descriptor to write to child's stdin, or %NULL
25735 * @standard_output: (out) (allow-none): return location for file descriptor to read child's stdout, or %NULL
25736 * @standard_error: (out) (allow-none): return location for file descriptor to read child's stderr, or %NULL
25737 * @error: return location for error
25739 * Executes a child program asynchronously (your program will not
25740 * block waiting for the child to exit). The child program is
25741 * specified by the only argument that must be provided, @argv. @argv
25742 * should be a %NULL-terminated array of strings, to be passed as the
25743 * argument vector for the child. The first string in @argv is of
25744 * course the name of the program to execute. By default, the name of
25745 * the program must be a full path. If @flags contains the
25746 * %G_SPAWN_SEARCH_PATH flag, the <envar>PATH</envar> environment variable
25747 * is used to search for the executable. If @flags contains the
25748 * %G_SPAWN_SEARCH_PATH_FROM_ENVP flag, the <envar>PATH</envar> variable from
25749 * @envp is used to search for the executable.
25750 * If both the %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP
25751 * flags are set, the <envar>PATH</envar> variable from @envp takes precedence
25752 * over the environment variable.
25754 * If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
25755 * used, then the program will be run from the current directory (or
25756 * @working_directory, if specified); this might be unexpected or even
25757 * dangerous in some cases when the current directory is world-writable.
25759 * On Windows, note that all the string or string vector arguments to
25760 * this function and the other g_spawn*() functions are in UTF-8, the
25761 * GLib file name encoding. Unicode characters that are not part of
25762 * the system codepage passed in these arguments will be correctly
25763 * available in the spawned program only if it uses wide character API
25764 * to retrieve its command line. For C programs built with Microsoft's
25765 * tools it is enough to make the program have a wmain() instead of
25766 * main(). wmain() has a wide character argument vector as parameter.
25768 * At least currently, mingw doesn't support wmain(), so if you use
25769 * mingw to develop the spawned program, it will have to call the
25770 * undocumented function __wgetmainargs() to get the wide character
25771 * argument vector and environment. See gspawn-win32-helper.c in the
25772 * GLib sources or init.c in the mingw runtime sources for a prototype
25773 * for that function. Alternatively, you can retrieve the Win32 system
25774 * level wide character command line passed to the spawned program
25775 * using the GetCommandLineW() function.
25777 * On Windows the low-level child process creation API
25778 * <function>CreateProcess()</function> doesn't use argument vectors,
25779 * but a command line. The C runtime library's
25780 * <function>spawn*()</function> family of functions (which
25781 * g_spawn_async_with_pipes() eventually calls) paste the argument
25782 * vector elements together into a command line, and the C runtime startup code
25783 * does a corresponding reconstruction of an argument vector from the
25784 * command line, to be passed to main(). Complications arise when you have
25785 * argument vector elements that contain spaces of double quotes. The
25786 * <function>spawn*()</function> functions don't do any quoting or
25787 * escaping, but on the other hand the startup code does do unquoting
25788 * and unescaping in order to enable receiving arguments with embedded
25789 * spaces or double quotes. To work around this asymmetry,
25790 * g_spawn_async_with_pipes() will do quoting and escaping on argument
25791 * vector elements that need it before calling the C runtime
25792 * spawn() function.
25794 * The returned @child_pid on Windows is a handle to the child
25795 * process, not its identifier. Process handles and process
25796 * identifiers are different concepts on Windows.
25798 * @envp is a %NULL-terminated array of strings, where each string
25799 * has the form <literal>KEY=VALUE</literal>. This will become
25800 * the child's environment. If @envp is %NULL, the child inherits its
25801 * parent's environment.
25803 * @flags should be the bitwise OR of any flags you want to affect the
25804 * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
25805 * child will not automatically be reaped; you must use a child watch to
25806 * be notified about the death of the child process. Eventually you must
25807 * call g_spawn_close_pid() on the @child_pid, in order to free
25808 * resources which may be associated with the child process. (On Unix,
25809 * using a child watch is equivalent to calling waitpid() or handling
25810 * the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
25811 * is equivalent to calling CloseHandle() on the process handle returned
25812 * in @child_pid). See g_child_watch_add().
25814 * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
25815 * descriptors will be inherited by the child; otherwise all
25816 * descriptors except stdin/stdout/stderr will be closed before
25817 * calling exec() in the child. %G_SPAWN_SEARCH_PATH
25818 * means that <literal>argv[0]</literal> need not be an absolute path, it
25819 * will be looked for in the <envar>PATH</envar> environment variable.
25820 * %G_SPAWN_SEARCH_PATH_FROM_ENVP means need not be an absolute path, it
25821 * will be looked for in the <envar>PATH</envar> variable from @envp. If
25822 * both %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP are used,
25823 * the value from @envp takes precedence over the environment.
25824 * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
25825 * be discarded, instead of going to the same location as the parent's
25826 * standard output. If you use this flag, @standard_output must be %NULL.
25827 * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
25828 * will be discarded, instead of going to the same location as the parent's
25829 * standard error. If you use this flag, @standard_error must be %NULL.
25830 * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
25831 * standard input (by default, the child's standard input is attached to
25832 * /dev/null). If you use this flag, @standard_input must be %NULL.
25833 * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
25834 * the file to execute, while the remaining elements are the
25835 * actual argument vector to pass to the file. Normally
25836 * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
25837 * passes all of @argv to the child.
25839 * @child_setup and @user_data are a function and user data. On POSIX
25840 * platforms, the function is called in the child after GLib has
25841 * performed all the setup it plans to perform (including creating
25842 * pipes, closing file descriptors, etc.) but before calling
25843 * exec(). That is, @child_setup is called just
25844 * before calling exec() in the child. Obviously
25845 * actions taken in this function will only affect the child, not the
25848 * On Windows, there is no separate fork() and exec()
25849 * functionality. Child processes are created and run with a single
25850 * API call, CreateProcess(). There is no sensible thing @child_setup
25851 * could be used for on Windows so it is ignored and not called.
25853 * If non-%NULL, @child_pid will on Unix be filled with the child's
25854 * process ID. You can use the process ID to send signals to the
25855 * child, or to use g_child_watch_add() (or waitpid()) if you specified the
25856 * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
25857 * filled with a handle to the child process only if you specified the
25858 * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
25859 * process using the Win32 API, for example wait for its termination
25860 * with the <function>WaitFor*()</function> functions, or examine its
25861 * exit code with GetExitCodeProcess(). You should close the handle
25862 * with CloseHandle() or g_spawn_close_pid() when you no longer need it.
25864 * If non-%NULL, the @standard_input, @standard_output, @standard_error
25865 * locations will be filled with file descriptors for writing to the child's
25866 * standard input or reading from its standard output or standard error.
25867 * The caller of g_spawn_async_with_pipes() must close these file descriptors
25868 * when they are no longer in use. If these parameters are %NULL, the corresponding
25869 * pipe won't be created.
25871 * If @standard_input is NULL, the child's standard input is attached to
25872 * /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
25874 * If @standard_error is NULL, the child's standard error goes to the same
25875 * location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
25878 * If @standard_output is NULL, the child's standard output goes to the same
25879 * location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
25882 * @error can be %NULL to ignore errors, or non-%NULL to report errors.
25883 * If an error is set, the function returns %FALSE. Errors
25884 * are reported even if they occur in the child (for example if the
25885 * executable in <literal>argv[0]</literal> is not found). Typically
25886 * the <literal>message</literal> field of returned errors should be displayed
25887 * to users. Possible errors are those from the #G_SPAWN_ERROR domain.
25889 * If an error occurs, @child_pid, @standard_input, @standard_output,
25890 * and @standard_error will not be filled with valid values.
25892 * If @child_pid is not %NULL and an error does not occur then the returned
25893 * process reference must be closed using g_spawn_close_pid().
25896 * If you are writing a GTK+ application, and the program you
25897 * are spawning is a graphical application, too, then you may
25898 * want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
25899 * the spawned program opens its windows on the right screen.
25902 * Returns: %TRUE on success, %FALSE if an error was set
25907 * g_spawn_check_exit_status:
25908 * @exit_status: An exit code as returned from g_spawn_sync()
25909 * @error: a #GError
25911 * Set @error if @exit_status indicates the child exited abnormally
25912 * (e.g. with a nonzero exit code, or via a fatal signal).
25914 * The g_spawn_sync() and g_child_watch_add() family of APIs return an
25915 * exit status for subprocesses encoded in a platform-specific way.
25916 * On Unix, this is guaranteed to be in the same format
25917 * <literal>waitpid(2)</literal> returns, and on Windows it is
25918 * guaranteed to be the result of
25919 * <literal>GetExitCodeProcess()</literal>. Prior to the introduction
25920 * of this function in GLib 2.34, interpreting @exit_status required
25921 * use of platform-specific APIs, which is problematic for software
25922 * using GLib as a cross-platform layer.
25924 * Additionally, many programs simply want to determine whether or not
25925 * the child exited successfully, and either propagate a #GError or
25926 * print a message to standard error. In that common case, this
25927 * function can be used. Note that the error message in @error will
25928 * contain human-readable information about the exit status.
25930 * The <literal>domain</literal> and <literal>code</literal> of @error
25931 * have special semantics in the case where the process has an "exit
25932 * code", as opposed to being killed by a signal. On Unix, this
25933 * happens if <literal>WIFEXITED</literal> would be true of
25934 * @exit_status. On Windows, it is always the case.
25936 * The special semantics are that the actual exit code will be the
25937 * code set in @error, and the domain will be %G_SPAWN_EXIT_ERROR.
25938 * This allows you to differentiate between different exit codes.
25940 * If the process was terminated by some means other than an exit
25941 * status, the domain will be %G_SPAWN_ERROR, and the code will be
25942 * %G_SPAWN_ERROR_FAILED.
25944 * This function just offers convenience; you can of course also check
25945 * the available platform via a macro such as %G_OS_UNIX, and use
25946 * <literal>WIFEXITED()</literal> and <literal>WEXITSTATUS()</literal>
25947 * on @exit_status directly. Do not attempt to scan or parse the
25948 * error message string; it may be translated and/or change in future
25949 * versions of GLib.
25951 * Returns: %TRUE if child exited successfully, %FALSE otherwise (and @error will be set)
25957 * g_spawn_close_pid:
25958 * @pid: The process reference to close
25960 * On some platforms, notably Windows, the #GPid type represents a resource
25961 * which must be closed to prevent resource leaking. g_spawn_close_pid()
25962 * is provided for this purpose. It should be used on all platforms, even
25963 * though it doesn't do anything under UNIX.
25968 * g_spawn_command_line_async:
25969 * @command_line: a command line
25970 * @error: return location for errors
25972 * A simple version of g_spawn_async() that parses a command line with
25973 * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
25974 * command line in the background. Unlike g_spawn_async(), the
25975 * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
25976 * that %G_SPAWN_SEARCH_PATH can have security implications, so
25977 * consider using g_spawn_async() directly if appropriate. Possible
25978 * errors are those from g_shell_parse_argv() and g_spawn_async().
25980 * The same concerns on Windows apply as for g_spawn_command_line_sync().
25982 * Returns: %TRUE on success, %FALSE if error is set.
25987 * g_spawn_command_line_sync:
25988 * @command_line: a command line
25989 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output
25990 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child errors
25991 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid()
25992 * @error: return location for errors
25994 * A simple version of g_spawn_sync() with little-used parameters
25995 * removed, taking a command line instead of an argument vector. See
25996 * g_spawn_sync() for full details. @command_line will be parsed by
25997 * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
25998 * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
25999 * implications, so consider using g_spawn_sync() directly if
26000 * appropriate. Possible errors are those from g_spawn_sync() and those
26001 * from g_shell_parse_argv().
26003 * If @exit_status is non-%NULL, the platform-specific exit status of
26004 * the child is stored there; see the documentation of
26005 * g_spawn_check_exit_status() for how to use and interpret this.
26007 * On Windows, please note the implications of g_shell_parse_argv()
26008 * parsing @command_line. Parsing is done according to Unix shell rules, not
26009 * Windows command interpreter rules.
26010 * Space is a separator, and backslashes are
26011 * special. Thus you cannot simply pass a @command_line containing
26012 * canonical Windows paths, like "c:\\program files\\app\\app.exe", as
26013 * the backslashes will be eaten, and the space will act as a
26014 * separator. You need to enclose such paths with single quotes, like
26015 * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
26017 * Returns: %TRUE on success, %FALSE if an error was set
26023 * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
26024 * @argv: (array zero-terminated=1): child's argument vector
26025 * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
26026 * @flags: flags from #GSpawnFlags
26027 * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26028 * @user_data: (closure): user data for @child_setup
26029 * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output, or %NULL
26030 * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child error messages, or %NULL
26031 * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid(), or %NULL
26032 * @error: return location for error, or %NULL
26034 * Executes a child synchronously (waits for the child to exit before returning).
26035 * All output from the child is stored in @standard_output and @standard_error,
26036 * if those parameters are non-%NULL. Note that you must set the
26037 * %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
26038 * passing %NULL for @standard_output and @standard_error.
26040 * If @exit_status is non-%NULL, the platform-specific exit status of
26041 * the child is stored there; see the documentation of
26042 * g_spawn_check_exit_status() for how to use and interpret this.
26043 * Note that it is invalid to pass %G_SPAWN_DO_NOT_REAP_CHILD in
26046 * If an error occurs, no data is returned in @standard_output,
26047 * @standard_error, or @exit_status.
26049 * This function calls g_spawn_async_with_pipes() internally; see that
26050 * function for full details on the other parameters and details on
26051 * how these functions work on Windows.
26053 * Returns: %TRUE on success, %FALSE if an error was set.
26059 * @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
26060 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
26061 * @...: the arguments to insert in the output.
26063 * An implementation of the standard sprintf() function which supports
26064 * positional parameters, as specified in the Single Unix Specification.
26066 * Note that it is usually better to use g_snprintf(), to avoid the
26067 * risk of buffer overflow.
26069 * See also g_strdup_printf().
26071 * Returns: the number of bytes printed.
26078 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
26079 * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
26081 * A wrapper for the POSIX stat() function. The stat() function
26082 * returns information about a file. On Windows the stat() function in
26083 * the C library checks only the FAT-style READONLY attribute and does
26084 * not look at the ACL at all. Thus on Windows the protection bits in
26085 * the st_mode field are a fabrication of little use.
26087 * On Windows the Microsoft C libraries have several variants of the
26088 * <structname>stat</structname> struct and stat() function with names
26089 * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
26090 * used here is for 32-bit code the one with 32-bit size and time
26091 * fields, specifically called "_stat32".
26093 * In Microsoft's compiler, by default "struct stat" means one with
26094 * 64-bit time fields while in MinGW "struct stat" is the legacy one
26095 * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
26096 * header defines a type GStatBuf which is the appropriate struct type
26097 * depending on the platform and/or compiler being used. On POSIX it
26098 * is just "struct stat", but note that even on POSIX platforms,
26099 * "stat" might be a macro.
26101 * See your C library manual for more details about stat().
26103 * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
26110 * @dest: destination buffer.
26111 * @src: source string.
26113 * Copies a nul-terminated string into the dest buffer, include the
26114 * trailing nul, and return a pointer to the trailing nul byte.
26115 * This is useful for concatenating multiple strings together
26116 * without having to repeatedly scan for the end.
26118 * Returns: a pointer to trailing nul byte.
26125 * @v2: a key to compare with @v1
26127 * Compares two strings for byte-by-byte equality and returns %TRUE
26128 * if they are equal. It can be passed to g_hash_table_new() as the
26129 * @key_equal_func parameter, when using non-%NULL strings as keys in a
26132 * Note that this function is primarily meant as a hash table comparison
26133 * function. For a general-purpose, %NULL-safe string comparison function,
26136 * Returns: %TRUE if the two keys match
26141 * g_str_has_prefix:
26142 * @str: a nul-terminated string
26143 * @prefix: the nul-terminated prefix to look for
26145 * Looks whether the string @str begins with @prefix.
26147 * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
26153 * g_str_has_suffix:
26154 * @str: a nul-terminated string
26155 * @suffix: the nul-terminated suffix to look for
26157 * Looks whether the string @str ends with @suffix.
26159 * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
26168 * Converts a string to a hash value.
26170 * This function implements the widely used "djb" hash apparently posted
26171 * by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
26172 * unsigned hash value starts at 5381 and for each byte 'c' in the
26173 * string, is updated: <literal>hash = hash * 33 + c</literal>. This
26174 * function uses the signed value of each byte.
26176 * It can be passed to g_hash_table_new() as the @hash_func parameter,
26177 * when using non-%NULL strings as keys in a #GHashTable.
26179 * Returns: a hash value corresponding to the key
26185 * @string: a nul-terminated array of bytes
26186 * @valid_chars: bytes permitted in @string
26187 * @substitutor: replacement character for disallowed bytes
26189 * For each character in @string, if the character is not in
26190 * @valid_chars, replaces the character with @substitutor.
26191 * Modifies @string in place, and return @string itself, not
26192 * a copy. The return value is to allow nesting such as
26194 * g_ascii_strup (g_strcanon (str, "abc", '?'))
26204 * @s2: a string to compare with @s1.
26206 * A case-insensitive string comparison, corresponding to the standard
26207 * strcasecmp() function on platforms which support it.
26209 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
26210 * Deprecated: 2.2: See g_strncasecmp() for a discussion of why this function is deprecated and how to replace it.
26216 * @string: a string to remove the trailing whitespace from
26218 * Removes trailing whitespace from a string.
26220 * This function doesn't allocate or reallocate any memory;
26221 * it modifies @string in place. The pointer to @string is
26222 * returned to allow the nesting of functions.
26224 * Also see g_strchug() and g_strstrip().
26226 * Returns: @string.
26232 * @string: a string to remove the leading whitespace from
26234 * Removes leading whitespace from a string, by moving the rest
26235 * of the characters forward.
26237 * This function doesn't allocate or reallocate any memory;
26238 * it modifies @string in place. The pointer to @string is
26239 * returned to allow the nesting of functions.
26241 * Also see g_strchomp() and g_strstrip().
26249 * @str1: (allow-none): a C string or %NULL
26250 * @str2: (allow-none): another C string or %NULL
26252 * Compares @str1 and @str2 like strcmp(). Handles %NULL
26253 * gracefully by sorting it before non-%NULL strings.
26254 * Comparing two %NULL pointers returns 0.
26256 * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
26263 * @source: a string to compress
26265 * Replaces all escaped characters with their one byte equivalent.
26267 * This function does the reverse conversion of g_strescape().
26269 * Returns: a newly-allocated copy of @source with all escaped character compressed
26275 * @string1: the first string to add, which must not be %NULL
26276 * @...: a %NULL-terminated list of strings to append to the string
26278 * Concatenates all of the given strings into one long string.
26279 * The returned string should be freed with g_free() when no longer needed.
26281 * Note that this function is usually not the right function to use to
26282 * assemble a translated message from pieces, since proper translation
26283 * often requires the pieces to be reordered.
26285 * <warning><para>The variable argument list <emphasis>must</emphasis> end
26286 * with %NULL. If you forget the %NULL, g_strconcat() will start appending
26287 * random memory junk to your string.</para></warning>
26289 * Returns: a newly-allocated string containing all the string arguments
26295 * @string: the string to convert
26296 * @delimiters: (allow-none): a string containing the current delimiters, or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
26297 * @new_delimiter: the new delimiter character
26299 * Converts any delimiter characters in @string to @new_delimiter.
26300 * Any characters in @string which are found in @delimiters are
26301 * changed to the @new_delimiter character. Modifies @string in place,
26302 * and returns @string itself, not a copy. The return value is to
26303 * allow nesting such as
26305 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
26314 * @string: the string to convert.
26316 * Converts a string to lower case.
26318 * Returns: the string
26319 * 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.
26325 * @str: the string to duplicate
26327 * Duplicates a string. If @str is %NULL it returns %NULL.
26328 * The returned string should be freed with g_free()
26329 * when no longer needed.
26331 * Returns: a newly-allocated copy of @str
26337 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26338 * @...: the parameters to insert into the format string
26340 * Similar to the standard C sprintf() function but safer, since it
26341 * calculates the maximum space required and allocates memory to hold
26342 * the result. The returned string should be freed with g_free() when no
26345 * Returns: a newly-allocated string holding the result
26350 * g_strdup_vprintf:
26351 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26352 * @args: the list of parameters to insert into the format string
26354 * Similar to the standard C vsprintf() function but safer, since it
26355 * calculates the maximum space required and allocates memory to hold
26356 * the result. The returned string should be freed with g_free() when
26357 * no longer needed.
26359 * See also g_vasprintf(), which offers the same functionality, but
26360 * additionally returns the length of the allocated string.
26362 * Returns: a newly-allocated string holding the result
26368 * @str_array: a %NULL-terminated array of strings
26370 * Copies %NULL-terminated array of strings. The copy is a deep copy;
26371 * the new array should be freed by first freeing each string, then
26372 * the array itself. g_strfreev() does this for you. If called
26373 * on a %NULL value, g_strdupv() simply returns %NULL.
26375 * Returns: a new %NULL-terminated array of strings.
26381 * @errnum: the system error number. See the standard C %errno documentation
26383 * Returns a string corresponding to the given error code, e.g.
26384 * "no such process". You should use this function in preference to
26385 * strerror(), because it returns a string in UTF-8 encoding, and since
26386 * not all platforms support the strerror() function.
26388 * Returns: a UTF-8 string describing the error code. If the error code is unknown, it returns "unknown error (<code>)".
26394 * @source: a string to escape
26395 * @exceptions: a string of characters not to escape in @source
26397 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
26398 * and '"' in the string @source by inserting a '\' before
26399 * them. Additionally all characters in the range 0x01-0x1F (everything
26400 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
26401 * replaced with a '\' followed by their octal representation.
26402 * Characters supplied in @exceptions are not escaped.
26404 * g_strcompress() does the reverse conversion.
26406 * Returns: a newly-allocated copy of @source with certain characters escaped. See above.
26412 * @str_array: a %NULL-terminated array of strings to free
26414 * Frees a %NULL-terminated array of strings, and the array itself.
26415 * If called on a %NULL value, g_strfreev() simply returns.
26421 * @string: a #GString
26422 * @val: the string to append onto the end of @string
26424 * Adds a string onto the end of a #GString, expanding
26432 * g_string_append_c:
26433 * @string: a #GString
26434 * @c: the byte to append onto the end of @string
26436 * Adds a byte onto the end of a #GString, expanding
26444 * g_string_append_len:
26445 * @string: a #GString
26446 * @val: bytes to append
26447 * @len: number of bytes of @val to use
26449 * Appends @len bytes of @val to @string. Because @len is
26450 * provided, @val may contain embedded nuls and need not
26451 * be nul-terminated.
26453 * Since this function does not stop at nul bytes, it is
26454 * the caller's responsibility to ensure that @val has at
26455 * least @len addressable bytes.
26462 * g_string_append_printf:
26463 * @string: a #GString
26464 * @format: the string format. See the printf() documentation
26465 * @...: the parameters to insert into the format string
26467 * Appends a formatted string onto the end of a #GString.
26468 * This function is similar to g_string_printf() except
26469 * that the text is appended to the #GString.
26474 * g_string_append_unichar:
26475 * @string: a #GString
26476 * @wc: a Unicode character
26478 * Converts a Unicode character into UTF-8, and appends it
26486 * g_string_append_uri_escaped:
26487 * @string: a #GString
26488 * @unescaped: a string
26489 * @reserved_chars_allowed: a string of reserved characters allowed to be used, or %NULL
26490 * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
26492 * Appends @unescaped to @string, escaped any characters that
26493 * are reserved in URIs using URI-style escape sequences.
26501 * g_string_append_vprintf:
26502 * @string: a #GString
26503 * @format: the string format. See the printf() documentation
26504 * @args: the list of arguments to insert in the output
26506 * Appends a formatted string onto the end of a #GString.
26507 * This function is similar to g_string_append_printf()
26508 * except that the arguments to the format string are passed
26516 * g_string_ascii_down:
26517 * @string: a GString
26519 * Converts all uppercase ASCII letters to lowercase ASCII letters.
26521 * Returns: passed-in @string pointer, with all the uppercase characters converted to lowercase in place, with semantics that exactly match g_ascii_tolower().
26526 * g_string_ascii_up:
26527 * @string: a GString
26529 * Converts all lowercase ASCII letters to uppercase ASCII letters.
26531 * Returns: passed-in @string pointer, with all the lowercase characters converted to uppercase in place, with semantics that exactly match g_ascii_toupper().
26537 * @string: the destination #GString. Its current contents are destroyed.
26538 * @rval: the string to copy into @string
26540 * Copies the bytes from a string into a #GString,
26541 * destroying any previous contents. It is rather like
26542 * the standard strcpy() function, except that you do not
26543 * have to worry about having enough space to copy the string.
26550 * g_string_chunk_clear:
26551 * @chunk: a #GStringChunk
26553 * Frees all strings contained within the #GStringChunk.
26554 * After calling g_string_chunk_clear() it is not safe to
26555 * access any of the strings which were contained within it.
26562 * g_string_chunk_free:
26563 * @chunk: a #GStringChunk
26565 * Frees all memory allocated by the #GStringChunk.
26566 * After calling g_string_chunk_free() it is not safe to
26567 * access any of the strings which were contained within it.
26572 * g_string_chunk_insert:
26573 * @chunk: a #GStringChunk
26574 * @string: the string to add
26576 * Adds a copy of @string to the #GStringChunk.
26577 * It returns a pointer to the new copy of the string
26578 * in the #GStringChunk. The characters in the string
26579 * can be changed, if necessary, though you should not
26580 * change anything after the end of the string.
26582 * Unlike g_string_chunk_insert_const(), this function
26583 * does not check for duplicates. Also strings added
26584 * with g_string_chunk_insert() will not be searched
26585 * by g_string_chunk_insert_const() when looking for
26588 * Returns: a pointer to the copy of @string within the #GStringChunk
26593 * g_string_chunk_insert_const:
26594 * @chunk: a #GStringChunk
26595 * @string: the string to add
26597 * Adds a copy of @string to the #GStringChunk, unless the same
26598 * string has already been added to the #GStringChunk with
26599 * g_string_chunk_insert_const().
26601 * This function is useful if you need to copy a large number
26602 * of strings but do not want to waste space storing duplicates.
26603 * But you must remember that there may be several pointers to
26604 * the same string, and so any changes made to the strings
26605 * should be done very carefully.
26607 * Note that g_string_chunk_insert_const() will not return a
26608 * pointer to a string added with g_string_chunk_insert(), even
26609 * if they do match.
26611 * Returns: a pointer to the new or existing copy of @string within the #GStringChunk
26616 * g_string_chunk_insert_len:
26617 * @chunk: a #GStringChunk
26618 * @string: bytes to insert
26619 * @len: number of bytes of @string to insert, or -1 to insert a nul-terminated string
26621 * Adds a copy of the first @len bytes of @string to the #GStringChunk.
26622 * The copy is nul-terminated.
26624 * Since this function does not stop at nul bytes, it is the caller's
26625 * responsibility to ensure that @string has at least @len addressable
26628 * The characters in the returned string can be changed, if necessary,
26629 * though you should not change anything after the end of the string.
26631 * Returns: a pointer to the copy of @string within the #GStringChunk
26637 * g_string_chunk_new:
26638 * @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.
26640 * Creates a new #GStringChunk.
26642 * Returns: a new #GStringChunk
26648 * @string: a #GString
26650 * Converts a #GString to lowercase.
26652 * Returns: the #GString
26653 * 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.
26660 * @v2: another #GString
26662 * Compares two strings for equality, returning %TRUE if they are equal.
26663 * For use with #GHashTable.
26665 * Returns: %TRUE if the strings are the same length and contain the same bytes
26671 * @string: a #GString
26672 * @pos: the position of the content to remove
26673 * @len: the number of bytes to remove, or -1 to remove all following bytes
26675 * Removes @len bytes from a #GString, starting at position @pos.
26676 * The rest of the #GString is shifted down to fill the gap.
26684 * @string: a #GString
26685 * @free_segment: if %TRUE, the actual character data is freed as well
26687 * Frees the memory allocated for the #GString.
26688 * If @free_segment is %TRUE it also frees the character data. If
26689 * it's %FALSE, the caller gains ownership of the buffer and must
26690 * free it after use with g_free().
26692 * Returns: the character data of @string (i.e. %NULL if @free_segment is %TRUE)
26697 * g_string_free_to_bytes:
26698 * @string: (transfer full): a #GString
26700 * Transfers ownership of the contents of @string to a newly allocated
26701 * #GBytes. The #GString structure itself is deallocated, and it is
26702 * therefore invalid to use @string after invoking this function.
26704 * Note that while #GString ensures that its buffer always has a
26705 * trailing nul character (not reflected in its "len"), the returned
26706 * #GBytes does not include this extra nul; i.e. it has length exactly
26707 * equal to the "len" member.
26709 * Returns: A newly allocated #GBytes containing contents of @string; @string itself is freed
26716 * @str: a string to hash
26718 * Creates a hash code for @str; for use with #GHashTable.
26720 * Returns: hash code for @str
26726 * @string: a #GString
26727 * @pos: the position to insert the copy of the string
26728 * @val: the string to insert
26730 * Inserts a copy of a string into a #GString,
26731 * expanding it if necessary.
26738 * g_string_insert_c:
26739 * @string: a #GString
26740 * @pos: the position to insert the byte
26741 * @c: the byte to insert
26743 * Inserts a byte into a #GString, expanding it if necessary.
26750 * g_string_insert_len:
26751 * @string: a #GString
26752 * @pos: position in @string where insertion should happen, or -1 for at the end
26753 * @val: bytes to insert
26754 * @len: number of bytes of @val to insert
26756 * Inserts @len bytes of @val into @string at @pos.
26757 * Because @len is provided, @val may contain embedded
26758 * nuls and need not be nul-terminated. If @pos is -1,
26759 * bytes are inserted at the end of the string.
26761 * Since this function does not stop at nul bytes, it is
26762 * the caller's responsibility to ensure that @val has at
26763 * least @len addressable bytes.
26770 * g_string_insert_unichar:
26771 * @string: a #GString
26772 * @pos: the position at which to insert character, or -1 to append at the end of the string
26773 * @wc: a Unicode character
26775 * Converts a Unicode character into UTF-8, and insert it
26776 * into the string at the given position.
26784 * @init: the initial text to copy into the string
26786 * Creates a new #GString, initialized with the given string.
26788 * Returns: the new #GString
26793 * g_string_new_len:
26794 * @init: initial contents of the string
26795 * @len: length of @init to use
26797 * Creates a new #GString with @len bytes of the @init buffer.
26798 * Because a length is provided, @init need not be nul-terminated,
26799 * and can contain embedded nul bytes.
26801 * Since this function does not stop at nul bytes, it is the caller's
26802 * responsibility to ensure that @init has at least @len addressable
26805 * Returns: a new #GString
26810 * g_string_overwrite:
26811 * @string: a #GString
26812 * @pos: the position at which to start overwriting
26813 * @val: the string that will overwrite the @string starting at @pos
26815 * Overwrites part of a string, lengthening it if necessary.
26823 * g_string_overwrite_len:
26824 * @string: a #GString
26825 * @pos: the position at which to start overwriting
26826 * @val: the string that will overwrite the @string starting at @pos
26827 * @len: the number of bytes to write from @val
26829 * Overwrites part of a string, lengthening it if necessary.
26830 * This function will work with embedded nuls.
26838 * g_string_prepend:
26839 * @string: a #GString
26840 * @val: the string to prepend on the start of @string
26842 * Adds a string on to the start of a #GString,
26843 * expanding it if necessary.
26850 * g_string_prepend_c:
26851 * @string: a #GString
26852 * @c: the byte to prepend on the start of the #GString
26854 * Adds a byte onto the start of a #GString,
26855 * expanding it if necessary.
26862 * g_string_prepend_len:
26863 * @string: a #GString
26864 * @val: bytes to prepend
26865 * @len: number of bytes in @val to prepend
26867 * Prepends @len bytes of @val to @string.
26868 * Because @len is provided, @val may contain
26869 * embedded nuls and need not be nul-terminated.
26871 * Since this function does not stop at nul bytes,
26872 * it is the caller's responsibility to ensure that
26873 * @val has at least @len addressable bytes.
26880 * g_string_prepend_unichar:
26881 * @string: a #GString
26882 * @wc: a Unicode character
26884 * Converts a Unicode character into UTF-8, and prepends it
26893 * @string: a #GString
26894 * @format: the string format. See the printf() documentation
26895 * @...: the parameters to insert into the format string
26897 * Writes a formatted string into a #GString.
26898 * This is similar to the standard sprintf() function,
26899 * except that the #GString buffer automatically expands
26900 * to contain the results. The previous contents of the
26901 * #GString are destroyed.
26906 * g_string_set_size:
26907 * @string: a #GString
26908 * @len: the new length
26910 * Sets the length of a #GString. If the length is less than
26911 * the current length, the string will be truncated. If the
26912 * length is greater than the current length, the contents
26913 * of the newly added area are undefined. (However, as
26914 * always, string->str[string->len] will be a nul byte.)
26921 * g_string_sized_new:
26922 * @dfl_size: the default size of the space allocated to hold the string
26924 * Creates a new #GString, with enough space for @dfl_size
26925 * bytes. This is useful if you are going to add a lot of
26926 * text to the string and don't want it to be reallocated
26929 * Returns: the new #GString
26934 * g_string_sprintf:
26935 * @string: a #GString
26936 * @format: the string format. See the sprintf() documentation
26937 * @...: the parameters to insert into the format string
26939 * Writes a formatted string into a #GString.
26940 * This is similar to the standard sprintf() function,
26941 * except that the #GString buffer automatically expands
26942 * to contain the results. The previous contents of the
26943 * #GString are destroyed.
26945 * Deprecated: This function has been renamed to g_string_printf().
26950 * g_string_sprintfa:
26951 * @string: a #GString
26952 * @format: the string format. See the sprintf() documentation
26953 * @...: the parameters to insert into the format string
26955 * Appends a formatted string onto the end of a #GString.
26956 * This function is similar to g_string_sprintf() except that
26957 * the text is appended to the #GString.
26959 * Deprecated: This function has been renamed to g_string_append_printf()
26964 * g_string_truncate:
26965 * @string: a #GString
26966 * @len: the new size of @string
26968 * Cuts off the end of the GString, leaving the first @len bytes.
26976 * @string: a #GString
26978 * Converts a #GString to uppercase.
26981 * 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.
26986 * g_string_vprintf:
26987 * @string: a #GString
26988 * @format: the string format. See the printf() documentation
26989 * @args: the parameters to insert into the format string
26991 * Writes a formatted string into a #GString.
26992 * This function is similar to g_string_printf() except that
26993 * the arguments to the format string are passed as a va_list.
27002 * @msgval: another string
27004 * An auxiliary function for gettext() support (see Q_()).
27006 * 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.
27013 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
27014 * @...: a %NULL-terminated list of strings to join
27016 * Joins a number of strings together to form one long string, with the
27017 * optional @separator inserted between each of them. The returned string
27018 * should be freed with g_free().
27020 * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
27026 * @separator: (allow-none): a string to insert between each of the strings, or %NULL
27027 * @str_array: a %NULL-terminated array of strings to join
27029 * Joins a number of strings together to form one long string, with the
27030 * optional @separator inserted between each of them. The returned string
27031 * should be freed with g_free().
27033 * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
27039 * @dest: destination buffer, already containing one nul-terminated string
27040 * @src: source buffer
27041 * @dest_size: length of @dest buffer in bytes (not length of existing string inside @dest)
27043 * Portability wrapper that calls strlcat() on systems which have it,
27044 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
27045 * guaranteeing nul-termination for @dest. The total size of @dest won't
27046 * exceed @dest_size.
27048 * At most dest_size - 1 characters will be copied.
27049 * Unlike strncat, dest_size is the full size of dest, not the space left over.
27050 * This function does NOT allocate memory.
27051 * This always NUL terminates (unless siz == 0 or there were no NUL characters
27052 * in the dest_size characters of dest to start with).
27054 * <note><para>Caveat: this is supposedly a more secure alternative to
27055 * strcat() or strncat(), but for real security g_strconcat() is harder
27056 * to mess up.</para></note>
27058 * Returns: size of attempted result, which is MIN (dest_size, strlen (original dest)) + strlen (src), so if retval >= dest_size, truncation occurred.
27064 * @dest: destination buffer
27065 * @src: source buffer
27066 * @dest_size: length of @dest in bytes
27068 * Portability wrapper that calls strlcpy() on systems which have it,
27069 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
27070 * guaranteed to be nul-terminated; @src must be nul-terminated;
27071 * @dest_size is the buffer size, not the number of chars to copy.
27073 * At most dest_size - 1 characters will be copied. Always nul-terminates
27074 * (unless dest_size == 0). This function does <emphasis>not</emphasis>
27075 * allocate memory. Unlike strncpy(), this function doesn't pad dest (so
27076 * it's often faster). It returns the size of the attempted result,
27077 * strlen (src), so if @retval >= @dest_size, truncation occurred.
27079 * <note><para>Caveat: strlcpy() is supposedly more secure than
27080 * strcpy() or strncpy(), but if you really want to avoid screwups,
27081 * g_strdup() is an even better idea.</para></note>
27083 * Returns: length of @src
27090 * @s2: a string to compare with @s1.
27091 * @n: the maximum number of characters to compare.
27093 * A case-insensitive string comparison, corresponding to the standard
27094 * strncasecmp() function on platforms which support it.
27095 * It is similar to g_strcasecmp() except it only compares the first @n
27096 * characters of the strings.
27098 * Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2.
27099 * 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 techniques: g_ascii_strncasecmp(), which only works on ASCII and is not locale-sensitive, and g_utf8_casefold() followed by strcmp() on the resulting strings, which is good for case-insensitive sorting of UTF-8.
27105 * @str: the string to duplicate
27106 * @n: the maximum number of bytes to copy from @str
27108 * Duplicates the first @n bytes of a string, returning a newly-allocated
27109 * buffer @n + 1 bytes long which will always be nul-terminated.
27110 * If @str is less than @n bytes long the buffer is padded with nuls.
27111 * If @str is %NULL it returns %NULL.
27112 * The returned value should be freed when no longer needed.
27115 * To copy a number of characters from a UTF-8 encoded string, use
27116 * g_utf8_strncpy() instead.
27119 * Returns: a newly-allocated buffer containing the first @n bytes of @str, nul-terminated
27125 * @length: the length of the new string
27126 * @fill_char: the byte to fill the string with
27128 * Creates a new string @length bytes long filled with @fill_char.
27129 * The returned string should be freed when no longer needed.
27131 * Returns: a newly-allocated string filled the @fill_char
27137 * @string: the string to reverse
27139 * Reverses all of the bytes in a string. For example,
27140 * <literal>g_strreverse ("abcdef")</literal> will result
27143 * Note that g_strreverse() doesn't work on UTF-8 strings
27144 * containing multibyte characters. For that purpose, use
27145 * g_utf8_strreverse().
27147 * Returns: the same pointer passed in as @string
27153 * @haystack: a nul-terminated string
27154 * @needle: the nul-terminated string to search for
27156 * Searches the string @haystack for the last occurrence
27157 * of the string @needle.
27159 * Returns: a pointer to the found occurrence, or %NULL if not found.
27165 * @haystack: a nul-terminated string
27166 * @haystack_len: the maximum length of @haystack
27167 * @needle: the nul-terminated string to search for
27169 * Searches the string @haystack for the last occurrence
27170 * of the string @needle, limiting the length of the search
27171 * to @haystack_len.
27173 * Returns: a pointer to the found occurrence, or %NULL if not found.
27179 * @signum: the signal number. See the <literal>signal</literal> documentation
27181 * Returns a string describing the given signal, e.g. "Segmentation fault".
27182 * You should use this function in preference to strsignal(), because it
27183 * returns a string in UTF-8 encoding, and since not all platforms support
27184 * the strsignal() function.
27186 * Returns: a UTF-8 string describing the signal. If the signal is unknown, it returns "unknown signal (<signum>)".
27192 * @string: a string to split
27193 * @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.
27194 * @max_tokens: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
27196 * Splits a string into a maximum of @max_tokens pieces, using the given
27197 * @delimiter. If @max_tokens is reached, the remainder of @string is
27198 * appended to the last token.
27200 * As a special case, the result of splitting the empty string "" is an empty
27201 * vector, not a vector containing a single string. The reason for this
27202 * special case is that being able to represent a empty vector is typically
27203 * more useful than consistent handling of empty elements. If you do need
27204 * to represent empty elements, you'll need to check for the empty string
27205 * before calling g_strsplit().
27207 * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
27213 * @string: The string to be tokenized
27214 * @delimiters: A nul-terminated string containing bytes that are used to split the string.
27215 * @max_tokens: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
27217 * Splits @string into a number of tokens not containing any of the characters
27218 * in @delimiter. A token is the (possibly empty) longest string that does not
27219 * contain any of the characters in @delimiters. If @max_tokens is reached, the
27220 * remainder is appended to the last token.
27222 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
27223 * %NULL-terminated vector containing the three strings "abc", "def",
27226 * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
27227 * vector containing the four strings "", "def", "ghi", and "".
27229 * As a special case, the result of splitting the empty string "" is an empty
27230 * vector, not a vector containing a single string. The reason for this
27231 * special case is that being able to represent a empty vector is typically
27232 * more useful than consistent handling of empty elements. If you do need
27233 * to represent empty elements, you'll need to check for the empty string
27234 * before calling g_strsplit_set().
27236 * Note that this function works on bytes not characters, so it can't be used
27237 * to delimit UTF-8 strings for anything but ASCII characters.
27239 * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
27246 * @haystack: a string
27247 * @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.
27248 * @needle: the string to search for
27250 * Searches the string @haystack for the first occurrence
27251 * of the string @needle, limiting the length of the search
27252 * to @haystack_len.
27254 * Returns: a pointer to the found occurrence, or %NULL if not found.
27260 * @string: a string to remove the leading and trailing whitespace from
27262 * Removes leading and trailing whitespace from a string.
27263 * See g_strchomp() and g_strchug().
27271 * @nptr: the string to convert to a numeric value.
27272 * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
27274 * Converts a string to a #gdouble value.
27275 * It calls the standard strtod() function to handle the conversion, but
27276 * if the string is not completely converted it attempts the conversion
27277 * again with g_ascii_strtod(), and returns the best match.
27279 * This function should seldom be used. The normal situation when reading
27280 * numbers not for human consumption is to use g_ascii_strtod(). Only when
27281 * you know that you must expect both locale formatted and C formatted numbers
27282 * should you use this. Make sure that you don't pass strings such as comma
27283 * separated lists of values, since the commas may be interpreted as a decimal
27284 * point in some locales, causing unexpected results.
27286 * Returns: the #gdouble value.
27292 * @string: the string to convert.
27294 * Converts a string to upper case.
27296 * Returns: the string
27297 * 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.
27303 * @str_array: a %NULL-terminated array of strings
27305 * Returns the length of the given %NULL-terminated
27306 * string array @str_array.
27308 * Returns: length of @str_array.
27315 * @testpath: The test path for a new test case.
27316 * @Fixture: The type of a fixture data structure.
27317 * @tdata: Data argument for the test functions.
27318 * @fsetup: The function to set up the fixture data.
27319 * @ftest: The actual test function.
27320 * @fteardown: The function to tear down the fixture data.
27322 * Hook up a new test case at @testpath, similar to g_test_add_func().
27323 * A fixture data structure with setup and teardown function may be provided
27324 * though, similar to g_test_create_case().
27325 * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and
27326 * fteardown() callbacks can expect a @Fixture pointer as first argument in
27327 * a type safe manner.
27334 * g_test_add_data_func:
27335 * @testpath: /-separated test case path name for the test.
27336 * @test_data: Test data argument for the test function.
27337 * @test_func: The test function to invoke for this test.
27339 * Create a new test case, similar to g_test_create_case(). However
27340 * the test is assumed to use no fixture, and test suites are automatically
27341 * created on the fly and added to the root fixture, based on the
27342 * slash-separated portions of @testpath. The @test_data argument
27343 * will be passed as first argument to @test_func.
27345 * If @testpath includes the component "subprocess" anywhere in it,
27346 * the test will be skipped by default, and only run if explicitly
27347 * required via the <option>-p</option> command-line option or
27348 * g_test_trap_subprocess().
27355 * g_test_add_data_func_full:
27356 * @testpath: /-separated test case path name for the test.
27357 * @test_data: Test data argument for the test function.
27358 * @test_func: The test function to invoke for this test.
27359 * @data_free_func: #GDestroyNotify for @test_data.
27361 * Create a new test case, as with g_test_add_data_func(), but freeing
27362 * @test_data after the test run is complete.
27370 * @testpath: /-separated test case path name for the test.
27371 * @test_func: The test function to invoke for this test.
27373 * Create a new test case, similar to g_test_create_case(). However
27374 * the test is assumed to use no fixture, and test suites are automatically
27375 * created on the fly and added to the root fixture, based on the
27376 * slash-separated portions of @testpath.
27378 * If @testpath includes the component "subprocess" anywhere in it,
27379 * the test will be skipped by default, and only run if explicitly
27380 * required via the <option>-p</option> command-line option or
27381 * g_test_trap_subprocess().
27388 * g_test_assert_expected_messages:
27390 * Asserts that all messages previously indicated via
27391 * g_test_expect_message() have been seen and suppressed.
27399 * @bug_uri_snippet: Bug specific bug tracker URI portion.
27401 * This function adds a message to test reports that
27402 * associates a bug URI with a test case.
27403 * Bug URIs are constructed from a base URI set with g_test_bug_base()
27404 * and @bug_uri_snippet.
27412 * @uri_pattern: the base pattern for bug URIs
27414 * Specify the base URI for bug reports.
27416 * The base URI is used to construct bug report messages for
27417 * g_test_message() when g_test_bug() is called.
27418 * Calling this function outside of a test case sets the
27419 * default base URI for all test cases. Calling it from within
27420 * a test case changes the base URI for the scope of the test
27422 * Bug URIs are constructed by appending a bug specific URI
27423 * portion to @uri_pattern, or by replacing the special string
27424 * '\%s' within @uri_pattern if that is present.
27431 * g_test_build_filename:
27432 * @file_type: the type of file (built vs. distributed)
27433 * @first_path: the first segment of the pathname
27434 * @...: %NULL-terminated additional path segments
27436 * Creates the pathname to a data file that is required for a test.
27438 * This function is conceptually similar to g_build_filename() except
27439 * that the first argument has been replaced with a #GTestFileType
27442 * The data file should either have been distributed with the module
27443 * containing the test (%G_TEST_DIST) or built as part of the build
27444 * system of that module (%G_TEST_BUILT).
27446 * In order for this function to work in srcdir != builddir situations,
27447 * the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
27448 * have been defined. As of 2.38, this is done by the Makefile.decl
27449 * included in GLib. Please ensure that your copy is up to date before
27450 * using this function.
27452 * In case neither variable is set, this function will fall back to
27453 * using the dirname portion of argv[0], possibly removing ".libs".
27454 * This allows for casual running of tests directly from the commandline
27455 * in the srcdir == builddir case and should also support running of
27456 * installed tests, assuming the data files have been installed in the
27457 * same relative path as the test binary.
27459 * Returns: the path of the file, to be freed using g_free()
27465 * g_test_create_case:
27466 * @test_name: the name for the test case
27467 * @data_size: the size of the fixture data structure
27468 * @test_data: test data argument for the test functions
27469 * @data_setup: the function to set up the fixture data
27470 * @data_test: the actual test function
27471 * @data_teardown: the function to teardown the fixture data
27473 * Create a new #GTestCase, named @test_name, this API is fairly
27474 * low level, calling g_test_add() or g_test_add_func() is preferable.
27475 * When this test is executed, a fixture structure of size @data_size
27476 * will be allocated and filled with 0s. Then @data_setup is called
27477 * to initialize the fixture. After fixture setup, the actual test
27478 * function @data_test is called. Once the test run completed, the
27479 * fixture structure is torn down by calling @data_teardown and
27480 * after that the memory is released.
27482 * Splitting up a test run into fixture setup, test function and
27483 * fixture teardown is most usful if the same fixture is used for
27484 * multiple tests. In this cases, g_test_create_case() will be
27485 * called with the same fixture, but varying @test_name and
27486 * @data_test arguments.
27488 * Returns: a newly allocated #GTestCase.
27494 * g_test_create_suite:
27495 * @suite_name: a name for the suite
27497 * Create a new test suite with the name @suite_name.
27499 * Returns: A newly allocated #GTestSuite instance.
27505 * g_test_expect_message:
27506 * @log_domain: (allow-none): the log domain of the message
27507 * @log_level: the log level of the message
27508 * @pattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27510 * Indicates that a message with the given @log_domain and @log_level,
27511 * with text matching @pattern, is expected to be logged. When this
27512 * message is logged, it will not be printed, and the test case will
27515 * Use g_test_assert_expected_messages() to assert that all
27516 * previously-expected messages have been seen and suppressed.
27518 * You can call this multiple times in a row, if multiple messages are
27519 * expected as a result of a single call. (The messages must appear in
27520 * the same order as the calls to g_test_expect_message().)
27525 * /* g_main_context_push_thread_default() should fail if the
27526 * * context is already owned by another thread.
27528 * g_test_expect_message (G_LOG_DOMAIN,
27529 * G_LOG_LEVEL_CRITICAL,
27530 * "assertion*acquired_context*failed");
27531 * g_main_context_push_thread_default (bad_context);
27532 * g_test_assert_expected_messages ();
27535 * Note that you cannot use this to test g_error() messages, since
27536 * g_error() intentionally never returns even if the program doesn't
27537 * abort; use g_test_trap_subprocess() in this case.
27546 * Indicates that a test failed. This function can be called
27547 * multiple times from the same test. You can use this function
27548 * if your test failed in a recoverable way.
27550 * Do not use this function if the failure of a test could cause
27551 * other tests to malfunction.
27553 * Calling this function will not stop the test from running, you
27554 * need to return from the test function yourself. So you can
27555 * produce additional diagnostic messages or even continue running
27558 * If not called from inside a test, this function does nothing.
27567 * Returns whether a test has already failed. This will
27568 * be the case when g_test_fail(), g_test_incomplete()
27569 * or g_test_skip() have been called, but also if an
27570 * assertion has failed.
27572 * This can be useful to return early from a test if
27573 * continuing after a failed assertion might be harmful.
27575 * The return value of this function is only meaningful
27576 * if it is called from inside a test function.
27578 * Returns: %TRUE if the test has failed
27585 * @file_type: the type of file (built vs. distributed)
27587 * Gets the pathname of the directory containing test files of the type
27588 * specified by @file_type.
27590 * This is approximately the same as calling g_test_build_filename("."),
27591 * but you don't need to free the return value.
27593 * Returns: the path of the directory, owned by GLib
27599 * g_test_get_filename:
27600 * @file_type: the type of file (built vs. distributed)
27601 * @first_path: the first segment of the pathname
27602 * @...: %NULL-terminated additional path segments
27604 * Gets the pathname to a data file that is required for a test.
27606 * This is the same as g_test_build_filename() with two differences.
27607 * The first difference is that must only use this function from within
27608 * a testcase function. The second difference is that you need not free
27609 * the return value -- it will be automatically freed when the testcase
27610 * finishes running.
27612 * It is safe to use this function from a thread inside of a testcase
27613 * but you must ensure that all such uses occur before the main testcase
27614 * function returns (ie: it is best to ensure that all threads have been
27617 * Returns: the path, automatically freed at the end of the testcase
27625 * Get the toplevel test suite for the test path API.
27627 * Returns: the toplevel #GTestSuite
27633 * g_test_incomplete:
27634 * @msg: (allow-none): explanation
27636 * Indicates that a test failed because of some incomplete
27637 * functionality. This function can be called multiple times
27638 * from the same test.
27640 * Calling this function will not stop the test from running, you
27641 * need to return from the test function yourself. So you can
27642 * produce additional diagnostic messages or even continue running
27645 * If not called from inside a test, this function does nothing.
27653 * @argc: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
27654 * @argv: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
27655 * @...: Reserved for future extension. Currently, you must pass %NULL.
27657 * Initialize the GLib testing framework, e.g. by seeding the
27658 * test random number generator, the name for g_get_prgname()
27659 * and parsing test related command line args.
27660 * So far, the following arguments are understood:
27663 * <term><option>-l</option></term>
27665 * List test cases available in a test executable.
27666 * </para></listitem>
27669 * <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
27671 * Provide a random seed to reproduce test runs using random numbers.
27672 * </para></listitem>
27675 * <term><option>--verbose</option></term>
27676 * <listitem><para>Run tests verbosely.</para></listitem>
27679 * <term><option>-q</option>, <option>--quiet</option></term>
27680 * <listitem><para>Run tests quietly.</para></listitem>
27683 * <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
27685 * Execute all tests matching <replaceable>TESTPATH</replaceable>.
27686 * This can also be used to force a test to run that would otherwise
27687 * be skipped (ie, a test whose name contains "/subprocess").
27688 * </para></listitem>
27691 * <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
27693 * Execute tests according to these test modes:
27696 * <term>perf</term>
27698 * Performance tests, may take long and report results.
27699 * </para></listitem>
27702 * <term>slow, thorough</term>
27704 * Slow and thorough tests, may take quite long and
27705 * maximize coverage.
27706 * </para></listitem>
27709 * <term>quick</term>
27711 * Quick tests, should run really quickly and give good coverage.
27712 * </para></listitem>
27715 * <term>undefined</term>
27717 * Tests for undefined behaviour, may provoke programming errors
27718 * under g_test_trap_subprocess() or g_test_expect_messages() to check
27719 * that appropriate assertions or warnings are given
27720 * </para></listitem>
27723 * <term>no-undefined</term>
27725 * Avoid tests for undefined behaviour
27726 * </para></listitem>
27729 * </para></listitem>
27732 * <term><option>--debug-log</option></term>
27733 * <listitem><para>Debug test logging output.</para></listitem>
27742 * g_test_initialized:
27744 * Returns %TRUE if g_test_init() has been called.
27746 * Returns: %TRUE if g_test_init() has been called.
27752 * g_test_log_buffer_free:
27754 * Internal function for gtester to free test log messages, no ABI guarantees provided.
27759 * g_test_log_buffer_new:
27761 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27766 * g_test_log_buffer_pop:
27768 * Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
27773 * g_test_log_buffer_push:
27775 * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27780 * g_test_log_msg_free:
27782 * Internal function for gtester to free test log messages, no ABI guarantees provided.
27787 * g_test_log_set_fatal_handler:
27788 * @log_func: the log handler function.
27789 * @user_data: data passed to the log handler.
27791 * Installs a non-error fatal log handler which can be
27792 * used to decide whether log messages which are counted
27793 * as fatal abort the program.
27795 * The use case here is that you are running a test case
27796 * that depends on particular libraries or circumstances
27797 * and cannot prevent certain known critical or warning
27798 * messages. So you install a handler that compares the
27799 * domain and message to precisely not abort in such a case.
27801 * Note that the handler is reset at the beginning of
27802 * any test case, so you have to set it inside each test
27803 * function which needs the special behavior.
27805 * This handler has no effect on g_error messages.
27812 * g_test_maximized_result:
27813 * @maximized_quantity: the reported value
27814 * @format: the format string of the report message
27815 * @...: arguments to pass to the printf() function
27817 * Report the result of a performance or measurement test.
27818 * The test should generally strive to maximize the reported
27819 * quantities (larger values are better than smaller ones),
27820 * this and @maximized_quantity can determine sorting
27821 * order for test result reports.
27829 * @format: the format string
27830 * @...: printf-like arguments to @format
27832 * Add a message to the test report.
27839 * g_test_minimized_result:
27840 * @minimized_quantity: the reported value
27841 * @format: the format string of the report message
27842 * @...: arguments to pass to the printf() function
27844 * Report the result of a performance or measurement test.
27845 * The test should generally strive to minimize the reported
27846 * quantities (smaller values are better than larger ones),
27847 * this and @minimized_quantity can determine sorting
27848 * order for test result reports.
27857 * Returns %TRUE if tests are run in performance mode.
27859 * Returns: %TRUE if in performance mode
27864 * g_test_queue_destroy:
27865 * @destroy_func: Destroy callback for teardown phase.
27866 * @destroy_data: Destroy callback data.
27868 * This function enqueus a callback @destroy_func to be executed
27869 * during the next test case teardown phase. This is most useful
27870 * to auto destruct allocted test resources at the end of a test run.
27871 * Resources are released in reverse queue order, that means enqueueing
27872 * callback A before callback B will cause B() to be called before
27873 * A() during teardown.
27880 * g_test_queue_free:
27881 * @gfree_pointer: the pointer to be stored.
27883 * Enqueue a pointer to be released with g_free() during the next
27884 * teardown phase. This is equivalent to calling g_test_queue_destroy()
27885 * with a destroy callback of g_free().
27892 * g_test_queue_unref:
27893 * @gobject: the object to unref
27895 * Enqueue an object to be released with g_object_unref() during
27896 * the next teardown phase. This is equivalent to calling
27897 * g_test_queue_destroy() with a destroy callback of g_object_unref().
27906 * Returns %TRUE if tests are run in quick mode.
27907 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
27908 * there is no "medium speed".
27910 * Returns: %TRUE if in quick mode
27917 * Returns %TRUE if tests are run in quiet mode.
27918 * The default is neither g_test_verbose() nor g_test_quiet().
27920 * Returns: %TRUE if in quiet mode
27927 * Get a reproducible random bit (0 or 1), see g_test_rand_int()
27928 * for details on test case random numbers.
27935 * g_test_rand_double:
27937 * Get a reproducible random floating point number,
27938 * see g_test_rand_int() for details on test case random numbers.
27940 * Returns: a random number from the seeded random number generator.
27946 * g_test_rand_double_range:
27947 * @range_start: the minimum value returned by this function
27948 * @range_end: the minimum value not returned by this function
27950 * Get a reproducible random floating pointer number out of a specified range,
27951 * see g_test_rand_int() for details on test case random numbers.
27953 * Returns: a number with @range_start <= number < @range_end.
27961 * Get a reproducible random integer number.
27963 * The random numbers generated by the g_test_rand_*() family of functions
27964 * change with every new test program start, unless the --seed option is
27965 * given when starting test programs.
27967 * For individual test cases however, the random number generator is
27968 * reseeded, to avoid dependencies between tests and to make --seed
27969 * effective for all test cases.
27971 * Returns: a random number from the seeded random number generator.
27977 * g_test_rand_int_range:
27978 * @begin: the minimum value returned by this function
27979 * @end: the smallest value not to be returned by this function
27981 * Get a reproducible random integer number out of a specified range,
27982 * see g_test_rand_int() for details on test case random numbers.
27984 * Returns: a number with @begin <= number < @end.
27992 * Runs all tests under the toplevel suite which can be retrieved
27993 * with g_test_get_root(). Similar to g_test_run_suite(), the test
27994 * cases to be run are filtered according to
27995 * test path arguments (-p <replaceable>testpath</replaceable>) as
27996 * parsed by g_test_init().
27997 * g_test_run_suite() or g_test_run() may only be called once
28000 * Returns: 0 on success
28006 * g_test_run_suite:
28007 * @suite: a #GTestSuite
28009 * Execute the tests within @suite and all nested #GTestSuites.
28010 * The test suites to be executed are filtered according to
28011 * test path arguments (-p <replaceable>testpath</replaceable>)
28012 * as parsed by g_test_init().
28013 * g_test_run_suite() or g_test_run() may only be called once
28016 * Returns: 0 on success
28022 * g_test_set_nonfatal_assertions:
28024 * Changes the behaviour of g_assert_cmpstr(), g_assert_cmpint(),
28025 * g_assert_cmpuint(), g_assert_cmphex(), g_assert_cmpfloat(),
28026 * g_assert_true(), g_assert_false(), g_assert_null(), g_assert_no_error(),
28027 * g_assert_error(), g_test_assert_expected_messages() and the various
28028 * g_test_trap_assert_*() macros to not abort to program, but instead
28029 * call g_test_fail() and continue.
28031 * Note that the g_assert_not_reached() and g_assert() are not
28032 * affected by this.
28034 * This function can only be called after g_test_init().
28042 * @msg: (allow-none): explanation
28044 * Indicates that a test was skipped.
28046 * Calling this function will not stop the test from running, you
28047 * need to return from the test function yourself. So you can
28048 * produce additional diagnostic messages or even continue running
28051 * If not called from inside a test, this function does nothing.
28060 * Returns %TRUE if tests are run in slow mode.
28061 * Exactly one of g_test_quick() and g_test_slow() is active in any run;
28062 * there is no "medium speed".
28064 * Returns: the opposite of g_test_quick()
28069 * g_test_subprocess:
28071 * Returns %TRUE (after g_test_init() has been called) if the test
28072 * program is running under g_test_trap_subprocess().
28074 * Returns: %TRUE if the test program is running under g_test_trap_subprocess().
28080 * g_test_suite_add:
28081 * @suite: a #GTestSuite
28082 * @test_case: a #GTestCase
28084 * Adds @test_case to @suite.
28091 * g_test_suite_add_suite:
28092 * @suite: a #GTestSuite
28093 * @nestedsuite: another #GTestSuite
28095 * Adds @nestedsuite to @suite.
28104 * Returns %TRUE if tests are run in thorough mode, equivalent to
28107 * Returns: the same thing as g_test_slow()
28112 * g_test_timer_elapsed:
28114 * Get the time since the last start of the timer with g_test_timer_start().
28116 * Returns: the time since the last start of the timer, as a double
28122 * g_test_timer_last:
28124 * Report the last result of g_test_timer_elapsed().
28126 * Returns: the last result of g_test_timer_elapsed(), as a double
28132 * g_test_timer_start:
28134 * Start a timing test. Call g_test_timer_elapsed() when the task is supposed
28135 * to be done. Call this function again to restart the timer.
28142 * g_test_trap_assert_failed:
28144 * Assert that the last test subprocess failed.
28145 * See g_test_trap_subprocess().
28147 * This is sometimes used to test situations that are formally considered to
28148 * be undefined behaviour, like inputs that fail a g_return_if_fail()
28149 * check. In these situations you should skip the entire test, including the
28150 * call to g_test_trap_subprocess(), unless g_test_undefined() returns %TRUE
28151 * to indicate that undefined behaviour may be tested.
28158 * g_test_trap_assert_passed:
28160 * Assert that the last test subprocess passed.
28161 * See g_test_trap_subprocess().
28168 * g_test_trap_assert_stderr:
28169 * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28171 * Assert that the stderr output of the last test subprocess
28172 * matches @serrpattern. See g_test_trap_subprocess().
28174 * This is sometimes used to test situations that are formally
28175 * considered to be undefined behaviour, like code that hits a
28176 * g_assert() or g_error(). In these situations you should skip the
28177 * entire test, including the call to g_test_trap_subprocess(), unless
28178 * g_test_undefined() returns %TRUE to indicate that undefined
28179 * behaviour may be tested.
28186 * g_test_trap_assert_stderr_unmatched:
28187 * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28189 * Assert that the stderr output of the last test subprocess
28190 * does not match @serrpattern. See g_test_trap_subprocess().
28197 * g_test_trap_assert_stdout:
28198 * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28200 * Assert that the stdout output of the last test subprocess matches
28201 * @soutpattern. See g_test_trap_subprocess().
28208 * g_test_trap_assert_stdout_unmatched:
28209 * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28211 * Assert that the stdout output of the last test subprocess
28212 * does not match @soutpattern. See g_test_trap_subprocess().
28219 * g_test_trap_fork:
28220 * @usec_timeout: Timeout for the forked test in micro seconds.
28221 * @test_trap_flags: Flags to modify forking behaviour.
28223 * Fork the current test program to execute a test case that might
28224 * not return or that might abort.
28226 * If @usec_timeout is non-0, the forked test case is aborted and
28227 * considered failing if its run time exceeds it.
28229 * The forking behavior can be configured with the #GTestTrapFlags flags.
28231 * In the following example, the test code forks, the forked child
28232 * process produces some sample output and exits successfully.
28233 * The forking parent process then asserts successful child program
28234 * termination and validates child program outputs.
28238 * test_fork_patterns (void)
28240 * if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
28242 * g_print ("some stdout text: somagic17\n");
28243 * g_printerr ("some stderr text: semagic43\n");
28244 * exit (0); /* successful test run */
28246 * g_test_trap_assert_passed ();
28247 * g_test_trap_assert_stdout ("*somagic17*");
28248 * g_test_trap_assert_stderr ("*semagic43*");
28252 * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
28254 * Deprecated: This function is implemented only on Unix platforms, and is not always reliable due to problems inherent in fork-without-exec. Use g_test_trap_subprocess() instead.
28259 * g_test_trap_has_passed:
28261 * Check the result of the last g_test_trap_subprocess() call.
28263 * Returns: %TRUE if the last test subprocess terminated successfully.
28269 * g_test_trap_reached_timeout:
28271 * Check the result of the last g_test_trap_subprocess() call.
28273 * Returns: %TRUE if the last test subprocess got killed due to a timeout.
28279 * g_test_trap_subprocess:
28280 * @test_path: Test to run in a subprocess
28281 * @usec_timeout: Timeout for the subprocess test in micro seconds.
28282 * @test_flags: Flags to modify subprocess behaviour.
28284 * Respawns the test program to run only @test_path in a subprocess.
28285 * This can be used for a test case that might not return, or that
28286 * might abort. @test_path will normally be the name of the parent
28287 * test, followed by "<literal>/subprocess/</literal>" and then a name
28288 * for the specific subtest (or just ending with
28289 * "<literal>/subprocess</literal>" if the test only has one child
28290 * test); tests with names of this form will automatically be skipped
28291 * in the parent process.
28293 * If @usec_timeout is non-0, the test subprocess is aborted and
28294 * considered failing if its run time exceeds it.
28296 * The subprocess behavior can be configured with the
28297 * #GTestSubprocessFlags flags.
28299 * You can use methods such as g_test_trap_assert_passed(),
28300 * g_test_trap_assert_failed(), and g_test_trap_assert_stderr() to
28301 * check the results of the subprocess. (But note that
28302 * g_test_trap_assert_stdout() and g_test_trap_assert_stderr()
28303 * cannot be used if @test_flags specifies that the child should
28304 * inherit the parent stdout/stderr.)
28306 * If your <literal>main ()</literal> needs to behave differently in
28307 * the subprocess, you can call g_test_subprocess() (after calling
28308 * g_test_init()) to see whether you are in a subprocess.
28310 * The following example tests that calling
28311 * <literal>my_object_new(1000000)</literal> will abort with an error
28316 * test_create_large_object_subprocess (void)
28318 * my_object_new (1000000);
28322 * test_create_large_object (void)
28324 * g_test_trap_subprocess ("/myobject/create_large_object/subprocess", 0, 0);
28325 * g_test_trap_assert_failed ();
28326 * g_test_trap_assert_stderr ("*ERROR*too large*");
28330 * main (int argc, char **argv)
28332 * g_test_init (&argc, &argv, NULL);
28334 * g_test_add_func ("/myobject/create_large_object",
28335 * test_create_large_object);
28336 * /* Because of the '/subprocess' in the name, this test will
28337 * * not be run by the g_test_run () call below.
28339 * g_test_add_func ("/myobject/create_large_object/subprocess",
28340 * test_create_large_object_subprocess);
28342 * return g_test_run ();
28351 * g_test_undefined:
28353 * Returns %TRUE if tests may provoke assertions and other formally-undefined
28354 * behaviour, to verify that appropriate warnings are given. It might, in some
28355 * cases, be useful to turn this off if running tests under valgrind.
28357 * Returns: %TRUE if tests may provoke programming errors
28364 * Returns %TRUE if tests are run in verbose mode.
28365 * The default is neither g_test_verbose() nor g_test_quiet().
28367 * Returns: %TRUE if in verbose mode
28373 * @retval: the return value of this thread
28375 * Terminates the current thread.
28377 * If another thread is waiting for us using g_thread_join() then the
28378 * waiting thread will be woken up and get @retval as the return value
28379 * of g_thread_join().
28381 * Calling <literal>g_thread_exit (retval)</literal> is equivalent to
28382 * returning @retval from the function @func, as given to g_thread_new().
28385 * You must only call g_thread_exit() from a thread that you created
28386 * yourself with g_thread_new() or related APIs. You must not call
28387 * this function from a thread created with another threading library
28388 * or or from within a #GThreadPool.
28395 * @thread: a #GThread
28397 * Waits until @thread finishes, i.e. the function @func, as
28398 * given to g_thread_new(), returns or g_thread_exit() is called.
28399 * If @thread has already terminated, then g_thread_join()
28400 * returns immediately.
28402 * Any thread can wait for any other thread by calling g_thread_join(),
28403 * not just its 'creator'. Calling g_thread_join() from multiple threads
28404 * for the same @thread leads to undefined behaviour.
28406 * The value returned by @func or given to g_thread_exit() is
28407 * returned by this function.
28409 * g_thread_join() consumes the reference to the passed-in @thread.
28410 * This will usually cause the #GThread struct and associated resources
28411 * to be freed. Use g_thread_ref() to obtain an extra reference if you
28412 * want to keep the GThread alive beyond the g_thread_join() call.
28414 * Returns: the return value of the thread
28420 * @name: (allow-none): an (optional) name for the new thread
28421 * @func: a function to execute in the new thread
28422 * @data: an argument to supply to the new thread
28424 * This function creates a new thread. The new thread starts by invoking
28425 * @func with the argument data. The thread will run until @func returns
28426 * or until g_thread_exit() is called from the new thread. The return value
28427 * of @func becomes the return value of the thread, which can be obtained
28428 * with g_thread_join().
28430 * The @name can be useful for discriminating threads in a debugger.
28431 * It is not used for other purposes and does not have to be unique.
28432 * Some systems restrict the length of @name to 16 bytes.
28434 * If the thread can not be created the program aborts. See
28435 * g_thread_try_new() if you want to attempt to deal with failures.
28437 * To free the struct returned by this function, use g_thread_unref().
28438 * Note that g_thread_join() implicitly unrefs the #GThread as well.
28440 * Returns: the new #GThread
28446 * g_thread_pool_free:
28447 * @pool: a #GThreadPool
28448 * @immediate: should @pool shut down immediately?
28449 * @wait_: should the function wait for all tasks to be finished?
28451 * Frees all resources allocated for @pool.
28453 * If @immediate is %TRUE, no new task is processed for @pool.
28454 * Otherwise @pool is not freed before the last task is processed.
28455 * Note however, that no thread of this pool is interrupted while
28456 * processing a task. Instead at least all still running threads
28457 * can finish their tasks before the @pool is freed.
28459 * If @wait_ is %TRUE, the functions does not return before all
28460 * tasks to be processed (dependent on @immediate, whether all
28461 * or only the currently running) are ready.
28462 * Otherwise the function returns immediately.
28464 * After calling this function @pool must not be used anymore.
28469 * g_thread_pool_get_max_idle_time:
28471 * This function will return the maximum @interval that a
28472 * thread will wait in the thread pool for new tasks before
28475 * If this function returns 0, threads waiting in the thread
28476 * pool for new work are not stopped.
28478 * Returns: the maximum @interval (milliseconds) to wait for new tasks in the thread pool before stopping the thread
28484 * g_thread_pool_get_max_threads:
28485 * @pool: a #GThreadPool
28487 * Returns the maximal number of threads for @pool.
28489 * Returns: the maximal number of threads
28494 * g_thread_pool_get_max_unused_threads:
28496 * Returns the maximal allowed number of unused threads.
28498 * Returns: the maximal number of unused threads
28503 * g_thread_pool_get_num_threads:
28504 * @pool: a #GThreadPool
28506 * Returns the number of threads currently running in @pool.
28508 * Returns: the number of threads currently running
28513 * g_thread_pool_get_num_unused_threads:
28515 * Returns the number of currently unused threads.
28517 * Returns: the number of currently unused threads
28522 * g_thread_pool_new:
28523 * @func: a function to execute in the threads of the new thread pool
28524 * @user_data: user data that is handed over to @func every time it is called
28525 * @max_threads: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
28526 * @exclusive: should this thread pool be exclusive?
28527 * @error: return location for error, or %NULL
28529 * This function creates a new thread pool.
28531 * Whenever you call g_thread_pool_push(), either a new thread is
28532 * created or an unused one is reused. At most @max_threads threads
28533 * are running concurrently for this thread pool. @max_threads = -1
28534 * allows unlimited threads to be created for this thread pool. The
28535 * newly created or reused thread now executes the function @func
28536 * with the two arguments. The first one is the parameter to
28537 * g_thread_pool_push() and the second one is @user_data.
28539 * The parameter @exclusive determines whether the thread pool owns
28540 * all threads exclusive or shares them with other thread pools.
28541 * If @exclusive is %TRUE, @max_threads threads are started
28542 * immediately and they will run exclusively for this thread pool
28543 * until it is destroyed by g_thread_pool_free(). If @exclusive is
28544 * %FALSE, threads are created when needed and shared between all
28545 * non-exclusive thread pools. This implies that @max_threads may
28546 * not be -1 for exclusive thread pools.
28548 * @error can be %NULL to ignore errors, or non-%NULL to report
28549 * errors. An error can only occur when @exclusive is set to %TRUE
28550 * and not all @max_threads threads could be created.
28552 * Returns: the new #GThreadPool
28557 * g_thread_pool_push:
28558 * @pool: a #GThreadPool
28559 * @data: a new task for @pool
28560 * @error: return location for error, or %NULL
28562 * Inserts @data into the list of tasks to be executed by @pool.
28564 * When the number of currently running threads is lower than the
28565 * maximal allowed number of threads, a new thread is started (or
28566 * reused) with the properties given to g_thread_pool_new().
28567 * Otherwise, @data stays in the queue until a thread in this pool
28568 * finishes its previous task and processes @data.
28570 * @error can be %NULL to ignore errors, or non-%NULL to report
28571 * errors. An error can only occur when a new thread couldn't be
28572 * created. In that case @data is simply appended to the queue of
28575 * Before version 2.32, this function did not return a success status.
28577 * Returns: %TRUE on success, %FALSE if an error occurred
28582 * g_thread_pool_set_max_idle_time:
28583 * @interval: the maximum @interval (in milliseconds) a thread can be idle
28585 * This function will set the maximum @interval that a thread
28586 * waiting in the pool for new tasks can be idle for before
28587 * being stopped. This function is similar to calling
28588 * g_thread_pool_stop_unused_threads() on a regular timeout,
28589 * except this is done on a per thread basis.
28591 * By setting @interval to 0, idle threads will not be stopped.
28593 * The default value is 15000 (15 seconds).
28600 * g_thread_pool_set_max_threads:
28601 * @pool: a #GThreadPool
28602 * @max_threads: a new maximal number of threads for @pool, or -1 for unlimited
28603 * @error: return location for error, or %NULL
28605 * Sets the maximal allowed number of threads for @pool.
28606 * A value of -1 means that the maximal number of threads
28607 * is unlimited. If @pool is an exclusive thread pool, setting
28608 * the maximal number of threads to -1 is not allowed.
28610 * Setting @max_threads to 0 means stopping all work for @pool.
28611 * It is effectively frozen until @max_threads is set to a non-zero
28614 * A thread is never terminated while calling @func, as supplied by
28615 * g_thread_pool_new(). Instead the maximal number of threads only
28616 * has effect for the allocation of new threads in g_thread_pool_push().
28617 * A new thread is allocated, whenever the number of currently
28618 * running threads in @pool is smaller than the maximal number.
28620 * @error can be %NULL to ignore errors, or non-%NULL to report
28621 * errors. An error can only occur when a new thread couldn't be
28624 * Before version 2.32, this function did not return a success status.
28626 * Returns: %TRUE on success, %FALSE if an error occurred
28631 * g_thread_pool_set_max_unused_threads:
28632 * @max_threads: maximal number of unused threads
28634 * Sets the maximal number of unused threads to @max_threads.
28635 * If @max_threads is -1, no limit is imposed on the number
28636 * of unused threads.
28638 * The default value is 2.
28643 * g_thread_pool_set_sort_function:
28644 * @pool: a #GThreadPool
28645 * @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.
28646 * @user_data: user data passed to @func
28648 * Sets the function used to sort the list of tasks. This allows the
28649 * tasks to be processed by a priority determined by @func, and not
28650 * just in the order in which they were added to the pool.
28652 * Note, if the maximum number of threads is more than 1, the order
28653 * that threads are executed cannot be guaranteed 100%. Threads are
28654 * scheduled by the operating system and are executed at random. It
28655 * cannot be assumed that threads are executed in the order they are
28663 * g_thread_pool_stop_unused_threads:
28665 * Stops all currently unused threads. This does not change the
28666 * maximal number of unused threads. This function can be used to
28667 * regularly stop all unused threads e.g. from g_timeout_add().
28672 * g_thread_pool_unprocessed:
28673 * @pool: a #GThreadPool
28675 * Returns the number of tasks still unprocessed in @pool.
28677 * Returns: the number of unprocessed tasks
28683 * @thread: a #GThread
28685 * Increase the reference count on @thread.
28687 * Returns: a new reference to @thread
28695 * This functions returns the #GThread corresponding to the
28696 * current thread. Note that this function does not increase
28697 * the reference count of the returned struct.
28699 * This function will return a #GThread even for threads that
28700 * were not created by GLib (i.e. those created by other threading
28701 * APIs). This may be useful for thread identification purposes
28702 * (i.e. comparisons) but you must not use GLib functions (such
28703 * as g_thread_join()) on these threads.
28705 * Returns: the #GThread representing the current thread
28710 * g_thread_supported:
28712 * This macro returns %TRUE if the thread system is initialized,
28713 * and %FALSE if it is not.
28715 * For language bindings, g_thread_get_initialized() provides
28716 * the same functionality as a function.
28718 * Returns: %TRUE, if the thread system is initialized
28723 * g_thread_try_new:
28724 * @name: (allow-none): an (optional) name for the new thread
28725 * @func: a function to execute in the new thread
28726 * @data: an argument to supply to the new thread
28727 * @error: return location for error, or %NULL
28729 * This function is the same as g_thread_new() except that
28730 * it allows for the possibility of failure.
28732 * If a thread can not be created (due to resource limits),
28733 * @error is set and %NULL is returned.
28735 * Returns: the new #GThread, or %NULL if an error occurred
28742 * @thread: a #GThread
28744 * Decrease the reference count on @thread, possibly freeing all
28745 * resources associated with it.
28747 * Note that each thread holds a reference to its #GThread while
28748 * it is running, so it is safe to drop your own reference to it
28749 * if you don't need it anymore.
28758 * Causes the calling thread to voluntarily relinquish the CPU, so
28759 * that other threads can run.
28761 * This function is often used as a method to make busy wait less evil.
28767 * @time_: a #GTimeVal
28768 * @microseconds: number of microseconds to add to @time
28770 * Adds the given number of microseconds to @time_. @microseconds can
28771 * also be negative to decrease the value of @time_.
28776 * g_time_val_from_iso8601:
28777 * @iso_date: an ISO 8601 encoded date string
28778 * @time_: (out): a #GTimeVal
28780 * Converts a string containing an ISO 8601 encoded date and time
28781 * to a #GTimeVal and puts it into @time_.
28783 * @iso_date must include year, month, day, hours, minutes, and
28784 * seconds. It can optionally include fractions of a second and a time
28785 * zone indicator. (In the absence of any time zone indication, the
28786 * timestamp is assumed to be in local time.)
28788 * Returns: %TRUE if the conversion was successful.
28794 * g_time_val_to_iso8601:
28795 * @time_: a #GTimeVal
28797 * Converts @time_ into an RFC 3339 encoded string, relative to the
28798 * Coordinated Universal Time (UTC). This is one of the many formats
28799 * allowed by ISO 8601.
28801 * ISO 8601 allows a large number of date/time formats, with or without
28802 * punctuation and optional elements. The format returned by this function
28803 * is a complete date and time, with optional punctuation included, the
28804 * UTC time zone represented as "Z", and the @tv_usec part included if
28805 * and only if it is nonzero, i.e. either
28806 * "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
28808 * This corresponds to the Internet date/time format defined by
28809 * <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
28810 * to either of the two most-precise formats defined by
28811 * <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
28812 * "Date and Time Formats"</ulink>. Both of these documents are profiles of
28815 * Use g_date_time_format() or g_strdup_printf() if a different
28816 * variation of ISO 8601 format is required.
28818 * Returns: a newly allocated string containing an ISO 8601 date
28824 * g_time_zone_adjust_time:
28825 * @tz: a #GTimeZone
28826 * @type: the #GTimeType of @time_
28827 * @time_: a pointer to a number of seconds since January 1, 1970
28829 * Finds an interval within @tz that corresponds to the given @time_,
28830 * possibly adjusting @time_ if required to fit into an interval.
28831 * The meaning of @time_ depends on @type.
28833 * This function is similar to g_time_zone_find_interval(), with the
28834 * difference that it always succeeds (by making the adjustments
28835 * described below).
28837 * In any of the cases where g_time_zone_find_interval() succeeds then
28838 * this function returns the same value, without modifying @time_.
28840 * This function may, however, modify @time_ in order to deal with
28841 * non-existent times. If the non-existent local @time_ of 02:30 were
28842 * requested on March 14th 2010 in Toronto then this function would
28843 * adjust @time_ to be 03:00 and return the interval containing the
28846 * Returns: the interval containing @time_, never -1
28852 * g_time_zone_find_interval:
28853 * @tz: a #GTimeZone
28854 * @type: the #GTimeType of @time_
28855 * @time_: a number of seconds since January 1, 1970
28857 * Finds an the interval within @tz that corresponds to the given @time_.
28858 * The meaning of @time_ depends on @type.
28860 * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
28861 * succeed (since universal time is monotonic and continuous).
28863 * Otherwise @time_ is treated is local time. The distinction between
28864 * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
28865 * the case that the given @time_ is ambiguous. In Toronto, for example,
28866 * 01:30 on November 7th 2010 occurred twice (once inside of daylight
28867 * savings time and the next, an hour later, outside of daylight savings
28868 * time). In this case, the different value of @type would result in a
28869 * different interval being returned.
28871 * It is still possible for this function to fail. In Toronto, for
28872 * example, 02:00 on March 14th 2010 does not exist (due to the leap
28873 * forward to begin daylight savings time). -1 is returned in that
28876 * Returns: the interval containing @time_, or -1 in case of failure
28882 * g_time_zone_get_abbreviation:
28883 * @tz: a #GTimeZone
28884 * @interval: an interval within the timezone
28886 * Determines the time zone abbreviation to be used during a particular
28887 * @interval of time in the time zone @tz.
28889 * For example, in Toronto this is currently "EST" during the winter
28890 * months and "EDT" during the summer months when daylight savings time
28893 * Returns: the time zone abbreviation, which belongs to @tz
28899 * g_time_zone_get_offset:
28900 * @tz: a #GTimeZone
28901 * @interval: an interval within the timezone
28903 * Determines the offset to UTC in effect during a particular @interval
28904 * of time in the time zone @tz.
28906 * The offset is the number of seconds that you add to UTC time to
28907 * arrive at local time for @tz (ie: negative numbers for time zones
28908 * west of GMT, positive numbers for east).
28910 * Returns: the number of seconds that should be added to UTC to get the local time in @tz
28916 * g_time_zone_is_dst:
28917 * @tz: a #GTimeZone
28918 * @interval: an interval within the timezone
28920 * Determines if daylight savings time is in effect during a particular
28921 * @interval of time in the time zone @tz.
28923 * Returns: %TRUE if daylight savings time is in effect
28930 * @identifier: (allow-none): a timezone identifier
28932 * Creates a #GTimeZone corresponding to @identifier.
28934 * @identifier can either be an RFC3339/ISO 8601 time offset or
28935 * something that would pass as a valid value for the
28936 * <varname>TZ</varname> environment variable (including %NULL).
28938 * In Windows, @identifier can also be the unlocalized name of a time
28939 * zone for standard time, for example "Pacific Standard Time".
28941 * Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
28942 * <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
28943 * <literal>"±hhmm"</literal> and <literal>"±hh"</literal>. Offsets are
28944 * time values to be added to Coordinated Universal Time (UTC) to get
28947 * In Unix, the <varname>TZ</varname> environment variable typically
28948 * corresponds to the name of a file in the zoneinfo database, or
28949 * string in "std offset [dst [offset],start[/time],end[/time]]"
28950 * (POSIX) format. There are no spaces in the specification. The
28951 * name of standard and daylight savings time zone must be three or more
28952 * alphabetic characters. Offsets are time values to be added to local
28953 * time to get Coordinated Universal Time (UTC) and should be
28954 * <literal>"[±]hh[[:]mm[:ss]]"</literal>. Dates are either
28955 * <literal>"Jn"</literal> (Julian day with n between 1 and 365, leap
28956 * years not counted), <literal>"n"</literal> (zero-based Julian day
28957 * with n between 0 and 365) or <literal>"Mm.w.d"</literal> (day d
28958 * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
28959 * 0 is a Sunday). Times are in local wall clock time, the default is
28962 * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
28963 * accepts POSIX format. The Windows format uses US rules for all time
28964 * zones; daylight savings time is 60 minutes behind the standard time
28965 * with date and time of change taken from Pacific Standard Time.
28966 * Offsets are time values to be added to the local time to get
28967 * Coordinated Universal Time (UTC).
28969 * g_time_zone_new_local() calls this function with the value of the
28970 * <varname>TZ</varname> environment variable. This function itself is
28971 * independent of the value of <varname>TZ</varname>, but if @identifier
28972 * is %NULL then <filename>/etc/localtime</filename> will be consulted
28973 * to discover the correct time zone on Unix and the registry will be
28974 * consulted or GetTimeZoneInformation() will be used to get the local
28975 * time zone on Windows.
28977 * If intervals are not available, only time zone rules from
28978 * <varname>TZ</varname> environment variable or other means, then they
28979 * will be computed from year 1900 to 2037. If the maximum year for the
28980 * rules is available and it is greater than 2037, then it will followed
28984 * url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
28985 * §5.6</ulink> for a precise definition of valid RFC3339 time offsets
28986 * (the <varname>time-offset</varname> expansion) and ISO 8601 for the
28987 * full list of valid time offsets. See <ulink
28988 * url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
28989 * GNU C Library manual</ulink> for an explanation of the possible
28990 * values of the <varname>TZ</varname> environment variable. See <ulink
28991 * url='http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx'>
28992 * Microsoft Time Zone Index Values</ulink> for the list of time zones
28995 * You should release the return value by calling g_time_zone_unref()
28996 * when you are done with it.
28998 * Returns: the requested timezone
29004 * g_time_zone_new_local:
29006 * Creates a #GTimeZone corresponding to local time. The local time
29007 * zone may change between invocations to this function; for example,
29008 * if the system administrator changes it.
29010 * This is equivalent to calling g_time_zone_new() with the value of the
29011 * <varname>TZ</varname> environment variable (including the possibility
29014 * You should release the return value by calling g_time_zone_unref()
29015 * when you are done with it.
29017 * Returns: the local timezone
29023 * g_time_zone_new_utc:
29025 * Creates a #GTimeZone corresponding to UTC.
29027 * This is equivalent to calling g_time_zone_new() with a value like
29028 * "Z", "UTC", "+00", etc.
29030 * You should release the return value by calling g_time_zone_unref()
29031 * when you are done with it.
29033 * Returns: the universal timezone
29040 * @tz: a #GTimeZone
29042 * Increases the reference count on @tz.
29044 * Returns: a new reference to @tz.
29050 * g_time_zone_unref:
29051 * @tz: a #GTimeZone
29053 * Decreases the reference count on @tz.
29061 * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
29062 * @function: function to call
29063 * @data: data to pass to @function
29065 * Sets a function to be called at regular intervals, with the default
29066 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
29067 * until it returns %FALSE, at which point the timeout is automatically
29068 * destroyed and the function will not be called again. The first call
29069 * to the function will be at the end of the first @interval.
29071 * Note that timeout functions may be delayed, due to the processing of other
29072 * event sources. Thus they should not be relied on for precise timing.
29073 * After each call to the timeout function, the time of the next
29074 * timeout is recalculated based on the current time and the given interval
29075 * (it does not try to 'catch up' time lost in delays).
29077 * If you want to have a timer in the "seconds" range and do not care
29078 * about the exact time of the first call of the timer, use the
29079 * g_timeout_add_seconds() function; this function allows for more
29080 * optimizations and more efficient system power usage.
29082 * This internally creates a main loop source using g_timeout_source_new()
29083 * and attaches it to the main loop context using g_source_attach(). You can
29084 * do these steps manually if you need greater control.
29086 * The interval given is in terms of monotonic time, not wall clock
29087 * time. See g_get_monotonic_time().
29089 * Returns: the ID (greater than 0) of the event source.
29094 * g_timeout_add_full:
29095 * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
29096 * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
29097 * @function: function to call
29098 * @data: data to pass to @function
29099 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
29101 * Sets a function to be called at regular intervals, with the given
29102 * priority. The function is called repeatedly until it returns
29103 * %FALSE, at which point the timeout is automatically destroyed and
29104 * the function will not be called again. The @notify function is
29105 * called when the timeout is destroyed. The first call to the
29106 * function will be at the end of the first @interval.
29108 * Note that timeout functions may be delayed, due to the processing of other
29109 * event sources. Thus they should not be relied on for precise timing.
29110 * After each call to the timeout function, the time of the next
29111 * timeout is recalculated based on the current time and the given interval
29112 * (it does not try to 'catch up' time lost in delays).
29114 * This internally creates a main loop source using g_timeout_source_new()
29115 * and attaches it to the main loop context using g_source_attach(). You can
29116 * do these steps manually if you need greater control.
29118 * The interval given in terms of monotonic time, not wall clock time.
29119 * See g_get_monotonic_time().
29121 * Returns: the ID (greater than 0) of the event source.
29122 * Rename to: g_timeout_add
29127 * g_timeout_add_seconds:
29128 * @interval: the time between calls to the function, in seconds
29129 * @function: function to call
29130 * @data: data to pass to @function
29132 * Sets a function to be called at regular intervals with the default
29133 * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
29134 * it returns %FALSE, at which point the timeout is automatically destroyed
29135 * and the function will not be called again.
29137 * This internally creates a main loop source using
29138 * g_timeout_source_new_seconds() and attaches it to the main loop context
29139 * using g_source_attach(). You can do these steps manually if you need
29140 * greater control. Also see g_timeout_add_seconds_full().
29142 * Note that the first call of the timer may not be precise for timeouts
29143 * of one second. If you need finer precision and have such a timeout,
29144 * you may want to use g_timeout_add() instead.
29146 * The interval given is in terms of monotonic time, not wall clock
29147 * time. See g_get_monotonic_time().
29149 * Returns: the ID (greater than 0) of the event source.
29155 * g_timeout_add_seconds_full:
29156 * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
29157 * @interval: the time between calls to the function, in seconds
29158 * @function: function to call
29159 * @data: data to pass to @function
29160 * @notify: (allow-none): function to call when the timeout is removed, or %NULL
29162 * Sets a function to be called at regular intervals, with @priority.
29163 * The function is called repeatedly until it returns %FALSE, at which
29164 * point the timeout is automatically destroyed and the function will
29165 * not be called again.
29167 * Unlike g_timeout_add(), this function operates at whole second granularity.
29168 * The initial starting point of the timer is determined by the implementation
29169 * and the implementation is expected to group multiple timers together so that
29170 * they fire all at the same time.
29171 * To allow this grouping, the @interval to the first timer is rounded
29172 * and can deviate up to one second from the specified interval.
29173 * Subsequent timer iterations will generally run at the specified interval.
29175 * Note that timeout functions may be delayed, due to the processing of other
29176 * event sources. Thus they should not be relied on for precise timing.
29177 * After each call to the timeout function, the time of the next
29178 * timeout is recalculated based on the current time and the given @interval
29180 * If you want timing more precise than whole seconds, use g_timeout_add()
29183 * The grouping of timers to fire at the same time results in a more power
29184 * and CPU efficient behavior so if your timer is in multiples of seconds
29185 * and you don't require the first timer exactly one second from now, the
29186 * use of g_timeout_add_seconds() is preferred over g_timeout_add().
29188 * This internally creates a main loop source using
29189 * g_timeout_source_new_seconds() and attaches it to the main loop context
29190 * using g_source_attach(). You can do these steps manually if you need
29193 * The interval given is in terms of monotonic time, not wall clock
29194 * time. See g_get_monotonic_time().
29196 * Returns: the ID (greater than 0) of the event source.
29197 * Rename to: g_timeout_add_seconds
29203 * g_timeout_source_new:
29204 * @interval: the timeout interval in milliseconds.
29206 * Creates a new timeout source.
29208 * The source will not initially be associated with any #GMainContext
29209 * and must be added to one with g_source_attach() before it will be
29212 * The interval given is in terms of monotonic time, not wall clock
29213 * time. See g_get_monotonic_time().
29215 * Returns: the newly-created timeout source
29220 * g_timeout_source_new_seconds:
29221 * @interval: the timeout interval in seconds
29223 * Creates a new timeout source.
29225 * The source will not initially be associated with any #GMainContext
29226 * and must be added to one with g_source_attach() before it will be
29229 * The scheduling granularity/accuracy of this timeout source will be
29232 * The interval given in terms of monotonic time, not wall clock time.
29233 * See g_get_monotonic_time().
29235 * Returns: the newly-created timeout source
29241 * g_timer_continue:
29242 * @timer: a #GTimer.
29244 * Resumes a timer that has previously been stopped with
29245 * g_timer_stop(). g_timer_stop() must be called before using this
29254 * @timer: a #GTimer to destroy.
29256 * Destroys a timer, freeing associated resources.
29262 * @timer: a #GTimer.
29263 * @microseconds: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
29265 * If @timer has been started but not stopped, obtains the time since
29266 * the timer was started. If @timer has been stopped, obtains the
29267 * elapsed time between the time it was started and the time it was
29268 * stopped. The return value is the number of seconds elapsed,
29269 * including any fractional part. The @microseconds out parameter is
29270 * essentially useless.
29272 * Returns: seconds elapsed as a floating point value, including any fractional part.
29279 * Creates a new timer, and starts timing (i.e. g_timer_start() is
29280 * implicitly called for you).
29282 * Returns: a new #GTimer.
29288 * @timer: a #GTimer.
29290 * This function is useless; it's fine to call g_timer_start() on an
29291 * already-started timer to reset the start time, so g_timer_reset()
29292 * serves no purpose.
29298 * @timer: a #GTimer.
29300 * Marks a start time, so that future calls to g_timer_elapsed() will
29301 * report the time since g_timer_start() was called. g_timer_new()
29302 * automatically marks the start time, so no need to call
29303 * g_timer_start() immediately after creating the timer.
29309 * @timer: a #GTimer.
29311 * Marks an end time, so calls to g_timer_elapsed() will return the
29312 * difference between this end time and the start time.
29317 * g_trash_stack_height:
29318 * @stack_p: a #GTrashStack
29320 * Returns the height of a #GTrashStack.
29322 * Note that execution of this function is of O(N) complexity
29323 * where N denotes the number of items on the stack.
29325 * Returns: the height of the stack
29330 * g_trash_stack_peek:
29331 * @stack_p: a #GTrashStack
29333 * Returns the element at the top of a #GTrashStack
29334 * which may be %NULL.
29336 * Returns: the element at the top of the stack
29341 * g_trash_stack_pop:
29342 * @stack_p: a #GTrashStack
29344 * Pops a piece of memory off a #GTrashStack.
29346 * Returns: the element at the top of the stack
29351 * g_trash_stack_push:
29352 * @stack_p: a #GTrashStack
29353 * @data_p: the piece of memory to push on the stack
29355 * Pushes a piece of memory onto a #GTrashStack.
29363 * Removes all keys and values from the #GTree and decreases its
29364 * reference count by one. If keys and/or values are dynamically
29365 * allocated, you should either free them first or create the #GTree
29366 * using g_tree_new_full(). In the latter case the destroy functions
29367 * you supplied will be called on all keys and values before destroying
29375 * @func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
29376 * @user_data: user data to pass to the function.
29378 * Calls the given function for each of the key/value pairs in the #GTree.
29379 * The function is passed the key and value of each pair, and the given
29380 * @data parameter. The tree is traversed in sorted order.
29382 * The tree may not be modified while iterating over it (you can't
29383 * add/remove items). To remove all items matching a predicate, you need
29384 * to add each item to a list in your #GTraverseFunc as you walk over
29385 * the tree, then walk the list and remove each item.
29393 * Gets the height of a #GTree.
29395 * If the #GTree contains no nodes, the height is 0.
29396 * If the #GTree contains only one root node the height is 1.
29397 * If the root node has children the height is 2, etc.
29399 * Returns: the height of the #GTree.
29406 * @key: the key to insert.
29407 * @value: the value corresponding to the key.
29409 * Inserts a key/value pair into a #GTree. If the given key already exists
29410 * in the #GTree its corresponding value is set to the new value. If you
29411 * supplied a value_destroy_func when creating the #GTree, the old value is
29412 * freed using that function. If you supplied a @key_destroy_func when
29413 * creating the #GTree, the passed key is freed using that function.
29415 * The tree is automatically 'balanced' as new key/value pairs are added,
29416 * so that the distance from the root to every leaf is as small as possible.
29423 * @key: the key to look up.
29425 * Gets the value corresponding to the given key. Since a #GTree is
29426 * automatically balanced as key/value pairs are added, key lookup is very
29429 * Returns: the value corresponding to the key, or %NULL if the key was not found.
29434 * g_tree_lookup_extended:
29436 * @lookup_key: the key to look up.
29437 * @orig_key: returns the original key.
29438 * @value: returns the value associated with the key.
29440 * Looks up a key in the #GTree, returning the original key and the
29441 * associated value and a #gboolean which is %TRUE if the key was found. This
29442 * is useful if you need to free the memory allocated for the original key,
29443 * for example before calling g_tree_remove().
29445 * Returns: %TRUE if the key was found in the #GTree.
29451 * @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.
29453 * Creates a new #GTree.
29455 * Returns: a new #GTree.
29461 * @key_compare_func: qsort()-style comparison function.
29462 * @key_compare_data: data to pass to comparison function.
29463 * @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.
29464 * @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.
29466 * Creates a new #GTree like g_tree_new() and allows to specify functions
29467 * to free the memory allocated for the key and value that get called when
29468 * removing the entry from the #GTree.
29470 * Returns: a new #GTree.
29475 * g_tree_new_with_data:
29476 * @key_compare_func: qsort()-style comparison function.
29477 * @key_compare_data: data to pass to comparison function.
29479 * Creates a new #GTree with a comparison function that accepts user data.
29480 * See g_tree_new() for more details.
29482 * Returns: a new #GTree.
29490 * Gets the number of nodes in a #GTree.
29492 * Returns: the number of nodes in the #GTree.
29500 * Increments the reference count of @tree by one. It is safe to call
29501 * this function from any thread.
29503 * Returns: the passed in #GTree.
29511 * @key: the key to remove.
29513 * Removes a key/value pair from a #GTree.
29515 * If the #GTree was created using g_tree_new_full(), the key and value
29516 * are freed using the supplied destroy functions, otherwise you have to
29517 * make sure that any dynamically allocated values are freed yourself.
29518 * If the key does not exist in the #GTree, the function does nothing.
29520 * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
29527 * @key: the key to insert.
29528 * @value: the value corresponding to the key.
29530 * Inserts a new key and value into a #GTree similar to g_tree_insert().
29531 * The difference is that if the key already exists in the #GTree, it gets
29532 * replaced by the new key. If you supplied a @value_destroy_func when
29533 * creating the #GTree, the old value is freed using that function. If you
29534 * supplied a @key_destroy_func when creating the #GTree, the old key is
29535 * freed using that function.
29537 * The tree is automatically 'balanced' as new key/value pairs are added,
29538 * so that the distance from the root to every leaf is as small as possible.
29545 * @search_func: a function used to search the #GTree
29546 * @user_data: the data passed as the second argument to @search_func
29548 * Searches a #GTree using @search_func.
29550 * The @search_func is called with a pointer to the key of a key/value
29551 * pair in the tree, and the passed in @user_data. If @search_func returns
29552 * 0 for a key/value pair, then the corresponding value is returned as
29553 * the result of g_tree_search(). If @search_func returns -1, searching
29554 * will proceed among the key/value pairs that have a smaller key; if
29555 * @search_func returns 1, searching will proceed among the key/value
29556 * pairs that have a larger key.
29558 * Returns: the value corresponding to the found key, or %NULL if the key was not found.
29565 * @key: the key to remove.
29567 * Removes a key and its associated value from a #GTree without calling
29568 * the key and value destroy functions.
29570 * If the key does not exist in the #GTree, the function does nothing.
29572 * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
29579 * @traverse_func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
29580 * @traverse_type: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
29581 * @user_data: user data to pass to the function.
29583 * Calls the given function for each node in the #GTree.
29585 * 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>.
29593 * Decrements the reference count of @tree by one. If the reference count
29594 * drops to 0, all keys and values will be destroyed (if destroy
29595 * functions were specified) and all memory allocated by @tree will be
29598 * It is safe to call this function from any thread.
29606 * @n_bytes: number of bytes to allocate.
29608 * Attempts to allocate @n_bytes, and returns %NULL on failure.
29609 * Contrast with g_malloc(), which aborts the program on failure.
29611 * Returns: the allocated memory, or %NULL.
29617 * @n_bytes: number of bytes to allocate
29619 * Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
29620 * failure. Contrast with g_malloc0(), which aborts the program on failure.
29623 * Returns: the allocated memory, or %NULL
29629 * @n_blocks: the number of blocks to allocate
29630 * @n_block_bytes: the size of each block in bytes
29632 * This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
29633 * but care is taken to detect possible overflow during multiplication.
29636 * Returns: the allocated memory, or %NULL
29642 * @n_blocks: the number of blocks to allocate
29643 * @n_block_bytes: the size of each block in bytes
29645 * This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29646 * but care is taken to detect possible overflow during multiplication.
29649 * Returns: the allocated memory, or %NULL.
29655 * @mem: (allow-none): previously-allocated memory, or %NULL.
29656 * @n_bytes: number of bytes to allocate.
29658 * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
29659 * on failure. Contrast with g_realloc(), which aborts the program
29660 * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
29662 * Returns: the allocated memory, or %NULL.
29668 * @mem: (allow-none): previously-allocated memory, or %NULL.
29669 * @n_blocks: the number of blocks to allocate
29670 * @n_block_bytes: the size of each block in bytes
29672 * This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29673 * but care is taken to detect possible overflow during multiplication.
29676 * Returns: the allocated memory, or %NULL.
29682 * @str: a UCS-4 encoded string
29683 * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29684 * @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.
29685 * @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.
29686 * @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.
29688 * Convert a string from UCS-4 to UTF-16. A 0 character will be
29689 * added to the result after the converted text.
29691 * 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.
29697 * @str: a UCS-4 encoded string
29698 * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29699 * @items_read: (allow-none): location to store number of characters read, or %NULL.
29700 * @items_written: (allow-none): location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
29701 * @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.
29703 * Convert a string from a 32-bit fixed width representation as UCS-4.
29704 * to UTF-8. The result will be terminated with a 0 byte.
29706 * 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.
29711 * g_unichar_break_type:
29712 * @c: a Unicode character
29714 * Determines the break type of @c. @c should be a Unicode character
29715 * (to derive a character from UTF-8 encoded text, use
29716 * g_utf8_get_char()). The break type is used to find word and line
29717 * breaks ("text boundaries"), Pango implements the Unicode boundary
29718 * resolution algorithms and normally you would use a function such
29719 * as pango_break() instead of caring about break types yourself.
29721 * Returns: the break type of @c
29726 * g_unichar_combining_class:
29727 * @uc: a Unicode character
29729 * Determines the canonical combining class of a Unicode character.
29731 * Returns: the combining class of the character
29737 * g_unichar_compose:
29738 * @a: a Unicode character
29739 * @b: a Unicode character
29740 * @ch: return location for the composed character
29742 * Performs a single composition step of the
29743 * Unicode canonical composition algorithm.
29745 * This function includes algorithmic Hangul Jamo composition,
29746 * but it is not exactly the inverse of g_unichar_decompose().
29747 * No composition can have either of @a or @b equal to zero.
29748 * To be precise, this function composes if and only if
29749 * there exists a Primary Composite P which is canonically
29750 * equivalent to the sequence <@a,@b>. See the Unicode
29751 * Standard for the definition of Primary Composite.
29753 * If @a and @b do not compose a new character, @ch is set to zero.
29755 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29758 * Returns: %TRUE if the characters could be composed
29764 * g_unichar_decompose:
29765 * @ch: a Unicode character
29766 * @a: return location for the first component of @ch
29767 * @b: return location for the second component of @ch
29769 * Performs a single decomposition step of the
29770 * Unicode canonical decomposition algorithm.
29772 * This function does not include compatibility
29773 * decompositions. It does, however, include algorithmic
29774 * Hangul Jamo decomposition, as well as 'singleton'
29775 * decompositions which replace a character by a single
29776 * other character. In the case of singletons *@b will
29779 * If @ch is not decomposable, *@a is set to @ch and *@b
29782 * Note that the way Unicode decomposition pairs are
29783 * defined, it is guaranteed that @b would not decompose
29784 * further, but @a may itself decompose. To get the full
29785 * canonical decomposition for @ch, one would need to
29786 * recursively call this function on @a. Or use
29787 * g_unichar_fully_decompose().
29789 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29792 * Returns: %TRUE if the character could be decomposed
29798 * g_unichar_digit_value:
29799 * @c: a Unicode character
29801 * Determines the numeric value of a character as a decimal
29804 * Returns: If @c is a decimal digit (according to g_unichar_isdigit()), its numeric value. Otherwise, -1.
29809 * g_unichar_fully_decompose:
29810 * @ch: a Unicode character.
29811 * @compat: whether perform canonical or compatibility decomposition
29812 * @result: (allow-none): location to store decomposed result, or %NULL
29813 * @result_len: length of @result
29815 * Computes the canonical or compatibility decomposition of a
29816 * Unicode character. For compatibility decomposition,
29817 * pass %TRUE for @compat; for canonical decomposition
29818 * pass %FALSE for @compat.
29820 * The decomposed sequence is placed in @result. Only up to
29821 * @result_len characters are written into @result. The length
29822 * of the full decomposition (irrespective of @result_len) is
29823 * returned by the function. For canonical decomposition,
29824 * currently all decompositions are of length at most 4, but
29825 * this may change in the future (very unlikely though).
29826 * At any rate, Unicode does guarantee that a buffer of length
29827 * 18 is always enough for both compatibility and canonical
29828 * decompositions, so that is the size recommended. This is provided
29829 * as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
29831 * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29834 * Returns: the length of the full decomposition.
29840 * g_unichar_get_mirror_char:
29841 * @ch: a Unicode character
29842 * @mirrored_ch: location to store the mirrored character
29844 * In Unicode, some characters are <firstterm>mirrored</firstterm>. This
29845 * means that their images are mirrored horizontally in text that is laid
29846 * out from right to left. For instance, "(" would become its mirror image,
29847 * ")", in right-to-left text.
29849 * If @ch has the Unicode mirrored property and there is another unicode
29850 * character that typically has a glyph that is the mirror image of @ch's
29851 * glyph and @mirrored_ch is set, it puts that character in the address
29852 * pointed to by @mirrored_ch. Otherwise the original character is put.
29854 * Returns: %TRUE if @ch has a mirrored character, %FALSE otherwise
29860 * g_unichar_get_script:
29861 * @ch: a Unicode character
29863 * Looks up the #GUnicodeScript for a particular character (as defined
29864 * by Unicode Standard Annex \#24). No check is made for @ch being a
29865 * valid Unicode character; if you pass in invalid character, the
29866 * result is undefined.
29868 * This function is equivalent to pango_script_for_unichar() and the
29869 * two are interchangeable.
29871 * Returns: the #GUnicodeScript for the character.
29877 * g_unichar_isalnum:
29878 * @c: a Unicode character
29880 * Determines whether a character is alphanumeric.
29881 * Given some UTF-8 text, obtain a character value
29882 * with g_utf8_get_char().
29884 * Returns: %TRUE if @c is an alphanumeric character
29889 * g_unichar_isalpha:
29890 * @c: a Unicode character
29892 * Determines whether a character is alphabetic (i.e. a letter).
29893 * Given some UTF-8 text, obtain a character value with
29894 * g_utf8_get_char().
29896 * Returns: %TRUE if @c is an alphabetic character
29901 * g_unichar_iscntrl:
29902 * @c: a Unicode character
29904 * Determines whether a character is a control character.
29905 * Given some UTF-8 text, obtain a character value with
29906 * g_utf8_get_char().
29908 * Returns: %TRUE if @c is a control character
29913 * g_unichar_isdefined:
29914 * @c: a Unicode character
29916 * Determines if a given character is assigned in the Unicode
29919 * Returns: %TRUE if the character has an assigned value
29924 * g_unichar_isdigit:
29925 * @c: a Unicode character
29927 * Determines whether a character is numeric (i.e. a digit). This
29928 * covers ASCII 0-9 and also digits in other languages/scripts. Given
29929 * some UTF-8 text, obtain a character value with g_utf8_get_char().
29931 * Returns: %TRUE if @c is a digit
29936 * g_unichar_isgraph:
29937 * @c: a Unicode character
29939 * Determines whether a character is printable and not a space
29940 * (returns %FALSE for control characters, format characters, and
29941 * spaces). g_unichar_isprint() is similar, but returns %TRUE for
29942 * spaces. Given some UTF-8 text, obtain a character value with
29943 * g_utf8_get_char().
29945 * Returns: %TRUE if @c is printable unless it's a space
29950 * g_unichar_islower:
29951 * @c: a Unicode character
29953 * Determines whether a character is a lowercase letter.
29954 * Given some UTF-8 text, obtain a character value with
29955 * g_utf8_get_char().
29957 * Returns: %TRUE if @c is a lowercase letter
29962 * g_unichar_ismark:
29963 * @c: a Unicode character
29965 * Determines whether a character is a mark (non-spacing mark,
29966 * combining mark, or enclosing mark in Unicode speak).
29967 * Given some UTF-8 text, obtain a character value
29968 * with g_utf8_get_char().
29970 * Note: in most cases where isalpha characters are allowed,
29971 * ismark characters should be allowed to as they are essential
29972 * for writing most European languages as well as many non-Latin
29975 * Returns: %TRUE if @c is a mark character
29981 * g_unichar_isprint:
29982 * @c: a Unicode character
29984 * Determines whether a character is printable.
29985 * Unlike g_unichar_isgraph(), returns %TRUE for spaces.
29986 * Given some UTF-8 text, obtain a character value with
29987 * g_utf8_get_char().
29989 * Returns: %TRUE if @c is printable
29994 * g_unichar_ispunct:
29995 * @c: a Unicode character
29997 * Determines whether a character is punctuation or a symbol.
29998 * Given some UTF-8 text, obtain a character value with
29999 * g_utf8_get_char().
30001 * Returns: %TRUE if @c is a punctuation or symbol character
30006 * g_unichar_isspace:
30007 * @c: a Unicode character
30009 * Determines whether a character is a space, tab, or line separator
30010 * (newline, carriage return, etc.). Given some UTF-8 text, obtain a
30011 * character value with g_utf8_get_char().
30013 * (Note: don't use this to do word breaking; you have to use
30014 * Pango or equivalent to get word breaking right, the algorithm
30015 * is fairly complex.)
30017 * Returns: %TRUE if @c is a space character
30022 * g_unichar_istitle:
30023 * @c: a Unicode character
30025 * Determines if a character is titlecase. Some characters in
30026 * Unicode which are composites, such as the DZ digraph
30027 * have three case variants instead of just two. The titlecase
30028 * form is used at the beginning of a word where only the
30029 * first letter is capitalized. The titlecase form of the DZ
30030 * digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
30032 * Returns: %TRUE if the character is titlecase
30037 * g_unichar_isupper:
30038 * @c: a Unicode character
30040 * Determines if a character is uppercase.
30042 * Returns: %TRUE if @c is an uppercase character
30047 * g_unichar_iswide:
30048 * @c: a Unicode character
30050 * Determines if a character is typically rendered in a double-width
30053 * Returns: %TRUE if the character is wide
30058 * g_unichar_iswide_cjk:
30059 * @c: a Unicode character
30061 * Determines if a character is typically rendered in a double-width
30062 * cell under legacy East Asian locales. If a character is wide according to
30063 * g_unichar_iswide(), then it is also reported wide with this function, but
30064 * the converse is not necessarily true. See the
30065 * <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
30066 * Annex #11</ulink> for details.
30068 * If a character passes the g_unichar_iswide() test then it will also pass
30069 * this test, but not the other way around. Note that some characters may
30070 * pas both this test and g_unichar_iszerowidth().
30072 * Returns: %TRUE if the character is wide in legacy East Asian locales
30078 * g_unichar_isxdigit:
30079 * @c: a Unicode character.
30081 * Determines if a character is a hexidecimal digit.
30083 * Returns: %TRUE if the character is a hexadecimal digit
30088 * g_unichar_iszerowidth:
30089 * @c: a Unicode character
30091 * Determines if a given character typically takes zero width when rendered.
30092 * The return value is %TRUE for all non-spacing and enclosing marks
30093 * (e.g., combining accents), format characters, zero-width
30094 * space, but not U+00AD SOFT HYPHEN.
30096 * A typical use of this function is with one of g_unichar_iswide() or
30097 * g_unichar_iswide_cjk() to determine the number of cells a string occupies
30098 * when displayed on a grid display (terminals). However, note that not all
30099 * terminals support zero-width rendering of zero-width marks.
30101 * Returns: %TRUE if the character has zero width
30107 * g_unichar_to_utf8:
30108 * @c: a Unicode character code
30109 * @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.
30111 * Converts a single character to UTF-8.
30113 * Returns: number of bytes written
30118 * g_unichar_tolower:
30119 * @c: a Unicode character.
30121 * Converts a character to lower case.
30123 * 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.
30128 * g_unichar_totitle:
30129 * @c: a Unicode character
30131 * Converts a character to the titlecase.
30133 * Returns: the result of converting @c to titlecase. If @c is not an uppercase or lowercase character, @c is returned unchanged.
30138 * g_unichar_toupper:
30139 * @c: a Unicode character
30141 * Converts a character to uppercase.
30143 * 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.
30149 * @c: a Unicode character
30151 * Classifies a Unicode character by type.
30153 * Returns: the type of the character.
30158 * g_unichar_validate:
30159 * @ch: a Unicode character
30161 * Checks whether @ch is a valid Unicode character. Some possible
30162 * integer values of @ch will not be valid. 0 is considered a valid
30163 * character, though it's normally a string terminator.
30165 * Returns: %TRUE if @ch is a valid Unicode character
30170 * g_unichar_xdigit_value:
30171 * @c: a Unicode character
30173 * Determines the numeric value of a character as a hexidecimal
30176 * Returns: If @c is a hex digit (according to g_unichar_isxdigit()), its numeric value. Otherwise, -1.
30181 * g_unicode_canonical_decomposition:
30182 * @ch: a Unicode character.
30183 * @result_len: location to store the length of the return value.
30185 * Computes the canonical decomposition of a Unicode character.
30187 * Returns: a newly allocated string of Unicode characters. @result_len is set to the resulting length of the string.
30188 * Deprecated: 2.30: Use the more flexible g_unichar_fully_decompose() instead.
30193 * g_unicode_canonical_ordering:
30194 * @string: a UCS-4 encoded string.
30195 * @len: the maximum length of @string to use.
30197 * Computes the canonical ordering of a string in-place.
30198 * This rearranges decomposed characters in the string
30199 * according to their combining classes. See the Unicode
30200 * manual for more information.
30205 * g_unicode_script_from_iso15924:
30206 * @iso15924: a Unicode script
30208 * Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
30209 * codes to scripts. For example, the code for Arabic is 'Arab'.
30210 * This function accepts four letter codes encoded as a @guint32 in a
30211 * big-endian fashion. That is, the code expected for Arabic is
30212 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
30214 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
30215 * representation of names of scripts</ulink> for details.
30217 * 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.
30223 * g_unicode_script_to_iso15924:
30224 * @script: a Unicode script
30226 * Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
30227 * codes to scripts. For example, the code for Arabic is 'Arab'. The
30228 * four letter codes are encoded as a @guint32 by this function in a
30229 * big-endian fashion. That is, the code returned for Arabic is
30230 * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
30232 * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
30233 * representation of names of scripts</ulink> for details.
30235 * 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.
30242 * @fd: a file descriptor
30243 * @condition: IO conditions to watch for on @fd
30244 * @function: a #GPollFDFunc
30245 * @user_data: data to pass to @function
30247 * Sets a function to be called when the IO condition, as specified by
30248 * @condition becomes true for @fd.
30250 * @function will be called when the specified IO condition becomes
30251 * %TRUE. The function is expected to clear whatever event caused the
30252 * IO condition to become true and return %TRUE in order to be notified
30253 * when it happens again. If @function returns %FALSE then the watch
30254 * will be cancelled.
30256 * The return value of this function can be passed to g_source_remove()
30257 * to cancel the watch at any time that it exists.
30259 * The source will never close the fd -- you must do it yourself.
30261 * Returns: the ID (greater than 0) of the event source
30267 * g_unix_fd_add_full:
30268 * @priority: the priority of the source
30269 * @fd: a file descriptor
30270 * @condition: IO conditions to watch for on @fd
30271 * @function: a #GUnixFDSourceFunc
30272 * @user_data: data to pass to @function
30273 * @notify: function to call when the idle is removed, or %NULL
30275 * Sets a function to be called when the IO condition, as specified by
30276 * @condition becomes true for @fd.
30278 * This is the same as g_unix_fd_add(), except that it allows you to
30279 * specify a non-default priority and a provide a #GDestroyNotify for
30282 * Returns: the ID (greater than 0) of the event source
30288 * g_unix_fd_source_new:
30289 * @fd: a file descriptor
30290 * @condition: IO conditions to watch for on @fd
30292 * Creates a #GSource to watch for a particular IO condition on a file
30295 * The source will never close the fd -- you must do it yourself.
30297 * Returns: the newly created #GSource
30303 * g_unix_open_pipe:
30304 * @fds: Array of two integers
30305 * @flags: Bitfield of file descriptor flags, see "man 2 fcntl"
30306 * @error: a #GError
30308 * Similar to the UNIX pipe() call, but on modern systems like Linux
30309 * uses the pipe2() system call, which atomically creates a pipe with
30310 * the configured flags. The only supported flag currently is
30311 * <literal>FD_CLOEXEC</literal>. If for example you want to configure
30312 * <literal>O_NONBLOCK</literal>, that must still be done separately with
30315 * <note>This function does *not* take <literal>O_CLOEXEC</literal>, it takes
30316 * <literal>FD_CLOEXEC</literal> as if for fcntl(); these are
30317 * different on Linux/glibc.</note>
30319 * Returns: %TRUE on success, %FALSE if not (and errno will be set).
30325 * g_unix_set_fd_nonblocking:
30326 * @fd: A file descriptor
30327 * @nonblock: If %TRUE, set the descriptor to be non-blocking
30328 * @error: a #GError
30330 * Control the non-blocking state of the given file descriptor,
30331 * according to @nonblock. On most systems this uses <literal>O_NONBLOCK</literal>, but
30332 * on some older ones may use <literal>O_NDELAY</literal>.
30334 * Returns: %TRUE if successful
30340 * g_unix_signal_add:
30341 * @signum: Signal number
30342 * @handler: Callback
30343 * @user_data: Data for @handler
30345 * A convenience function for g_unix_signal_source_new(), which
30346 * attaches to the default #GMainContext. You can remove the watch
30347 * using g_source_remove().
30349 * Returns: An ID (greater than 0) for the event source
30355 * g_unix_signal_add_full:
30356 * @priority: the priority of the signal source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30357 * @signum: Signal number
30358 * @handler: Callback
30359 * @user_data: Data for @handler
30360 * @notify: #GDestroyNotify for @handler
30362 * A convenience function for g_unix_signal_source_new(), which
30363 * attaches to the default #GMainContext. You can remove the watch
30364 * using g_source_remove().
30366 * Returns: An ID (greater than 0) for the event source
30367 * Rename to: g_unix_signal_add
30373 * g_unix_signal_source_new:
30374 * @signum: A signal number
30376 * Create a #GSource that will be dispatched upon delivery of the UNIX
30377 * signal @signum. In GLib versions before 2.36, only
30378 * <literal>SIGHUP</literal>, <literal>SIGINT</literal>,
30379 * <literal>SIGTERM</literal> can be monitored. In GLib 2.36,
30380 * <literal>SIGUSR1</literal> and <literal>SIGUSR2</literal> were
30383 * Note that unlike the UNIX default, all sources which have created a
30384 * watch will be dispatched, regardless of which underlying thread
30385 * invoked g_unix_signal_source_new().
30387 * For example, an effective use of this function is to handle <literal>SIGTERM</literal>
30388 * cleanly; flushing any outstanding files, and then calling
30389 * g_main_loop_quit (). It is not safe to do any of this a regular
30390 * UNIX signal handler; your handler may be invoked while malloc() or
30391 * another library function is running, causing reentrancy if you
30392 * attempt to use it from the handler. None of the GLib/GObject API
30393 * is safe against this kind of reentrancy.
30395 * The interaction of this source when combined with native UNIX
30396 * functions like sigprocmask() is not defined.
30398 * The source will not initially be associated with any #GMainContext
30399 * and must be added to one with g_source_attach() before it will be
30402 * Returns: A newly created #GSource
30409 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
30411 * A wrapper for the POSIX unlink() function. The unlink() function
30412 * deletes a name from the filesystem. If this was the last link to the
30413 * file and no processes have it opened, the diskspace occupied by the
30416 * See your C library manual for more details about unlink(). Note
30417 * that on Windows, it is in general not possible to delete files that
30418 * are open to some process, or mapped into memory.
30420 * Returns: 0 if the name was successfully deleted, -1 if an error occurred
30427 * @variable: the environment variable to remove, must not contain '='
30429 * Removes an environment variable from the environment.
30431 * Note that on some systems, when variables are overwritten, the
30432 * memory used for the previous variables and its value isn't reclaimed.
30435 * Environment variable handling in UNIX is not thread-safe, and your
30436 * program may crash if one thread calls g_unsetenv() while another
30437 * thread is calling getenv(). (And note that many functions, such as
30438 * gettext(), call getenv() internally.) This function is only safe
30439 * to use at the very start of your program, before creating any other
30440 * threads (or creating objects that create worker threads of their
30443 * If you need to set up the environment for a child process, you can
30444 * use g_get_environ() to get an environment array, modify that with
30445 * g_environ_setenv() and g_environ_unsetenv(), and then pass that
30446 * array directly to execvpe(), g_spawn_async(), or the like.
30447 * </para></warning>
30454 * g_uri_escape_string:
30455 * @unescaped: the unescaped input string.
30456 * @reserved_chars_allowed: (allow-none): a string of reserved characters that are allowed to be used, or %NULL.
30457 * @allow_utf8: %TRUE if the result can include UTF-8 characters.
30459 * Escapes a string for use in a URI.
30461 * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
30462 * characters plus dash, dot, underscore and tilde) are escaped.
30463 * But if you specify characters in @reserved_chars_allowed they are not
30464 * escaped. This is useful for the "reserved" characters in the URI
30465 * specification, since those are allowed unescaped in some portions of
30468 * Returns: an escaped version of @unescaped. The returned string should be freed when no longer needed.
30474 * g_uri_list_extract_uris:
30475 * @uri_list: an URI list
30477 * Splits an URI list conforming to the text/uri-list
30478 * mime type defined in RFC 2483 into individual URIs,
30479 * discarding any comments. The URIs are not validated.
30481 * Returns: (transfer full): a newly allocated %NULL-terminated list of strings holding the individual URIs. The array should be freed with g_strfreev().
30487 * g_uri_parse_scheme:
30488 * @uri: a valid URI.
30490 * Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
30492 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
30493 * </programlisting>
30494 * Common schemes include "file", "http", "svn+ssh", etc.
30496 * Returns: The "Scheme" component of the URI, or %NULL on error. The returned string should be freed when no longer needed.
30502 * g_uri_unescape_segment:
30503 * @escaped_string: (allow-none): A string, may be %NULL
30504 * @escaped_string_end: (allow-none): Pointer to end of @escaped_string, may be %NULL
30505 * @illegal_characters: (allow-none): An optional string of illegal characters not to be allowed, may be %NULL
30507 * Unescapes a segment of an escaped string.
30509 * If any of the characters in @illegal_characters or the character zero appears
30510 * as an escaped character in @escaped_string then that is an error and %NULL
30511 * will be returned. This is useful it you want to avoid for instance having a
30512 * slash being expanded in an escaped path element, which might confuse pathname
30515 * 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.
30521 * g_uri_unescape_string:
30522 * @escaped_string: an escaped string to be unescaped.
30523 * @illegal_characters: (allow-none): a string of illegal characters not to be allowed, or %NULL.
30525 * Unescapes a whole escaped string.
30527 * If any of the characters in @illegal_characters or the character zero appears
30528 * as an escaped character in @escaped_string then that is an error and %NULL
30529 * will be returned. This is useful it you want to avoid for instance having a
30530 * slash being expanded in an escaped path element, which might confuse pathname
30533 * Returns: an unescaped version of @escaped_string. The returned string should be freed when no longer needed.
30540 * @microseconds: number of microseconds to pause
30542 * Pauses the current thread for the given number of microseconds.
30544 * There are 1 million microseconds per second (represented by the
30545 * #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
30546 * depending on hardware and operating system; don't rely on the exact
30547 * length of the sleep.
30553 * @str: a UTF-16 encoded string
30554 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
30555 * @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.
30556 * @items_written: (allow-none): location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
30557 * @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.
30559 * Convert a string from UTF-16 to UCS-4. The result will be
30562 * 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.
30568 * @str: a UTF-16 encoded string
30569 * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
30570 * @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.
30571 * @items_written: (allow-none): location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
30572 * @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.
30574 * Convert a string from UTF-16 to UTF-8. The result will be
30575 * terminated with a 0 byte.
30577 * Note that the input is expected to be already in native endianness,
30578 * an initial byte-order-mark character is not handled specially.
30579 * g_convert() can be used to convert a byte buffer of UTF-16 data of
30580 * ambiguous endianess.
30582 * Further note that this function does not validate the result
30583 * string; it may e.g. include embedded NUL characters. The only
30584 * validation done by this function is to ensure that the input can
30585 * be correctly interpreted as UTF-16, i.e. it doesn't contain
30586 * things unpaired surrogates.
30588 * 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.
30594 * @str: a UTF-8 encoded string
30595 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30597 * Converts a string into a form that is independent of case. The
30598 * result will not correspond to any particular case, but can be
30599 * compared for equality or ordered with the results of calling
30600 * g_utf8_casefold() on other strings.
30602 * Note that calling g_utf8_casefold() followed by g_utf8_collate() is
30603 * only an approximation to the correct linguistic case insensitive
30604 * ordering, though it is a fairly good one. Getting this exactly
30605 * right would require a more sophisticated collation function that
30606 * takes case sensitivity into account. GLib does not currently
30607 * provide such a function.
30609 * Returns: a newly allocated string, that is a case independent form of @str.
30615 * @str1: a UTF-8 encoded string
30616 * @str2: a UTF-8 encoded string
30618 * Compares two strings for ordering using the linguistically
30619 * correct rules for the <link linkend="setlocale">current locale</link>.
30620 * When sorting a large number of strings, it will be significantly
30621 * faster to obtain collation keys with g_utf8_collate_key() and
30622 * compare the keys with strcmp() when sorting instead of sorting
30623 * the original strings.
30625 * Returns: < 0 if @str1 compares before @str2, 0 if they compare equal, > 0 if @str1 compares after @str2.
30630 * g_utf8_collate_key:
30631 * @str: a UTF-8 encoded string.
30632 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30634 * Converts a string into a collation key that can be compared
30635 * with other collation keys produced by the same function using
30638 * The results of comparing the collation keys of two strings
30639 * with strcmp() will always be the same as comparing the two
30640 * original keys with g_utf8_collate().
30642 * Note that this function depends on the
30643 * <link linkend="setlocale">current locale</link>.
30645 * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
30650 * g_utf8_collate_key_for_filename:
30651 * @str: a UTF-8 encoded string.
30652 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30654 * Converts a string into a collation key that can be compared
30655 * with other collation keys produced by the same function using strcmp().
30657 * In order to sort filenames correctly, this function treats the dot '.'
30658 * as a special case. Most dictionary orderings seem to consider it
30659 * insignificant, thus producing the ordering "event.c" "eventgenerator.c"
30660 * "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
30661 * would like to treat numbers intelligently so that "file1" "file10" "file5"
30662 * is sorted as "file1" "file5" "file10".
30664 * Note that this function depends on the
30665 * <link linkend="setlocale">current locale</link>.
30667 * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
30673 * g_utf8_find_next_char:
30674 * @p: a pointer to a position within a UTF-8 encoded string
30675 * @end: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
30677 * Finds the start of the next UTF-8 character in the string after @p.
30679 * @p does not have to be at the beginning of a UTF-8 character. No check
30680 * is made to see if the character found is actually valid other than
30681 * it starts with an appropriate byte.
30683 * Returns: a pointer to the found character or %NULL
30688 * g_utf8_find_prev_char:
30689 * @str: pointer to the beginning of a UTF-8 encoded string
30690 * @p: pointer to some position within @str
30692 * Given a position @p with a UTF-8 encoded string @str, find the start
30693 * of the previous UTF-8 character starting before @p. Returns %NULL if no
30694 * UTF-8 characters are present in @str before @p.
30696 * @p does not have to be at the beginning of a UTF-8 character. No check
30697 * is made to see if the character found is actually valid other than
30698 * it starts with an appropriate byte.
30700 * Returns: a pointer to the found character or %NULL.
30706 * @p: a pointer to Unicode character encoded as UTF-8
30708 * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
30709 * If @p does not point to a valid UTF-8 encoded character, results are
30710 * undefined. If you are not sure that the bytes are complete
30711 * valid Unicode characters, you should use g_utf8_get_char_validated()
30714 * Returns: the resulting character
30719 * g_utf8_get_char_validated:
30720 * @p: a pointer to Unicode character encoded as UTF-8
30721 * @max_len: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
30723 * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
30724 * This function checks for incomplete characters, for invalid characters
30725 * such as characters that are out of the range of Unicode, and for
30726 * overlong encodings of valid characters.
30728 * 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.
30733 * g_utf8_normalize:
30734 * @str: a UTF-8 encoded string.
30735 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30736 * @mode: the type of normalization to perform.
30738 * Converts a string into canonical form, standardizing
30739 * such issues as whether a character with an accent
30740 * is represented as a base character and combining
30741 * accent or as a single precomposed character. The
30742 * string has to be valid UTF-8, otherwise %NULL is
30743 * returned. You should generally call g_utf8_normalize()
30744 * before comparing two Unicode strings.
30746 * The normalization mode %G_NORMALIZE_DEFAULT only
30747 * standardizes differences that do not affect the
30748 * text content, such as the above-mentioned accent
30749 * representation. %G_NORMALIZE_ALL also standardizes
30750 * the "compatibility" characters in Unicode, such
30751 * as SUPERSCRIPT THREE to the standard forms
30752 * (in this case DIGIT THREE). Formatting information
30753 * may be lost but for most text operations such
30754 * characters should be considered the same.
30756 * %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
30757 * are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
30758 * but returned a result with composed forms rather
30759 * than a maximally decomposed form. This is often
30760 * useful if you intend to convert the string to
30761 * a legacy encoding or pass it to a system with
30762 * less capable Unicode handling.
30764 * Returns: a newly allocated string, that is the normalized form of @str, or %NULL if @str is not valid UTF-8.
30769 * g_utf8_offset_to_pointer:
30770 * @str: a UTF-8 encoded string
30771 * @offset: a character offset within @str
30773 * Converts from an integer character offset to a pointer to a position
30774 * within the string.
30776 * Since 2.10, this function allows to pass a negative @offset to
30777 * step backwards. It is usually worth stepping backwards from the end
30778 * instead of forwards if @offset is in the last fourth of the string,
30779 * since moving forward is about 3 times faster than moving backward.
30782 * This function doesn't abort when reaching the end of @str. Therefore
30783 * you should be sure that @offset is within string boundaries before
30784 * calling that function. Call g_utf8_strlen() when unsure.
30786 * This limitation exists as this function is called frequently during
30787 * text rendering and therefore has to be as fast as possible.
30790 * Returns: the resulting pointer
30795 * g_utf8_pointer_to_offset:
30796 * @str: a UTF-8 encoded string
30797 * @pos: a pointer to a position within @str
30799 * Converts from a pointer to position within a string to a integer
30800 * character offset.
30802 * Since 2.10, this function allows @pos to be before @str, and returns
30803 * a negative offset in this case.
30805 * Returns: the resulting character offset
30810 * g_utf8_prev_char:
30811 * @p: a pointer to a position within a UTF-8 encoded string
30813 * Finds the previous UTF-8 character in the string before @p.
30815 * @p does not have to be at the beginning of a UTF-8 character. No check
30816 * is made to see if the character found is actually valid other than
30817 * it starts with an appropriate byte. If @p might be the first
30818 * character of the string, you must use g_utf8_find_prev_char() instead.
30820 * Returns: a pointer to the found character.
30826 * @p: a nul-terminated UTF-8 encoded string
30827 * @len: the maximum length of @p
30828 * @c: a Unicode character
30830 * Finds the leftmost occurrence of the given Unicode character
30831 * in a UTF-8 encoded string, while limiting the search to @len bytes.
30832 * If @len is -1, allow unbounded search.
30834 * 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.
30840 * @str: a UTF-8 encoded string
30841 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30843 * Converts all Unicode characters in the string that have a case
30844 * to lowercase. The exact manner that this is done depends
30845 * on the current locale, and may result in the number of
30846 * characters in the string changing.
30848 * Returns: a newly allocated string, with all characters converted to lowercase.
30854 * @p: pointer to the start of a UTF-8 encoded string
30855 * @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
30857 * Computes the length of the string in characters, not including
30858 * the terminating nul character. If the @max'th byte falls in the
30859 * middle of a character, the last (partial) character is not counted.
30861 * Returns: the length of the string in characters
30867 * @dest: buffer to fill with characters from @src
30868 * @src: UTF-8 encoded string
30869 * @n: character count
30871 * Like the standard C strncpy() function, but
30872 * copies a given number of characters instead of a given number of
30873 * bytes. The @src string must be valid UTF-8 encoded text.
30874 * (Use g_utf8_validate() on all text before trying to use UTF-8
30875 * utility functions with it.)
30883 * @p: a nul-terminated UTF-8 encoded string
30884 * @len: the maximum length of @p
30885 * @c: a Unicode character
30887 * Find the rightmost occurrence of the given Unicode character
30888 * in a UTF-8 encoded string, while limiting the search to @len bytes.
30889 * If @len is -1, allow unbounded search.
30891 * 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.
30896 * g_utf8_strreverse:
30897 * @str: a UTF-8 encoded string
30898 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30900 * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
30901 * (Use g_utf8_validate() on all text before trying to use UTF-8
30902 * utility functions with it.)
30904 * This function is intended for programmatic uses of reversed strings.
30905 * It pays no attention to decomposed characters, combining marks, byte
30906 * order marks, directional indicators (LRM, LRO, etc) and similar
30907 * characters which might need special handling when reversing a string
30908 * for display purposes.
30910 * Note that unlike g_strreverse(), this function returns
30911 * newly-allocated memory, which should be freed with g_free() when
30912 * no longer needed.
30914 * Returns: a newly-allocated string which is the reverse of @str.
30921 * @str: a UTF-8 encoded string
30922 * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30924 * Converts all Unicode characters in the string that have a case
30925 * to uppercase. The exact manner that this is done depends
30926 * on the current locale, and may result in the number of
30927 * characters in the string increasing. (For instance, the
30928 * German ess-zet will be changed to SS.)
30930 * Returns: a newly allocated string, with all characters converted to uppercase.
30935 * g_utf8_substring:
30936 * @str: a UTF-8 encoded string
30937 * @start_pos: a character offset within @str
30938 * @end_pos: another character offset within @str
30940 * Copies a substring out of a UTF-8 encoded string.
30941 * The substring will contain @end_pos - @start_pos
30944 * Returns: a newly allocated copy of the requested substring. Free with g_free() when no longer needed.
30951 * @str: a UTF-8 encoded string
30952 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30953 * @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.
30954 * @items_written: (allow-none): location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
30955 * @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.
30957 * Convert a string from UTF-8 to a 32-bit fixed width
30958 * representation as UCS-4. A trailing 0 character will be added to the
30959 * string after the converted text.
30961 * 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.
30966 * g_utf8_to_ucs4_fast:
30967 * @str: a UTF-8 encoded string
30968 * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30969 * @items_written: (allow-none): location to store the number of characters in the result, or %NULL.
30971 * Convert a string from UTF-8 to a 32-bit fixed width
30972 * representation as UCS-4, assuming valid UTF-8 input.
30973 * This function is roughly twice as fast as g_utf8_to_ucs4()
30974 * but does no error checking on the input. A trailing 0 character
30975 * will be added to the string after the converted text.
30977 * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free().
30983 * @str: a UTF-8 encoded string
30984 * @len: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
30985 * @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.
30986 * @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.
30987 * @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.
30989 * Convert a string from UTF-8 to UTF-16. A 0 character will be
30990 * added to the result after the converted text.
30992 * 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.
30998 * @str: (array length=max_len) (element-type guint8): a pointer to character data
30999 * @max_len: max bytes to validate, or -1 to go until NUL
31000 * @end: (allow-none) (out) (transfer none): return location for end of valid data
31002 * Validates UTF-8 encoded text. @str is the text to validate;
31003 * if @str is nul-terminated, then @max_len can be -1, otherwise
31004 * @max_len should be the number of bytes to validate.
31005 * If @end is non-%NULL, then the end of the valid range
31006 * will be stored there (i.e. the start of the first invalid
31007 * character if some bytes were invalid, or the end of the text
31008 * being validated otherwise).
31010 * Note that g_utf8_validate() returns %FALSE if @max_len is
31011 * positive and any of the @max_len bytes are NUL.
31013 * Returns %TRUE if all of @str was valid. Many GLib and GTK+
31014 * routines <emphasis>require</emphasis> valid UTF-8 as input;
31015 * so data read from a file or the network should be checked
31016 * with g_utf8_validate() before doing anything else with it.
31018 * Returns: %TRUE if the text was valid UTF-8
31024 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
31025 * @utb: a pointer to a struct utimbuf.
31027 * A wrapper for the POSIX utime() function. The utime() function
31028 * sets the access and modification timestamps of a file.
31030 * See your C library manual for more details about how utime() works
31033 * Returns: 0 if the operation was successful, -1 if an error occurred
31039 * g_variant_builder_add: (skp)
31040 * @builder: a #GVariantBuilder
31041 * @format_string: a #GVariant varargs format string
31042 * @...: arguments, as per @format_string
31044 * Adds to a #GVariantBuilder.
31046 * This call is a convenience wrapper that is exactly equivalent to
31047 * calling g_variant_new() followed by g_variant_builder_add_value().
31049 * This function might be used as follows:
31053 * make_pointless_dictionary (void)
31055 * GVariantBuilder *builder;
31058 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
31059 * for (i = 0; i < 16; i++)
31063 * sprintf (buf, "%d", i);
31064 * g_variant_builder_add (builder, "{is}", i, buf);
31067 * return g_variant_builder_end (builder);
31069 * </programlisting>
31076 * g_variant_builder_add_parsed:
31077 * @builder: a #GVariantBuilder
31078 * @format: a text format #GVariant
31079 * @...: arguments as per @format
31081 * Adds to a #GVariantBuilder.
31083 * This call is a convenience wrapper that is exactly equivalent to
31084 * calling g_variant_new_parsed() followed by
31085 * g_variant_builder_add_value().
31087 * This function might be used as follows:
31091 * make_pointless_dictionary (void)
31093 * GVariantBuilder *builder;
31096 * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
31097 * g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
31098 * g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
31099 * g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
31100 * return g_variant_builder_end (builder);
31102 * </programlisting>
31109 * g_variant_builder_add_value:
31110 * @builder: a #GVariantBuilder
31111 * @value: a #GVariant
31113 * Adds @value to @builder.
31115 * It is an error to call this function in any way that would create an
31116 * inconsistent value to be constructed. Some examples of this are
31117 * putting different types of items into an array, putting the wrong
31118 * types or number of items in a tuple, putting more than one value into
31121 * If @value is a floating reference (see g_variant_ref_sink()),
31122 * the @builder instance takes ownership of @value.
31129 * g_variant_builder_clear: (skip)
31130 * @builder: a #GVariantBuilder
31132 * Releases all memory associated with a #GVariantBuilder without
31133 * freeing the #GVariantBuilder structure itself.
31135 * It typically only makes sense to do this on a stack-allocated
31136 * #GVariantBuilder if you want to abort building the value part-way
31137 * through. This function need not be called if you call
31138 * g_variant_builder_end() and it also doesn't need to be called on
31139 * builders allocated with g_variant_builder_new (see
31140 * g_variant_builder_unref() for that).
31142 * This function leaves the #GVariantBuilder structure set to all-zeros.
31143 * It is valid to call this function on either an initialised
31144 * #GVariantBuilder or one that is set to all-zeros but it is not valid
31145 * to call this function on uninitialised memory.
31152 * g_variant_builder_close:
31153 * @builder: a #GVariantBuilder
31155 * Closes the subcontainer inside the given @builder that was opened by
31156 * the most recent call to g_variant_builder_open().
31158 * It is an error to call this function in any way that would create an
31159 * inconsistent value to be constructed (ie: too few values added to the
31167 * g_variant_builder_end:
31168 * @builder: a #GVariantBuilder
31170 * Ends the builder process and returns the constructed value.
31172 * It is not permissible to use @builder in any way after this call
31173 * except for reference counting operations (in the case of a
31174 * heap-allocated #GVariantBuilder) or by reinitialising it with
31175 * g_variant_builder_init() (in the case of stack-allocated).
31177 * It is an error to call this function in any way that would create an
31178 * inconsistent value to be constructed (ie: insufficient number of
31179 * items added to a container with a specific number of children
31180 * required). It is also an error to call this function if the builder
31181 * was created with an indefinite array or maybe type and no children
31182 * have been added; in this case it is impossible to infer the type of
31185 * Returns: (transfer none): a new, floating, #GVariant
31191 * g_variant_builder_init: (skip)
31192 * @builder: a #GVariantBuilder
31193 * @type: a container type
31195 * Initialises a #GVariantBuilder structure.
31197 * @type must be non-%NULL. It specifies the type of container to
31198 * construct. It can be an indefinite type such as
31199 * %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
31200 * Maybe, array, tuple, dictionary entry and variant-typed values may be
31203 * After the builder is initialised, values are added using
31204 * g_variant_builder_add_value() or g_variant_builder_add().
31206 * After all the child values are added, g_variant_builder_end() frees
31207 * the memory associated with the builder and returns the #GVariant that
31210 * This function completely ignores the previous contents of @builder.
31211 * On one hand this means that it is valid to pass in completely
31212 * uninitialised memory. On the other hand, this means that if you are
31213 * initialising over top of an existing #GVariantBuilder you need to
31214 * first call g_variant_builder_clear() in order to avoid leaking
31217 * You must not call g_variant_builder_ref() or
31218 * g_variant_builder_unref() on a #GVariantBuilder that was initialised
31219 * with this function. If you ever pass a reference to a
31220 * #GVariantBuilder outside of the control of your own code then you
31221 * should assume that the person receiving that reference may try to use
31222 * reference counting; you should use g_variant_builder_new() instead of
31230 * g_variant_builder_new:
31231 * @type: a container type
31233 * Allocates and initialises a new #GVariantBuilder.
31235 * You should call g_variant_builder_unref() on the return value when it
31236 * is no longer needed. The memory will not be automatically freed by
31239 * In most cases it is easier to place a #GVariantBuilder directly on
31240 * the stack of the calling function and initialise it with
31241 * g_variant_builder_init().
31243 * Returns: (transfer full): a #GVariantBuilder
31249 * g_variant_builder_open:
31250 * @builder: a #GVariantBuilder
31251 * @type: a #GVariantType
31253 * Opens a subcontainer inside the given @builder. When done adding
31254 * items to the subcontainer, g_variant_builder_close() must be called.
31256 * It is an error to call this function in any way that would cause an
31257 * inconsistent value to be constructed (ie: adding too many values or
31258 * a value of an incorrect type).
31265 * g_variant_builder_ref:
31266 * @builder: a #GVariantBuilder allocated by g_variant_builder_new()
31268 * Increases the reference count on @builder.
31270 * Don't call this on stack-allocated #GVariantBuilder instances or bad
31271 * things will happen.
31273 * Returns: (transfer full): a new reference to @builder
31279 * g_variant_builder_unref:
31280 * @builder: (transfer full): a #GVariantBuilder allocated by g_variant_builder_new()
31282 * Decreases the reference count on @builder.
31284 * In the event that there are no more references, releases all memory
31285 * associated with the #GVariantBuilder.
31287 * Don't call this on stack-allocated #GVariantBuilder instances or bad
31288 * things will happen.
31295 * g_variant_byteswap:
31296 * @value: a #GVariant
31298 * Performs a byteswapping operation on the contents of @value. The
31299 * result is that all multi-byte numeric data contained in @value is
31300 * byteswapped. That includes 16, 32, and 64bit signed and unsigned
31301 * integers as well as file handles and double precision floating point
31304 * This function is an identity mapping on any value that does not
31305 * contain multi-byte numeric data. That include strings, booleans,
31306 * bytes and containers containing only these things (recursively).
31308 * The returned value is always in normal form and is marked as trusted.
31310 * Returns: (transfer full): the byteswapped form of @value
31316 * g_variant_check_format_string:
31317 * @value: a #GVariant
31318 * @format_string: a valid #GVariant format string
31319 * @copy_only: %TRUE to ensure the format string makes deep copies
31321 * Checks if calling g_variant_get() with @format_string on @value would
31322 * be valid from a type-compatibility standpoint. @format_string is
31323 * assumed to be a valid format string (from a syntactic standpoint).
31325 * If @copy_only is %TRUE then this function additionally checks that it
31326 * would be safe to call g_variant_unref() on @value immediately after
31327 * the call to g_variant_get() without invalidating the result. This is
31328 * only possible if deep copies are made (ie: there are no pointers to
31329 * the data inside of the soon-to-be-freed #GVariant instance). If this
31330 * check fails then a g_critical() is printed and %FALSE is returned.
31332 * This function is meant to be used by functions that wish to provide
31333 * varargs accessors to #GVariant values of uncertain values (eg:
31334 * g_variant_lookup() or g_menu_model_get_item_attribute()).
31336 * Returns: %TRUE if @format_string is safe to use
31342 * g_variant_classify:
31343 * @value: a #GVariant
31345 * Classifies @value according to its top-level type.
31347 * Returns: the #GVariantClass of @value
31353 * g_variant_compare:
31354 * @one: (type GVariant): a basic-typed #GVariant instance
31355 * @two: (type GVariant): a #GVariant instance of the same type
31357 * Compares @one and @two.
31359 * The types of @one and @two are #gconstpointer only to allow use of
31360 * this function with #GTree, #GPtrArray, etc. They must each be a
31363 * Comparison is only defined for basic types (ie: booleans, numbers,
31364 * strings). For booleans, %FALSE is less than %TRUE. Numbers are
31365 * ordered in the usual way. Strings are in ASCII lexographical order.
31367 * It is a programmer error to attempt to compare container values or
31368 * two values that have types that are not exactly equal. For example,
31369 * you cannot compare a 32-bit signed integer with a 32-bit unsigned
31370 * integer. Also note that this function is not particularly
31371 * well-behaved when it comes to comparison of doubles; in particular,
31372 * the handling of incomparable values (ie: NaN) is undefined.
31374 * If you only require an equality comparison, g_variant_equal() is more
31377 * Returns: negative value if a < b; zero if a = b; positive value if a > b.
31383 * g_variant_dup_bytestring:
31384 * @value: an array-of-bytes #GVariant instance
31385 * @length: (out) (allow-none) (default NULL): a pointer to a #gsize, to store the length (not including the nul terminator)
31387 * Similar to g_variant_get_bytestring() except that instead of
31388 * returning a constant string, the string is duplicated.
31390 * The return value must be freed using g_free().
31392 * Returns: (transfer full) (array zero-terminated=1 length=length) (element-type guint8): a newly allocated string
31398 * g_variant_dup_bytestring_array:
31399 * @value: an array of array of bytes #GVariant ('aay')
31400 * @length: (out) (allow-none): the length of the result, or %NULL
31402 * Gets the contents of an array of array of bytes #GVariant. This call
31403 * makes a deep copy; the return result should be released with
31406 * If @length is non-%NULL then the number of elements in the result is
31407 * stored there. In any case, the resulting array will be
31408 * %NULL-terminated.
31410 * For an empty array, @length will be set to 0 and a pointer to a
31411 * %NULL pointer will be returned.
31413 * Returns: (array length=length) (transfer full): an array of strings
31419 * g_variant_dup_objv:
31420 * @value: an array of object paths #GVariant
31421 * @length: (out) (allow-none): the length of the result, or %NULL
31423 * Gets the contents of an array of object paths #GVariant. This call
31424 * makes a deep copy; the return result should be released with
31427 * If @length is non-%NULL then the number of elements in the result
31428 * is stored there. In any case, the resulting array will be
31429 * %NULL-terminated.
31431 * For an empty array, @length will be set to 0 and a pointer to a
31432 * %NULL pointer will be returned.
31434 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
31440 * g_variant_dup_string:
31441 * @value: a string #GVariant instance
31442 * @length: (out): a pointer to a #gsize, to store the length
31444 * Similar to g_variant_get_string() except that instead of returning
31445 * a constant string, the string is duplicated.
31447 * The string will always be utf8 encoded.
31449 * The return value must be freed using g_free().
31451 * Returns: (transfer full): a newly allocated string, utf8 encoded
31457 * g_variant_dup_strv:
31458 * @value: an array of strings #GVariant
31459 * @length: (out) (allow-none): the length of the result, or %NULL
31461 * Gets the contents of an array of strings #GVariant. This call
31462 * makes a deep copy; the return result should be released with
31465 * If @length is non-%NULL then the number of elements in the result
31466 * is stored there. In any case, the resulting array will be
31467 * %NULL-terminated.
31469 * For an empty array, @length will be set to 0 and a pointer to a
31470 * %NULL pointer will be returned.
31472 * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
31479 * @one: (type GVariant): a #GVariant instance
31480 * @two: (type GVariant): a #GVariant instance
31482 * Checks if @one and @two have the same type and value.
31484 * The types of @one and @two are #gconstpointer only to allow use of
31485 * this function with #GHashTable. They must each be a #GVariant.
31487 * Returns: %TRUE if @one and @two are equal
31493 * g_variant_get: (skip)
31494 * @value: a #GVariant instance
31495 * @format_string: a #GVariant format string
31496 * @...: arguments, as per @format_string
31498 * Deconstructs a #GVariant instance.
31500 * Think of this function as an analogue to scanf().
31502 * The arguments that are expected by this function are entirely
31503 * determined by @format_string. @format_string also restricts the
31504 * permissible types of @value. It is an error to give a value with
31505 * an incompatible type. See the section on <link
31506 * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
31507 * Please note that the syntax of the format string is very likely to be
31508 * extended in the future.
31510 * @format_string determines the C types that are used for unpacking
31511 * the values and also determines if the values are copied or borrowed,
31512 * see the section on
31513 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31520 * g_variant_get_boolean:
31521 * @value: a boolean #GVariant instance
31523 * Returns the boolean value of @value.
31525 * It is an error to call this function with a @value of any type
31526 * other than %G_VARIANT_TYPE_BOOLEAN.
31528 * Returns: %TRUE or %FALSE
31534 * g_variant_get_byte:
31535 * @value: a byte #GVariant instance
31537 * Returns the byte value of @value.
31539 * It is an error to call this function with a @value of any type
31540 * other than %G_VARIANT_TYPE_BYTE.
31542 * Returns: a #guchar
31548 * g_variant_get_bytestring:
31549 * @value: an array-of-bytes #GVariant instance
31551 * Returns the string value of a #GVariant instance with an
31552 * array-of-bytes type. The string has no particular encoding.
31554 * If the array does not end with a nul terminator character, the empty
31555 * string is returned. For this reason, you can always trust that a
31556 * non-%NULL nul-terminated string will be returned by this function.
31558 * If the array contains a nul terminator character somewhere other than
31559 * the last byte then the returned string is the string, up to the first
31560 * such nul character.
31562 * It is an error to call this function with a @value that is not an
31565 * The return value remains valid as long as @value exists.
31567 * Returns: (transfer none) (array zero-terminated=1) (element-type guint8): the constant string
31573 * g_variant_get_bytestring_array:
31574 * @value: an array of array of bytes #GVariant ('aay')
31575 * @length: (out) (allow-none): the length of the result, or %NULL
31577 * Gets the contents of an array of array of bytes #GVariant. This call
31578 * makes a shallow copy; the return result should be released with
31579 * g_free(), but the individual strings must not be modified.
31581 * If @length is non-%NULL then the number of elements in the result is
31582 * stored there. In any case, the resulting array will be
31583 * %NULL-terminated.
31585 * For an empty array, @length will be set to 0 and a pointer to a
31586 * %NULL pointer will be returned.
31588 * Returns: (array length=length) (transfer container): an array of constant strings
31594 * g_variant_get_child: (skip)
31595 * @value: a container #GVariant
31596 * @index_: the index of the child to deconstruct
31597 * @format_string: a #GVariant format string
31598 * @...: arguments, as per @format_string
31600 * Reads a child item out of a container #GVariant instance and
31601 * deconstructs it according to @format_string. This call is
31602 * essentially a combination of g_variant_get_child_value() and
31605 * @format_string determines the C types that are used for unpacking
31606 * the values and also determines if the values are copied or borrowed,
31607 * see the section on
31608 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31615 * g_variant_get_child_value:
31616 * @value: a container #GVariant
31617 * @index_: the index of the child to fetch
31619 * Reads a child item out of a container #GVariant instance. This
31620 * includes variants, maybes, arrays, tuples and dictionary
31621 * entries. It is an error to call this function on any other type of
31624 * It is an error if @index_ is greater than the number of child items
31625 * in the container. See g_variant_n_children().
31627 * The returned value is never floating. You should free it with
31628 * g_variant_unref() when you're done with it.
31630 * This function is O(1).
31632 * Returns: (transfer full): the child at the specified index
31638 * g_variant_get_data:
31639 * @value: a #GVariant instance
31641 * Returns a pointer to the serialised form of a #GVariant instance.
31642 * The returned data may not be in fully-normalised form if read from an
31643 * untrusted source. The returned data must not be freed; it remains
31644 * valid for as long as @value exists.
31646 * If @value is a fixed-sized value that was deserialised from a
31647 * corrupted serialised container then %NULL may be returned. In this
31648 * case, the proper thing to do is typically to use the appropriate
31649 * number of nul bytes in place of @value. If @value is not fixed-sized
31650 * then %NULL is never returned.
31652 * In the case that @value is already in serialised form, this function
31653 * is O(1). If the value is not already in serialised form,
31654 * serialisation occurs implicitly and is approximately O(n) in the size
31657 * To deserialise the data returned by this function, in addition to the
31658 * serialised data, you must know the type of the #GVariant, and (if the
31659 * machine might be different) the endianness of the machine that stored
31660 * it. As a result, file formats or network messages that incorporate
31661 * serialised #GVariant<!---->s must include this information either
31662 * implicitly (for instance "the file always contains a
31663 * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
31664 * explicitly (by storing the type and/or endianness in addition to the
31665 * serialised data).
31667 * Returns: (transfer none): the serialised form of @value, or %NULL
31673 * g_variant_get_data_as_bytes:
31674 * @value: a #GVariant
31676 * Returns a pointer to the serialised form of a #GVariant instance.
31677 * The semantics of this function are exactly the same as
31678 * g_variant_get_data(), except that the returned #GBytes holds
31679 * a reference to the variant data.
31681 * Returns: (transfer full): A new #GBytes representing the variant data
31687 * g_variant_get_double:
31688 * @value: a double #GVariant instance
31690 * Returns the double precision floating point value of @value.
31692 * It is an error to call this function with a @value of any type
31693 * other than %G_VARIANT_TYPE_DOUBLE.
31695 * Returns: a #gdouble
31701 * g_variant_get_fixed_array:
31702 * @value: a #GVariant array with fixed-sized elements
31703 * @n_elements: (out): a pointer to the location to store the number of items
31704 * @element_size: the size of each element
31706 * Provides access to the serialised data for an array of fixed-sized
31709 * @value must be an array with fixed-sized elements. Numeric types are
31710 * fixed-size, as are tuples containing only other fixed-sized types.
31712 * @element_size must be the size of a single element in the array,
31713 * as given by the section on
31714 * <link linkend='gvariant-serialised-data-memory'>Serialised Data
31717 * In particular, arrays of these fixed-sized types can be interpreted
31718 * as an array of the given C type, with @element_size set to
31719 * <code>sizeof</code> the appropriate type:
31722 * <tgroup cols='2'>
31723 * <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
31725 * <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
31726 * <entry>#gint16 (etc.)</entry></row>
31727 * <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
31728 * <entry>#guchar (not #gboolean!)</entry></row>
31729 * <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
31730 * <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
31731 * <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
31736 * For example, if calling this function for an array of 32 bit integers,
31737 * you might say <code>sizeof (gint32)</code>. This value isn't used
31738 * except for the purpose of a double-check that the form of the
31739 * serialised data matches the caller's expectation.
31741 * @n_elements, which must be non-%NULL is set equal to the number of
31742 * items in the array.
31744 * Returns: (array length=n_elements) (transfer none): a pointer to the fixed array
31750 * g_variant_get_handle:
31751 * @value: a handle #GVariant instance
31753 * Returns the 32-bit signed integer value of @value.
31755 * It is an error to call this function with a @value of any type other
31756 * than %G_VARIANT_TYPE_HANDLE.
31758 * By convention, handles are indexes into an array of file descriptors
31759 * that are sent alongside a D-Bus message. If you're not interacting
31760 * with D-Bus, you probably don't need them.
31762 * Returns: a #gint32
31768 * g_variant_get_int16:
31769 * @value: a int16 #GVariant instance
31771 * Returns the 16-bit signed integer value of @value.
31773 * It is an error to call this function with a @value of any type
31774 * other than %G_VARIANT_TYPE_INT16.
31776 * Returns: a #gint16
31782 * g_variant_get_int32:
31783 * @value: a int32 #GVariant instance
31785 * Returns the 32-bit signed integer value of @value.
31787 * It is an error to call this function with a @value of any type
31788 * other than %G_VARIANT_TYPE_INT32.
31790 * Returns: a #gint32
31796 * g_variant_get_int64:
31797 * @value: a int64 #GVariant instance
31799 * Returns the 64-bit signed integer value of @value.
31801 * It is an error to call this function with a @value of any type
31802 * other than %G_VARIANT_TYPE_INT64.
31804 * Returns: a #gint64
31810 * g_variant_get_maybe:
31811 * @value: a maybe-typed value
31813 * Given a maybe-typed #GVariant instance, extract its value. If the
31814 * value is Nothing, then this function returns %NULL.
31816 * Returns: (allow-none) (transfer full): the contents of @value, or %NULL
31822 * g_variant_get_normal_form:
31823 * @value: a #GVariant
31825 * Gets a #GVariant instance that has the same value as @value and is
31826 * trusted to be in normal form.
31828 * If @value is already trusted to be in normal form then a new
31829 * reference to @value is returned.
31831 * If @value is not already trusted, then it is scanned to check if it
31832 * is in normal form. If it is found to be in normal form then it is
31833 * marked as trusted and a new reference to it is returned.
31835 * If @value is found not to be in normal form then a new trusted
31836 * #GVariant is created with the same value as @value.
31838 * It makes sense to call this function if you've received #GVariant
31839 * data from untrusted sources and you want to ensure your serialised
31840 * output is definitely in normal form.
31842 * Returns: (transfer full): a trusted #GVariant
31848 * g_variant_get_objv:
31849 * @value: an array of object paths #GVariant
31850 * @length: (out) (allow-none): the length of the result, or %NULL
31852 * Gets the contents of an array of object paths #GVariant. This call
31853 * makes a shallow copy; the return result should be released with
31854 * g_free(), but the individual strings must not be modified.
31856 * If @length is non-%NULL then the number of elements in the result
31857 * is stored there. In any case, the resulting array will be
31858 * %NULL-terminated.
31860 * For an empty array, @length will be set to 0 and a pointer to a
31861 * %NULL pointer will be returned.
31863 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31869 * g_variant_get_size:
31870 * @value: a #GVariant instance
31872 * Determines the number of bytes that would be required to store @value
31873 * with g_variant_store().
31875 * If @value has a fixed-sized type then this function always returned
31878 * In the case that @value is already in serialised form or the size has
31879 * already been calculated (ie: this function has been called before)
31880 * then this function is O(1). Otherwise, the size is calculated, an
31881 * operation which is approximately O(n) in the number of values
31884 * Returns: the serialised size of @value
31890 * g_variant_get_string:
31891 * @value: a string #GVariant instance
31892 * @length: (allow-none) (default 0) (out): a pointer to a #gsize, to store the length
31894 * Returns the string value of a #GVariant instance with a string
31895 * type. This includes the types %G_VARIANT_TYPE_STRING,
31896 * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
31898 * The string will always be utf8 encoded.
31900 * If @length is non-%NULL then the length of the string (in bytes) is
31901 * returned there. For trusted values, this information is already
31902 * known. For untrusted values, a strlen() will be performed.
31904 * It is an error to call this function with a @value of any type
31905 * other than those three.
31907 * The return value remains valid as long as @value exists.
31909 * Returns: (transfer none): the constant string, utf8 encoded
31915 * g_variant_get_strv:
31916 * @value: an array of strings #GVariant
31917 * @length: (out) (allow-none): the length of the result, or %NULL
31919 * Gets the contents of an array of strings #GVariant. This call
31920 * makes a shallow copy; the return result should be released with
31921 * g_free(), but the individual strings must not be modified.
31923 * If @length is non-%NULL then the number of elements in the result
31924 * is stored there. In any case, the resulting array will be
31925 * %NULL-terminated.
31927 * For an empty array, @length will be set to 0 and a pointer to a
31928 * %NULL pointer will be returned.
31930 * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31936 * g_variant_get_type:
31937 * @value: a #GVariant
31939 * Determines the type of @value.
31941 * The return value is valid for the lifetime of @value and must not
31944 * Returns: a #GVariantType
31950 * g_variant_get_type_string:
31951 * @value: a #GVariant
31953 * Returns the type string of @value. Unlike the result of calling
31954 * g_variant_type_peek_string(), this string is nul-terminated. This
31955 * string belongs to #GVariant and must not be freed.
31957 * Returns: the type string for the type of @value
31963 * g_variant_get_uint16:
31964 * @value: a uint16 #GVariant instance
31966 * Returns the 16-bit unsigned integer value of @value.
31968 * It is an error to call this function with a @value of any type
31969 * other than %G_VARIANT_TYPE_UINT16.
31971 * Returns: a #guint16
31977 * g_variant_get_uint32:
31978 * @value: a uint32 #GVariant instance
31980 * Returns the 32-bit unsigned integer value of @value.
31982 * It is an error to call this function with a @value of any type
31983 * other than %G_VARIANT_TYPE_UINT32.
31985 * Returns: a #guint32
31991 * g_variant_get_uint64:
31992 * @value: a uint64 #GVariant instance
31994 * Returns the 64-bit unsigned integer value of @value.
31996 * It is an error to call this function with a @value of any type
31997 * other than %G_VARIANT_TYPE_UINT64.
31999 * Returns: a #guint64
32005 * g_variant_get_va: (skip)
32006 * @value: a #GVariant
32007 * @format_string: a string that is prefixed with a format string
32008 * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
32009 * @app: a pointer to a #va_list
32011 * This function is intended to be used by libraries based on #GVariant
32012 * that want to provide g_variant_get()-like functionality to their
32015 * The API is more general than g_variant_get() to allow a wider range
32016 * of possible uses.
32018 * @format_string must still point to a valid format string, but it only
32019 * need to be nul-terminated if @endptr is %NULL. If @endptr is
32020 * non-%NULL then it is updated to point to the first character past the
32021 * end of the format string.
32023 * @app is a pointer to a #va_list. The arguments, according to
32024 * @format_string, are collected from this #va_list and the list is left
32025 * pointing to the argument following the last.
32027 * These two generalisations allow mixing of multiple calls to
32028 * g_variant_new_va() and g_variant_get_va() within a single actual
32029 * varargs call by the user.
32031 * @format_string determines the C types that are used for unpacking
32032 * the values and also determines if the values are copied or borrowed,
32033 * see the section on
32034 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32041 * g_variant_get_variant:
32042 * @value: a variant #GVariant instance
32044 * Unboxes @value. The result is the #GVariant instance that was
32045 * contained in @value.
32047 * Returns: (transfer full): the item contained in the variant
32054 * @value: (type GVariant): a basic #GVariant value as a #gconstpointer
32056 * Generates a hash value for a #GVariant instance.
32058 * The output of this function is guaranteed to be the same for a given
32059 * value only per-process. It may change between different processor
32060 * architectures or even different versions of GLib. Do not use this
32061 * function as a basis for building protocols or file formats.
32063 * The type of @value is #gconstpointer only to allow use of this
32064 * function with #GHashTable. @value must be a #GVariant.
32066 * Returns: a hash value corresponding to @value
32072 * g_variant_is_container:
32073 * @value: a #GVariant instance
32075 * Checks if @value is a container.
32077 * Returns: %TRUE if @value is a container
32083 * g_variant_is_floating:
32084 * @value: a #GVariant
32086 * Checks whether @value has a floating reference count.
32088 * This function should only ever be used to assert that a given variant
32089 * is or is not floating, or for debug purposes. To acquire a reference
32090 * to a variant that might be floating, always use g_variant_ref_sink()
32091 * or g_variant_take_ref().
32093 * See g_variant_ref_sink() for more information about floating reference
32096 * Returns: whether @value is floating
32102 * g_variant_is_normal_form:
32103 * @value: a #GVariant instance
32105 * Checks if @value is in normal form.
32107 * The main reason to do this is to detect if a given chunk of
32108 * serialised data is in normal form: load the data into a #GVariant
32109 * using g_variant_new_from_data() and then use this function to
32112 * If @value is found to be in normal form then it will be marked as
32113 * being trusted. If the value was already marked as being trusted then
32114 * this function will immediately return %TRUE.
32116 * Returns: %TRUE if @value is in normal form
32122 * g_variant_is_object_path:
32123 * @string: a normal C nul-terminated string
32125 * Determines if a given string is a valid D-Bus object path. You
32126 * should ensure that a string is a valid D-Bus object path before
32127 * passing it to g_variant_new_object_path().
32129 * A valid object path starts with '/' followed by zero or more
32130 * sequences of characters separated by '/' characters. Each sequence
32131 * must contain only the characters "[A-Z][a-z][0-9]_". No sequence
32132 * (including the one following the final '/' character) may be empty.
32134 * Returns: %TRUE if @string is a D-Bus object path
32140 * g_variant_is_of_type:
32141 * @value: a #GVariant instance
32142 * @type: a #GVariantType
32144 * Checks if a value has a type matching the provided type.
32146 * Returns: %TRUE if the type of @value matches @type
32152 * g_variant_is_signature:
32153 * @string: a normal C nul-terminated string
32155 * Determines if a given string is a valid D-Bus type signature. You
32156 * should ensure that a string is a valid D-Bus type signature before
32157 * passing it to g_variant_new_signature().
32159 * D-Bus type signatures consist of zero or more definite #GVariantType
32160 * strings in sequence.
32162 * Returns: %TRUE if @string is a D-Bus type signature
32168 * g_variant_iter_copy:
32169 * @iter: a #GVariantIter
32171 * Creates a new heap-allocated #GVariantIter to iterate over the
32172 * container that was being iterated over by @iter. Iteration begins on
32173 * the new iterator from the current position of the old iterator but
32174 * the two copies are independent past that point.
32176 * Use g_variant_iter_free() to free the return value when you no longer
32179 * A reference is taken to the container that @iter is iterating over
32180 * and will be releated only when g_variant_iter_free() is called.
32182 * Returns: (transfer full): a new heap-allocated #GVariantIter
32188 * g_variant_iter_free:
32189 * @iter: (transfer full): a heap-allocated #GVariantIter
32191 * Frees a heap-allocated #GVariantIter. Only call this function on
32192 * iterators that were returned by g_variant_iter_new() or
32193 * g_variant_iter_copy().
32200 * g_variant_iter_init: (skip)
32201 * @iter: a pointer to a #GVariantIter
32202 * @value: a container #GVariant
32204 * Initialises (without allocating) a #GVariantIter. @iter may be
32205 * completely uninitialised prior to this call; its old value is
32208 * The iterator remains valid for as long as @value exists, and need not
32209 * be freed in any way.
32211 * Returns: the number of items in @value
32217 * g_variant_iter_loop: (skip)
32218 * @iter: a #GVariantIter
32219 * @format_string: a GVariant format string
32220 * @...: the arguments to unpack the value into
32222 * Gets the next item in the container and unpacks it into the variable
32223 * argument list according to @format_string, returning %TRUE.
32225 * If no more items remain then %FALSE is returned.
32227 * On the first call to this function, the pointers appearing on the
32228 * variable argument list are assumed to point at uninitialised memory.
32229 * On the second and later calls, it is assumed that the same pointers
32230 * will be given and that they will point to the memory as set by the
32231 * previous call to this function. This allows the previous values to
32232 * be freed, as appropriate.
32234 * This function is intended to be used with a while loop as
32235 * demonstrated in the following example. This function can only be
32236 * used when iterating over an array. It is only valid to call this
32237 * function with a string constant for the format string and the same
32238 * string constant must be used each time. Mixing calls to this
32239 * function and g_variant_iter_next() or g_variant_iter_next_value() on
32240 * the same iterator causes undefined behavior.
32242 * If you break out of a such a while loop using g_variant_iter_loop() then
32243 * you must free or unreference all the unpacked values as you would with
32244 * g_variant_get(). Failure to do so will cause a memory leak.
32246 * See the section on <link linkend='gvariant-format-strings'>GVariant
32247 * Format Strings</link>.
32250 * <title>Memory management with g_variant_iter_loop()</title>
32252 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
32254 * iterate_dictionary (GVariant *dictionary)
32256 * GVariantIter iter;
32260 * g_variant_iter_init (&iter, dictionary);
32261 * while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
32263 * g_print ("Item '%s' has type '%s'\n", key,
32264 * g_variant_get_type_string (value));
32266 * /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
32267 * /<!-- -->* unless breaking out of this loop *<!-- -->/
32270 * </programlisting>
32273 * For most cases you should use g_variant_iter_next().
32275 * This function is really only useful when unpacking into #GVariant or
32276 * #GVariantIter in order to allow you to skip the call to
32277 * g_variant_unref() or g_variant_iter_free().
32279 * For example, if you are only looping over simple integer and string
32280 * types, g_variant_iter_next() is definitely preferred. For string
32281 * types, use the '&' prefix to avoid allocating any memory at all (and
32282 * thereby avoiding the need to free anything as well).
32284 * @format_string determines the C types that are used for unpacking
32285 * the values and also determines if the values are copied or borrowed,
32286 * see the section on
32287 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32289 * Returns: %TRUE if a value was unpacked, or %FALSE if there was no value
32295 * g_variant_iter_n_children:
32296 * @iter: a #GVariantIter
32298 * Queries the number of child items in the container that we are
32299 * iterating over. This is the total number of items -- not the number
32300 * of items remaining.
32302 * This function might be useful for preallocation of arrays.
32304 * Returns: the number of children in the container
32310 * g_variant_iter_new:
32311 * @value: a container #GVariant
32313 * Creates a heap-allocated #GVariantIter for iterating over the items
32316 * Use g_variant_iter_free() to free the return value when you no longer
32319 * A reference is taken to @value and will be released only when
32320 * g_variant_iter_free() is called.
32322 * Returns: (transfer full): a new heap-allocated #GVariantIter
32328 * g_variant_iter_next: (skip)
32329 * @iter: a #GVariantIter
32330 * @format_string: a GVariant format string
32331 * @...: the arguments to unpack the value into
32333 * Gets the next item in the container and unpacks it into the variable
32334 * argument list according to @format_string, returning %TRUE.
32336 * If no more items remain then %FALSE is returned.
32338 * All of the pointers given on the variable arguments list of this
32339 * function are assumed to point at uninitialised memory. It is the
32340 * responsibility of the caller to free all of the values returned by
32341 * the unpacking process.
32343 * See the section on <link linkend='gvariant-format-strings'>GVariant
32344 * Format Strings</link>.
32347 * <title>Memory management with g_variant_iter_next()</title>
32349 * /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
32351 * iterate_dictionary (GVariant *dictionary)
32353 * GVariantIter iter;
32357 * g_variant_iter_init (&iter, dictionary);
32358 * while (g_variant_iter_next (&iter, "{sv}", &key, &value))
32360 * g_print ("Item '%s' has type '%s'\n", key,
32361 * g_variant_get_type_string (value));
32363 * /<!-- -->* must free data for ourselves *<!-- -->/
32364 * g_variant_unref (value);
32368 * </programlisting>
32371 * For a solution that is likely to be more convenient to C programmers
32372 * when dealing with loops, see g_variant_iter_loop().
32374 * @format_string determines the C types that are used for unpacking
32375 * the values and also determines if the values are copied or borrowed,
32376 * see the section on
32377 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32379 * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value
32385 * g_variant_iter_next_value:
32386 * @iter: a #GVariantIter
32388 * Gets the next item in the container. If no more items remain then
32389 * %NULL is returned.
32391 * Use g_variant_unref() to drop your reference on the return value when
32392 * you no longer need it.
32395 * <title>Iterating with g_variant_iter_next_value()</title>
32397 * /<!-- -->* recursively iterate a container *<!-- -->/
32399 * iterate_container_recursive (GVariant *container)
32401 * GVariantIter iter;
32404 * g_variant_iter_init (&iter, container);
32405 * while ((child = g_variant_iter_next_value (&iter)))
32407 * g_print ("type '%s'\n", g_variant_get_type_string (child));
32409 * if (g_variant_is_container (child))
32410 * iterate_container_recursive (child);
32412 * g_variant_unref (child);
32415 * </programlisting>
32418 * Returns: (allow-none) (transfer full): a #GVariant, or %NULL
32424 * g_variant_lookup: (skip)
32425 * @dictionary: a dictionary #GVariant
32426 * @key: the key to lookup in the dictionary
32427 * @format_string: a GVariant format string
32428 * @...: the arguments to unpack the value into
32430 * Looks up a value in a dictionary #GVariant.
32432 * This function is a wrapper around g_variant_lookup_value() and
32433 * g_variant_get(). In the case that %NULL would have been returned,
32434 * this function returns %FALSE. Otherwise, it unpacks the returned
32435 * value and returns %TRUE.
32437 * @format_string determines the C types that are used for unpacking
32438 * the values and also determines if the values are copied or borrowed,
32439 * see the section on
32440 * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32442 * Returns: %TRUE if a value was unpacked
32448 * g_variant_lookup_value:
32449 * @dictionary: a dictionary #GVariant
32450 * @key: the key to lookup in the dictionary
32451 * @expected_type: (allow-none): a #GVariantType, or %NULL
32453 * Looks up a value in a dictionary #GVariant.
32455 * This function works with dictionaries of the type
32456 * <literal>a{s*}</literal> (and equally well with type
32457 * <literal>a{o*}</literal>, but we only further discuss the string case
32458 * for sake of clarity).
32460 * In the event that @dictionary has the type <literal>a{sv}</literal>,
32461 * the @expected_type string specifies what type of value is expected to
32462 * be inside of the variant. If the value inside the variant has a
32463 * different type then %NULL is returned. In the event that @dictionary
32464 * has a value type other than <literal>v</literal> then @expected_type
32465 * must directly match the key type and it is used to unpack the value
32466 * directly or an error occurs.
32468 * In either case, if @key is not found in @dictionary, %NULL is
32471 * If the key is found and the value has the correct type, it is
32472 * returned. If @expected_type was specified then any non-%NULL return
32473 * value will have this type.
32475 * Returns: (transfer full): the value of the dictionary key, or %NULL
32481 * g_variant_n_children:
32482 * @value: a container #GVariant
32484 * Determines the number of children in a container #GVariant instance.
32485 * This includes variants, maybes, arrays, tuples and dictionary
32486 * entries. It is an error to call this function on any other type of
32489 * For variants, the return value is always 1. For values with maybe
32490 * types, it is always zero or one. For arrays, it is the length of the
32491 * array. For tuples it is the number of tuple items (which depends
32492 * only on the type). For dictionary entries, it is always 2
32494 * This function is O(1).
32496 * Returns: the number of children in the container
32502 * g_variant_new: (skip)
32503 * @format_string: a #GVariant format string
32504 * @...: arguments, as per @format_string
32506 * Creates a new #GVariant instance.
32508 * Think of this function as an analogue to g_strdup_printf().
32510 * The type of the created instance and the arguments that are
32511 * expected by this function are determined by @format_string. See the
32512 * section on <link linkend='gvariant-format-strings'>GVariant Format
32513 * Strings</link>. Please note that the syntax of the format string is
32514 * very likely to be extended in the future.
32516 * The first character of the format string must not be '*' '?' '@' or
32517 * 'r'; in essence, a new #GVariant must always be constructed by this
32518 * function (and not merely passed through it unmodified).
32520 * Returns: a new floating #GVariant instance
32526 * g_variant_new_array:
32527 * @child_type: (allow-none): the element type of the new array
32528 * @children: (allow-none) (array length=n_children): an array of #GVariant pointers, the children
32529 * @n_children: the length of @children
32531 * Creates a new #GVariant array from @children.
32533 * @child_type must be non-%NULL if @n_children is zero. Otherwise, the
32534 * child type is determined by inspecting the first element of the
32535 * @children array. If @child_type is non-%NULL then it must be a
32538 * The items of the array are taken from the @children array. No entry
32539 * in the @children array may be %NULL.
32541 * All items in the array must have the same type, which must be the
32542 * same as @child_type, if given.
32544 * If the @children are floating references (see g_variant_ref_sink()), the
32545 * new instance takes ownership of them as if via g_variant_ref_sink().
32547 * Returns: (transfer none): a floating reference to a new #GVariant array
32553 * g_variant_new_boolean:
32554 * @value: a #gboolean value
32556 * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
32558 * Returns: (transfer none): a floating reference to a new boolean #GVariant instance
32564 * g_variant_new_byte:
32565 * @value: a #guint8 value
32567 * Creates a new byte #GVariant instance.
32569 * Returns: (transfer none): a floating reference to a new byte #GVariant instance
32575 * g_variant_new_bytestring:
32576 * @string: (array zero-terminated=1) (element-type guint8): a normal nul-terminated string in no particular encoding
32578 * Creates an array-of-bytes #GVariant with the contents of @string.
32579 * This function is just like g_variant_new_string() except that the
32580 * string need not be valid utf8.
32582 * The nul terminator character at the end of the string is stored in
32585 * Returns: (transfer none): a floating reference to a new bytestring #GVariant instance
32591 * g_variant_new_bytestring_array:
32592 * @strv: (array length=length): an array of strings
32593 * @length: the length of @strv, or -1
32595 * Constructs an array of bytestring #GVariant from the given array of
32598 * If @length is -1 then @strv is %NULL-terminated.
32600 * Returns: (transfer none): a new floating #GVariant instance
32606 * g_variant_new_dict_entry: (constructor)
32607 * @key: a basic #GVariant, the key
32608 * @value: a #GVariant, the value
32610 * Creates a new dictionary entry #GVariant. @key and @value must be
32611 * non-%NULL. @key must be a value of a basic type (ie: not a container).
32613 * If the @key or @value are floating references (see g_variant_ref_sink()),
32614 * the new instance takes ownership of them as if via g_variant_ref_sink().
32616 * Returns: (transfer none): a floating reference to a new dictionary entry #GVariant
32622 * g_variant_new_double:
32623 * @value: a #gdouble floating point value
32625 * Creates a new double #GVariant instance.
32627 * Returns: (transfer none): a floating reference to a new double #GVariant instance
32633 * g_variant_new_fixed_array:
32634 * @element_type: the #GVariantType of each element
32635 * @elements: a pointer to the fixed array of contiguous elements
32636 * @n_elements: the number of elements
32637 * @element_size: the size of each element
32639 * Provides access to the serialised data for an array of fixed-sized
32642 * @value must be an array with fixed-sized elements. Numeric types are
32643 * fixed-size as are tuples containing only other fixed-sized types.
32645 * @element_size must be the size of a single element in the array. For
32646 * example, if calling this function for an array of 32 bit integers,
32647 * you might say <code>sizeof (gint32)</code>. This value isn't used
32648 * except for the purpose of a double-check that the form of the
32649 * serialised data matches the caller's expectation.
32651 * @n_elements, which must be non-%NULL is set equal to the number of
32652 * items in the array.
32654 * Returns: (transfer none): a floating reference to a new array #GVariant instance
32660 * g_variant_new_from_bytes:
32661 * @type: a #GVariantType
32662 * @bytes: a #GBytes
32663 * @trusted: if the contents of @bytes are trusted
32665 * Constructs a new serialised-mode #GVariant instance. This is the
32666 * inner interface for creation of new serialised values that gets
32667 * called from various functions in gvariant.c.
32669 * A reference is taken on @bytes.
32671 * Returns: (transfer none): a new #GVariant with a floating reference
32677 * g_variant_new_from_data:
32678 * @type: a definite #GVariantType
32679 * @data: (array length=size) (element-type guint8): the serialised data
32680 * @size: the size of @data
32681 * @trusted: %TRUE if @data is definitely in normal form
32682 * @notify: (scope async): function to call when @data is no longer needed
32683 * @user_data: data for @notify
32685 * Creates a new #GVariant instance from serialised data.
32687 * @type is the type of #GVariant instance that will be constructed.
32688 * The interpretation of @data depends on knowing the type.
32690 * @data is not modified by this function and must remain valid with an
32691 * unchanging value until such a time as @notify is called with
32692 * @user_data. If the contents of @data change before that time then
32693 * the result is undefined.
32695 * If @data is trusted to be serialised data in normal form then
32696 * @trusted should be %TRUE. This applies to serialised data created
32697 * within this process or read from a trusted location on the disk (such
32698 * as a file installed in /usr/lib alongside your application). You
32699 * should set trusted to %FALSE if @data is read from the network, a
32700 * file in the user's home directory, etc.
32702 * If @data was not stored in this machine's native endianness, any multi-byte
32703 * numeric values in the returned variant will also be in non-native
32704 * endianness. g_variant_byteswap() can be used to recover the original values.
32706 * @notify will be called with @user_data when @data is no longer
32707 * needed. The exact time of this call is unspecified and might even be
32708 * before this function returns.
32710 * Returns: (transfer none): a new floating #GVariant of type @type
32716 * g_variant_new_handle:
32717 * @value: a #gint32 value
32719 * Creates a new handle #GVariant instance.
32721 * By convention, handles are indexes into an array of file descriptors
32722 * that are sent alongside a D-Bus message. If you're not interacting
32723 * with D-Bus, you probably don't need them.
32725 * Returns: (transfer none): a floating reference to a new handle #GVariant instance
32731 * g_variant_new_int16:
32732 * @value: a #gint16 value
32734 * Creates a new int16 #GVariant instance.
32736 * Returns: (transfer none): a floating reference to a new int16 #GVariant instance
32742 * g_variant_new_int32:
32743 * @value: a #gint32 value
32745 * Creates a new int32 #GVariant instance.
32747 * Returns: (transfer none): a floating reference to a new int32 #GVariant instance
32753 * g_variant_new_int64:
32754 * @value: a #gint64 value
32756 * Creates a new int64 #GVariant instance.
32758 * Returns: (transfer none): a floating reference to a new int64 #GVariant instance
32764 * g_variant_new_maybe:
32765 * @child_type: (allow-none): the #GVariantType of the child, or %NULL
32766 * @child: (allow-none): the child value, or %NULL
32768 * Depending on if @child is %NULL, either wraps @child inside of a
32769 * maybe container or creates a Nothing instance for the given @type.
32771 * At least one of @child_type and @child must be non-%NULL.
32772 * If @child_type is non-%NULL then it must be a definite type.
32773 * If they are both non-%NULL then @child_type must be the type
32776 * If @child is a floating reference (see g_variant_ref_sink()), the new
32777 * instance takes ownership of @child.
32779 * Returns: (transfer none): a floating reference to a new #GVariant maybe instance
32785 * g_variant_new_object_path:
32786 * @object_path: a normal C nul-terminated string
32788 * Creates a D-Bus object path #GVariant with the contents of @string.
32789 * @string must be a valid D-Bus object path. Use
32790 * g_variant_is_object_path() if you're not sure.
32792 * Returns: (transfer none): a floating reference to a new object path #GVariant instance
32798 * g_variant_new_objv:
32799 * @strv: (array length=length) (element-type utf8): an array of strings
32800 * @length: the length of @strv, or -1
32802 * Constructs an array of object paths #GVariant from the given array of
32805 * Each string must be a valid #GVariant object path; see
32806 * g_variant_is_object_path().
32808 * If @length is -1 then @strv is %NULL-terminated.
32810 * Returns: (transfer none): a new floating #GVariant instance
32816 * g_variant_new_parsed:
32817 * @format: a text format #GVariant
32818 * @...: arguments as per @format
32820 * Parses @format and returns the result.
32822 * @format must be a text format #GVariant with one extension: at any
32823 * point that a value may appear in the text, a '%' character followed
32824 * by a GVariant format string (as per g_variant_new()) may appear. In
32825 * that case, the same arguments are collected from the argument list as
32826 * g_variant_new() would have collected.
32828 * Consider this simple example:
32830 * <informalexample><programlisting>
32831 * g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
32832 * </programlisting></informalexample>
32834 * In the example, the variable argument parameters are collected and
32835 * filled in as if they were part of the original string to produce the
32836 * result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
32838 * This function is intended only to be used with @format as a string
32839 * literal. Any parse error is fatal to the calling process. If you
32840 * want to parse data from untrusted sources, use g_variant_parse().
32842 * You may not use this function to return, unmodified, a single
32843 * #GVariant pointer from the argument list. ie: @format may not solely
32844 * be anything along the lines of "%*", "%?", "\%r", or anything starting
32847 * Returns: a new floating #GVariant instance
32852 * g_variant_new_parsed_va:
32853 * @format: a text format #GVariant
32854 * @app: a pointer to a #va_list
32856 * Parses @format and returns the result.
32858 * This is the version of g_variant_new_parsed() intended to be used
32861 * The return value will be floating if it was a newly created GVariant
32862 * instance. In the case that @format simply specified the collection
32863 * of a #GVariant pointer (eg: @format was "%*") then the collected
32864 * #GVariant pointer will be returned unmodified, without adding any
32865 * additional references.
32867 * In order to behave correctly in all cases it is necessary for the
32868 * calling function to g_variant_ref_sink() the return result before
32869 * returning control to the user that originally provided the pointer.
32870 * At this point, the caller will have their own full reference to the
32871 * result. This can also be done by adding the result to a container,
32872 * or by passing it to another g_variant_new() call.
32874 * Returns: a new, usually floating, #GVariant
32879 * g_variant_new_printf: (skip)
32880 * @format_string: a printf-style format string
32881 * @...: arguments for @format_string
32883 * Creates a string-type GVariant using printf formatting.
32885 * This is similar to calling g_strdup_printf() and then
32886 * g_variant_new_string() but it saves a temporary variable and an
32887 * unnecessary copy.
32889 * Returns: (transfer none): a floating reference to a new string #GVariant instance
32895 * g_variant_new_signature:
32896 * @signature: a normal C nul-terminated string
32898 * Creates a D-Bus type signature #GVariant with the contents of
32899 * @string. @string must be a valid D-Bus type signature. Use
32900 * g_variant_is_signature() if you're not sure.
32902 * Returns: (transfer none): a floating reference to a new signature #GVariant instance
32908 * g_variant_new_string:
32909 * @string: a normal utf8 nul-terminated string
32911 * Creates a string #GVariant with the contents of @string.
32913 * @string must be valid utf8.
32915 * Returns: (transfer none): a floating reference to a new string #GVariant instance
32921 * g_variant_new_strv:
32922 * @strv: (array length=length) (element-type utf8): an array of strings
32923 * @length: the length of @strv, or -1
32925 * Constructs an array of strings #GVariant from the given array of
32928 * If @length is -1 then @strv is %NULL-terminated.
32930 * Returns: (transfer none): a new floating #GVariant instance
32936 * g_variant_new_take_string: (skip)
32937 * @string: a normal utf8 nul-terminated string
32939 * Creates a string #GVariant with the contents of @string.
32941 * @string must be valid utf8.
32943 * This function consumes @string. g_free() will be called on @string
32944 * when it is no longer required.
32946 * You must not modify or access @string in any other way after passing
32947 * it to this function. It is even possible that @string is immediately
32950 * Returns: (transfer none): a floating reference to a new string #GVariant instance
32956 * g_variant_new_tuple:
32957 * @children: (array length=n_children): the items to make the tuple out of
32958 * @n_children: the length of @children
32960 * Creates a new tuple #GVariant out of the items in @children. The
32961 * type is determined from the types of @children. No entry in the
32962 * @children array may be %NULL.
32964 * If @n_children is 0 then the unit tuple is constructed.
32966 * If the @children are floating references (see g_variant_ref_sink()), the
32967 * new instance takes ownership of them as if via g_variant_ref_sink().
32969 * Returns: (transfer none): a floating reference to a new #GVariant tuple
32975 * g_variant_new_uint16:
32976 * @value: a #guint16 value
32978 * Creates a new uint16 #GVariant instance.
32980 * Returns: (transfer none): a floating reference to a new uint16 #GVariant instance
32986 * g_variant_new_uint32:
32987 * @value: a #guint32 value
32989 * Creates a new uint32 #GVariant instance.
32991 * Returns: (transfer none): a floating reference to a new uint32 #GVariant instance
32997 * g_variant_new_uint64:
32998 * @value: a #guint64 value
33000 * Creates a new uint64 #GVariant instance.
33002 * Returns: (transfer none): a floating reference to a new uint64 #GVariant instance
33008 * g_variant_new_va: (skip)
33009 * @format_string: a string that is prefixed with a format string
33010 * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
33011 * @app: a pointer to a #va_list
33013 * This function is intended to be used by libraries based on
33014 * #GVariant that want to provide g_variant_new()-like functionality
33017 * The API is more general than g_variant_new() to allow a wider range
33018 * of possible uses.
33020 * @format_string must still point to a valid format string, but it only
33021 * needs to be nul-terminated if @endptr is %NULL. If @endptr is
33022 * non-%NULL then it is updated to point to the first character past the
33023 * end of the format string.
33025 * @app is a pointer to a #va_list. The arguments, according to
33026 * @format_string, are collected from this #va_list and the list is left
33027 * pointing to the argument following the last.
33029 * These two generalisations allow mixing of multiple calls to
33030 * g_variant_new_va() and g_variant_get_va() within a single actual
33031 * varargs call by the user.
33033 * The return value will be floating if it was a newly created GVariant
33034 * instance (for example, if the format string was "(ii)"). In the case
33035 * that the format_string was '*', '?', 'r', or a format starting with
33036 * '@' then the collected #GVariant pointer will be returned unmodified,
33037 * without adding any additional references.
33039 * In order to behave correctly in all cases it is necessary for the
33040 * calling function to g_variant_ref_sink() the return result before
33041 * returning control to the user that originally provided the pointer.
33042 * At this point, the caller will have their own full reference to the
33043 * result. This can also be done by adding the result to a container,
33044 * or by passing it to another g_variant_new() call.
33046 * Returns: a new, usually floating, #GVariant
33052 * g_variant_new_variant: (constructor)
33053 * @value: a #GVariant instance
33055 * Boxes @value. The result is a #GVariant instance representing a
33056 * variant containing the original value.
33058 * If @child is a floating reference (see g_variant_ref_sink()), the new
33059 * instance takes ownership of @child.
33061 * Returns: (transfer none): a floating reference to a new variant #GVariant instance
33068 * @type: (allow-none): a #GVariantType, or %NULL
33069 * @text: a string containing a GVariant in text form
33070 * @limit: (allow-none): a pointer to the end of @text, or %NULL
33071 * @endptr: (allow-none): a location to store the end pointer, or %NULL
33072 * @error: (allow-none): a pointer to a %NULL #GError pointer, or %NULL
33074 * Parses a #GVariant from a text representation.
33076 * A single #GVariant is parsed from the content of @text.
33078 * The format is described <link linkend='gvariant-text'>here</link>.
33080 * The memory at @limit will never be accessed and the parser behaves as
33081 * if the character at @limit is the nul terminator. This has the
33082 * effect of bounding @text.
33084 * If @endptr is non-%NULL then @text is permitted to contain data
33085 * following the value that this function parses and @endptr will be
33086 * updated to point to the first character past the end of the text
33087 * parsed by this function. If @endptr is %NULL and there is extra data
33088 * then an error is returned.
33090 * If @type is non-%NULL then the value will be parsed to have that
33091 * type. This may result in additional parse errors (in the case that
33092 * the parsed value doesn't fit the type) but may also result in fewer
33093 * errors (in the case that the type would have been ambiguous, such as
33094 * with empty arrays).
33096 * In the event that the parsing is successful, the resulting #GVariant
33099 * In case of any error, %NULL will be returned. If @error is non-%NULL
33100 * then it will be set to reflect the error that occurred.
33102 * Officially, the language understood by the parser is "any string
33103 * produced by g_variant_print()".
33105 * Returns: a reference to a #GVariant, or %NULL
33111 * @value: a #GVariant
33112 * @type_annotate: %TRUE if type information should be included in the output
33114 * Pretty-prints @value in the format understood by g_variant_parse().
33116 * The format is described <link linkend='gvariant-text'>here</link>.
33118 * If @type_annotate is %TRUE, then type information is included in
33121 * Returns: (transfer full): a newly-allocated string holding the result.
33127 * g_variant_print_string: (skip)
33128 * @value: a #GVariant
33129 * @string: (allow-none) (default NULL): a #GString, or %NULL
33130 * @type_annotate: %TRUE if type information should be included in the output
33132 * Behaves as g_variant_print(), but operates on a #GString.
33134 * If @string is non-%NULL then it is appended to and returned. Else,
33135 * a new empty #GString is allocated and it is returned.
33137 * Returns: a #GString containing the string
33144 * @value: a #GVariant
33146 * Increases the reference count of @value.
33148 * Returns: the same @value
33154 * g_variant_ref_sink:
33155 * @value: a #GVariant
33157 * #GVariant uses a floating reference count system. All functions with
33158 * names starting with <literal>g_variant_new_</literal> return floating
33161 * Calling g_variant_ref_sink() on a #GVariant with a floating reference
33162 * will convert the floating reference into a full reference. Calling
33163 * g_variant_ref_sink() on a non-floating #GVariant results in an
33164 * additional normal reference being added.
33166 * In other words, if the @value is floating, then this call "assumes
33167 * ownership" of the floating reference, converting it to a normal
33168 * reference. If the @value is not floating, then this call adds a
33169 * new normal reference increasing the reference count by one.
33171 * All calls that result in a #GVariant instance being inserted into a
33172 * container will call g_variant_ref_sink() on the instance. This means
33173 * that if the value was just created (and has only its floating
33174 * reference) then the container will assume sole ownership of the value
33175 * at that point and the caller will not need to unreference it. This
33176 * makes certain common styles of programming much easier while still
33177 * maintaining normal refcounting semantics in situations where values
33178 * are not floating.
33180 * Returns: the same @value
33187 * @value: the #GVariant to store
33188 * @data: the location to store the serialised data at
33190 * Stores the serialised form of @value at @data. @data should be
33191 * large enough. See g_variant_get_size().
33193 * The stored data is in machine native byte order but may not be in
33194 * fully-normalised form if read from an untrusted source. See
33195 * g_variant_get_normal_form() for a solution.
33197 * As with g_variant_get_data(), to be able to deserialise the
33198 * serialised variant successfully, its type and (if the destination
33199 * machine might be different) its endianness must also be available.
33201 * This function is approximately O(n) in the size of @data.
33208 * g_variant_take_ref:
33209 * @value: a #GVariant
33211 * If @value is floating, sink it. Otherwise, do nothing.
33213 * Typically you want to use g_variant_ref_sink() in order to
33214 * automatically do the correct thing with respect to floating or
33215 * non-floating references, but there is one specific scenario where
33216 * this function is helpful.
33218 * The situation where this function is helpful is when creating an API
33219 * that allows the user to provide a callback function that returns a
33220 * #GVariant. We certainly want to allow the user the flexibility to
33221 * return a non-floating reference from this callback (for the case
33222 * where the value that is being returned already exists).
33224 * At the same time, the style of the #GVariant API makes it likely that
33225 * for newly-created #GVariant instances, the user can be saved some
33226 * typing if they are allowed to return a #GVariant with a floating
33229 * Using this function on the return value of the user's callback allows
33230 * the user to do whichever is more convenient for them. The caller
33231 * will alway receives exactly one full reference to the value: either
33232 * the one that was returned in the first place, or a floating reference
33233 * that has been converted to a full reference.
33235 * This function has an odd interaction when combined with
33236 * g_variant_ref_sink() running at the same time in another thread on
33237 * the same #GVariant instance. If g_variant_ref_sink() runs first then
33238 * the result will be that the floating reference is converted to a hard
33239 * reference. If g_variant_take_ref() runs first then the result will
33240 * be that the floating reference is converted to a hard reference and
33241 * an additional reference on top of that one is added. It is best to
33242 * avoid this situation.
33244 * Returns: the same @value
33249 * g_variant_type_copy:
33250 * @type: a #GVariantType
33252 * Makes a copy of a #GVariantType. It is appropriate to call
33253 * g_variant_type_free() on the return value. @type may not be %NULL.
33255 * Returns: (transfer full): a new #GVariantType Since 2.24
33260 * g_variant_type_dup_string:
33261 * @type: a #GVariantType
33263 * Returns a newly-allocated copy of the type string corresponding to
33264 * @type. The returned string is nul-terminated. It is appropriate to
33265 * call g_free() on the return value.
33267 * Returns: (transfer full): the corresponding type string Since 2.24
33272 * g_variant_type_element:
33273 * @type: an array or maybe #GVariantType
33275 * Determines the element type of an array or maybe type.
33277 * This function may only be used with array or maybe types.
33279 * Returns: (transfer none): the element type of @type Since 2.24
33284 * g_variant_type_equal:
33285 * @type1: (type GVariantType): a #GVariantType
33286 * @type2: (type GVariantType): a #GVariantType
33288 * Compares @type1 and @type2 for equality.
33290 * Only returns %TRUE if the types are exactly equal. Even if one type
33291 * is an indefinite type and the other is a subtype of it, %FALSE will
33292 * be returned if they are not exactly equal. If you want to check for
33293 * subtypes, use g_variant_type_is_subtype_of().
33295 * The argument types of @type1 and @type2 are only #gconstpointer to
33296 * allow use with #GHashTable without function pointer casting. For
33297 * both arguments, a valid #GVariantType must be provided.
33299 * Returns: %TRUE if @type1 and @type2 are exactly equal Since 2.24
33304 * g_variant_type_first:
33305 * @type: a tuple or dictionary entry #GVariantType
33307 * Determines the first item type of a tuple or dictionary entry
33310 * This function may only be used with tuple or dictionary entry types,
33311 * but must not be used with the generic tuple type
33312 * %G_VARIANT_TYPE_TUPLE.
33314 * In the case of a dictionary entry type, this returns the type of
33317 * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
33319 * This call, together with g_variant_type_next() provides an iterator
33320 * interface over tuple and dictionary entry types.
33322 * Returns: (transfer none): the first item type of @type, or %NULL Since 2.24
33327 * g_variant_type_free:
33328 * @type: (allow-none): a #GVariantType, or %NULL
33330 * Frees a #GVariantType that was allocated with
33331 * g_variant_type_copy(), g_variant_type_new() or one of the container
33332 * type constructor functions.
33334 * In the case that @type is %NULL, this function does nothing.
33341 * g_variant_type_get_string_length:
33342 * @type: a #GVariantType
33344 * Returns the length of the type string corresponding to the given
33345 * @type. This function must be used to determine the valid extent of
33346 * the memory region returned by g_variant_type_peek_string().
33348 * Returns: the length of the corresponding type string Since 2.24
33353 * g_variant_type_hash:
33354 * @type: (type GVariantType): a #GVariantType
33358 * The argument type of @type is only #gconstpointer to allow use with
33359 * #GHashTable without function pointer casting. A valid
33360 * #GVariantType must be provided.
33362 * Returns: the hash value Since 2.24
33367 * g_variant_type_is_array:
33368 * @type: a #GVariantType
33370 * Determines if the given @type is an array type. This is true if the
33371 * type string for @type starts with an 'a'.
33373 * This function returns %TRUE for any indefinite type for which every
33374 * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
33377 * Returns: %TRUE if @type is an array type Since 2.24
33382 * g_variant_type_is_basic:
33383 * @type: a #GVariantType
33385 * Determines if the given @type is a basic type.
33387 * Basic types are booleans, bytes, integers, doubles, strings, object
33388 * paths and signatures.
33390 * Only a basic type may be used as the key of a dictionary entry.
33392 * This function returns %FALSE for all indefinite types except
33393 * %G_VARIANT_TYPE_BASIC.
33395 * Returns: %TRUE if @type is a basic type Since 2.24
33400 * g_variant_type_is_container:
33401 * @type: a #GVariantType
33403 * Determines if the given @type is a container type.
33405 * Container types are any array, maybe, tuple, or dictionary
33406 * entry types plus the variant type.
33408 * This function returns %TRUE for any indefinite type for which every
33409 * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
33412 * Returns: %TRUE if @type is a container type Since 2.24
33417 * g_variant_type_is_definite:
33418 * @type: a #GVariantType
33420 * Determines if the given @type is definite (ie: not indefinite).
33422 * A type is definite if its type string does not contain any indefinite
33423 * type characters ('*', '?', or 'r').
33425 * A #GVariant instance may not have an indefinite type, so calling
33426 * this function on the result of g_variant_get_type() will always
33427 * result in %TRUE being returned. Calling this function on an
33428 * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
33429 * %FALSE being returned.
33431 * Returns: %TRUE if @type is definite Since 2.24
33436 * g_variant_type_is_dict_entry:
33437 * @type: a #GVariantType
33439 * Determines if the given @type is a dictionary entry type. This is
33440 * true if the type string for @type starts with a '{'.
33442 * This function returns %TRUE for any indefinite type for which every
33443 * definite subtype is a dictionary entry type --
33444 * %G_VARIANT_TYPE_DICT_ENTRY, for example.
33446 * Returns: %TRUE if @type is a dictionary entry type Since 2.24
33451 * g_variant_type_is_maybe:
33452 * @type: a #GVariantType
33454 * Determines if the given @type is a maybe type. This is true if the
33455 * type string for @type starts with an 'm'.
33457 * This function returns %TRUE for any indefinite type for which every
33458 * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
33461 * Returns: %TRUE if @type is a maybe type Since 2.24
33466 * g_variant_type_is_subtype_of:
33467 * @type: a #GVariantType
33468 * @supertype: a #GVariantType
33470 * Checks if @type is a subtype of @supertype.
33472 * This function returns %TRUE if @type is a subtype of @supertype. All
33473 * types are considered to be subtypes of themselves. Aside from that,
33474 * only indefinite types can have subtypes.
33476 * Returns: %TRUE if @type is a subtype of @supertype Since 2.24
33481 * g_variant_type_is_tuple:
33482 * @type: a #GVariantType
33484 * Determines if the given @type is a tuple type. This is true if the
33485 * type string for @type starts with a '(' or if @type is
33486 * %G_VARIANT_TYPE_TUPLE.
33488 * This function returns %TRUE for any indefinite type for which every
33489 * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
33492 * Returns: %TRUE if @type is a tuple type Since 2.24
33497 * g_variant_type_is_variant:
33498 * @type: a #GVariantType
33500 * Determines if the given @type is the variant type.
33502 * Returns: %TRUE if @type is the variant type Since 2.24
33507 * g_variant_type_key:
33508 * @type: a dictionary entry #GVariantType
33510 * Determines the key type of a dictionary entry type.
33512 * This function may only be used with a dictionary entry type. Other
33513 * than the additional restriction, this call is equivalent to
33514 * g_variant_type_first().
33516 * Returns: (transfer none): the key type of the dictionary entry Since 2.24
33521 * g_variant_type_n_items:
33522 * @type: a tuple or dictionary entry #GVariantType
33524 * Determines the number of items contained in a tuple or
33525 * dictionary entry type.
33527 * This function may only be used with tuple or dictionary entry types,
33528 * but must not be used with the generic tuple type
33529 * %G_VARIANT_TYPE_TUPLE.
33531 * In the case of a dictionary entry type, this function will always
33534 * Returns: the number of items in @type Since 2.24
33539 * g_variant_type_new:
33540 * @type_string: a valid GVariant type string
33542 * Creates a new #GVariantType corresponding to the type string given
33543 * by @type_string. It is appropriate to call g_variant_type_free() on
33544 * the return value.
33546 * It is a programmer error to call this function with an invalid type
33547 * string. Use g_variant_type_string_is_valid() if you are unsure.
33549 * Returns: (transfer full): a new #GVariantType
33555 * g_variant_type_new_array: (constructor)
33556 * @element: a #GVariantType
33558 * Constructs the type corresponding to an array of elements of the
33561 * It is appropriate to call g_variant_type_free() on the return value.
33563 * Returns: (transfer full): a new array #GVariantType Since 2.24
33568 * g_variant_type_new_dict_entry: (constructor)
33569 * @key: a basic #GVariantType
33570 * @value: a #GVariantType
33572 * Constructs the type corresponding to a dictionary entry with a key
33573 * of type @key and a value of type @value.
33575 * It is appropriate to call g_variant_type_free() on the return value.
33577 * Returns: (transfer full): a new dictionary entry #GVariantType Since 2.24
33582 * g_variant_type_new_maybe: (constructor)
33583 * @element: a #GVariantType
33585 * Constructs the type corresponding to a maybe instance containing
33586 * type @type or Nothing.
33588 * It is appropriate to call g_variant_type_free() on the return value.
33590 * Returns: (transfer full): a new maybe #GVariantType Since 2.24
33595 * g_variant_type_new_tuple:
33596 * @items: (array length=length): an array of #GVariantTypes, one for each item
33597 * @length: the length of @items, or -1
33599 * Constructs a new tuple type, from @items.
33601 * @length is the number of items in @items, or -1 to indicate that
33602 * @items is %NULL-terminated.
33604 * It is appropriate to call g_variant_type_free() on the return value.
33606 * Returns: (transfer full): a new tuple #GVariantType Since 2.24
33611 * g_variant_type_next:
33612 * @type: a #GVariantType from a previous call
33614 * Determines the next item type of a tuple or dictionary entry
33617 * @type must be the result of a previous call to
33618 * g_variant_type_first() or g_variant_type_next().
33620 * If called on the key type of a dictionary entry then this call
33621 * returns the value type. If called on the value type of a dictionary
33622 * entry then this call returns %NULL.
33624 * For tuples, %NULL is returned when @type is the last item in a tuple.
33626 * Returns: (transfer none): the next #GVariantType after @type, or %NULL Since 2.24
33631 * g_variant_type_peek_string: (skip)
33632 * @type: a #GVariantType
33634 * Returns the type string corresponding to the given @type. The
33635 * result is not nul-terminated; in order to determine its length you
33636 * must call g_variant_type_get_string_length().
33638 * To get a nul-terminated string, see g_variant_type_dup_string().
33640 * Returns: the corresponding type string (not nul-terminated) Since 2.24
33645 * g_variant_type_string_is_valid:
33646 * @type_string: a pointer to any string
33648 * Checks if @type_string is a valid GVariant type string. This call is
33649 * equivalent to calling g_variant_type_string_scan() and confirming
33650 * that the following character is a nul terminator.
33652 * Returns: %TRUE if @type_string is exactly one valid type string Since 2.24
33657 * g_variant_type_string_scan:
33658 * @string: a pointer to any string
33659 * @limit: (allow-none): the end of @string, or %NULL
33660 * @endptr: (out) (allow-none): location to store the end pointer, or %NULL
33662 * Scan for a single complete and valid GVariant type string in @string.
33663 * The memory pointed to by @limit (or bytes beyond it) is never
33666 * If a valid type string is found, @endptr is updated to point to the
33667 * first character past the end of the string that was found and %TRUE
33670 * If there is no valid type string starting at @string, or if the type
33671 * string does not end before @limit then %FALSE is returned.
33673 * For the simple case of checking if a string is a valid type string,
33674 * see g_variant_type_string_is_valid().
33676 * Returns: %TRUE if a valid type string was found
33682 * g_variant_type_value:
33683 * @type: a dictionary entry #GVariantType
33685 * Determines the value type of a dictionary entry type.
33687 * This function may only be used with a dictionary entry type.
33689 * Returns: (transfer none): the value type of the dictionary entry Since 2.24
33695 * @value: a #GVariant
33697 * Decreases the reference count of @value. When its reference count
33698 * drops to 0, the memory used by the variant is freed.
33706 * @string: the return location for the newly-allocated string.
33707 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33708 * @args: the list of arguments to insert in the output.
33710 * An implementation of the GNU vasprintf() function which supports
33711 * positional parameters, as specified in the Single Unix Specification.
33712 * This function is similar to g_vsprintf(), except that it allocates a
33713 * string to hold the output, instead of putting the output in a buffer
33714 * you allocate in advance.
33716 * Returns: the number of bytes printed.
33723 * @file: the stream to write to.
33724 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33725 * @args: the list of arguments to insert in the output.
33727 * An implementation of the standard fprintf() function which supports
33728 * positional parameters, as specified in the Single Unix Specification.
33730 * Returns: the number of bytes printed.
33737 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33738 * @args: the list of arguments to insert in the output.
33740 * An implementation of the standard vprintf() function which supports
33741 * positional parameters, as specified in the Single Unix Specification.
33743 * Returns: the number of bytes printed.
33750 * @string: the buffer to hold the output.
33751 * @n: the maximum number of bytes to produce (including the terminating nul character).
33752 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33753 * @args: the list of arguments to insert in the output.
33755 * A safer form of the standard vsprintf() function. The output is guaranteed
33756 * to not exceed @n characters (including the terminating nul character), so
33757 * it is easy to ensure that a buffer overflow cannot occur.
33759 * See also g_strdup_vprintf().
33761 * In versions of GLib prior to 1.2.3, this function may return -1 if the
33762 * output was truncated, and the truncated string may not be nul-terminated.
33763 * In versions prior to 1.3.12, this function returns the length of the output
33766 * The return value of g_vsnprintf() conforms to the vsnprintf() function
33767 * as standardized in ISO C99. Note that this is different from traditional
33768 * vsnprintf(), which returns the length of the output string.
33770 * The format string may contain positional parameters, as specified in
33771 * the Single Unix Specification.
33773 * Returns: the number of bytes which would be produced if the buffer was large enough.
33779 * @string: the buffer to hold the output.
33780 * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33781 * @args: the list of arguments to insert in the output.
33783 * An implementation of the standard vsprintf() function which supports
33784 * positional parameters, as specified in the Single Unix Specification.
33786 * Returns: the number of bytes printed.
33792 * g_wakeup_acknowledge:
33793 * @wakeup: a #GWakeup
33795 * Acknowledges receipt of a wakeup signal on @wakeup.
33797 * You must call this after @wakeup polls as ready. If not, it will
33798 * continue to poll as ready until you do so.
33800 * If you call this function and @wakeup is not signaled, nothing
33809 * @wakeup: a #GWakeup
33813 * You must not currently be polling on the #GPollFD returned by
33814 * g_wakeup_get_pollfd(), or the result is undefined.
33819 * g_wakeup_get_pollfd:
33820 * @wakeup: a #GWakeup
33821 * @poll_fd: a #GPollFD
33823 * Prepares a @poll_fd such that polling on it will succeed when
33824 * g_wakeup_signal() has been called on @wakeup.
33826 * @poll_fd is valid until @wakeup is freed.
33835 * Creates a new #GWakeup.
33837 * You should use g_wakeup_free() to free it when you are done.
33839 * Returns: a new #GWakeup
33846 * @wakeup: a #GWakeup
33850 * Any future (or present) polling on the #GPollFD returned by
33851 * g_wakeup_get_pollfd() will immediately succeed until such a time as
33852 * g_wakeup_acknowledge() is called.
33854 * This function is safe to call from a UNIX signal handler.
33862 * @...: format string, followed by parameters to insert into the format string (as with printf())
33864 * A convenience function/macro to log a warning message.
33866 * You can make warnings fatal at runtime by setting the
33867 * <envar>G_DEBUG</envar> environment variable (see
33868 * <ulink url="glib-running.html">Running GLib Applications</ulink>).
33873 * g_win32_error_message:
33874 * @error: error code.
33876 * Translate a Win32 error code (as returned by GetLastError()) into
33877 * the corresponding message. The message is either language neutral,
33878 * or in the thread's language, or the user's language, the system's
33879 * language, or US English (see docs for FormatMessage()). The
33880 * returned string is in UTF-8. It should be deallocated with
33883 * Returns: newly-allocated error message
33888 * g_win32_get_package_installation_directory:
33889 * @package: (allow-none): You should pass %NULL for this.
33890 * @dll_name: (allow-none): The name of a DLL that a package provides in UTF-8, or %NULL.
33892 * Try to determine the installation directory for a software package.
33894 * This function is deprecated. Use
33895 * g_win32_get_package_installation_directory_of_module() instead.
33897 * The use of @package is deprecated. You should always pass %NULL. A
33898 * warning is printed if non-NULL is passed as @package.
33900 * The original intended use of @package was for a short identifier of
33901 * the package, typically the same identifier as used for
33902 * <literal>GETTEXT_PACKAGE</literal> in software configured using GNU
33903 * autotools. The function first looks in the Windows Registry for the
33904 * value <literal>#InstallationDirectory</literal> in the key
33905 * <literal>#HKLM\Software\@package</literal>, and if that value
33906 * exists and is a string, returns that.
33908 * It is strongly recommended that packagers of GLib-using libraries
33909 * for Windows do not store installation paths in the Registry to be
33910 * used by this function as that interfers with having several
33911 * parallel installations of the library. Enabling multiple
33912 * installations of different versions of some GLib-using library, or
33913 * GLib itself, is desirable for various reasons.
33915 * For this reason it is recommeded to always pass %NULL as
33916 * @package to this function, to avoid the temptation to use the
33917 * Registry. In version 2.20 of GLib the @package parameter
33918 * will be ignored and this function won't look in the Registry at all.
33920 * If @package is %NULL, or the above value isn't found in the
33921 * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
33922 * into the current process. Typically that would be the name of the
33923 * DLL calling this function, looking for its installation
33924 * directory. The function then asks Windows what directory that DLL
33925 * was loaded from. If that directory's last component is "bin" or
33926 * "lib", the parent directory is returned, otherwise the directory
33927 * itself. If that DLL isn't loaded, the function proceeds as if
33928 * @dll_name was %NULL.
33930 * If both @package and @dll_name are %NULL, the directory from where
33931 * the main executable of the process was loaded is used instead in
33932 * the same way as above.
33934 * 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.
33935 * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to g_win32_get_package_installation_directory_of_module() instead.
33940 * g_win32_get_package_installation_directory_of_module:
33941 * @hmodule: (allow-none): The Win32 handle for a DLL loaded into the current process, or %NULL
33943 * This function tries to determine the installation directory of a
33944 * software package based on the location of a DLL of the software
33947 * @hmodule should be the handle of a loaded DLL or %NULL. The
33948 * function looks up the directory that DLL was loaded from. If
33949 * @hmodule is NULL, the directory the main executable of the current
33950 * process is looked up. If that directory's last component is "bin"
33951 * or "lib", its parent directory is returned, otherwise the directory
33954 * It thus makes sense to pass only the handle to a "public" DLL of a
33955 * software package to this function, as such DLLs typically are known
33956 * to be installed in a "bin" or occasionally "lib" subfolder of the
33957 * installation folder. DLLs that are of the dynamically loaded module
33958 * or plugin variety are often located in more private locations
33959 * deeper down in the tree, from which it is impossible for GLib to
33960 * deduce the root of the package installation.
33962 * The typical use case for this function is to have a DllMain() that
33963 * saves the handle for the DLL. Then when code in the DLL needs to
33964 * construct names of files in the installation tree it calls this
33965 * function passing the DLL handle.
33967 * 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.
33973 * g_win32_get_package_installation_subdirectory:
33974 * @package: (allow-none): You should pass %NULL for this.
33975 * @dll_name: (allow-none): The name of a DLL that a package provides, in UTF-8, or %NULL.
33976 * @subdir: A subdirectory of the package installation directory, also in UTF-8
33978 * This function is deprecated. Use
33979 * g_win32_get_package_installation_directory_of_module() and
33980 * g_build_filename() instead.
33982 * Returns a newly-allocated string containing the path of the
33983 * subdirectory @subdir in the return value from calling
33984 * g_win32_get_package_installation_directory() with the @package and
33985 * @dll_name parameters. See the documentation for
33986 * g_win32_get_package_installation_directory() for more details. In
33987 * particular, note that it is deprecated to pass anything except NULL
33990 * 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.
33991 * 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().
33996 * g_win32_get_windows_version:
33998 * Returns version information for the Windows operating system the
33999 * code is running on. See MSDN documentation for the GetVersion()
34000 * function. To summarize, the most significant bit is one on Win9x,
34001 * and zero on NT-based systems. Since version 2.14, GLib works only
34002 * on NT-based systems, so checking whether your are running on Win9x
34003 * in your own software is moot. The least significant byte is 4 on
34004 * Windows NT 4, and 5 on Windows XP. Software that needs really
34005 * detailed version and feature information should use Win32 API like
34006 * GetVersionEx() and VerifyVersionInfo().
34008 * Returns: The version information.
34014 * g_win32_getlocale:
34016 * The setlocale() function in the Microsoft C library uses locale
34017 * names of the form "English_United States.1252" etc. We want the
34018 * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
34019 * current thread locale from Windows - without any encoding info -
34020 * and returns it as a string of the above form for use in forming
34021 * file names etc. The returned string should be deallocated with
34024 * Returns: newly-allocated locale name.
34029 * g_win32_locale_filename_from_utf8:
34030 * @utf8filename: a UTF-8 encoded filename.
34032 * Converts a filename from UTF-8 to the system codepage.
34034 * On NT-based Windows, on NTFS file systems, file names are in
34035 * Unicode. It is quite possible that Unicode file names contain
34036 * characters not representable in the system codepage. (For instance,
34037 * Greek or Cyrillic characters on Western European or US Windows
34038 * installations, or various less common CJK characters on CJK Windows
34041 * In such a case, and if the filename refers to an existing file, and
34042 * the file system stores alternate short (8.3) names for directory
34043 * entries, the short form of the filename is returned. Note that the
34044 * "short" name might in fact be longer than the Unicode name if the
34045 * Unicode name has very short pathname components containing
34046 * non-ASCII characters. If no system codepage name for the file is
34047 * possible, %NULL is returned.
34049 * The return value is dynamically allocated and should be freed with
34050 * g_free() when no longer needed.
34052 * Returns: The converted filename, or %NULL on conversion failure and lack of short names.
34060 * A standard boolean type.
34061 * Variables of this type should only contain the value
34069 * Corresponds to the standard C <type>char</type> type.
34076 * An untyped pointer to constant data.
34077 * The data pointed to should not be changed.
34079 * This is typically used in function prototypes to indicate
34080 * that the data pointed to will not be altered by the function.
34087 * Corresponds to the standard C <type>double</type> type.
34088 * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
34095 * Corresponds to the standard C <type>float</type> type.
34096 * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
34103 * Corresponds to the standard C <type>int</type> type.
34104 * Values of this type can range from #G_MININT to #G_MAXINT.
34111 * A signed integer guaranteed to be 16 bits on all platforms.
34112 * Values of this type can range from #G_MININT16 (= -32,768) to
34113 * #G_MAXINT16 (= 32,767).
34115 * To print or scan values of this type, use
34116 * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
34123 * A signed integer guaranteed to be 32 bits on all platforms.
34124 * Values of this type can range from #G_MININT32 (= -2,147,483,648)
34125 * to #G_MAXINT32 (= 2,147,483,647).
34127 * To print or scan values of this type, use
34128 * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
34135 * A signed integer guaranteed to be 64 bits on all platforms.
34136 * Values of this type can range from #G_MININT64
34137 * (= -9,223,372,036,854,775,808) to #G_MAXINT64
34138 * (= 9,223,372,036,854,775,807).
34140 * To print or scan values of this type, use
34141 * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
34148 * A signed integer guaranteed to be 8 bits on all platforms.
34149 * Values of this type can range from #G_MININT8 (= -128) to
34150 * #G_MAXINT8 (= 127).
34157 * Corresponds to the C99 type <type>intptr_t</type>,
34158 * a signed integer type that can hold any pointer.
34160 * To print or scan values of this type, use
34161 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
34169 * @arg: Do not use this argument
34171 * Do not call this function; it is used to share private
34172 * API between glib, gobject, and gio.
34177 * glib_check_version:
34178 * @required_major: the required major version.
34179 * @required_minor: the required minor version.
34180 * @required_micro: the required micro version.
34182 * Checks that the GLib library in use is compatible with the
34183 * given version. Generally you would pass in the constants
34184 * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
34185 * as the three arguments to this function; that produces
34186 * a check that the library in use is compatible with
34187 * the version of GLib the application or module was compiled
34190 * Compatibility is defined by two things: first the version
34191 * of the running library is newer than the version
34192 * @required_major.required_minor.@required_micro. Second
34193 * the running library must be binary compatible with the
34194 * version @required_major.required_minor.@required_micro
34195 * (same major version.)
34197 * 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.
34204 * @str: The string to be translated
34206 * Returns the translated string from the glib translations.
34207 * This is an internal function and should only be used by
34208 * the internals of glib (such as libgio).
34210 * Returns: the transation of @str to the current locale
34215 * glib_mem_profiler_table:
34217 * A #GMemVTable containing profiling variants of the memory
34218 * allocation functions. Use them together with g_mem_profile()
34219 * in order to get information about the memory allocation pattern
34226 * @msgctxtid: a combined message context and message id, separated by a \004 character
34227 * @msgidoffset: the offset of the message id in @msgctxid
34229 * This function is a variant of glib_gettext() which supports
34230 * a disambiguating message context. See g_dpgettext() for full
34233 * This is an internal function and should only be used by
34234 * the internals of glib (such as libgio).
34236 * Returns: the translation of @str to the current locale
34243 * Corresponds to the standard C <type>long</type> type.
34244 * Values of this type can range from #G_MINLONG to #G_MAXLONG.
34251 * A signed integer type that is used for file offsets,
34252 * corresponding to the C99 type <type>off64_t</type>.
34253 * Values of this type can range from #G_MINOFFSET to
34256 * To print or scan values of this type, use
34257 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
34266 * An untyped pointer.
34267 * #gpointer looks better and is easier to use
34268 * than <type>void*</type>.
34275 * Corresponds to the standard C <type>short</type> type.
34276 * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
34283 * An unsigned integer type of the result of the sizeof operator,
34284 * corresponding to the <type>size_t</type> type defined in C99.
34285 * This type is wide enough to hold the numeric value of a pointer,
34286 * so it is usually 32bit wide on a 32bit platform and 64bit wide
34287 * on a 64bit platform. Values of this type can range from 0 to
34290 * To print or scan values of this type, use
34291 * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
34298 * A signed variant of #gsize, corresponding to the
34299 * <type>ssize_t</type> defined on most platforms.
34300 * Values of this type can range from #G_MINSSIZE
34303 * To print or scan values of this type, use
34304 * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
34311 * Corresponds to the standard C <type>unsigned char</type> type.
34318 * Corresponds to the standard C <type>unsigned int</type> type.
34319 * Values of this type can range from 0 to #G_MAXUINT.
34326 * An unsigned integer guaranteed to be 16 bits on all platforms.
34327 * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
34329 * To print or scan values of this type, use
34330 * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
34337 * An unsigned integer guaranteed to be 32 bits on all platforms.
34338 * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
34340 * To print or scan values of this type, use
34341 * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
34348 * An unsigned integer guaranteed to be 64 bits on all platforms.
34349 * Values of this type can range from 0 to #G_MAXUINT64
34350 * (= 18,446,744,073,709,551,615).
34352 * To print or scan values of this type, use
34353 * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
34360 * An unsigned integer guaranteed to be 8 bits on all platforms.
34361 * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
34368 * Corresponds to the C99 type <type>uintptr_t</type>,
34369 * an unsigned integer type that can hold any pointer.
34371 * To print or scan values of this type, use
34372 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
34381 * Corresponds to the standard C <type>unsigned long</type> type.
34382 * Values of this type can range from 0 to #G_MAXULONG.
34389 * Corresponds to the standard C <type>unsigned short</type> type.
34390 * Values of this type can range from 0 to #G_MAXUSHORT.
34395 /************************************************************/
34396 /* THIS FILE IS GENERATED DO NOT EDIT */
34397 /************************************************************/